[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 3 require_once dirname(__FILE__) . '/syncml.php'; 4 require_once 'XML/WBXML/Decoder.php'; 5 require_once 'XML/WBXML/Encoder.php'; 6 7 /** 8 * The Horde_RPC_syncml_wbxml class provides a SyncML implementation of the 9 * Horde RPC system using WBXML encoding. 10 * 11 * $Horde: framework/RPC/RPC/syncml_wbxml.php,v 1.11.10.6 2006/01/01 21:28:33 jan Exp $ 12 * 13 * Copyright 2003-2006 Chuck Hagenbuch <chuck@horde.org> 14 * Copyright 2003-2006 Anthony Mills <amills@pyramid6.com> 15 * 16 * See the enclosed file COPYING for license information (LGPL). If you 17 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 18 * 19 * @author Chuck Hagenbuch <chuck@horde.org> 20 * @author Anthony Mills <amills@pyramid6.com> 21 * @since Horde 3.0 22 * @package Horde_RPC 23 */ 24 class Horde_RPC_syncml_wbxml extends Horde_RPC_syncml { 25 26 /** 27 * Sends an RPC request to the server and returns the result. 28 * 29 * @param string $request The raw request string. 30 * 31 * @return string The WBXML encoded response from the server (binary). 32 */ 33 function getResponse($request) 34 { 35 /* Catch any errors/warnings/notices that may get thrown while 36 * processing. Don't want to let anything go to the client that's not 37 * part of the valid response. */ 38 ob_start(); 39 40 /* Very useful for debugging. Logs WBXML packets to 41 * $this->_debugDir. */ 42 if (!empty($this->_debugDir) && is_dir($this->_debugDir)) { 43 $packetNum = @intval(file_get_contents($this->_debugDir . '/syncml.packetnum')); 44 if (!isset($packetNum)) { 45 $packetNum = 0; 46 } 47 48 $fp = fopen($this->_debugDir . '/syncml_client_' . $packetNum . '.wbxml', 'wb'); 49 fwrite($fp, $request); 50 fclose($fp); 51 } 52 53 54 $decoder = &new XML_WBXML_Decoder(); 55 $this->_output = &new XML_WBXML_Encoder(); 56 57 $decoder->setContentHandler($this); 58 59 $r = $decoder->decode($request); 60 if (is_a($r, 'PEAR_Error')) { 61 Horde::logMessage('SyncML: ' . 62 $r->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR); 63 } 64 65 $this->_output->setVersion($decoder->getVersion()); 66 $this->_output->setCharset($decoder->getCharsetStr()); 67 $response = $this->_output->getOutput(); 68 69 if (is_a($response, 'PEAR_Error')) { 70 Horde::logMessage($response, __FILE__, __LINE__, PEAR_LOG_ERR); 71 $response = $response->getMessage(); 72 } 73 74 if (!empty($this->_debugDir) && is_dir($this->_debugDir)) { 75 $fp = fopen($this->_debugDir . '/syncml_server_' . $packetNum . '.wbxml', 'wb'); 76 fwrite($fp, $response); 77 fclose($fp); 78 79 $fp = @fopen($this->_debugDir . '/syncml.packetnum', 'w'); 80 if ($fp) { 81 fwrite($fp, ++$packetNum); 82 fclose($fp); 83 } 84 85 } 86 87 /* Clear the output buffer that we started above, and log anything 88 * that came up for later debugging. */ 89 $errorLogging = ob_get_clean(); 90 if (!empty($errorLogging)) { 91 Horde::logMessage('SyncML: caught output=' . $errorLogging, 92 __FILE__, __LINE__, PEAR_LOG_DEBUG); 93 } 94 95 return $response; 96 } 97 98 /** 99 * Returns the Content-Type of the response. 100 * 101 * @return string The MIME Content-Type of the RPC response. 102 */ 103 function getResponseContentType() 104 { 105 return 'application/vnd.syncml+wbxml'; 106 } 107 108 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |