| 1 | package HTTP::MobileAgent::Vodafone; | ||||||||||||||||||||||
| 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.21; | |||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 10 | ▶ | use base qw(HTTP::MobileAgent); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | |||||||||||||||||||||||
| 9 | 10 | __PACKAGE__->make_accessors( | |||||||||||||||||||||
| 10 | qw(name version model type packet_compliant | ||||||||||||||||||||||
| 11 | serial_number vendor vendor_version java_info) | ||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 73 | ▶ | sub is_j_phone { shift->is_vodafone } | ||||||||||||||||||||
|
Subroutine
is_j_phone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | 90 | ▶ | sub is_vodafone { 1 } | ||||||||||||||||||||
|
Subroutine
is_vodafone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 17 | |||||||||||||||||||||||
| 18 | 2 | ▶ | sub is_softbank { shift->is_vodafone } | ||||||||||||||||||||
|
Subroutine
is_softbank: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 6 | ▶ | sub carrier { 'V' } | ||||||||||||||||||||
|
Subroutine
carrier: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 21 | |||||||||||||||||||||||
| 22 | 6 | ▶ | sub carrier_longname { 'Vodafone' } | ||||||||||||||||||||
|
Subroutine
carrier_longname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | 10 | ▶ | sub is_type_c { shift->{type} =~ /^C/ } | ||||||||||||||||||||
|
Subroutine
is_type_c: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 25 | 10 | ▶ | sub is_type_p { shift->{type} =~ /^P/ } | ||||||||||||||||||||
|
Subroutine
is_type_p: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 26 | 10 | ▶ | sub is_type_w { shift->{type} =~ /^W/ } | ||||||||||||||||||||
|
Subroutine
is_type_w: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 27 | 9 | ▶ | sub is_type_3gc { shift->{type} eq '3GC' } | ||||||||||||||||||||
|
Subroutine
is_type_3gc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 28 | |||||||||||||||||||||||
| 29 | sub parse { | ||||||||||||||||||||||
| 30 | 77 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
parse: called CC=18 SCAR=29.7
Pod
undocumented
| |||||||||||||||||||||||
| 31 | |||||||||||||||||||||||
| 32 | 77 | ▶ | return $self->_parse_3gc if($self->user_agent =~ /^Vodafone/); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 33 | 74 | ▶ | return $self->_parse_softbank_3gc if($self->user_agent =~ /^SoftBank/); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 34 | 71 | ▶ | return $self->_parse_motorola_3gc if($self->user_agent =~ /^MOT-/); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 35 | 69 | ▶ | return $self->_parse_crawler if($self->user_agent =~ /^Nokia/); # ad hoc | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | 68 | my($main, @rest) = split / /, _subtract_ua($self->user_agent); | |||||||||||||||||||||
| 38 | |||||||||||||||||||||||
| 39 | 68 | ▶ | if (@rest) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 40 | # J-PHONE/4.0/J-SH51/SNJSHA3029293 SH/0001aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.1.0 | ||||||||||||||||||||||
| 41 | 21 | $self->{packet_compliant} = 1; | |||||||||||||||||||||
| 42 | 21 | @{$self}{qw(name version model serial_number)} = split m!/!, $main; | |||||||||||||||||||||
| 43 | 21 | ▶ | if ($self->{serial_number}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 44 | 20 | ▶ | $self->{serial_number} =~ s/^SN// or return $self->no_match; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||
| 46 | |||||||||||||||||||||||
| 47 | 21 | my $vendor = shift @rest; | |||||||||||||||||||||
| 48 | 21 | @{$self}{qw(vendor vendor_version)} = split m!/!, $vendor; | |||||||||||||||||||||
| 49 | |||||||||||||||||||||||
| 50 | 21 | my %java_info = map split(m!/!), @rest; | |||||||||||||||||||||
| 51 | 21 | $self->{java_info} = \%java_info; | |||||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||||
| 53 | # J-PHONE/2.0/J-DN02 | ||||||||||||||||||||||
| 54 | 47 | @{$self}{qw(name version model)} = split m!/!, $main; | |||||||||||||||||||||
| 55 | 47 | ▶ | $self->{name} = 'J-PHONE' if $self->{name} eq 'J-Phone'; # for J-Phone/5.0/J-SH03 (YahooSeeker) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 56 | 47 | ▶ | $self->{vendor} = ($self->{model} =~ /J-([A-Z]+)/)[0] if $self->{model}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | 68 | ▶ | if ($self->version =~ /^2\./) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 60 | 12 | $self->{type} = 'C2'; | |||||||||||||||||||||
| 61 | } elsif ($self->version =~ /^3\./) { | ||||||||||||||||||||||
| 62 | 32 | ▶ | if ($self->get_header('x-jphone-java')) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 63 | 0 | $self->{type} = 'C4'; | |||||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||||
| 65 | 32 | $self->{type} = 'C3'; | |||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||
| 67 | } elsif ($self->version =~ /^4\./) { | ||||||||||||||||||||||
| 68 | 21 | my($jscl_ver) = ($self->{java_info}->{'Ext-Profile'} =~ /JSCL-(\d.+)/); | |||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | 21 | ▶ | if ($jscl_ver =~ /^1\.1\./) { | ||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||
| 71 | 21 | $self->{type} = 'P4'; | |||||||||||||||||||||
| 72 | } elsif ($jscl_ver eq '1.2.1') { | ||||||||||||||||||||||
| 73 | 0 | $self->{type} = 'P5'; | |||||||||||||||||||||
| 74 | } elsif ($jscl_ver eq '1.2.2') { | ||||||||||||||||||||||
| 75 | 0 | $self->{type} = 'P6'; | |||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||
| 77 | 0 | $self->{type} = 'P7'; | |||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||
| 79 | } elsif ($self->version =~ /^5\./) { | ||||||||||||||||||||||
| 80 | 2 | $self->{type} = 'W'; | |||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||
| 83 | |||||||||||||||||||||||
| 84 | # for 3gc | ||||||||||||||||||||||
| 85 | sub _parse_3gc { | ||||||||||||||||||||||
| 86 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
_parse_3gc: called CC=3 SCAR=11.0
| |||||||||||||||||||||||
| 87 | |||||||||||||||||||||||
| 88 | # Vodafone/1.0/V802SE/SEJ001 Browser/SEMC-Browser/4.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 | ||||||||||||||||||||||
| 89 | # Vodafone/1.0/V702NK/NKJ001 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1 | ||||||||||||||||||||||
| 90 | # SoftBank/1.0/910T/TJ001 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1 | ||||||||||||||||||||||
| 91 | 6 | my($main, @rest) = split / /, $self->user_agent; | |||||||||||||||||||||
| 92 | 6 | $self->{packet_compliant} = 1; | |||||||||||||||||||||
| 93 | 6 | $self->{type} = '3GC'; | |||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | 6 | @{$self}{qw(name version model _maker serial_number)} = split m!/!, $main; | |||||||||||||||||||||
| 96 | 6 | ▶ | if ($self->{serial_number}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 97 | 4 | ▶ | $self->{serial_number} =~ s/^SN// or return $self->no_match; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||
| 99 | |||||||||||||||||||||||
| 100 | 6 | my($java_info) = $self->user_agent =~ /(Profile.*)$/; | |||||||||||||||||||||
| 101 | 6 | my %java_info = map split(m!/!), split / /,$java_info; | |||||||||||||||||||||
| 102 | 6 | $self->{java_info} = \%java_info; | |||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||
| 104 | |||||||||||||||||||||||
| 105 | # for softbank 3gc | ||||||||||||||||||||||
| 106 | 10 | *_parse_softbank_3gc = \&_parse_3gc; | |||||||||||||||||||||
| 107 | |||||||||||||||||||||||
| 108 | # for motorola 3gc | ||||||||||||||||||||||
| 109 | sub _parse_motorola_3gc{ | ||||||||||||||||||||||
| 110 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
_parse_motorola_3gc: called CC=4 SCAR=14.2
| |||||||||||||||||||||||
| 111 | 2 | my($main, @rest) = split / /, $self->user_agent; | |||||||||||||||||||||
| 112 | |||||||||||||||||||||||
| 113 | #MOT-V980/80.2B.04I MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 | ||||||||||||||||||||||
| 114 | |||||||||||||||||||||||
| 115 | 2 | $self->{packet_compliant} = 1; | |||||||||||||||||||||
| 116 | 2 | $self->{type} = '3GC'; | |||||||||||||||||||||
| 117 | |||||||||||||||||||||||
| 118 | 2 | @{$self}{qw(name)} = split m!/!, $main; | |||||||||||||||||||||
| 119 | |||||||||||||||||||||||
| 120 | 2 | shift @rest; | |||||||||||||||||||||
| 121 | 2 | my %java_info = map split(m!/!), @rest; | |||||||||||||||||||||
| 122 | 2 | $self->{java_info} = \%java_info; | |||||||||||||||||||||
| 123 | |||||||||||||||||||||||
| 124 | 2 | ▶ | $self->{model} = 'V702MO' if $self->{name} eq 'MOT-V980'; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 125 | 2 | ▶ | $self->{model} = 'V702sMO' if $self->{name} eq 'MOT-C980'; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 126 | 2 | ▶ | $self->{model} ||= $self->get_header('x-jphone-msname'); | ||||||||||||||||||||
|
Condition33%1/3
$self->{"model"} ||= $self->get_header("x-jphone-msname")
MC/DC0%0/2
$self->{"model"} ||= $self->get_header("x-jphone-msname")
$self->{"model"}
$self->get_header("x-jphone-msname")
Truth table33%1/3
A ||= B
A= $self->{"model"}B= $self->get_header("x-jphone-msname")
| |||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||
| 128 | |||||||||||||||||||||||
| 129 | # for crawler | ||||||||||||||||||||||
| 130 | sub _parse_crawler { | ||||||||||||||||||||||
| 131 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
_parse_crawler: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 132 | 1 | my($main, @rest) = split / /, _subtract_ua($self->user_agent); | |||||||||||||||||||||
| 133 | |||||||||||||||||||||||
| 134 | # Nokia6820/2.0 (4.83) Profile/MIDP-1.0 Configuration/CLDC-1.0 | ||||||||||||||||||||||
| 135 | 1 | @{$self}{qw(model)} = split m!/!, $main; | |||||||||||||||||||||
| 136 | 1 | $self->{name} = 'Vodafone'; | |||||||||||||||||||||
| 137 | 1 | $self->{type} = '3GC'; | |||||||||||||||||||||
| 138 | |||||||||||||||||||||||
| 139 | 1 | shift @rest; | |||||||||||||||||||||
| 140 | 1 | my %java_info = map split(m!/!), @rest; | |||||||||||||||||||||
| 141 | 1 | $self->{java_info} = \%java_info; | |||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||
| 143 | |||||||||||||||||||||||
| 144 | sub _make_display { | ||||||||||||||||||||||
| 145 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
_make_display: called CC=2 SCAR=7.0
| |||||||||||||||||||||||
| 146 | 1 | my($width, $height) = split /\*/, $self->get_header('x-jphone-display'); | |||||||||||||||||||||
| 147 | |||||||||||||||||||||||
| 148 | 1 | my($color, $depth); | |||||||||||||||||||||
| 149 | 1 | ▶ | if (my $c_str = $self->get_header('x-jphone-color')) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 150 | 1 | ($color, $depth) = $c_str =~ /^([CG])(\d+)$/; | |||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||
| 152 | |||||||||||||||||||||||
| 153 | 1 | return HTTP::MobileAgent::Display->new( | |||||||||||||||||||||
| 154 | width => $width, | ||||||||||||||||||||||
| 155 | height => $height, | ||||||||||||||||||||||
| 156 | color => $color eq 'C', | ||||||||||||||||||||||
| 157 | depth => $depth, | ||||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||
| 160 | |||||||||||||||||||||||
| 161 | sub _subtract_ua { | ||||||||||||||||||||||
| 162 | 69 | ▶ | my $user_agent = shift; | ||||||||||||||||||||
|
Subroutine
_subtract_ua: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 163 | 69 | $user_agent =~ s/\s*\(compatible\s*[^\)]+\)//i; | |||||||||||||||||||||
| 164 | 69 | return $user_agent; | |||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||
| 166 | |||||||||||||||||||||||
| 167 | 10 | 1; | |||||||||||||||||||||
| 168 | __END__ | ||||||||||||||||||||||