line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::MobileAgent; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
3809
|
use strict; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
606
|
|
4
|
14
|
|
|
14
|
|
80
|
use vars qw($VERSION); |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
1013
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.36'; |
6
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
16244
|
use HTTP::MobileAgent::Request; |
|
14
|
|
|
|
|
40
|
|
|
14
|
|
|
|
|
1193
|
|
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
|
14
|
|
|
14
|
|
86
|
use vars qw($MobileAgentRE); |
|
14
|
|
|
|
|
23
|
|
|
14
|
|
|
|
|
6285
|
|
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
|
605
|
|
|
605
|
1
|
39530
|
my($class, $stuff) = @_; |
31
|
605
|
|
|
|
|
2728
|
my $request = HTTP::MobileAgent::Request->new($stuff); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# parse UA string |
34
|
605
|
|
|
|
|
2429
|
my $ua = $request->get('User-Agent'); |
35
|
605
|
|
|
|
|
1200
|
my $sub = 'NonMobile'; |
36
|
605
|
100
|
|
|
|
10081
|
if ($ua =~ /$MobileAgentRE/) { |
37
|
436
|
100
|
|
|
|
8004
|
$sub = $1 ? 'DoCoMo' : $2 ? 'JPhone' : $3 ? 'EZweb' : 'AirHPhone'; |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
605
|
|
|
|
|
2669
|
my $self = bless { _request => $request }, "$class\::$sub"; |
41
|
605
|
|
|
|
|
2863
|
$self->parse; |
42
|
605
|
|
|
|
|
1727
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub user_agent { |
47
|
991
|
|
|
991
|
1
|
1649
|
my $self = shift; |
48
|
991
|
|
|
|
|
2407
|
$self->get_header('User-Agent'); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_header { |
52
|
1037
|
|
|
1037
|
0
|
1441
|
my($self, $header) = @_; |
53
|
1037
|
|
|
|
|
4457
|
$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
|
330
|
|
|
330
|
1
|
2383
|
sub name { shift->{name} } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub display { |
63
|
174
|
|
|
174
|
1
|
348
|
my $self = shift; |
64
|
174
|
100
|
|
|
|
417
|
unless ($self->{display}) { |
65
|
172
|
|
|
|
|
518
|
$self->{display} = $self->_make_display; |
66
|
|
|
|
|
|
|
} |
67
|
174
|
|
|
|
|
551
|
return $self->{display}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# utility for subclasses |
71
|
|
|
|
|
|
|
sub make_accessors { |
72
|
84
|
|
|
84
|
0
|
383
|
my($class, @attr) = @_; |
73
|
84
|
|
|
|
|
213
|
for my $attr (@attr) { |
74
|
14
|
|
|
14
|
|
80
|
no strict 'refs'; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
5176
|
|
75
|
518
|
|
|
1699
|
|
2428
|
*{"$class\::$attr"} = sub { shift->{$attr} }; |
|
518
|
|
|
|
|
3538
|
|
|
1699
|
|
|
|
|
11316
|
|
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
|
392
|
|
|
392
|
1
|
1438
|
sub is_docomo { 0 } |
87
|
493
|
|
|
493
|
0
|
2274
|
sub is_j_phone { 0 } |
88
|
188
|
|
|
188
|
1
|
1160
|
sub is_vodafone { 0 } |
89
|
0
|
|
|
0
|
0
|
0
|
sub is_softbank { 0 } |
90
|
417
|
|
|
417
|
1
|
1896
|
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
|
|
|
|
11
|
$self->is_ezweb && ! $self->is_wap2; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub is_wap2 { |
101
|
18
|
|
|
18
|
1
|
24
|
my $self = shift; |
102
|
18
|
50
|
|
|
|
66
|
$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__ |