| 1 | package HTTP::MobileAgent::DoCoMo; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 10 | $VERSION = 0.19; | |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use base qw(HTTP::MobileAgent); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 10 | __PACKAGE__->make_accessors( | |||||||||||||||||||||||||||||||
| 10 | qw(version model status bandwidth | ||||||||||||||||||||||||||||||||
| 11 | serial_number is_foma card_id xhtml_compliant comment) | ||||||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use HTTP::MobileAgent::DoCoMoDisplayMap qw($DisplayMap); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | # various preferences | ||||||||||||||||||||||||||||||||
| 17 | 10 | ▶ | use vars qw($DefaultCacheSize $HTMLVerMap $GPSModels); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 10 | $DefaultCacheSize = 5; | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | # http://www.nttdocomo.co.jp/p_s/imode/spec/useragent.html | ||||||||||||||||||||||||||||||||
| 21 | 10 | $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|850i/ => '4.0', | ||||||||||||||||||||||||||||||||
| 27 | qr/eggy|P751v/ => '3.2', | ||||||||||||||||||||||||||||||||
| 28 | qr/505i|506i|252i|253i|P213i|600i|700i|701i|800i|880i|SH851i|P851i|881i|900i|901i/ => '5.0', | ||||||||||||||||||||||||||||||||
| 29 | qr/702i|D851iWM|902i/ => '6.0', | ||||||||||||||||||||||||||||||||
| 30 | ]; | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 10 | $GPSModels = { map { $_ => 1 } qw(F661i F505iGPS) }; | |||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 170 | ▶ | sub is_docomo { 1 } | ||||||||||||||||||||||||||||||
|
Subroutine
is_docomo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 32 | ▶ | sub carrier { 'I' } | ||||||||||||||||||||||||||||||
|
Subroutine
carrier: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 32 | ▶ | sub carrier_longname { 'DoCoMo' } | ||||||||||||||||||||||||||||||
|
Subroutine
carrier_longname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | sub parse { | ||||||||||||||||||||||||||||||||
| 41 | 174 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 42 | 174 | my($main, $foma_or_comment) = split / /, $self->user_agent, 2; | |||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 174 | ▶ | if ($foma_or_comment && $foma_or_comment =~ s/^\((.*)\)$/$1/) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$foma_or_comment and $foma_or_comment =~ s/^\((.*)\)$/$1/
MC/DC100%2/2
$foma_or_comment and $foma_or_comment =~ s/^\((.*)\)$/$1/
$foma_or_comment
$foma_or_comment =~ s/^\((.*)\)$/$1/
Truth table100%3/3
A and B
A= $foma_or_commentB= $foma_or_comment =~ s/^\((.*)\)$/$1/
| |||||||||||||||||||||||||||||||||
| 45 | # DoCoMo/1.0/P209is (Google CHTML Proxy/1.0) | ||||||||||||||||||||||||||||||||
| 46 | 4 | $self->{comment} = $1; | |||||||||||||||||||||||||||||||
| 47 | 4 | $self->_parse_main($main); | |||||||||||||||||||||||||||||||
| 48 | } elsif ($foma_or_comment) { | ||||||||||||||||||||||||||||||||
| 49 | # DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789) | ||||||||||||||||||||||||||||||||
| 50 | 17 | $self->{is_foma} = 1; | |||||||||||||||||||||||||||||||
| 51 | 17 | @{$self}{qw(name version)} = split m!/!, $main; | |||||||||||||||||||||||||||||||
| 52 | 17 | $self->_parse_foma($foma_or_comment); | |||||||||||||||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||||||||||||||
| 54 | # DoCoMo/1.0/R692i/c10 | ||||||||||||||||||||||||||||||||
| 55 | 153 | $self->_parse_main($main); | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | 174 | ▶ | $self->{xhtml_compliant} = $self->version eq '2.0' ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | sub _parse_main { | ||||||||||||||||||||||||||||||||
| 61 | 157 | ▶ | my($self, $main) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_main: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||
| 62 | 157 | my($name, $version, $model, $cache, @rest) = split m!/!, $main; | |||||||||||||||||||||||||||||||
| 63 | 157 | $self->{name} = $name; | |||||||||||||||||||||||||||||||
| 64 | 157 | $self->{version} = $version; | |||||||||||||||||||||||||||||||
| 65 | 157 | $self->{model} = $model; | |||||||||||||||||||||||||||||||
| 66 | 157 | ▶ | $self->{model} = 'SH505i' if $self->{model} eq 'SH505i2'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 157 | ▶ | if ($cache) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 69 | 105 | ▶ | $cache =~ s/^c// or return $self->no_match; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | 105 | $self->{cache_size} = $cache; | |||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | 157 | for (@rest) { | |||||||||||||||||||||||||||||||
| 74 | 38 | ▶ | /^ser(\w{11})$/ and do { $self->{serial_number} = $1; next }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | 33 | ▶ | /^(T[CDBJ])$/ and do { $self->{status} = $1; next }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | 14 | ▶ | /^s(\d+)$/ and do { $self->{bandwidth} = $1; next }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 77 | 9 | ▶ | /^W(\d+)H(\d+)$/ and do { $self->{display_bytes} = "$1*$2"; next; }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | sub _parse_foma { | ||||||||||||||||||||||||||||||||
| 82 | 17 | ▶ | my($self, $foma) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_foma: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 17 | ▶ | $foma =~ s/^([^\(]+)// or return $self->no_match; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 85 | 17 | $self->{model} = $1; | |||||||||||||||||||||||||||||||
| 86 | 17 | ▶ | $self->{model} = 'SH2101V' if $1 eq 'MST_v_SH2101V'; # Huh? | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 17 | ▶ | if ($foma =~ s/^\((.*?)\)$//) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | 16 | my @options = split /;/, $1; | |||||||||||||||||||||||||||||||
| 90 | 16 | for (@options) { | |||||||||||||||||||||||||||||||
| 91 | 21 | ▶ | /^c(\d+)$/ and $self->{cache_size} = $1, next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | /^ser(\w{15})$/ and $self->{serial_number} = $1, next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 93 | 3 | ▶ | /^icc(\w{20})$/ and $self->{card_id} = $1, next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | /^(T[CDBJ])$/ and $self->{status} = $1, next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | /^W(\d+)H(\d+)$/ and $self->{display_bytes} = "$1*$2", next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 0 | $self->no_match; | |||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | sub html_version { | ||||||||||||||||||||||||||||||||
| 102 | 32 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
html_version: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 32 | my @map = @$HTMLVerMap; | |||||||||||||||||||||||||||||||
| 105 | 32 | ▶ | while (my($re, $version) = splice(@map, 0, 2)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | 111 | ▶ | return $version if $self->model =~ /$re/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | sub cache_size { | ||||||||||||||||||||||||||||||||
| 112 | 32 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
cache_size: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 113 | 32 | ▶ | return $self->{cache_size} || $DefaultCacheSize; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'cache_size'} || $HTTP::MobileAgent::DoCoMo::DefaultCacheSize
MC/DC0%0/2
$self->{'cache_size'} || $HTTP::MobileAgent::DoCoMo::DefaultCacheSize
$self->{'cache_size'}
$HTTP::MobileAgent::DoCoMo::DefaultCacheSize
Truth table66%2/3
A || B
A= $self->{'cache_size'}B= $HTTP::MobileAgent::DoCoMo::DefaultCacheSize
| |||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | sub series { | ||||||||||||||||||||||||||||||||
| 117 | 32 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
series: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 118 | 32 | my $model = $self->model; | |||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | 32 | ▶ | if ($self->is_foma && $model =~ /\d{4}/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->is_foma and $model =~ /\d{4}/
MC/DC50%1/2
$self->is_foma and $model =~ /\d{4}/
$self->is_foma
$model =~ /\d{4}/
Truth table66%2/3
A and B
A= $self->is_fomaB= $model =~ /\d{4}/
| |||||||||||||||||||||||||||||||||
| 121 | 9 | return 'FOMA'; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 23 | $model =~ /(\d{3}i)/; | |||||||||||||||||||||||||||||||
| 125 | 23 | return $1; | |||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | sub vendor { | ||||||||||||||||||||||||||||||||
| 129 | 32 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
vendor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 130 | 32 | my $model = $self->model; | |||||||||||||||||||||||||||||||
| 131 | 32 | $model =~ /^([A-Z]+)\d/; | |||||||||||||||||||||||||||||||
| 132 | 32 | return $1; | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | sub _make_display { | ||||||||||||||||||||||||||||||||
| 136 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_make_display: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 137 | 4 | my $display = $DisplayMap->{uc($self->model)}; | |||||||||||||||||||||||||||||||
| 138 | 4 | ▶ | if ($self->{display_bytes}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | 1 | my($w, $h) = split /\*/, $self->{display_bytes}; | |||||||||||||||||||||||||||||||
| 140 | 1 | $display->{width_bytes} = $w; | |||||||||||||||||||||||||||||||
| 141 | 1 | $display->{height_bytes} = $h; | |||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | 4 | return HTTP::MobileAgent::Display->new(%$display); | |||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | sub is_gps { | ||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
is_gps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 148 | 1 | return exists $GPSModels->{$self->model}; | |||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | 10 | 1; | |||||||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||||||||