root/HTTP-MobileAgent/trunk/lib/HTTP/MobileAgent/EZweb.pm

Revision 875 (checked in by miyagawa, 17 years ago)

version 0.09

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 package HTTP::MobileAgent::EZweb;
2
3 use strict;
4 use vars qw($VERSION);
5 $VERSION = 0.09;
6
7 use base qw(HTTP::MobileAgent);
8
9 __PACKAGE__->make_accessors(
10     qw(version device_id server xhtml_compliant comment)
11 );
12
13 sub is_ezweb { 1 }
14
15 sub parse {
16     my $self = shift;
17     my $ua = $self->user_agent;
18     if ($ua =~ s/^KDDI\-//) {
19         # KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1
20         $self->{xhtml_compliant} = 1;
21         my($device, $browser, $opt, $server) = split / /, $ua, 4;
22         $self->{device_id} = $device;
23
24         my($name, $version) = split m!/!, $browser;
25         $self->{name} = $name;
26         $self->{version} = "$version $opt";
27         $self->{server} = $server;
28     }
29     else {
30         # UP.Browser/3.01-HI01 UP.Link/3.4.5.2
31         my($browser, $server, $comment) = split / /, $ua, 3;
32         my($name, $software) = split m!/!, $browser;
33         $self->{name} = $name;
34         @{$self}{qw(version device_id)} = split /-/, $software;
35         $self->{server} = $server;
36         if ($comment) {
37             $comment =~ s/^\((.*)\)$/$1/;
38             $self->{comment} = $comment;
39         }
40     }
41 }
42
43 sub _make_display {
44     my $self = shift;
45     my($width, $height) = split /,/, $self->get_header('x-up-devcap-screenpixels');
46     my $depth = (split /,/, $self->get_header('x-up-devcap-screendepth'))[0];
47     my $color = $self->get_header('x-up-devcap-iscolor');
48     return HTTP::MobileAgent::Display->new(
49         width  => $width,
50         height => $height,
51         color  => (defined $color && $color eq '1'),
52         depth  => 2 ** $depth,
53     );
54 }
55
56 1;
57 __END__
58
59 =head1 NAME
60
61 HTTP::MobileAgent::EZweb - EZweb implementation
62
63 =head1 SYNOPSIS
64
65   use HTTP::MobileAgent;
66
67   local $ENV{HTTP_USER_AGENT} = "UP.Browser/3.01-HI02 UP.Link/3.2.1.2";
68   my $agent = HTTP::MobileAgent->new;
69
70   printf "Name: %s\n", $agent->name;            # "UP.Browser"
71   printf "Version: %s\n", $agent->version;      # 3.01
72   printf "DevieID: %s\n", $agent->device_id;    # HI02
73   printf "Server: %s\n", $agent->server;        # "UP.Link/3.2.1.2"
74
75   # e.g.) UP.Browser/3.01-HI02 UP.Link/3.2.1.2 (Google WAP Proxy/1.0)
76   printf "Comment: %s\n", $agent->comment;      # "Google WAP Proxy/1.0"
77
78   # e.g.) KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1
79   print "XHTML compiant!\n" if $agent->xhtml_compliant; # true
80
81 =head1 DESCRIPTION
82
83 HTTP::MobileAgent::EZweb is a subclass of HTTP::MobileAgent, which
84 implements EZweb (WAP1.0/2.0) user agents.
85
86 =head1 METHODS
87
88 See L<HTTP::MobileAgent/"METHODS"> for common methods. Here are
89 HTTP::MobileAgent::EZweb specific methods.
90
91 =over 4
92
93 =item version
94
95   $version = $agent->version;
96
97 returns UP.Browser version number like '3.01'.
98
99 =item device_id
100
101   $device_id = $agent->device_id;
102
103 returns device ID like 'TS21'.
104
105 =item server
106
107   $server = $agent->server;
108
109 returns server string like "UP.Link/3.2.1.2".
110
111 =item comment
112
113   $comment = $agent->comment;
114
115 returns comment like "Google WAP Proxy/1.0". returns undef if nothinng.
116
117 =item xhtml_compliant
118
119   if ($agent->xhtml_compliant) { }
120
121 returns if the agent is XHTML compliant.
122
123 =back
124
125 =head1 TODO
126
127 =over 4
128
129 =item *
130
131 Spec information support listed in
132 http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html
133
134 (Patches are always welcome ;))
135
136 =back
137
138 =head1 AUTHOR
139
140 Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
141
142 This library is free software; you can redistribute it and/or modify
143 it under the same terms as Perl itself.
144
145 =head1 SEE ALSO
146
147 L<HTTP::MobileAgent>
148
149 http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
150
151 http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html
152
153 =cut
Note: See TracBrowser for help on using the browser.