[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/SyncML/Command/ -> Put.php (source)

   1  <?php
   2  
   3  include_once  'SyncML/Command.php';
   4  
   5  /**
   6   * $Horde: framework/SyncML/SyncML/Command/Put.php,v 1.12.10.7 2006/05/31 17:06:36 selsky Exp $
   7   *
   8   * The SyncML_Command_Put:: class handles DevInf device information
   9   * sent by the client. The data is stored in a SyncML_DeviceInfo
  10   * object which is defined in Device.php and then stored in
  11   * SyncML_Device as an attribute.
  12   *
  13   * Copyright 2005-2006 Cuck Hagenbuch <chuck@horde.org>
  14   *
  15   * See the enclosed file COPYING for license information (LGPL). If you
  16   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  17   *
  18   * @author  Karsten Fourmont <karsten@horde.org>
  19   * @since   Horde 3.0
  20   * @package SyncML
  21   */
  22  class SyncML_Command_Put extends SyncML_Command {
  23  
  24      var $_devinf;
  25  
  26      /**
  27       * Local vars to remember state.
  28       */
  29      var $_currentDS;
  30      var $_CTType;
  31      var $_VerCT;
  32  
  33      var $_currentPropName;
  34      var $_currentParamName;
  35      var $_currentCTType;
  36  
  37      var $_currentXNam;
  38  
  39      function startElement($uri, $element, $attrs)
  40      {
  41          parent::startElement($uri, $element, $attrs);
  42          switch (count($this->_Stack)) {
  43          case 1:
  44              $this->_devinf = &new SyncML_DeviceInfo();
  45              break;
  46  
  47          case 5:
  48              if ($element == 'DataStore') {
  49                  $this->_currentDS = &new SyncML_DataStore();
  50              }
  51              break;
  52          }
  53      }
  54  
  55      function endElement($uri, $element)
  56      {
  57          global $backend;
  58  
  59          $di = &$this->_devinf;
  60          switch (count($this->_Stack)) {
  61          case 1:
  62              $_SESSION['SyncML.state']->setDeviceInfo($di);
  63              if (DEBUGLOG_DEVINF) {
  64                  $fp = @fopen('/tmp/sync/devinf.txt', 'a');
  65                  if ($fp) {
  66                      @fwrite($fp, var_export($di, true));
  67                      @fclose($fp);
  68                  }
  69              }
  70  
  71          case 5:
  72              switch ($element) {
  73              case 'VerDTD':
  74                  $di->_VerDTD = trim($this->_chars);
  75                  break;
  76  
  77              case 'Man':
  78                  $di->_Man = trim($this->_chars);
  79                  break;
  80  
  81              case 'Mod':
  82                  $di->_Mod = trim($this->_chars);
  83                  break;
  84  
  85              case 'OEM':
  86                  $di->_OEM = trim($this->_chars);
  87                  break;
  88  
  89              case 'FwV':
  90                  $di->_FwV = trim($this->_chars);
  91                  break;
  92  
  93              case 'SwV':
  94                  $di->_SwV = trim($this->_chars);
  95                  break;
  96  
  97              case 'HwV':
  98                  $di->_HwV = trim($this->_chars);
  99                  break;
 100  
 101              case 'DevID':
 102                  $di->_DevID = trim($this->_chars);
 103                  break;
 104  
 105              case 'DevTyp':
 106                  $di->_DevTyp = trim($this->_chars);
 107                  break;
 108  
 109              case 'UTC':
 110                  $di->_UTC = true;
 111                  break;
 112  
 113              case 'SupportLargeObjs':
 114                  $di->_SupportLargeObjs = true;
 115                  break;
 116  
 117              case 'SupportNumberOfChanges':
 118                  $di->_SupportNumberOfChanges = true;
 119                  break;
 120  
 121              case 'DataStore':
 122                  $di->_DataStore[] = $this->_currentDS;
 123                  break;
 124  
 125              case 'CTCap':
 126              case 'Ext':
 127                  // Automatically handled by subelements.
 128                  break;
 129              }
 130              break;
 131  
 132          case 6:
 133              if ($this->_Stack[4] == 'DataStore') {
 134                  switch ($element) {
 135                  case 'SourceRef':
 136                      $this->_currentDS->_SourceRef = trim($this->_chars);
 137                      break;
 138  
 139                  case 'DisplayName':
 140                      $this->_currentDS->_DisplayName = trim($this->_chars);
 141                      break;
 142  
 143                  case 'MaxGUIDSize':
 144                      $this->_currentDS->_MaxGUIDSize = trim($this->_chars);
 145                      break;
 146  
 147                  case 'DSMem':
 148                      // Currently ignored, to be done.
 149                      break;
 150  
 151                  case 'SyncCap':
 152                      // Automatically handled by SyncType subelement.
 153                      break;
 154  
 155                  case 'Rx-Pref':
 156                      $this->_currentDS->_Rx_Pref[$this->_CTType] = $this->_VerCT;
 157                      break;
 158  
 159                  case 'Rx':
 160                      $this->_currentDS->_Rx[$this->_CTType] = $this->_VerCT;
 161                      break;
 162  
 163                  case 'Tx-Pref':
 164                      $this->_currentDS->_Tx_Pref[$this->_CTType] = $this->_VerCT;
 165                      break;
 166  
 167                  case 'Tx':
 168                      $this->_currentDS->_Tx[$this->_CTType] = $this->_VerCT;
 169                      break;
 170                  }
 171              }
 172  
 173              if ($this->_Stack[4] == 'CTCap') {
 174                  switch ($element) {
 175                  case 'CTType':
 176                      $this->_currentCTType = trim($this->_chars);
 177                      break;
 178  
 179                  case 'PropName':
 180                      $this->_currentPropName = trim($this->_chars);
 181                      // Reset param state.
 182                      unset($this->_currentParamName);
 183                      $di->_CTCap[$this->_currentCTType][$this->_currentPropName] = &new SyncML_Property();
 184                      break;
 185  
 186                  case 'ParamName':
 187                      $this->_currentParamName = trim($this->_chars);
 188                      $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_params[$this->_currentParamName] = &new SyncML_PropertyParameter();
 189                      break;
 190  
 191                  case 'ValEnum':
 192                      if (!empty($this->_currentParamName)) {
 193                          // We're in parameter mode.
 194                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_params[$this->_currentParamName]->_ValEnum[trim($this->_chars)] = true;
 195                      } else {
 196                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_ValEnum[trim($this->_chars)] = true;
 197                      }
 198                      break;
 199  
 200                  case 'DataType':
 201                      if (!empty($this->_currentParamName)) {
 202                          // We're in parameter mode.
 203                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_params[$this->_currentParamName]->_DataType = trim($this->_chars);
 204                      } else {
 205                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_DataType = trim($this->_chars);
 206                      }
 207                      break;
 208  
 209                  case 'Size':
 210                      if (!empty($this->_currentParamName)) {
 211                          // We're in parameter mode.
 212                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_params[$this->_currentParamName]->_Size = trim($this->_chars);
 213                      } else {
 214                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_Size = trim($this->_chars);
 215                      }
 216                      break;
 217  
 218                  case 'DisplayName':
 219                      if (!empty($this->_currentParamName)) {
 220                          // We're in parameter mode.
 221                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_params[$this->_currentParamName]->_DisplayName = trim($this->_chars);
 222                      } else {
 223                          $di->_CTCap[$this->_currentCTType][$this->_currentPropName]->_DisplayName = trim($this->_chars);
 224                      }
 225                      break;
 226                  }
 227              }
 228  
 229              if ($this->_Stack[4] == 'Ext' && $element == 'XNam') {
 230                  $this->_currentXNam = trim($this->_chars);
 231              }
 232              if ($this->_Stack[4] == 'Ext' && $element == 'XVal') {
 233                  $di->_Ext[$this->_currentXNam][] = trim($this->_chars);
 234              }
 235              break;
 236  
 237          case 7:
 238              if ($element == 'VerCT') {
 239                  $this->_VerCT = trim($this->_chars);
 240              } elseif ($element == 'CTType') {
 241                  $this->_CTType = trim($this->_chars);
 242              } elseif ($element == 'SyncType') {
 243                  $this->_currentDS->_SyncCap[trim($this->_chars)] = true;
 244              }
 245              break;
 246          }
 247  
 248          parent::endElement($uri, $element);
 249      }
 250  
 251      function output($currentCmdID, &$output)
 252      {
 253          $state = &$_SESSION['SyncML.state'];
 254  
 255          $status = &new SyncML_Command_Status((($state->isAuthorized()) ? RESPONSE_OK : RESPONSE_INVALID_CREDENTIALS), 'Put');
 256          $status->setCmdRef($this->_cmdID);
 257  
 258          $ref = ($state->getVersion() == 0) ? './devinf10' : './devinf11';
 259  
 260          $status->setSourceRef($ref);
 261  
 262          return $status->output($currentCmdID, $output);
 263      }
 264  
 265  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7