line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::MobileAgent; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
174342
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
402
|
|
4
|
9
|
|
|
9
|
|
43
|
use vars qw($VERSION); |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
550
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.23_03'; |
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
3458
|
use HTTP::MobileAgent::Request; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
589
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require HTTP::MobileAgent::DoCoMo; |
10
|
|
|
|
|
|
|
require HTTP::MobileAgent::JPhone; |
11
|
|
|
|
|
|
|
require HTTP::MobileAgent::EZweb; |
12
|
|
|
|
|
|
|
require HTTP::MobileAgent::AirHPhone; |
13
|
|
|
|
|
|
|
require HTTP::MobileAgent::NonMobile; |
14
|
|
|
|
|
|
|
require HTTP::MobileAgent::Display; |
15
|
|
|
|
|
|
|
|
16
|
9
|
|
|
9
|
|
47
|
use vars qw($MobileAgentRE); |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
3464
|
|
17
|
|
|
|
|
|
|
# this matching should be robust enough |
18
|
|
|
|
|
|
|
# detailed analysis is done in subclass's parse() |
19
|
|
|
|
|
|
|
my $DoCoMoRE = '^DoCoMo/\d\.\d[ /]'; |
20
|
|
|
|
|
|
|
my $JPhoneRE = '^J-PHONE/\d\.\d'; |
21
|
|
|
|
|
|
|
my $VodafoneRE = '^Vodafone/\d\.\d'; |
22
|
|
|
|
|
|
|
my $VodafoneMotRE = '^MOT-'; |
23
|
|
|
|
|
|
|
my $EZwebRE = '^(?:KDDI-[A-Z]+\d+[A-Z]? )?UP\.Browser\/'; |
24
|
|
|
|
|
|
|
my $AirHRE = '^Mozilla/3\.0\(DDIPOCKET\;'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$MobileAgentRE = qr/(?:($DoCoMoRE)|($JPhoneRE)|($VodafoneRE)|($VodafoneMotRE)|($EZwebRE)|($AirHRE))/; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
566
|
|
|
566
|
1
|
202289
|
my($class, $stuff) = @_; |
30
|
566
|
|
|
|
|
1847
|
my $request = HTTP::MobileAgent::Request->new($stuff); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# parse UA string |
33
|
566
|
|
|
|
|
1516
|
my $ua = $request->get('User-Agent'); |
34
|
566
|
|
|
|
|
699
|
my $sub = 'NonMobile'; |
35
|
566
|
100
|
|
|
|
6669
|
if ($ua =~ /$MobileAgentRE/) { |
36
|
398
|
100
|
|
|
|
1927
|
$sub = $1 ? 'DoCoMo' : $2 ? 'JPhone' : $3 ? 'JPhone' : $4 ? 'JPhone' : $5 ? 'EZweb' : 'AirHPhone'; |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
566
|
|
|
|
|
2026
|
my $self = bless { _request => $request }, "$class\::$sub"; |
40
|
566
|
|
|
|
|
1668
|
$self->parse; |
41
|
566
|
|
|
|
|
1088
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub user_agent { |
46
|
759
|
|
|
759
|
1
|
3206
|
my $self = shift; |
47
|
759
|
|
|
|
|
1198
|
$self->get_header('User-Agent'); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_header { |
51
|
772
|
|
|
772
|
0
|
810
|
my($self, $header) = @_; |
52
|
772
|
|
|
|
|
1767
|
$self->{_request}->get($header); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# should be implemented in subclasses |
56
|
0
|
|
|
0
|
0
|
0
|
sub parse { die } |
57
|
0
|
|
|
0
|
|
0
|
sub _make_display { die } |
58
|
|
|
|
|
|
|
|
59
|
318
|
|
|
318
|
1
|
108062
|
sub name { shift->{name} } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub display { |
62
|
7
|
|
|
7
|
1
|
31
|
my $self = shift; |
63
|
7
|
50
|
|
|
|
17
|
unless ($self->{display}) { |
64
|
7
|
|
|
|
|
23
|
$self->{display} = $self->_make_display; |
65
|
|
|
|
|
|
|
} |
66
|
7
|
|
|
|
|
15
|
return $self->{display}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# utility for subclasses |
70
|
|
|
|
|
|
|
sub make_accessors { |
71
|
54
|
|
|
54
|
0
|
166
|
my($class, @attr) = @_; |
72
|
54
|
|
|
|
|
95
|
for my $attr (@attr) { |
73
|
9
|
|
|
9
|
|
50
|
no strict 'refs'; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
2581
|
|
74
|
315
|
|
|
853
|
|
636
|
*{"$class\::$attr"} = sub { shift->{$attr} }; |
|
315
|
|
|
|
|
1234
|
|
|
853
|
|
|
|
|
35497
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub no_match { |
79
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
80
|
0
|
|
|
|
|
0
|
require Carp; |
81
|
0
|
0
|
|
|
|
0
|
Carp::carp($self->user_agent, ": no match. Might be new variants. ", |
82
|
|
|
|
|
|
|
"please contact the author of HTTP::MobileAgent!") if $^W; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
383
|
|
|
383
|
1
|
70181
|
sub is_docomo { 0 } |
86
|
482
|
|
|
482
|
0
|
2093
|
sub is_j_phone { 0 } |
87
|
180
|
|
|
180
|
1
|
900
|
sub is_vodafone { 0 } |
88
|
405
|
|
|
405
|
1
|
1331
|
sub is_ezweb { 0 } |
89
|
0
|
|
|
0
|
0
|
0
|
sub is_airh_phone { 0 } |
90
|
0
|
|
|
0
|
1
|
0
|
sub is_non_mobile { 0 } |
91
|
0
|
|
|
0
|
1
|
0
|
sub is_tuka { 0 } |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub is_wap1 { |
94
|
3
|
|
|
3
|
1
|
65
|
my $self = shift; |
95
|
3
|
50
|
|
|
|
14
|
$self->is_ezweb && ! $self->is_wap2; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub is_wap2 { |
99
|
10
|
|
|
10
|
1
|
14
|
my $self = shift; |
100
|
10
|
50
|
|
|
|
22
|
$self->is_ezweb && $self->xhtml_compliant; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
0
|
1
|
|
sub carrier { undef } |
104
|
0
|
|
|
0
|
1
|
|
sub carrier_longname { undef } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
__END__ |