Net_UserAgent_Mobile
[ class tree: Net_UserAgent_Mobile ] [ index: Net_UserAgent_Mobile ] [ all elements ]

Source for file DoCoMo.php

Documentation is available at DoCoMo.php

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

Documentation generated on Tue, 23 Jun 2009 10:00:04 +0000 by phpDocumentor 1.4.2. PEAR Logo Copyright © PHP Group 2004.