source: tmp/version-2_5-test/data/module/Net/UserAgent/Mobile/DoCoMo.php @ 18609

Revision 18609, 25.9 KB checked in by kajiwara, 14 years ago (diff)

正式版にナイトリービルド版をマージしてみるテスト

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
4/**
5 * PHP versions 4 and 5
6 *
7 * Copyright (c) 2003-2009 KUBO Atsuhiro <kubo@iteman.jp>,
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 *     * Redistributions of source code must retain the above copyright
14 *       notice, this list of conditions and the following disclaimer.
15 *     * Redistributions in binary form must reproduce the above copyright
16 *       notice, this list of conditions and the following disclaimer in the
17 *       documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * @category   Networking
32 * @package    Net_UserAgent_Mobile
33 * @author     KUBO Atsuhiro <kubo@iteman.jp>
34 * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
35 * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
36 * @version    CVS: $Id$
37 * @link       http://www.nttdocomo.co.jp/service/imode/make/content/spec/useragent/index.html
38 * @link       http://www.nttdocomo.co.jp/service/imode/make/content/browser/browser2/useragent/index.html
39 * @since      File available since Release 0.1
40 */
41
42require_once dirname(__FILE__) . '/Common.php';
43require_once dirname(__FILE__) . '/Display.php';
44require_once dirname(__FILE__) . '/../Mobile.php';
45
46// {{{ Net_UserAgent_Mobile_DoCoMo
47
48/**
49 * NTT DoCoMo implementation
50 *
51 * Net_UserAgent_Mobile_DoCoMo is a subclass of {@link Net_UserAgent_Mobile_Common},
52 * which implements NTT docomo i-mode user agents.
53 *
54 * SYNOPSIS:
55 * <code>
56 * require_once 'Net/UserAgent/Mobile.php';
57 *
58 * $_SERVER['HTTP_USER_AGENT'] = 'DoCoMo/1.0/P502i/c10';
59 * $agent = &Net_UserAgent_Mobile::factory();
60 *
61 * printf("Name: %s\n", $agent->getName()); // 'DoCoMo'
62 * printf("Version: %s\n", $agent->getVersion()); // 1.0
63 * printf("HTML version: %s\n", $agent->getHTMLVersion()); // 2.0
64 * printf("Model: %s\n", $agent->getModel()); // 'P502i'
65 * printf("Cache: %dk\n", $agent->getCacheSize()); // 10
66 * if ($agent->isFOMA()) {
67 *     print "FOMA\n";             // false
68 * }
69 * printf("Vendor: %s\n", $agent->getVendor()); // 'P'
70 * printf("Series: %s\n", $agent->getSeries()); // '502i'
71 *
72 * // only available with <form utn>
73 * // e.g.) 'DoCoMo/1.0/P503i/c10/serNMABH200331';
74 * printf("Serial: %s\n", $agent->getSerialNumber()); // 'NMABH200331'
75 *
76 * // e.g.) 'DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789)';
77 * printf("Serial: %s\n", $agent->getSerialNumber()); // '0123456789abcde'
78 * printf("Card ID: %s\n", $agent->getCardID()); // '01234567890123456789'
79 *
80 * // e.g.) 'DoCoMo/1.0/P502i (Google CHTML Proxy/1.0)'
81 * printf("Comment: %s\n", $agent->getComment()); // 'Google CHTML Proxy/1.0'
82 *
83 * // e.g.) 'DoCoMo/1.0/D505i/c20/TB/W20H10'
84 * printf("Status: %s\n", $agent->getStatus()); // 'TB'
85 *
86 * // only available in eggy/M-stage
87 * // e.g.) 'DoCoMo/1.0/eggy/c300/s32/kPHS-K'
88 * printf("Bandwidth: %dkbps\n", $agent->getBandwidth()); // 32
89 * </code>
90 *
91 * @category   Networking
92 * @package    Net_UserAgent_Mobile
93 * @author     KUBO Atsuhiro <kubo@iteman.jp>
94 * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
95 * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
96 * @version    Release: 1.0.0
97 * @link       http://www.nttdocomo.co.jp/service/imode/make/content/spec/useragent/index.html
98 * @link       http://www.nttdocomo.co.jp/service/imode/make/content/browser/browser2/useragent/index.html
99 * @since      Class available since Release 0.1
100 */
101class Net_UserAgent_Mobile_DoCoMo extends Net_UserAgent_Mobile_Common
102{
103
104    // {{{ properties
105
106    /**#@+
107     * @access public
108     */
109
110    /**#@-*/
111
112    /**#@+
113     * @access private
114     */
115
116    /**
117     * status of the cache (TC, TB, TD, TJ)
118     * @var string
119     */
120    var $_status;
121
122    /**
123     * bandwidth like 32 as kilobytes unit
124     * @var integer
125     */
126    var $_bandwidth;
127
128    /**
129     * hardware unique serial number
130     * @var string
131     */
132    var $_serialNumber;
133
134    /**
135     * whether it's FOMA or not
136     * @var boolean
137     */
138    var $_isFOMA = false;
139
140    /**
141     * FOMA Card ID (20 digit alphanumeric)
142     * @var string
143     */
144    var $_cardID;
145
146    /**
147     * comment on user agent string like 'Google Proxy'
148     * @var string
149     */
150    var $_comment;
151
152    /**
153     * cache size as killobytes unit
154     * @var integer
155     */
156    var $_cacheSize;
157
158    /**
159     * width and height of the display
160     * @var string
161     */
162    var $_displayBytes;
163
164    /**
165     * The model names which have GPS capability.
166     *
167     * @var array
168     * @since Property available since Release 1.0.0RC1
169     */
170    var $_gpsModels = array('F884i',
171                            'F801i',
172                            'F905iBiz',
173                            'SO905iCS',
174                            'N905iBiz',
175                            'N905imyu',
176                            'SO905i',
177                            'F905i',
178                            'P905i',
179                            'N905i',
180                            'D905i',
181                            'SH905i',
182                            'P904i',
183                            'D904i',
184                            'F904i',
185                            'N904i',
186                            'SH904i',
187                            'F883iESS',
188                            'F883iES',
189                            'F903iBSC',
190                            'SO903i',
191                            'F903i',
192                            'D903i',
193                            'N903i',
194                            'P903i',
195                            'SH903i',
196                            'SA800i',
197                            'SA702i',
198                            'SA700iS',
199                            'F505iGPS',
200                            'F661i',
201                            'F884iES',
202                            'N906iL',
203                            'P906i',
204                            'SO906i',
205                            'SH906i',
206                            'N906imyu',
207                            'F906i',
208                            'N906i',
209                            'F01A',
210                            'F03A',
211                            'F06A',
212                            'F05A',
213                            'P01A',
214                            'P02A',
215                            'SH01A',
216                            'SH02A',
217                            'SH03A',
218                            'SH04A',
219                            'N01A',
220                            'N02A',
221                            'P07A3',
222                            'N06A3',
223                            'N08A3',
224                            'P08A3',
225                            'P09A3',
226                            'N09A3',
227                            'F09A3',
228                            'SH05A3',
229                            'SH06A3',
230                            'SH07A3'
231                            );
232
233    /**
234     * The HTML versions which maps models to HTML versions.
235     *
236     * @var array
237     * @since Property available since Release 1.0.0RC1
238     */
239    var $_htmlVersions = array(
240        'D501i' => '1.0',
241        'F501i' => '1.0',
242        'N501i' => '1.0',
243        'P501i' => '1.0',
244        'D502i' => '2.0',
245        'F502i' => '2.0',
246        'N502i' => '2.0',
247        'P502i' => '2.0',
248        'NM502i' => '2.0',
249        'SO502i' => '2.0',
250        'F502it' => '2.0',
251        'N502it' => '2.0',
252        'SO502iWM' => '2.0',
253        'SH821i' => '2.0',
254        'N821i' => '2.0',
255        'P821i' => '2.0',
256        'D209i' => '2.0',
257        'ER209i' => '2.0',
258        'F209i' => '2.0',
259        'KO209i' => '2.0',
260        'N209i' => '2.0',
261        'P209i' => '2.0',
262        'P209iS' => '2.0',
263        'R209i' => '2.0',
264        'P651ps' => '2.0',
265        'R691i' => '2.0',
266        'F210i' => '2.0',
267        'N210i' => '2.0',
268        'P210i' => '2.0',
269        'KO210i' => '2.0',
270        'F671i' => '2.0',
271        'D210i' => '3.0',
272        'SO210i' => '3.0',
273        'F503i' => '3.0',
274        'F503iS' => '3.0',
275        'P503i' => '3.0',
276        'P503iS' => '3.0',
277        'N503i' => '3.0',
278        'N503iS' => '3.0',
279        'SO503i' => '3.0',
280        'SO503iS' => '3.0',
281        'D503i' => '3.0',
282        'D503iS' => '3.0',
283        'F211i' => '3.0',
284        'D211i' => '3.0',
285        'N211i' => '3.0',
286        'N211iS' => '3.0',
287        'P211i' => '3.0',
288        'P211iS' => '3.0',
289        'SO211i' => '3.0',
290        'R211i' => '3.0',
291        'SH251i' => '3.0',
292        'SH251iS' => '3.0',
293        'R692i' => '3.0',
294        'N2001' => '3.0',
295        'N2002' => '3.0',
296        'P2002' => '3.0',
297        'D2101V' => '3.0',
298        'P2101V' => '3.0',
299        'SH2101V' => '3.0',
300        'T2101V' => '3.0',
301        'D504i' => '4.0',
302        'F504i' => '4.0',
303        'F504iS' => '4.0',
304        'N504i' => '4.0',
305        'N504iS' => '4.0',
306        'SO504i' => '4.0',
307        'P504i' => '4.0',
308        'P504iS' => '4.0',
309        'D251i' => '4.0',
310        'D251iS' => '4.0',
311        'F251i' => '4.0',
312        'N251i' => '4.0',
313        'N251iS' => '4.0',
314        'P251iS' => '4.0',
315        'F671iS' => '4.0',
316        'F212i' => '4.0',
317        'SO212i' => '4.0',
318        'F661i' => '4.0',
319        'F672i' => '4.0',
320        'SO213i' => '4.0',
321        'SO213iS' => '4.0',
322        'SO213iWR' => '4.0',
323        'F2051' => '4.0',
324        'N2051' => '4.0',
325        'P2102V' => '4.0',
326        'F2102V' => '4.0',
327        'N2102V' => '4.0',
328        'N2701' => '4.0',
329        'NM850iG' => '4.0',
330        'NM705i' => '4.0',
331        'NM706i' => '4.0',
332        'D505i' => '5.0',
333        'SO505i' => '5.0',
334        'SH505i' => '5.0',
335        'N505i' => '5.0',
336        'F505i' => '5.0',
337        'P505i' => '5.0',
338        'D505iS' => '5.0',
339        'P505iS' => '5.0',
340        'N505iS' => '5.0',
341        'SO505iS' => '5.0',
342        'SH505iS' => '5.0',
343        'F505iGPS' => '5.0',
344        'D252i' => '5.0',
345        'SH252i' => '5.0',
346        'P252i' => '5.0',
347        'N252i' => '5.0',
348        'P252iS' => '5.0',
349        'D506i' => '5.0',
350        'F506i' => '5.0',
351        'N506i' => '5.0',
352        'P506iC' => '5.0',
353        'SH506iC' => '5.0',
354        'SO506iC' => '5.0',
355        'N506iS' => '5.0',
356        'SO506i' => '5.0',
357        'SO506iS' => '5.0',
358        'N506iS2' => '5.0',
359        'D253i' => '5.0',
360        'N253i' => '5.0',
361        'P253i' => '5.0',
362        'D253iWM' => '5.0',
363        'P253iS' => '5.0',
364        'P213i' => '5.0',
365        'F900i' => '5.0',
366        'N900i' => '5.0',
367        'P900i' => '5.0',
368        'SH900i' => '5.0',
369        'F900iT' => '5.0',
370        'P900iV' => '5.0',
371        'N900iS' => '5.0',
372        'D900i' => '5.0',
373        'F900iC' => '5.0',
374        'N900iL' => '5.0',
375        'N900iG' => '5.0',
376        'F880iES' => '5.0',
377        'SH901iC' => '5.0',
378        'F901iC' => '5.0',
379        'N901iC' => '5.0',
380        'D901i' => '5.0',
381        'P901i' => '5.0',
382        'SH901iS' => '5.0',
383        'F901iS' => '5.0',
384        'D901iS' => '5.0',
385        'P901iS' => '5.0',
386        'N901iS' => '5.0',
387        'P901iTV' => '5.0',
388        'F700i' => '5.0',
389        'SH700i' => '5.0',
390        'N700i' => '5.0',
391        'P700i' => '5.0',
392        'F700iS' => '5.0',
393        'SH700iS' => '5.0',
394        'SA700iS' => '5.0',
395        'SH851i' => '5.0',
396        'P851i' => '5.0',
397        'F881iES' => '5.0',
398        'D701i' => '5.0',
399        'N701i' => '5.0',
400        'P701iD' => '5.0',
401        'D701iWM' => '5.0',
402        'N701iECO' => '5.0',
403        'SA800i' => '5.0',
404        'L600i' => '5.0',
405        'N600i' => '5.0',
406        'L601i' => '5.0',
407        'M702iS' => '5.0',
408        'M702iG' => '5.0',
409        'L602i' => '5.0',
410        'F902i' => '6.0',
411        'D902i' => '6.0',
412        'N902i' => '6.0',
413        'P902i' => '6.0',
414        'SH902i' => '6.0',
415        'SO902i' => '6.0',
416        'SH902iS' => '6.0',
417        'P902iS' => '6.0',
418        'N902iS' => '6.0',
419        'D902iS' => '6.0',
420        'F902iS' => '6.0',
421        'SO902iWP+' => '6.0',
422        'SH902iSL' => '6.0',
423        'N902iX' => '6.0',
424        'N902iL' => '6.0',
425        'P702i' => '6.0',
426        'N702iD' => '6.0',
427        'F702iD' => '6.0',
428        'SH702iD' => '6.0',
429        'D702i' => '6.0',
430        'SO702i' => '6.0',
431        'D702iBCL' => '6.0',
432        'SA702i' => '6.0',
433        'SH702iS' => '6.0',
434        'N702iS' => '6.0',
435        'P702iD' => '6.0',
436        'D702iF' => '6.0',
437        'D851iWM' => '6.0',
438        'F882iES' => '6.0',
439        'N601i' => '6.0',
440        'D800iDS' => '6.0',
441        'P703imyu' => '6.0',
442        'F883i' => '6.0',
443        'F883iS' => '6.0',
444        'P704imyu' => '6.0',
445        'L704i' => '6.0',
446        'L705i' => '6.0',
447        'L705iX' => '6.0',
448        'L852i' => '6.0',
449        'L706ie' => '6.0',
450        'L01A' => '6.0',
451        'L03A' => '6.0',
452        'SH903i' => '7.0',
453        'P903i' => '7.0',
454        'N903i' => '7.0',
455        'D903i' => '7.0',
456        'F903i' => '7.0',
457        'SO903i' => '7.0',
458        'D903iTV' => '7.0',
459        'F903iX' => '7.0',
460        'P903iTV' => '7.0',
461        'SH903iTV' => '7.0',
462        'F903iBSC' => '7.0',
463        'P903iX' => '7.0',
464        'SO903iTV' => '7.0',
465        'N703iD' => '7.0',
466        'F703i' => '7.0',
467        'P703i' => '7.0',
468        'D703i' => '7.0',
469        'SH703i' => '7.0',
470        'N703imyu' => '7.0',
471        'SO703i' => '7.0',
472        'SH904i' => '7.0',
473        'N904i' => '7.0',
474        'F904i' => '7.0',
475        'D904i' => '7.0',
476        'P904i' => '7.0',
477        'SO704i' => '7.0',
478        'F704i' => '7.0',
479        'N704imyu' => '7.0',
480        'SH704i' => '7.0',
481        'D704i' => '7.0',
482        'P704i' => '7.0',
483        'F883iES' => '7.0',
484        'F883iESS' => '7.0',
485        'F801i' => '7.0',
486        'F705i' => '7.0',
487        'D705i' => '7.0',
488        'D705imyu' => '7.0',
489        'SH705i' => '7.0',
490        'SH705i2' => '7.0',
491        'SH706ie' => '7.0',
492        'F05A' => '7.0',
493        'SH905i' => '7.1',
494        'D905i' => '7.1',
495        'N905i' => '7.1',
496        'P905i' => '7.1',
497        'F905i' => '7.1',
498        'SO905i' => '7.1',
499        'N905imyu' => '7.1',
500        'N905iBiz' => '7.1',
501        'SH905iTV' => '7.1',
502        'SO905iCS' => '7.1',
503        'F905iBiz' => '7.1',
504        'P905iTV' => '7.1',
505        'P705i' => '7.1',
506        'N705i' => '7.1',
507        'N705imyu' => '7.1',
508        'P705imyu' => '7.1',
509        'SO705i' => '7.1',
510        'P705iCL' => '7.1',
511        'F884i' => '7.1',
512        'F884iES' => '7.1',
513        'N906iL' => '7.1',
514        'N706i' => '7.1',
515        'SO706i' => '7.1',
516        'P706imyu' => '7.1',
517        'N706ie' => '7.1',
518        'N706i2' => '7.1',
519        'N03A' => '7.1',
520        'N05A' => '7.1',
521        'F07A' => '7.1',
522        'P906i' => '7.2',
523        'SO906i' => '7.2',
524        'SH906i' => '7.2',
525        'N906imyu' => '7.2',
526        'F906i' => '7.2',
527        'N906i' => '7.2',
528        'SH906iTV' => '7.2',
529        'F706i' => '7.2',
530        'SH706i' => '7.2',
531        'P706ie' => '7.2',
532        'SH706iw' => '7.2',
533        'F01A' => '7.2',
534        'F02A' => '7.2',
535        'F03A' => '7.2',
536        'F04A' => '7.2',
537        'F06A' => '7.2',
538        'P01A' => '7.2',
539        'P02A' => '7.2',
540        'P03A' => '7.2',
541        'P04A' => '7.2',
542        'P05A' => '7.2',
543        'P06A' => '7.2',
544        'SH01A' => '7.2',
545        'SH02A' => '7.2',
546        'SH03A' => '7.2',
547        'SH04A' => '7.2',
548        'N01A' => '7.2',
549        'N02A' => '7.2',
550        'N04A' => '7.2',
551        'P10A' => '7.2',
552                               );
553
554    /**#@-*/
555
556    /**#@+
557     * @access public
558     */
559
560    // }}}
561    // {{{ isDoCoMo()
562
563    /**
564     * returns true
565     *
566     * @return boolean
567     */
568    function isDoCoMo()
569    {
570        return true;
571    }
572
573    // }}}
574    // {{{ parse()
575
576    /**
577     * Parses HTTP_USER_AGENT string.
578     *
579     * @param string $userAgent User-Agent string
580     * @throws Net_UserAgent_Mobile_Error
581     */
582    function parse($userAgent)
583    {
584        @list($main, $foma_or_comment) = explode(' ', $userAgent, 2);
585
586        if ($foma_or_comment
587            && preg_match('/^\((.*)\)$/', $foma_or_comment, $matches)
588            ) {
589
590            // DoCoMo/1.0/P209is (Google CHTML Proxy/1.0)
591            $this->_comment = $matches[1];
592            $result = $this->_parseMain($main);
593        } elseif ($foma_or_comment) {
594
595            // DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789)
596            $this->_isFOMA = true;
597            @list($this->name, $this->version) = explode('/', $main);
598            $result = $this->_parseFOMA($foma_or_comment);
599        } else {
600
601            // DoCoMo/1.0/R692i/c10
602            $result = $this->_parseMain($main);
603        }
604
605        if (Net_UserAgent_Mobile::isError($result)) {
606            return $result;
607        }
608    }
609
610    // }}}
611    // {{{ makeDisplay()
612
613    /**
614     * create a new {@link Net_UserAgent_Mobile_Display} class instance
615     *
616     * @return Net_UserAgent_Mobile_Display
617     */
618    function makeDisplay()
619    {
620        include_once dirname(__FILE__) . '/DoCoMo/ScreenInfo.php';
621
622        $screenInfo = &Net_UserAgent_Mobile_DoCoMo_ScreenInfo::singleton();
623        $display = $screenInfo->get($this->getModel());
624        if (!is_null($this->_displayBytes)) {
625            @list($widthBytes, $heightBytes) = explode('*', $this->_displayBytes);
626            $display['width_bytes']  = $widthBytes;
627            $display['height_bytes'] = $heightBytes;
628        }
629
630        return new Net_UserAgent_Mobile_Display($display);
631    }
632
633    // }}}
634    // {{{ getHTMLVersion()
635
636    /**
637     * Gets the HTML version like '3.0'. Returns null if unknown.
638     *
639     * @return string
640     */
641    function getHTMLVersion()
642    {
643        return @$this->_htmlVersions[ $this->getModel() ];
644    }
645
646    // }}}
647    // {{{ getCacheSize()
648
649    /**
650     * returns cache size as kilobytes unit. returns 5 if unknown.
651     *
652     * @return integer
653     */
654    function getCacheSize()
655    {
656        if ($this->_cacheSize) {
657            return $this->_cacheSize;
658        }
659
660        return 5;
661    }
662
663    // }}}
664    // {{{ getSeries()
665
666    /**
667     * returns series name like '502i'. returns null if unknown.
668     *
669     * @return string
670     */
671    function getSeries()
672    {
673        if (preg_match('/(\d{4})/', $this->_rawModel)) {
674            return 'FOMA';
675        }
676
677        if (preg_match('/(\d{3}i)/', $this->_rawModel, $matches)) {
678            return $matches[1];
679        }
680
681        if ($this->_rawModel == 'P651ps') {
682            return '651';
683        }
684    }
685
686    // }}}
687    // {{{ getVendor()
688
689    /**
690     * returns vender code like 'SO' for Sony. returns null if unknown.
691     *
692     * @return string
693     */
694    function getVendor()
695    {
696        if (preg_match('/([A-Z]+)\d/', $this->_rawModel, $matches)) {
697            return $matches[1];
698        }
699    }
700
701    // }}}
702    // {{{ getStatus()
703
704    /**
705     * returns status like "TB", "TC", "TD" or "TJ", which means:
706     *
707     * TB | Browsers
708     * TC | Browsers with image off (only Available in HTML 5.0)
709     * TD | Fetching JAR
710     * TJ | i-Appli
711     *
712     * @return string
713     */
714    function getStatus()
715    {
716        return $this->_status;
717    }
718
719    // }}}
720    // {{{ getBandwidth()
721
722    /**
723     * returns bandwidth like 32 as killobytes unit. Only vailable in eggy,
724     * returns null otherwise.
725     *
726     * @return integer
727     */
728    function getBandwidth()
729    {
730        return $this->_bandwidth;
731    }
732
733    // }}}
734    // {{{ getSerialNumber()
735
736    /**
737     * returns hardware unique serial number (15 digit in FOMA, 11 digit
738     * otherwise alphanumeric). Only available with form utn attribute.
739     * returns null otherwise.
740     *
741     * @return string
742     */
743    function getSerialNumber()
744    {
745        return $this->_serialNumber;
746    }
747
748    // }}}
749    // {{{ isFOMA()
750
751    /**
752     * retuns whether it's FOMA or not
753     *
754     * @return boolean
755     */
756    function isFOMA()
757    {
758        return $this->_isFOMA;
759    }
760
761    // }}}
762    // {{{ getComment()
763
764    /**
765     * returns comment on user agent string like 'Google Proxy'. returns null
766     * otherwise.
767     *
768     * @return string
769     */
770    function getComment()
771    {
772        return $this->_comment;
773    }
774
775    // }}}
776    // {{{ getCardID()
777
778    /**
779     * returns FOMA Card ID (20 digit alphanumeric). Only available in FOMA
780     * with <form utn> attribute. returns null otherwise.
781     *
782     * @return string
783     */
784    function getCardID()
785    {
786        return $this->_cardID;
787    }
788
789    // }}}
790    // {{{ isGPS()
791
792    /**
793     * Returns whether a user agent is a GPS model or not.
794     *
795     * @return boolean
796     */
797    function isGPS()
798    {
799        return in_array($this->_rawModel, $this->_gpsModels);
800    }
801
802    // }}}
803    // {{{ getCarrierShortName()
804
805    /**
806     * returns the short name of the carrier
807     *
808     * @return string
809     */
810    function getCarrierShortName()
811    {
812        return 'I';
813    }
814
815    // }}}
816    // {{{ getCarrierLongName()
817
818    /**
819     * returns the long name of the carrier
820     *
821     * @return string
822     */
823    function getCarrierLongName()
824    {
825        return 'DoCoMo';
826    }
827
828    // }}}
829    // {{{ getUID()
830
831    /**
832     * Gets the UID of a subscriber.
833     *
834     * @return string
835     * @since Method available since Release 1.0.0RC1
836     */
837    function getUID()
838    {
839        if (array_key_exists('HTTP_X_DCMGUID', $_SERVER)) {
840            return $_SERVER['HTTP_X_DCMGUID'];
841        }
842    }
843
844    // }}}
845    // {{{ getBrowserVersion()
846
847    /**
848     * Gets the i-mode browser version.
849     *
850     * @return string
851     * @since Method available since Release 1.0.0RC3
852     */
853    function getBrowserVersion()
854    {
855        return $this->getCacheSize() == 500 ? '2.0' : '1.0';
856    }
857
858    /**#@-*/
859
860    /**#@+
861     * @access private
862     */
863
864    // }}}
865    // {{{ _parseMain()
866
867    /**
868     * parse main part of HTTP_USER_AGENT string (not FOMA)
869     *
870     * @param string $main main part of HTTP_USER_AGENT string
871     * @throws Net_UserAgent_Mobile_Error
872     */
873    function _parseMain($main)
874    {
875        @list($this->name, $this->version, $this->_rawModel, $cache, $rest) =
876            explode('/', $main, 5);
877        if ($this->_rawModel == 'SH505i2') {
878            $this->_model = 'SH505i';
879        }
880
881        if ($cache) {
882            if (!preg_match('/^c(\d+)$/', $cache, $matches)) {
883                return $this->noMatch();
884            }
885            $this->_cacheSize = (integer)$matches[1];
886        }
887
888        if ($rest) {
889            $rest = explode('/', $rest);
890            foreach ($rest as $value) {
891                if (preg_match('/^ser(\w{11})$/', $value, $matches)) {
892                    $this->_serialNumber = $matches[1];
893                    continue;
894                }
895                if (preg_match('/^(T[CDBJ])$/', $value, $matches)) {
896                    $this->_status = $matches[1];
897                    continue;
898                }
899                if (preg_match('/^s(\d+)$/', $value, $matches)) {
900                    $this->_bandwidth = (integer)$matches[1];
901                    continue;
902                }
903                if (preg_match('/^W(\d+)H(\d+)$/', $value, $matches)) {
904                    $this->_displayBytes = "{$matches[1]}*{$matches[2]}";
905                    continue;
906                }
907            }
908        }
909    }
910
911    // }}}
912    // {{{ _parseFOMA()
913
914    /**
915     * parse main part of HTTP_USER_AGENT string (FOMA)
916     *
917     * @param string $foma main part of HTTP_USER_AGENT string
918     * @throws Net_UserAgent_Mobile_Error
919     */
920    function _parseFOMA($foma)
921    {
922        if (!preg_match('/^([^(\s]+)/', $foma, $matches)) {
923            return $this->noMatch();
924        }
925
926        $this->_rawModel = $matches[1];
927        if ($this->_rawModel == 'MST_v_SH2101V') {
928            $this->_model = 'SH2101V';
929        }
930
931        if (preg_match('/^[^(\s]+\s?\(([^)]+)\)(?:\(([^)]+)\))?$/', $foma, $matches)) {
932            if (preg_match('/^compatible/', $matches[1])) { // The user-agent is DoCoMo compatible.
933                $this->_comment = $matches[1];
934                return;
935            }
936
937            if (count($matches) == 3) {
938                if (preg_match('/^compatible/', $matches[2])) { // The user-agent is DoCoMo compatible.
939                    $this->_comment = $matches[2];
940                }
941            }
942
943            $rest = explode(';', $matches[1]);
944            foreach ($rest as $value) {
945                if (preg_match('/^c(\d+)$/', $value, $matches)) {
946                    $this->_cacheSize = (integer)$matches[1];
947                    continue;
948                }
949                if (preg_match('/^ser(\w{15})$/', $value, $matches)) {
950                    $this->_serialNumber = $matches[1];
951                    continue;
952                }
953                if (preg_match('/^([A-Z]+)$/', $value, $matches)) {
954                    $this->_status = $matches[1];
955                    continue;
956                }
957                if (preg_match('/^icc(\w{20})?$/', $value, $matches)) {
958                    if (count($matches) == 2) {
959                        $this->_cardID = $matches[1];
960                    }
961                    continue;
962                }
963                if (preg_match('/^W(\d+)H(\d+)$/', $value, $matches)) {
964                    $this->_displayBytes = "{$matches[1]}*{$matches[2]}";
965                    continue;
966                }
967                return $this->noMatch();
968            }
969        }
970    }
971
972    /**#@-*/
973
974    // }}}
975}
976
977// }}}
978
979/*
980 * Local Variables:
981 * mode: php
982 * coding: iso-8859-1
983 * tab-width: 4
984 * c-basic-offset: 4
985 * c-hanging-comment-ender-p: nil
986 * indent-tabs-mode: nil
987 * End:
988 */
Note: See TracBrowser for help on using the repository browser.