Changeset 826

Show
Ignore:
Timestamp:
12/04/02 19:52:44
Author:
miyagawa
Message:

added is_wap12

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • HTTP-MobileAgent/trunk/Changes

    r792 r826  
    11Revision history for Perl extension HTTP::MobileAgent 
     2 
     30.06  Wed Dec  4 19:49:16 JST 2002 
     4        * Added is_wap1, is_wap2 utility method 
     5 
     60.05  Mon Nov 18 19:39:40 JST 2002 
     7        * Fixed bug in pattern match value check (caused bug in mod_perl environment) 
     8 
     90.04  Thu Nov 14 00:47:47 JST 2002 
     10        * Restored is_docomo, is_j_phone, is_ezweb API for handiness 
     11        - Added F212i, SO212i, P504iS, SH251iS in DoCoMoDisplayMap (auto-generated) 
    212 
    3130.03  Tue Oct 29 23:53:01 JST 2002 
  • HTTP-MobileAgent/trunk/MANIFEST

    r792 r826  
    1818t/04_ezweb.t 
    1919t/05_display.t 
     20t/06_nonmobile.t 
  • HTTP-MobileAgent/trunk/lib/HTTP/MobileAgent.pm

    r792 r826  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.03
     5$VERSION = 0.06
    66 
    77use HTTP::MobileAgent::Request; 
     
    2828    # parse UA string 
    2929    my $ua = $request->get('User-Agent'); 
    30     $ua =~ /$MobileAgentRE/; 
    31     my $sub = $1 ? 'DoCoMo' : $2 ? 'JPhone' : $3 ? 'EZweb' : 'NonMobile'; 
     30    my $sub = 'NonMobile'; 
     31    if ($ua =~ /$MobileAgentRE/) { 
     32        $sub = $1 ? 'DoCoMo' : $2 ? 'JPhone' : 'EZweb'; 
     33    } 
    3234 
    3335    my $self = bless { _request => $request }, "$class\::$sub"; 
     
    7678} 
    7779 
     80sub is_docomo  { 0 } 
     81sub is_j_phone { 0 } 
     82sub is_ezweb   { 0 } 
     83 
     84sub is_wap1 { 
     85    my $self = shift; 
     86    $self->is_ezweb && ! $self->is_wap2; 
     87} 
     88 
     89sub is_wap2 { 
     90    my $self = shift; 
     91    $self->is_ezweb && $self->xhtml_compliant; 
     92} 
     93 
     94 
    78951; 
    7996__END__ 
     
    91108  # or $agent = HTTP::MobileAgent->new($agent_string); 
    92109 
    93   if ($agent->name eq 'DoCoMo') { 
     110  if ($agent->is_docomo) { 
     111      # or if ($agent->name eq 'DoCoMo') 
    94112      # or if ($agent->isa('HTTP::MobileAgent::DoCoMo')) 
    95113      # it's NTT DoCoMo i-mode. 
    96114      # see what's available in H::MA::DoCoMo 
    97   } elsif ($agent->name eq 'J-PHONE') { 
     115  } elsif ($agent->is_j_phone) { 
    98116      # it's J-Phone. 
    99117      # see what's available in H::MA::JPhone 
    100   } elsif ($agent->name eq 'UP.Browser') { 
     118  } elsif ($agent->is_ezweb) { 
    101119      # it's KDDI/EZWeb. 
    102120      # see what's available in H::MA::EZweb 
     
    147165returns User-Agent name like 'DoCoMo'. 
    148166 
     167=item is_docomo, is_j_phone, is_ezweb, is_wap1, is_wap2 
     168 
     169   if ($agent->is_docomo) { } 
     170 
     171returns if the agent is DoCoMo, J-Phone or EZweb. 
     172 
    149173=item display 
    150174 
  • HTTP-MobileAgent/trunk/lib/HTTP/MobileAgent/Display.pm

    r792 r826  
    44    qw(width height color depth) 
    55); 
     6 
     7use vars qw($VERSION); 
     8$VERSION = 0.04; 
    69 
    710sub new { 
  • HTTP-MobileAgent/trunk/lib/HTTP/MobileAgent/DoCoMo.pm

    r792 r826  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.03
     5$VERSION = 0.04
    66 
    77use base qw(HTTP::MobileAgent); 
     
    2525    qr/502i|821i|209i|691i|(F|N|P|KO)210i|^F671i$/ => '2.0', 
    2626    qr/(D210i|SO210i)|503i|211i|SH251i|692i/ => '3.0', 
    27     qr/504i|[DF]251i|^F671iS$/ => '4.0', 
     27    qr/504i|251i|^F671iS$|212i/ => '4.0', 
    2828    qr/eggy|P751v/ => '3.2', 
    2929]; 
    3030 
     31sub is_docomo { 1 } 
    3132 
    3233sub parse { 
  • HTTP-MobileAgent/trunk/lib/HTTP/MobileAgent/DoCoMoDisplayMap.pm

    r792 r826  
    1111 
    1212$DisplayMap = { 
     13  'F212i' => { 
     14    'width' => 132, 
     15    'height' => 136, 
     16    'depth' => 65536, 
     17    'color' => 1 
     18  }, 
    1319  'P503iS' => { 
    1420    'width' => 120, 
     
    161167    'color' => 1 
    162168  }, 
     169  'SO212i' => { 
     170    'width' => 120, 
     171    'height' => 112, 
     172    'depth' => 65536, 
     173    'color' => 1 
     174  }, 
    163175  'D210i' => { 
    164176    'width' => 96, 
     
    196208    'depth' => 2, 
    197209    'color' => '' 
     210  }, 
     211  'P504iS' => { 
     212    'width' => 132, 
     213    'height' => 144, 
     214    'depth' => 65536, 
     215    'color' => 1 
    198216  }, 
    199217  'N210i' => { 
     
    345363    'height' => 98, 
    346364    'depth' => 4096, 
     365    'color' => 1 
     366  }, 
     367  'SH251iS' => { 
     368    'width' => 176, 
     369    'height' => 187, 
     370    'depth' => 65536, 
    347371    'color' => 1 
    348372  }, 
  • HTTP-MobileAgent/trunk/lib/HTTP/MobileAgent/EZweb.pm

    r792 r826  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.03
     5$VERSION = 0.04
    66 
    77use base qw(HTTP::MobileAgent); 
     
    1010    qw(version device_id server xhtml_compliant comment) 
    1111); 
     12 
     13sub is_ezweb { 1 } 
    1214 
    1315sub parse { 
  • HTTP-MobileAgent/trunk/lib/HTTP/MobileAgent/JPhone.pm

    r792 r826  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.03
     5$VERSION = 0.04
    66 
    77use base qw(HTTP::MobileAgent); 
     
    1111       serial_number vendor vendor_version java_info) 
    1212); 
     13 
     14sub is_j_phone { 1 } 
    1315 
    1416sub parse { 
  • HTTP-MobileAgent/trunk/t/02_docomo.t

    r777 r826  
    11use strict; 
    2 use Test::More tests => 585
     2use Test::More tests => 762
    33 
    44BEGIN { use_ok 'HTTP::MobileAgent' } 
     
    3434    [ "DoCoMo/1.0/P751v/c100/s64/kPHS-K", '1.0', '3.2', 'P751v', 100, undef, 'P', undef, { bandwidth => 64 } ], 
    3535    [ "DoCoMo/1.0/P209is (Google CHTML Proxy/1.0)", '1.0', '2.0', 'P209is', 5, undef, 'P', '209i', { comment => 'Google CHTML Proxy/1.0' } ], 
     36    [ "DoCoMo/1.0/F212i/c10/TB", '1.0', '4.0', 'F212i', 10, undef, 'F', '212i' ], 
    3637); 
    3738 
     
    4142    isa_ok $agent, 'HTTP::MobileAgent'; 
    4243    isa_ok $agent, 'HTTP::MobileAgent::DoCoMo'; 
     44    ok $agent->is_docomo && ! $agent->is_j_phone && ! $agent->is_ezweb; 
    4345    is $agent->name, 'DoCoMo'; 
    4446    is $agent->user_agent, $ua,         "ua is $ua"; 
     
    6365    isa_ok $agent, 'HTTP::MobileAgent', "$_"; 
    6466    is $agent->name, 'DoCoMo'; 
     67    ok $agent->is_docomo && ! $agent->is_j_phone && ! $agent->is_ezweb; 
    6568} 
    6669 
  • HTTP-MobileAgent/trunk/t/03_j_phone.t

    r777 r826  
    11use strict; 
    2 use Test::More tests => 159
     2use Test::More tests => 224
    33 
    44BEGIN { use_ok 'HTTP::MobileAgent' } 
     
    2727    isa_ok $agent, 'HTTP::MobileAgent'; 
    2828    isa_ok $agent, 'HTTP::MobileAgent::JPhone'; 
     29    ok !$agent->is_docomo && $agent->is_j_phone && !$agent->is_ezweb; 
    2930    is $agent->name, 'J-PHONE'; 
    3031    is $agent->user_agent, $ua,         "ua is $ua"; 
     
    4849    isa_ok $agent, 'HTTP::MobileAgent', "$_"; 
    4950    is $agent->name, 'J-PHONE'; 
     51    ok !$agent->is_docomo && $agent->is_j_phone && !$agent->is_ezweb; 
    5052} 
    5153 
  • HTTP-MobileAgent/trunk/t/04_ezweb.t

    r777 r826  
    11use strict; 
    2 use Test::More tests => 312
     2use Test::More tests => 460
    33 
    44BEGIN { use_ok 'HTTP::MobileAgent' } 
    55 
    66my @Tests = ( 
    7     # ua, version, device_id, server, xhtml_compliant, comment 
     7    # ua, version, device_id, server, xhtml_compliant, comment, is_wap1, is_wap2 
    88    [ 'UP.Browser/3.01-HI01 UP.Link/3.4.5.2', 
    9       '3.01', 'HI01', 'UP.Link/3.4.5.2', undef, undef ], 
     9      '3.01', 'HI01', 'UP.Link/3.4.5.2', undef, undef, 1, undef ], 
    1010    [ 'KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1', 
    11       '6.0.2.276 (GUI)', 'TS21', 'MMP/1.1', 1, undef ], 
     11      '6.0.2.276 (GUI)', 'TS21', 'MMP/1.1', 1, undef, undef, 1 ], 
    1212    [ 'UP.Browser/3.04-TS14 UP.Link/3.4.4 (Google WAP Proxy/1.0)', 
    13       '3.04', 'TS14', 'UP.Link/3.4.4', undef, 'Google WAP Proxy/1.0' ], 
     13      '3.04', 'TS14', 'UP.Link/3.4.4', undef, 'Google WAP Proxy/1.0', 1, undef ], 
    1414); 
    1515 
     
    2020    isa_ok $agent, 'HTTP::MobileAgent::EZweb'; 
    2121    is $agent->name, 'UP.Browser'; 
     22    ok !$agent->is_docomo && !$agent->is_j_phone && $agent->is_ezweb; 
    2223    is $agent->user_agent, $ua,         "ua is $ua"; 
    2324 
     
    2728    is $agent->xhtml_compliant, $data[3]; 
    2829    is $agent->comment, $data[4]; 
     30    ok $agent->is_wap1 if $data[5]; 
     31    ok $agent->is_wap2 if $data[6]; 
    2932} 
    3033 
     
    3639    isa_ok $agent, 'HTTP::MobileAgent', "$_"; 
    3740    is $agent->name, 'UP.Browser'; 
     41    ok !$agent->is_docomo && !$agent->is_j_phone && $agent->is_ezweb; 
    3842} 
    3943