line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::MobileAgent; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
175226
|
use strict; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
346
|
|
4
|
10
|
|
|
10
|
|
44
|
use vars qw($VERSION); |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
882
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.26_1'; |
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
3889
|
use HTTP::MobileAgent::Request; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
759
|
|
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
|
10
|
|
|
10
|
|
55
|
use vars qw($MobileAgentRE); |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
3855
|
|
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 = '^(?i:J-PHONE/\d\.\d)'; |
21
|
|
|
|
|
|
|
my $VodafoneRE = '^Vodafone/\d\.\d'; |
22
|
|
|
|
|
|
|
my $VodafoneMotRE = '^MOT-'; |
23
|
|
|
|
|
|
|
my $SoftBankRE = '^SoftBank/\d\.\d'; |
24
|
|
|
|
|
|
|
my $SoftBankCrawlerRE = '^Nokia[^/]+/\d\.\d'; |
25
|
|
|
|
|
|
|
my $EZwebRE = '^(?:KDDI-[A-Z]+\d+[A-Z]? )?UP\.Browser\/'; |
26
|
|
|
|
|
|
|
my $AirHRE = '^Mozilla/3\.0\((?:WILLCOM|DDIPOCKET)\;'; |
27
|
|
|
|
|
|
|
$MobileAgentRE = qr/(?:($DoCoMoRE)|($JPhoneRE|$VodafoneRE|$VodafoneMotRE|$SoftBankRE|$SoftBankCrawlerRE)|($EZwebRE)|($AirHRE))/; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
575
|
|
|
575
|
1
|
147336
|
my($class, $stuff) = @_; |
31
|
575
|
|
|
|
|
1560
|
my $request = HTTP::MobileAgent::Request->new($stuff); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# parse UA string |
34
|
575
|
|
|
|
|
1194
|
my $ua = $request->get('User-Agent'); |
35
|
575
|
|
|
|
|
631
|
my $sub = 'NonMobile'; |
36
|
575
|
100
|
|
|
|
6393
|
if ($ua =~ /$MobileAgentRE/) { |
37
|
407
|
100
|
|
|
|
1238
|
$sub = $1 ? 'DoCoMo' : $2 ? 'JPhone' : $3 ? 'EZweb' : 'AirHPhone'; |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
575
|
|
|
|
|
1419
|
my $self = bless { _request => $request }, "$class\::$sub"; |
41
|
575
|
|
|
|
|
1481
|
$self->parse; |
42
|
575
|
|
|
|
|
906
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub user_agent { |
47
|
926
|
|
|
926
|
1
|
3341
|
my $self = shift; |
48
|
926
|
|
|
|
|
1254
|
$self->get_header('User-Agent'); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_header { |
52
|
966
|
|
|
966
|
0
|
932
|
my($self, $header) = @_; |
53
|
966
|
|
|
|
|
1823
|
$self->{_request}->get($header); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# should be implemented in subclasses |
57
|
0
|
|
|
0
|
0
|
0
|
sub parse { die } |
58
|
0
|
|
|
0
|
|
0
|
sub _make_display { die } |
59
|
|
|
|
|
|
|
|
60
|
320
|
|
|
320
|
1
|
65886
|
sub name { shift->{name} } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub display { |
63
|
7
|
|
|
7
|
1
|
25
|
my $self = shift; |
64
|
7
|
50
|
|
|
|
14
|
unless ($self->{display}) { |
65
|
7
|
|
|
|
|
20
|
$self->{display} = $self->_make_display; |
66
|
|
|
|
|
|
|
} |
67
|
7
|
|
|
|
|
11
|
return $self->{display}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# utility for subclasses |
71
|
|
|
|
|
|
|
sub make_accessors { |
72
|
60
|
|
|
60
|
0
|
205
|
my($class, @attr) = @_; |
73
|
60
|
|
|
|
|
124
|
for my $attr (@attr) { |
74
|
10
|
|
|
10
|
|
55
|
no strict 'refs'; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
2783
|
|
75
|
370
|
|
|
1241
|
|
804
|
*{"$class\::$attr"} = sub { shift->{$attr} }; |
|
370
|
|
|
|
|
1480
|
|
|
1241
|
|
|
|
|
28453
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub no_match { |
80
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
81
|
0
|
|
|
|
|
0
|
require Carp; |
82
|
0
|
0
|
|
|
|
0
|
Carp::carp($self->user_agent, ": no match. Might be new variants. ", |
83
|
|
|
|
|
|
|
"please contact the author of HTTP::MobileAgent!") if $^W; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
389
|
|
|
389
|
1
|
59162
|
sub is_docomo { 0 } |
87
|
483
|
|
|
483
|
0
|
1701
|
sub is_j_phone { 0 } |
88
|
181
|
|
|
181
|
1
|
653
|
sub is_vodafone { 0 } |
89
|
0
|
|
|
0
|
0
|
0
|
sub is_softbank { 0 } |
90
|
410
|
|
|
410
|
1
|
1278
|
sub is_ezweb { 0 } |
91
|
0
|
|
|
0
|
0
|
0
|
sub is_airh_phone { 0 } |
92
|
0
|
|
|
0
|
1
|
0
|
sub is_non_mobile { 0 } |
93
|
0
|
|
|
0
|
1
|
0
|
sub is_tuka { 0 } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub is_wap1 { |
96
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
97
|
3
|
50
|
|
|
|
8
|
$self->is_ezweb && ! $self->is_wap2; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub is_wap2 { |
101
|
12
|
|
|
12
|
1
|
8
|
my $self = shift; |
102
|
12
|
50
|
|
|
|
20
|
$self->is_ezweb && $self->xhtml_compliant; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
0
|
1
|
|
sub carrier { undef } |
106
|
0
|
|
|
0
|
1
|
|
sub carrier_longname { undef } |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
__END__ |