| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::MobileAgent; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
229189
|
use strict; |
|
|
9
|
|
|
|
|
21
|
|
|
|
9
|
|
|
|
|
326
|
|
|
4
|
9
|
|
|
9
|
|
48
|
use warnings; |
|
|
9
|
|
|
|
|
95
|
|
|
|
9
|
|
|
|
|
323
|
|
|
5
|
9
|
|
|
9
|
|
51
|
use base 'Exporter'; |
|
|
9
|
|
|
|
|
14
|
|
|
|
9
|
|
|
|
|
11469
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/test_mobile_agent/; |
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw/test_mobile_agent_env |
|
11
|
|
|
|
|
|
|
test_mobile_agent_headers |
|
12
|
|
|
|
|
|
|
test_mobile_agent_list/; |
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub test_mobile_agent { |
|
16
|
1053
|
|
|
1053
|
1
|
2594828
|
my %env = test_mobile_agent_env(@_); |
|
17
|
|
|
|
|
|
|
|
|
18
|
1053
|
|
|
|
|
10278
|
$ENV{$_} = $env{$_} for keys %env; |
|
19
|
|
|
|
|
|
|
|
|
20
|
1053
|
50
|
|
|
|
5633
|
return %env if defined wantarray; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub test_mobile_agent_env { |
|
24
|
2106
|
|
|
2106
|
1
|
4946
|
my ($agent, %extra_headers) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
2106
|
|
|
|
|
5988
|
my ($vendor, $type) = _find_vendor($agent); |
|
27
|
2106
|
|
|
|
|
4789
|
my $class = _load_class($vendor); |
|
28
|
2106
|
|
|
|
|
10134
|
return $class->env($type, %extra_headers); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub test_mobile_agent_headers { |
|
32
|
1053
|
|
|
1053
|
1
|
2079586
|
my %env = test_mobile_agent_env(@_); |
|
33
|
|
|
|
|
|
|
|
|
34
|
1053
|
|
|
|
|
14831
|
require HTTP::Headers::Fast; |
|
35
|
1053
|
|
|
|
|
45414
|
my $headers = HTTP::Headers::Fast->new; |
|
36
|
1053
|
|
|
|
|
9291
|
foreach my $name (keys %env) { |
|
37
|
1518
|
|
|
|
|
17180
|
(my $short_name = $name) =~ s/^HTTP[-_]//; |
|
38
|
1518
|
|
|
|
|
17058
|
$headers->header($short_name => $env{$name}); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
1053
|
|
|
|
|
36083
|
$headers; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub test_mobile_agent_list { |
|
44
|
14
|
|
|
14
|
1
|
93754
|
my ($vendor, $type) = _find_vendor(@_); |
|
45
|
14
|
|
|
|
|
45
|
my $class = _load_class($vendor); |
|
46
|
14
|
|
|
|
|
240
|
return $class->list($type); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _find_vendor { |
|
50
|
2120
|
|
|
2120
|
|
3432
|
my $agent = shift; |
|
51
|
|
|
|
|
|
|
|
|
52
|
2120
|
100
|
|
|
|
13160
|
if ($agent =~ /^[a-z]+$/) { |
|
|
|
100
|
|
|
|
|
|
|
53
|
22
|
50
|
|
|
|
160
|
if ($agent =~ /^ip(?:hone|[oa]d)$/) { |
|
|
|
50
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
$agent =~ tr/p/P/; |
|
55
|
0
|
|
|
|
|
0
|
return ("Smartphone", "($agent;"); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
elsif ($agent eq 'android') { |
|
58
|
0
|
|
|
|
|
0
|
return ("Smartphone", 'Android'); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
22
|
|
|
|
|
119
|
return (ucfirst($agent), ''); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
elsif ($agent =~ /^[a-z]+\./) { |
|
63
|
4
|
|
|
|
|
17
|
my ($vendor, $type) = split /\./, $agent; |
|
64
|
4
|
50
|
|
|
|
24
|
if ($vendor =~ /^(ip(?:hone|[oa]d)|android)$/) { |
|
65
|
0
|
|
|
|
|
0
|
$type = "$vendor.+$type"; |
|
66
|
0
|
|
|
|
|
0
|
return ("Smartphone", qr/$type/); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
4
|
50
|
|
|
|
24
|
if ($type =~ /^iP(?:hone|[oa]d)$/i) { |
|
69
|
0
|
|
|
|
|
0
|
$type = "($type;"; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
4
|
|
|
|
|
17
|
return (ucfirst $vendor, $type); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
else { |
|
74
|
|
|
|
|
|
|
# do some guesswork |
|
75
|
2094
|
|
|
|
|
3062
|
my $vendor; |
|
76
|
2094
|
100
|
|
|
|
15938
|
if ($agent =~ /^DoCoMo/i) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
77
|
918
|
|
|
|
|
2366
|
return ('Docomo', $agent); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
elsif ($agent =~ /^J\-PHONE/i) { |
|
80
|
236
|
|
|
|
|
535
|
return ('Jphone', $agent); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
elsif ($agent =~ /^KDDI\-/i) { |
|
83
|
60
|
|
|
|
|
174
|
return ('Ezweb', $agent); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
elsif ($agent =~ /^UP\.Browser/i) { |
|
86
|
242
|
|
|
|
|
638
|
return ('Ezweb', $agent); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
elsif ($agent =~ /DDIPOCKET/i) { |
|
89
|
6
|
|
|
|
|
16
|
return ('Airh', $agent); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
elsif ($agent =~ /WILLCOM/i) { |
|
92
|
16
|
|
|
|
|
45
|
return ('Airh', $agent); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
elsif ($agent =~ /^Vodafone/i) { |
|
95
|
56
|
|
|
|
|
140
|
return ('Vodafone', $agent); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
elsif ($agent =~ /^MOT/i) { |
|
98
|
10
|
|
|
|
|
33
|
return ('Vodafone', $agent); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
elsif ($agent =~ /^Nokia/i) { |
|
101
|
4
|
|
|
|
|
15
|
return ('Vodafone', $agent); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
elsif ($agent =~ /^SoftBank/i) { |
|
104
|
216
|
|
|
|
|
603
|
return ('Softbank', $agent); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
elsif ($agent =~ /\(iP(?:hone|[ao]d);/) { |
|
107
|
0
|
|
|
|
|
0
|
return ('Smartphone', $agent); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
elsif ($agent =~ /Android/) { |
|
110
|
0
|
|
|
|
|
0
|
return ('Smartphone', $agent); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
else { |
|
113
|
330
|
|
|
|
|
1214
|
return ('Nonmobile', $agent); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _load_class { |
|
119
|
2120
|
|
|
2120
|
|
5607
|
my $vendor = shift; |
|
120
|
2120
|
|
|
|
|
4591
|
my $class = "Test::MobileAgent::$vendor"; |
|
121
|
2120
|
|
|
|
|
144523
|
eval "require $class"; |
|
122
|
2120
|
50
|
|
|
|
9551
|
if ($@) { |
|
123
|
0
|
|
|
|
|
0
|
$class = 'Test::MobileAgent::Nonmobile'; |
|
124
|
0
|
|
|
|
|
0
|
require Test::MobileAgent::Nonmobile; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
2120
|
|
|
|
|
4573
|
return $class; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |