line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::MobileAgent::DoCoMo; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
39
|
use strict; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
340
|
|
4
|
9
|
|
|
9
|
|
44
|
use vars qw($VERSION); |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
549
|
|
5
|
|
|
|
|
|
|
$VERSION = 0.19; |
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
101
|
use base qw(HTTP::MobileAgent); |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
1184
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->make_accessors( |
10
|
|
|
|
|
|
|
qw(version model status bandwidth |
11
|
|
|
|
|
|
|
serial_number is_foma card_id comment) |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
9
|
|
|
9
|
|
4118
|
use HTTP::MobileAgent::DoCoMoDisplayMap qw($DisplayMap); |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
1457
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# various preferences |
17
|
9
|
|
|
9
|
|
49
|
use vars qw($DefaultCacheSize $HTMLVerMap $GPSModels); |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
11921
|
|
18
|
|
|
|
|
|
|
$DefaultCacheSize = 5; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# http://www.nttdocomo.co.jp/p_s/imode/spec/useragent.html |
21
|
|
|
|
|
|
|
$HTMLVerMap = [ |
22
|
|
|
|
|
|
|
# regex => version |
23
|
|
|
|
|
|
|
qr/[DFNP]501i/ => '1.0', |
24
|
|
|
|
|
|
|
qr/502i|821i|209i|691i|(F|N|P|KO)210i|^F671i$/ => '2.0', |
25
|
|
|
|
|
|
|
qr/(D210i|SO210i)|503i|211i|SH251i|692i|200[12]|2101V/ => '3.0', |
26
|
|
|
|
|
|
|
qr/504i|251i|^F671iS$|^F661i$|^F672i$|212i|SO213i|2051|2102V|2701/ => '4.0', |
27
|
|
|
|
|
|
|
qr/eggy|P751v/ => '3.2', |
28
|
|
|
|
|
|
|
qr/505i|506i|252i|253i|P213i|900i|901i|700i|880i/ => '5.0', |
29
|
|
|
|
|
|
|
]; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$GPSModels = { map { $_ => 1 } qw(F661i F505iGPS) }; |
32
|
|
|
|
|
|
|
|
33
|
170
|
|
|
170
|
1
|
26605
|
sub is_docomo { 1 } |
34
|
|
|
|
|
|
|
|
35
|
32
|
|
|
32
|
1
|
6860
|
sub carrier { 'I' } |
36
|
|
|
|
|
|
|
|
37
|
32
|
|
|
32
|
1
|
108
|
sub carrier_longname { 'DoCoMo' } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub parse { |
40
|
174
|
|
|
174
|
0
|
203
|
my $self = shift; |
41
|
174
|
|
|
|
|
464
|
my($main, $foma_or_comment) = split / /, $self->user_agent, 2; |
42
|
|
|
|
|
|
|
|
43
|
174
|
100
|
100
|
|
|
691
|
if ($foma_or_comment && $foma_or_comment =~ s/^\((.*)\)$/$1/) { |
|
|
100
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# DoCoMo/1.0/P209is (Google CHTML Proxy/1.0) |
45
|
4
|
|
|
|
|
11
|
$self->{comment} = $1; |
46
|
4
|
|
|
|
|
15
|
$self->_parse_main($main); |
47
|
|
|
|
|
|
|
} elsif ($foma_or_comment) { |
48
|
|
|
|
|
|
|
# DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789) |
49
|
17
|
|
|
|
|
32
|
$self->{is_foma} = 1; |
50
|
17
|
|
|
|
|
42
|
@{$self}{qw(name version)} = split m!/!, $main; |
|
17
|
|
|
|
|
42
|
|
51
|
17
|
|
|
|
|
50
|
$self->_parse_foma($foma_or_comment); |
52
|
|
|
|
|
|
|
} else { |
53
|
|
|
|
|
|
|
# DoCoMo/1.0/R692i/c10 |
54
|
153
|
|
|
|
|
291
|
$self->_parse_main($main); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _parse_main { |
59
|
157
|
|
|
157
|
|
183
|
my($self, $main) = @_; |
60
|
157
|
|
|
|
|
491
|
my($name, $version, $model, $cache, @rest) = split m!/!, $main; |
61
|
157
|
|
|
|
|
299
|
$self->{name} = $name; |
62
|
157
|
|
|
|
|
212
|
$self->{version} = $version; |
63
|
157
|
|
|
|
|
217
|
$self->{model} = $model; |
64
|
157
|
100
|
|
|
|
373
|
$self->{model} = 'SH505i' if $self->{model} eq 'SH505i2'; |
65
|
|
|
|
|
|
|
|
66
|
157
|
100
|
|
|
|
281
|
if ($cache) { |
67
|
105
|
50
|
|
|
|
508
|
$cache =~ s/^c// or return $self->no_match; |
68
|
105
|
|
|
|
|
234
|
$self->{cache_size} = $cache; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
157
|
|
|
|
|
455
|
for (@rest) { |
72
|
38
|
100
|
|
|
|
111
|
/^ser(\w{11})$/ and do { $self->{serial_number} = $1; next }; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
23
|
|
73
|
33
|
100
|
|
|
|
125
|
/^(T[CDBJ])$/ and do { $self->{status} = $1; next }; |
|
19
|
|
|
|
|
55
|
|
|
19
|
|
|
|
|
66
|
|
74
|
14
|
100
|
|
|
|
56
|
/^s(\d+)$/ and do { $self->{bandwidth} = $1; next }; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
10
|
|
75
|
9
|
100
|
|
|
|
60
|
/^W(\d+)H(\d+)$/ and do { $self->{display_bytes} = "$1*$2"; next; }; |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
15
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _parse_foma { |
80
|
17
|
|
|
17
|
|
21
|
my($self, $foma) = @_; |
81
|
|
|
|
|
|
|
|
82
|
17
|
50
|
|
|
|
80
|
$foma =~ s/^([^\(]+)// or return $self->no_match; |
83
|
17
|
|
|
|
|
38
|
$self->{model} = $1; |
84
|
17
|
100
|
|
|
|
46
|
$self->{model} = 'SH2101V' if $1 eq 'MST_v_SH2101V'; # Huh? |
85
|
|
|
|
|
|
|
|
86
|
17
|
100
|
|
|
|
84
|
if ($foma =~ s/^\((.*?)\)$//) { |
87
|
16
|
|
|
|
|
48
|
my @options = split /;/, $1; |
88
|
16
|
|
|
|
|
28
|
for (@options) { |
89
|
21
|
100
|
|
|
|
125
|
/^c(\d+)$/ and $self->{cache_size} = $1, next; |
90
|
5
|
100
|
|
|
|
22
|
/^ser(\w{15})$/ and $self->{serial_number} = $1, next; |
91
|
3
|
100
|
|
|
|
26
|
/^icc(\w{20})$/ and $self->{card_id} = $1, next; |
92
|
1
|
50
|
|
|
|
13
|
/^(T[CDBJ])$/ and $self->{status} = $1, next; |
93
|
0
|
0
|
|
|
|
0
|
/^W(\d+)H(\d+)$/ and $self->{display_bytes} = "$1*$2", next; |
94
|
0
|
|
|
|
|
0
|
$self->no_match; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub html_version { |
100
|
32
|
|
|
32
|
1
|
62
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
32
|
|
|
|
|
155
|
my @map = @$HTMLVerMap; |
103
|
32
|
|
|
|
|
152
|
while (my($re, $version) = splice(@map, 0, 2)) { |
104
|
111
|
100
|
|
|
|
274
|
return $version if $self->model =~ /$re/; |
105
|
|
|
|
|
|
|
} |
106
|
0
|
|
|
|
|
0
|
return undef; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub cache_size { |
110
|
32
|
|
|
32
|
1
|
63
|
my $self = shift; |
111
|
32
|
|
66
|
|
|
231
|
return $self->{cache_size} || $DefaultCacheSize; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub series { |
115
|
32
|
|
|
32
|
1
|
54
|
my $self = shift; |
116
|
32
|
|
|
|
|
93
|
my $model = $self->model; |
117
|
|
|
|
|
|
|
|
118
|
32
|
100
|
66
|
|
|
96
|
if ($self->is_foma && $model =~ /\d{4}/) { |
119
|
9
|
|
|
|
|
32
|
return 'FOMA'; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
23
|
|
|
|
|
119
|
$model =~ /(\d{3}i)/; |
123
|
23
|
|
|
|
|
112
|
return $1; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub vendor { |
127
|
32
|
|
|
32
|
1
|
66
|
my $self = shift; |
128
|
32
|
|
|
|
|
101
|
my $model = $self->model; |
129
|
32
|
|
|
|
|
135
|
$model =~ /^([A-Z]+)\d/; |
130
|
32
|
|
|
|
|
147
|
return $1; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub _make_display { |
134
|
4
|
|
|
4
|
|
6
|
my $self = shift; |
135
|
4
|
|
|
|
|
13
|
my $display = $DisplayMap->{uc($self->model)}; |
136
|
4
|
100
|
|
|
|
11
|
if ($self->{display_bytes}) { |
137
|
1
|
|
|
|
|
5
|
my($w, $h) = split /\*/, $self->{display_bytes}; |
138
|
1
|
|
|
|
|
4
|
$display->{width_bytes} = $w; |
139
|
1
|
|
|
|
|
4
|
$display->{height_bytes} = $h; |
140
|
|
|
|
|
|
|
} |
141
|
4
|
|
|
|
|
20
|
return HTTP::MobileAgent::Display->new(%$display); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub is_gps { |
145
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
146
|
1
|
|
|
|
|
6
|
return exists $GPSModels->{$self->model}; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
__END__ |