root/lang/perl/HTTP-MobileAgent-Flash/trunk/lib/HTTP/MobileAgent/Flash.pm @ 38233

Revision 38233, 2.9 kB (checked in by walf443, 3 years ago)

shipped 0.10

Line 
1package HTTP::MobileAgent::Flash;
2use strict;
3use warnings;
4use vars qw($VERSION);
5$VERSION = '0.10';
6use 5.008001;
7
8use HTTP::MobileAgent;
9use HTTP::MobileAgent::Flash::DoCoMoFlashMap;
10use HTTP::MobileAgent::Flash::EZWebFlashMap;
11use HTTP::MobileAgent::Flash::SoftBankFlashMap;
12
13use Carp;
14
15use base qw(Class::Accessor);
16__PACKAGE__->mk_ro_accessors(qw(max_file_size version width height));
17
18sub import {
19    my $class = shift;
20    no strict 'refs';
21    *{"HTTP\::MobileAgent\::flash"}       = \&_flash;
22    *{"HTTP\::MobileAgent\::is_flash"}    = \&_is_flash;
23}
24
25sub _flash {
26    my $self = shift;
27    unless ($self->{flash}) {
28        $self->{flash} = HTTP::MobileAgent::Flash->new($self);
29    }
30    return $self->{flash};
31}
32
33sub _is_flash {
34    my $self = shift;
35    return ($self->flash->version > 0)? 1 : 0;
36}
37
38sub new {
39    my ($class, $agent) = @_;
40
41    my $map;
42    if ($agent->is_docomo) {
43        $map = $HTTP::MobileAgent::Flash::DoCoMoFlashMap::FLASH_MAP->{uc($agent->model)};
44    }
45    elsif ($agent->is_ezweb) {
46        $map = $HTTP::MobileAgent::Flash::EZWebFlashMap::FLASH_MAP->{uc($agent->model)};
47    }
48    elsif ($agent->is_softbank) {
49        $map = $HTTP::MobileAgent::Flash::SoftBankFlashMap::FLASH_MAP->{uc($agent->model)};
50    }
51
52    if ($map) {
53        return bless $map, $class;
54    }
55    else {
56        return bless {
57            max_file_size => -1,
58            version       => -1,
59            width         => -1,
60            height        => -1,
61        }, $class;
62    }
63}
64
65sub is_supported {
66    my $self = shift;
67    my $version = shift || "";
68
69    croak "You must set version before call is_supported()" if ($version eq "");
70
71    $version =~ s/Lite//ig;
72    return ($version <= $self->version)? 1 : 0;
73}
74
751;
76__END__
77
78=head1 NAME
79
80HTTP::MobileAgent::Flash - Flash information for HTTP::MobileAgent
81
82=head1 SYNOPSIS
83
84  use HTTP::MobileAgent;
85  use HTTP::MobileAgent::Flash;
86
87
88  my $agent = HTTP::MobileAgent->new;
89  print "Flash Version : " . $agent->flash->version;
90
91  if ($agent->is_flash )   { ...... }
92 
93  if ($agent->flash->is_supported('lite1.1') and $agent->flash->width <= 230) {
94    :
95  }
96  if ($agent->flash->is_supported('lite1.0') and $agent->flash->max_file_size <= 48) {
97    :
98  }
99
100=head1 DESCRIPTION
101
102This module adds C<flash>, C<is_flash> method to HTTP::MobileAgent
103
104=head1 METHODS
105
106=head2 is_flash
107
108=head2 flash
109
110=item version
111
112=item max_file_size
113
114=item is_supported
115
116  $agent->flash->is_supported('Lite1.1')
117  $agent->flash->is_supported('Lite1.0')
118
119=head1 AUTHOR
120
121KIMURA, takefumi E<lt>takefumi@mobilefactory.jpE<gt>
122
123This library is free software; you can redistribute it and/or modify
124it under the same terms as Perl itself.
125
126=head1 BUGS
127
128This module does not support the Vodafone, yet.
129
130=head1 SEE ALSO
131
132L<HTTP::MobileAgent>,
133L<http://www.nttdocomo.co.jp/service/imode/make/content/spec/flash/index.html>,
134L<http://www.au.kddi.com/ezfactory/mm/flash01.html>,
135L<http://creation.mb.softbank.jp/>
136
137=cut
Note: See TracBrowser for help on using the browser.