| 1 | package HTTP::MobileAttribute; |
|---|
| 2 | use strict; |
|---|
| 3 | use warnings; |
|---|
| 4 | our $VERSION = '0.05'; |
|---|
| 5 | use HTTP::MobileAttribute::Request; |
|---|
| 6 | use HTTP::MobileAttribute::CarrierDetector; |
|---|
| 7 | use UNIVERSAL::require; |
|---|
| 8 | |
|---|
| 9 | # XXX: This really affects the first time H::MobileAttribute gets loaded |
|---|
| 10 | sub import { |
|---|
| 11 | my $class = shift; |
|---|
| 12 | my %args = @_; |
|---|
| 13 | my $plugins = delete $args{plugins} || [ 'Core' ]; |
|---|
| 14 | |
|---|
| 15 | if (ref $plugins ne 'ARRAY') { |
|---|
| 16 | $plugins = [ $plugins ]; |
|---|
| 17 | } |
|---|
| 18 | $class->load_plugins(@$plugins); |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | sub carriers { qw/DoCoMo AirHPhone ThirdForce EZweb NonMobile/ } |
|---|
| 22 | |
|---|
| 23 | BEGIN { |
|---|
| 24 | for (carriers()) { |
|---|
| 25 | "HTTP::MobileAttribute::Agent::$_"->use or die $@; |
|---|
| 26 | } |
|---|
| 27 | }; |
|---|
| 28 | |
|---|
| 29 | sub new { |
|---|
| 30 | my ($class, $stuff) = @_; |
|---|
| 31 | |
|---|
| 32 | my $request = HTTP::MobileAttribute::Request->new($stuff); |
|---|
| 33 | |
|---|
| 34 | # XXX carrier name detection is actually simple, so instead of |
|---|
| 35 | # going through the hassle of doing Detector->detect, we simply |
|---|
| 36 | # create a function that does the right thing and use it |
|---|
| 37 | my $carrier_longname = HTTP::MobileAttribute::CarrierDetector::detect($request->get('User-Agent')); |
|---|
| 38 | |
|---|
| 39 | my $self = $class->agent_class($carrier_longname)->new({ |
|---|
| 40 | request => $request, |
|---|
| 41 | carrier_longname => $carrier_longname, |
|---|
| 42 | }); |
|---|
| 43 | $self->parse; |
|---|
| 44 | return $self; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | sub agent_class { 'HTTP::MobileAttribute::Agent::' . $_[1] } |
|---|
| 48 | |
|---|
| 49 | sub load_plugins { |
|---|
| 50 | my ($class, @plugins) = @_; |
|---|
| 51 | |
|---|
| 52 | for my $carrier (carriers()) { |
|---|
| 53 | $class->agent_class($carrier)->load_plugins(@plugins); |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | 1; |
|---|
| 59 | __END__ |
|---|
| 60 | |
|---|
| 61 | =encoding UTF-8 |
|---|
| 62 | |
|---|
| 63 | =for stopwords aaaatttt gmail dotottto commmmm Kazuhiro Osawa Plaggable DoCoMo ThirdForce Vodafone docs Daisuke Maki |
|---|
| 64 | |
|---|
| 65 | =head1 NAME |
|---|
| 66 | |
|---|
| 67 | HTTP::MobileAttribute - Yet Another HTTP::MobileAgent |
|---|
| 68 | |
|---|
| 69 | =head1 SYNOPSIS |
|---|
| 70 | |
|---|
| 71 | use HTTP::MobileAttribute; |
|---|
| 72 | |
|---|
| 73 | HTTP::MobileAttribute->load_plugins(qw/Flash Image CarrierName/); |
|---|
| 74 | |
|---|
| 75 | my $agent = HTTP::MobileAttribute->new; |
|---|
| 76 | $agent->is_supported_flash(); |
|---|
| 77 | $agent->is_supported_gif(); |
|---|
| 78 | |
|---|
| 79 | =head1 WARNINGS |
|---|
| 80 | |
|---|
| 81 | WE ARE NOW TESTING THE CONCEPT. |
|---|
| 82 | |
|---|
| 83 | DO NOT USE THIS MODULE. |
|---|
| 84 | |
|---|
| 85 | =head1 DESCRIPTION |
|---|
| 86 | |
|---|
| 87 | HTTP::MobileAttribute is Plaggable version of HTTP::MobileAgent. |
|---|
| 88 | |
|---|
| 89 | っていうか、まあ日本人しかつかわないだろうから日本語で docs かくね。 |
|---|
| 90 | |
|---|
| 91 | 現時点では、とりあえずキャリヤ判定がデキルッポイ。 |
|---|
| 92 | |
|---|
| 93 | =head1 コンセプト |
|---|
| 94 | |
|---|
| 95 | - キャリヤ判別もプラグァーブル |
|---|
| 96 | - トニカクぷらぐぁーぶる |
|---|
| 97 | - HTTP::MobileAgent とできるだけ互換性をもたす。かも。 |
|---|
| 98 | |
|---|
| 99 | =head1 非互換メモ |
|---|
| 100 | |
|---|
| 101 | 当たり前のことながら、$agent->isa はつかえないね。 |
|---|
| 102 | |
|---|
| 103 | carrier_longname が Vodafone じゃなくて ThirdForce を返すよ |
|---|
| 104 | |
|---|
| 105 | =head2 廃止したメソッド |
|---|
| 106 | |
|---|
| 107 | 可能な限り、HTTP::MobileAgent とメソッド名に互換性を持たせてある。 |
|---|
| 108 | ただし、今時どうみてもつかわんだろうというようなものは削ってある。 |
|---|
| 109 | |
|---|
| 110 | 具体的には |
|---|
| 111 | |
|---|
| 112 | DoCoMo: series |
|---|
| 113 | |
|---|
| 114 | なんだけど、つかってないよね?もし使ってる人いたら実装してください。 |
|---|
| 115 | |
|---|
| 116 | あと、 DoCoMo の、たぶん当時はつかってたんだろうけど今はつかってないっぽいものも消してある(もともとつけられるからつけただけなのかもしらんけど)。 |
|---|
| 117 | |
|---|
| 118 | vendor |
|---|
| 119 | cache_size |
|---|
| 120 | html_version |
|---|
| 121 | |
|---|
| 122 | =head1 気になってること |
|---|
| 123 | |
|---|
| 124 | =head2 メモリつかいすぎ疑惑 |
|---|
| 125 | |
|---|
| 126 | まあ、たしょうメモリはいっぱいつかうよね。 |
|---|
| 127 | |
|---|
| 128 | =head1 AUTHOR |
|---|
| 129 | |
|---|
| 130 | Tokuhiro Matsuno E<lt>tokuhirom aaaatttt gmail dotottto commmmmE<gt> |
|---|
| 131 | |
|---|
| 132 | Kazuhiro Osawa |
|---|
| 133 | |
|---|
| 134 | Daisuke Maki |
|---|
| 135 | |
|---|
| 136 | =head1 THANKS TO |
|---|
| 137 | |
|---|
| 138 | Tatsuhiko Miyagawa(original author of HTTP::MobileAgent) |
|---|
| 139 | Satoshi Tanimoto |
|---|
| 140 | Yoshiki Kurihara(Current mentainer of HTTP::MobileAgent) |
|---|
| 141 | |
|---|
| 142 | =head1 SEE ALSO |
|---|
| 143 | |
|---|
| 144 | L<HTTP::MobileAgent> |
|---|
| 145 | |
|---|
| 146 | =head1 LICENSE |
|---|
| 147 | |
|---|
| 148 | This library is free software; you can redistribute it and/or modify |
|---|
| 149 | it under the same terms as Perl itself. |
|---|
| 150 | |
|---|
| 151 | =cut |
|---|