[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] syncml syncml.php inc/class.syncml_command_get....
From: |
Johan Gunnarsson |
Subject: |
[Phpgroupware-cvs] syncml syncml.php inc/class.syncml_command_get.... |
Date: |
Thu, 16 Aug 2007 23:58:02 +0000 |
CVSROOT: /sources/phpgroupware
Module name: syncml
Changes by: Johan Gunnarsson <johang> 07/08/16 23:58:02
Modified files:
. : syncml.php
inc : class.syncml_command_get.inc.php
class.syncml_command_put.inc.php
class.syncml_command_synchdr.inc.php
class.syncml_database_devinf.inc.php
class.syncml_response.inc.php
class.syncml_session_dummy.inc.php
class.xml_offset_mapper.inc.php
constants.inc.php functions.inc.php
setup : setup.inc.php tables_baseline.inc.php
tables_current.inc.php tables_update.php
Added files:
inc : class.syncml_command_results.inc.php
class.syncml_wbxml_encoder.inc.php
class.syncml_wbxml_parser.inc.php
class.syncml_wbxml_response.inc.php
class.xml_parser.inc.php
wbxml_code_spaces.inc.php
Removed files:
inc : class.syncml_xml_parser.inc.php
Log message:
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/syncml/syncml.php?cvsroot=phpgroupware&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_get.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_put.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_synchdr.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_database_devinf.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_response.inc.php?cvsroot=phpgroupware&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_session_dummy.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.xml_offset_mapper.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/constants.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/functions.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_results.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_wbxml_encoder.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_wbxml_parser.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_wbxml_response.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.xml_parser.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/wbxml_code_spaces.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_xml_parser.inc.php?cvsroot=phpgroupware&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/setup.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/tables_baseline.inc.php?cvsroot=phpgroupware&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/tables_current.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/tables_update.php?cvsroot=phpgroupware&r1=1.1&r2=1.2
Patches:
Index: syncml.php
===================================================================
RCS file: /sources/phpgroupware/syncml/syncml.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- syncml.php 5 Aug 2007 17:15:39 -0000 1.3
+++ syncml.php 16 Aug 2007 23:58:00 -0000 1.4
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: syncml.php,v 1.3 2007/08/05 17:15:39 johang Exp $
+ * @version $Id: syncml.php,v 1.4 2007/08/16 23:58:00 johang Exp $
*/
ob_start();
@@ -26,9 +26,12 @@
require('../header.inc.php');
- require_once 'inc/class.syncml_xml_parser.inc.php';
+ require_once 'inc/class.xml_parser.inc.php';
require_once 'inc/class.xml_offset_mapper.inc.php';
+ require_once 'inc/class.syncml_wbxml_parser.inc.php';
+ require_once 'inc/class.syncml_wbxml_response.inc.php';
+
require_once 'inc/class.syncml_response.inc.php';
require_once 'inc/class.syncml_message.inc.php';
@@ -41,44 +44,55 @@
exit('I\'m a SyncML server (1)');
}
- $GLOBALS['HTTP_RAW_POST_DATA'] = implode("\r\n", file('php://input'));
+ $post_input = implode("\r\n", file('php://input'));
switch($_SERVER['CONTENT_TYPE'])
{
case 'application/vnd.syncml+xml':
- $parser = new syncml_xml_parser();
+ $parser = new xml_parser();
$response = new syncml_response();
+ $input = $post_input;
break;
- /*
case 'application/vnd.syncml+wbxml':
$parser = new syncml_wbxml_parser();
$response = new syncml_wbxml_response();
+
+ $input = array();
+ $input_length = strlen($post_input);
+
+ for($i = 0; $i < $input_length; $i++)
+ {
+ $input[] = ord($post_input{$i});
+ }
break;
- */
default:
exit('I\'m a SyncML server (2)');
}
+ unset($post_input);
+
$message = new syncml_message();
// the header
- $header = $parser->parse($GLOBALS['HTTP_RAW_POST_DATA'],
+
+ $header = $parser->parse($input,
new xml_offset_mapper(array('SYNCML', 'SYNCHDR')));
$message->process_header($header);
unset($header);
// the body
+
$body = $parser->parse($GLOBALS['HTTP_RAW_POST_DATA'],
new xml_offset_mapper(array('SYNCML', 'SYNCBODY')));
$message->process_body($body);
unset($body, $GLOBALS['HTTP_RAW_POST_DATA']);
- // execute everything
+ // execute and print everything
+
$message->execute($response);
- // print response
$response->print_response();
header('Content-Type: ' . $_SERVER['CONTENT_TYPE']);
Index: inc/class.syncml_command_get.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_get.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_command_get.inc.php 30 Jul 2007 13:04:39 -0000
1.1.1.1
+++ inc/class.syncml_command_get.inc.php 16 Aug 2007 23:58:00 -0000
1.2
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: class.syncml_command_get.inc.php,v 1.1.1.1
2007/07/30 13:04:39 johang Exp $
+ * @version $Id: class.syncml_command_get.inc.php,v 1.2 2007/08/16
23:58:00 johang Exp $
*/
require_once 'inc/class.syncml_command.inc.php';
@@ -65,7 +65,8 @@
foreach($this->item as $item)
{
- $result =
$database->get_item($item['target']['locuri']);
+ $result = $database->get_item(
+ $item['target']['locuri'],
$this->meta['type']);
if(is_null($result))
{
@@ -81,8 +82,6 @@
}
else
{
- $type = $database->get_type();
-
$response->add_status(
$this->cmdid, $session->msgid,
'Get',
NULL, NULL,
@@ -94,7 +93,7 @@
$response->add_result(
$this->cmdid, $session->msgid,
NULL, NULL,
- $type, array(
+ $this->meta['type'], array(
array(
'src_uri' =>
$item['target']['locuri'],
'data' =>
$result
Index: inc/class.syncml_command_put.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_put.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_command_put.inc.php 30 Jul 2007 13:04:38 -0000
1.1.1.1
+++ inc/class.syncml_command_put.inc.php 16 Aug 2007 23:58:00 -0000
1.2
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: class.syncml_command_put.inc.php,v 1.1.1.1
2007/07/30 13:04:38 johang Exp $
+ * @version $Id: class.syncml_command_put.inc.php,v 1.2 2007/08/16
23:58:00 johang Exp $
*/
require_once 'inc/class.syncml_command.inc.php';
@@ -36,25 +36,14 @@
return;
}
- /*
- if(!isset($this->noresp))
- {
- $response->add_status(
- $this->cmdid, $session->msgid, 'Put',
- NULL, NULL,
- SYNCML_STATUS_OK);
- }
- */
-
if(!$database)
{
// No database or source is given. Try getting
one by type.
- $type = $this->meta['type'];
-
- switch($type)
+ switch($this->meta['type'])
{
case
'application/vnd.syncml-devinf+xml':
+ case
'application/vnd.syncml-devinf+wbxml':
$database = new
syncml_database_devinf($session);
break;
default:
@@ -74,13 +63,15 @@
{
$result = $database->put_item(
$item['source']['locuri'],
- $item['data']);
+ $item['data'], $this->meta['type']);
+ if(!isset($this->noresp) || !$this->noresp)
+ {
$response->add_status(
$this->cmdid, $session->msgid, 'Put',
NULL, $item['source']['locuri'],
- SYNCML_STATUS_OK
- );
+ SYNCML_STATUS_OK);
+ }
}
}
}
Index: inc/class.syncml_command_synchdr.inc.php
===================================================================
RCS file:
/sources/phpgroupware/syncml/inc/class.syncml_command_synchdr.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.syncml_command_synchdr.inc.php 11 Aug 2007 17:24:37 -0000
1.2
+++ inc/class.syncml_command_synchdr.inc.php 16 Aug 2007 23:58:00 -0000
1.3
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: class.syncml_command_synchdr.inc.php,v 1.2
2007/08/11 17:24:37 johang Exp $
+ * @version $Id: class.syncml_command_synchdr.inc.php,v 1.3
2007/08/16 23:58:00 johang Exp $
*/
require_once 'inc/class.syncml_command.inc.php';
@@ -57,6 +57,16 @@
}
parent::parse_xml_array($xml_array);
+
+ if(!isset($this->source['locuri']))
+ {
+ $this->source['locuri'] = '';
+ }
+
+ if(!isset($this->target['locuri']))
+ {
+ $this->target['locuri'] = '';
+ }
}
function execute(&$response, &$session)
@@ -71,6 +81,14 @@
$response->set_max_size(SYNCML_MAXMSGSIZE);
}
+ $response->set_header(
+ $this->verdtd, $this->verproto,
+ $this->sessionid, $this->msgid,
+ isset($this->respuri) ?
+ $this->respuri :
$this->source['locuri'], '',
+ $this->target['locuri'], ''
+ );
+
switch($this->verproto)
{
case 'SyncML/1.0':
@@ -128,14 +146,6 @@
$session->msgid = $this->msgid;
$session->set_var('device_uri',
$this->source['locuri']);
-
- $response->set_header(
- $this->verdtd, $this->verproto,
- $this->sessionid, $this->msgid,
- isset($this->respuri) ?
- $this->respuri :
$this->source['locuri'], '',
- $this->target['locuri'], ''
- );
}
function handle_success(&$response, &$session)
@@ -157,14 +167,14 @@
*
* @param $code Status code to include in the command.
* @param $response Response object to write the status command
to.
+ * @param $session Session object.
*/
- function handle_failure($x, &$response, &$session)
+ function handle_failure($code, &$response, &$session)
{
- switch($x)
+ switch($code)
{
case SYNCML_STATUS_PROTOCOLVERSIONNOTSUPPORTED:
case SYNCML_STATUS_DTDVERSIONNOTSUPPORTED:
- $code = $x;
break;
case SYNCML_STATUS_MISSINGCREDENTIALS:
case SYNCML_UNSUPPORTEDAUTHTYPE:
@@ -189,6 +199,7 @@
/**
* Process the CRED node in SYNCHDR.
*
+ * @param $session Session object.
* @return mixed On failure, return error code. On success
return
* new session ID.
*/
Index: inc/class.syncml_database_devinf.inc.php
===================================================================
RCS file:
/sources/phpgroupware/syncml/inc/class.syncml_database_devinf.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_database_devinf.inc.php 30 Jul 2007 13:04:39 -0000
1.1.1.1
+++ inc/class.syncml_database_devinf.inc.php 16 Aug 2007 23:58:00 -0000
1.2
@@ -7,9 +7,11 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: class.syncml_database_devinf.inc.php,v 1.1.1.1
2007/07/30 13:04:39 johang Exp $
+ * @version $Id: class.syncml_database_devinf.inc.php,v 1.2
2007/08/16 23:58:00 johang Exp $
*/
+ require_once 'inc/functions.inc.php';
+
/**
* A device information database.
*/
@@ -17,39 +19,95 @@
{
var $session;
- var $sodatabase;
-
function syncml_database_devinf(&$session)
{
$this->session = &$session;
-
- // $this->sodatabase = new synml_sodatabase();
}
/**
- * Get preferred mime type of this database.
+ * Get DEVINF from this database.
*
- * @return string Mime type.
+ * @param $uri URI of item to get.
+ * @param $type Type of input data.
+ * @return mixed Returns NULL if item was not found.
*/
- function get_type()
+ function get_item($uri, $type)
{
- return 'application/vnd.syncml-devinf+xml';
+ switch($uri)
+ {
+ case './devinf10':
+ return $this->_encode(
+ $this->_get_devinf_10(), $type,
'1.0');
+ case './devinf11':
+ return $this->_encode(
+ $this->_get_devinf_11(), $type,
'1.1');
+ default:
+ return NULL;
+ }
}
/**
- * Get DEVINF from this database.
+ * Put DEVINF.
*
- * @param $uri URI of item to get.
- * @return mixed Returns NULL if item was not found.
+ * @param $uri URI of DEVINF to put.
+ * @param $data DEVINF data.
+ * @param $type Type of input data.
+ * @return bool True on success, false on failure.
*/
- function get_item($uri)
+ function put_item($uri, $data, $type)
{
switch($uri)
{
case './devinf10':
- return $this->_get_devinf_10();
case './devinf11':
- return $this->_get_devinf_11();
+ return
$this->_put_devinf($this->_decode($data, $type));
+ default:
+ return FALSE;
+ }
+ }
+
+ /**
+ * Encode to type from XML string.
+ *
+ * @param $data Data to decode.
+ * @param $type Type of input data.
+ * @return string Decoded data in XML format.
+ */
+ function _encode($data, $type, $dtd_version)
+ {
+ switch($type)
+ {
+ case 'application/vnd.syncml-devinf+wbxml':
+ $wbxml_encoder = new wbxml_encoder();
+
$wbxml_encoder->header(WBXML_OUTGOING_VERSION, sprintf(
+ '-//SYNCML//DTD DevInf %s//EN',
$dtd_version));
+ $xml_parser = new xml_parser();
+ return $xml_parser->parse($data,
$wbxml_encoder);
+ case 'application/vnd.syncml-devinf+xml':
+ return $data;
+ default:
+ return NULL;
+ }
+ }
+
+ /**
+ * Decode from type to XML array.
+ *
+ * @param $data Data to decode.
+ * @param $type Type of input data.
+ * @param $dtd_version
+ * @return string Decoded data in XML array format.
+ */
+ function _decode($data, $type)
+ {
+ switch($type)
+ {
+ case 'application/vnd.syncml-devinf+wbxml':
+ $mapper = new xml_mapper();
+ $parser = new wbxml_parser();
+ return $parser->parse($data, $mapper);
+ case 'application/vnd.syncml-devinf+xml':
+ return $data;
default:
return NULL;
}
@@ -62,7 +120,6 @@
'<VerDTD>1.0</VerDTD>' .
'<DevID>485749KR</DevID>' .
'<DevTyp>Server</DevTyp>' .
- '<SupportLargeObjs/>' .
'</DevInf>';
}
@@ -78,33 +135,11 @@
}
/**
- * Put DEVINF.
- *
- * @param $uri URI of DEVINF to put.
- * @param $data DEVINF data in XML array format.
- * @return bool True. False on failure.
- */
- function put_item($uri, $data)
- {
- switch($uri)
- {
- case './devinf10':
- // return $this->_put_devinf_10($data);
- return FALSE;
- case './devinf11':
- return $this->_put_devinf_11($data);
- default:
- return FALSE;
- }
- }
-
- /**
* Process DEVINF data.
*
* @param $data Devinf data as XML array.
- * @param $session Session object.
*/
- function _put_devinf_11($data)
+ function _put_devinf($data)
{
$this->session->set_var(
SYNCML_SUPPORTNUMBEROFCHANGES,
Index: inc/class.syncml_response.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_response.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- inc/class.syncml_response.inc.php 11 Aug 2007 17:24:37 -0000 1.3
+++ inc/class.syncml_response.inc.php 16 Aug 2007 23:58:00 -0000 1.4
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: class.syncml_response.inc.php,v 1.3 2007/08/11
17:24:37 johang Exp $
+ * @version $Id: class.syncml_response.inc.php,v 1.4 2007/08/16
23:58:00 johang Exp $
*/
define('METINF', 'xmlns="syncml:metinf"');
@@ -50,6 +50,11 @@
echo '</SyncML>';
}
+ function filter($data)
+ {
+ return $data;
+ }
+
function status_commands_only()
{
return $this->status_count == count($this->commands);
@@ -119,7 +124,7 @@
$item_d[$i] = '<Item>' . $item_d[$i] .
'</Item>';
}
- $this->commands[] =
+ $this->commands[] = $this->filter(
'<Results>' .
'<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
'<MsgRef>' . $msgref . '</MsgRef>' .
@@ -130,7 +135,8 @@
$this->get_meta(array('type' =>
$type)) .
'</Meta>' .
implode('', $item_d) .
- '</Results>';
+ '</Results>'
+ );
}
function add_alert($code, $item, $supportlargeobj = FALSE)
@@ -140,13 +146,14 @@
unset($item['meta']['maxobjsize']);
}
- $this->commands[] =
+ $this->commands[] = $this->filter(
'<Alert>' .
'<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
'<Data>' . $code . '</Data>' .
ec(is_array($item), 'Item',
$this->get_item($item,
$supportlargeobj)) .
- '</Alert>';
+ '</Alert>'
+ );
}
function set_syncml_namespace_version($version)
@@ -191,7 +198,7 @@
{
$this->status_count++;
- $this->commands[] =
+ $this->commands[] = $this->filter(
'<Status>' .
'<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
'<CmdRef>' . $cmdref . '</CmdRef>' .
@@ -201,7 +208,8 @@
ec((bool)$trgref, 'TargetRef', $trgref)
.
'<Data>' . $data . '</Data>' .
ec(is_array($item), "Item",
$this->get_item($item)) .
- '</Status>';
+ '</Status>'
+ );
}
function get_item($item)
@@ -245,7 +253,7 @@
{
$this->status_count++;
- $this->commands[] =
+ $this->commands[] = $this->filter(
'<Status>' .
'<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
'<CmdRef>' . $cmdref . '</CmdRef>' .
@@ -262,7 +270,8 @@
'<Format
xmlns="syncml:metinf">b64</Format>' .
'</Meta>' .
'</Chal>' .
- '</Status>';
+ '</Status>'
+ );
}
function add_status_with_anchor($cmdref, $msgref, $cmd, $trgref,
@@ -270,7 +279,7 @@
{
$this->status_count++;
- $this->commands[] =
+ $this->commands[] = $this->filter(
'<Status>' .
'<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
'<CmdRef>' . $cmdref . '</CmdRef>' .
@@ -286,7 +295,8 @@
'</Anchor>' .
'</Data>' .
'</Item>' .
- '</Status>';
+ '</Status>'
+ );
}
function build_add($meta, $item, $last_chunk)
@@ -327,7 +337,7 @@
function add_sync($trg_uri, $src_uri, $commands,
$supportnbrofchanges,
$nbrofchanges)
{
- $this->commands[] =
+ $this->commands[] = $this->filter(
'<Sync>' .
'<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
'<Target>' .
@@ -339,7 +349,8 @@
ec($supportnbrofchanges,
'NumberOfChanges',
$nbrofchanges) .
implode('', $commands) .
- '</Sync>';
+ '</Sync>'
+ );
}
}
?>
Index: inc/class.syncml_session_dummy.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_session_dummy.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_session_dummy.inc.php 30 Jul 2007 13:04:39 -0000
1.1.1.1
+++ inc/class.syncml_session_dummy.inc.php 16 Aug 2007 23:58:00 -0000
1.2
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: class.syncml_session_dummy.inc.php,v 1.1.1.1
2007/07/30 13:04:39 johang Exp $
+ * @version $Id: class.syncml_session_dummy.inc.php,v 1.2 2007/08/16
23:58:00 johang Exp $
*/
require_once 'inc/class.syncml_session.inc.php';
@@ -21,7 +21,11 @@
/**
* This dummy contructor by-passes the parent constructor.
*/
- function syncml_dummy_session()
+ function syncml_session_dummy()
+ {
+ }
+
+ function commit()
{
}
}
Index: inc/class.xml_offset_mapper.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.xml_offset_mapper.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.xml_offset_mapper.inc.php 30 Jul 2007 13:04:38 -0000 1.1.1.1
+++ inc/class.xml_offset_mapper.inc.php 16 Aug 2007 23:58:01 -0000 1.2
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: class.xml_offset_mapper.inc.php,v 1.1.1.1 2007/07/30
13:04:38 johang Exp $
+ * @version $Id: class.xml_offset_mapper.inc.php,v 1.2 2007/08/16
23:58:01 johang Exp $
*/
require 'inc/class.xml_mapper.inc.php';
@@ -51,7 +51,7 @@
$this->offset_count = count($offset);
}
- function start_tag(&$parser, $tag, $attrs)
+ function start_tag($parser, $tag, $attrs)
{
switch($this->offset_matching_depth)
{
@@ -72,7 +72,7 @@
$this->depth++;
}
- function end_tag(&$parser, $tag)
+ function end_tag($parser, $tag)
{
$this->depth--;
@@ -87,7 +87,7 @@
}
}
- function data(&$parser, $data)
+ function data($parser, $data)
{
if($this->offset_matching_depth == $this->offset_count
&&
$this->offset_matching_depth < $this->depth)
Index: inc/constants.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/constants.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/constants.inc.php 30 Jul 2007 13:04:38 -0000 1.1.1.1
+++ inc/constants.inc.php 16 Aug 2007 23:58:01 -0000 1.2
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: constants.inc.php,v 1.1.1.1 2007/07/30 13:04:38
johang Exp $
+ * @version $Id: constants.inc.php,v 1.2 2007/08/16 23:58:01 johang
Exp $
*/
/**
@@ -87,4 +87,18 @@
define('SYNCML_XML_DATA', -2);
define('SYNCML_XML_ORIGINAL_ORDER', -3);
define('SYNCML_XML_TAG_NAME', -4);
+
+ /**
+ * Used by WBXML parsing/encoding code.
+ */
+ define('WBXML_ATTRIBUTE_BIT', 0x80);
+ define('WBXML_CONTENT_BIT', 0x40);
+ define('WBXML_OUTGOING_VERSION', 0x02);
+
+ define('WBXML_SWITCH', 0x00);
+ define('WBXML_END', 0x01);
+ define('WBXML_STR_I', 0x03);
+ define('WBXML_LITERAL', 0x04);
+ define('WBXML_STR_T', 0x83);
+ define('WBXML_OPAQUE', 0xC3);
?>
Index: inc/functions.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/functions.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/functions.inc.php 5 Aug 2007 17:15:41 -0000 1.2
+++ inc/functions.inc.php 16 Aug 2007 23:58:01 -0000 1.3
@@ -7,7 +7,7 @@
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
* @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: functions.inc.php,v 1.2 2007/08/05 17:15:41 johang
Exp $
+ * @version $Id: functions.inc.php,v 1.3 2007/08/16 23:58:01 johang
Exp $
*/
/**
Index: setup/setup.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/setup/setup.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- setup/setup.inc.php 5 Aug 2007 17:15:41 -0000 1.2
+++ setup/setup.inc.php 16 Aug 2007 23:58:01 -0000 1.3
@@ -5,9 +5,9 @@
*
* @author Johan Gunnarsson <address@hidden>
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
- * @license GNU General Public License
+ * @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: setup.inc.php,v 1.2 2007/08/05 17:15:41 johang Exp $
+ * @version $Id: setup.inc.php,v 1.3 2007/08/16 23:58:01 johang Exp $
*/
$setup_info['syncml']['name'] = 'syncml';
Index: setup/tables_baseline.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/setup/tables_baseline.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- setup/tables_baseline.inc.php 5 Aug 2007 17:15:41 -0000 1.1
+++ setup/tables_baseline.inc.php 16 Aug 2007 23:58:01 -0000 1.2
@@ -5,9 +5,9 @@
*
* @author Johan Gunnarsson <address@hidden>
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
- * @license GNU General Public License
+ * @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: tables_baseline.inc.php,v 1.1 2007/08/05 17:15:41
johang Exp $
+ * @version $Id: tables_baseline.inc.php,v 1.2 2007/08/16 23:58:01
johang Exp $
*/
$phpgw_baseline = array(
Index: setup/tables_current.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/setup/tables_current.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- setup/tables_current.inc.php 5 Aug 2007 17:15:41 -0000 1.2
+++ setup/tables_current.inc.php 16 Aug 2007 23:58:01 -0000 1.3
@@ -5,9 +5,9 @@
*
* @author Johan Gunnarsson <address@hidden>
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
- * @license GNU General Public License
+ * @license GNU General Public License 3 or later
* @package syncml
- * @version $Id: tables_current.inc.php,v 1.2 2007/08/05 17:15:41
johang Exp $
+ * @version $Id: tables_current.inc.php,v 1.3 2007/08/16 23:58:01
johang Exp $
*/
$phpgw_baseline = array(
Index: setup/tables_update.php
===================================================================
RCS file: /sources/phpgroupware/syncml/setup/tables_update.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- setup/tables_update.php 5 Aug 2007 17:15:41 -0000 1.1
+++ setup/tables_update.php 16 Aug 2007 23:58:02 -0000 1.2
@@ -5,9 +5,9 @@
*
* @author Johan Gunnarsson <address@hidden>
* @copyright Copyright (c) 2007 Free Software Foundation, Inc.
- * @license GNU General Public License
+ * @license GNU General Public License 3 or later
* @package syncml
- * @version $ $
+ * @version $Id: tables_update.php,v 1.2 2007/08/16 23:58:02 johang
Exp $
*/
$test[] = '0.9.17.001';
Index: inc/class.syncml_command_results.inc.php
===================================================================
RCS file: inc/class.syncml_command_results.inc.php
diff -N inc/class.syncml_command_results.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.syncml_command_results.inc.php 16 Aug 2007 23:58:00 -0000
1.1
@@ -0,0 +1,40 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * SyncML interface
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package syncml
+ * @version $Id: class.syncml_command_results.inc.php,v 1.1
2007/08/16 23:58:00 johang Exp $
+ */
+
+ require_once 'inc/class.syncml_command.inc.php';
+
+ /**
+ * Takes care of incoming RESULTS commands.
+ */
+ class syncml_command_results extends syncml_command
+ {
+ function syncml_command_results($xml_array = array())
+ {
+ if(is_array($xml_array))
+ {
+ $this->parse_xml_array($xml_array);
+ }
+ }
+
+ function execute(&$response, &$session)
+ {
+ if($response->has_global_status_code())
+ {
+ $response->add_status(
+ $this->cmdid, $session->msgid,
'Results',
+ NULL, NULL,
+ $response->get_global_status_code());
+ return;
+ }
+ }
+ }
+?>
Index: inc/class.syncml_wbxml_encoder.inc.php
===================================================================
RCS file: inc/class.syncml_wbxml_encoder.inc.php
diff -N inc/class.syncml_wbxml_encoder.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.syncml_wbxml_encoder.inc.php 16 Aug 2007 23:58:00 -0000
1.1
@@ -0,0 +1,194 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * SyncML interface
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package syncml
+ * @version $Id: class.syncml_wbxml_encoder.inc.php,v 1.1 2007/08/16
23:58:00 johang Exp $
+ */
+
+ require_once 'inc/wbxml_code_spaces.inc.php';
+ require_once 'inc/constants.inc.php';
+
+ /**
+ * TODO:
+ * 1. No support for attributes *at all* (SyncML doesn't use
attributes)
+ * 2. LITERAL/LITERAL_A/LITERAL_C/LITERAL_AC (SyncML doesn't need to
use
+ * literals).
+ * 3. Having code spaces and code pages in global variables is not a
+ * good idea.
+ */
+
+ /**
+ * Encode XML events to WBXML.
+ */
+ class syncml_wbxml_encoder
+ {
+ var $structure = '';
+
+ var $namespaces = array('syncml');
+
+ var $last_tag_code = NULL;
+ var $last_attributes = NULL;
+ var $last_payload = NULL;
+
+ var $current_code_page = 0x00;
+
+ function _print_last_tag()
+ {
+ if(!is_null($this->last_tag_code))
+ {
+ if(is_array($this->last_attributes) &&
+ count($this->last_attributes) > 0)
+ {
+ $this->structure .=
+ chr($this->last_tag_code /* |
WBXML_ATTRIBUTE_BIT */) .
+ $this->last_payload /* .
+ chr(WBXML_ATTRSTART) */;
+
+ /*
+ foreach($this->last_attributes as $a)
+ {
+ // todo: print attribute
+ }
+ */
+ }
+ else
+ {
+ $this->structure .=
+ chr($this->last_tag_code) .
$this->last_payload;
+ }
+ }
+
+ $this->last_tag_code = $this->last_attributes =
+ $this->last_payload = NULL;
+ }
+
+ function header($version, $dtd_string, $charset)
+ {
+ $this->structure .= chr($version);
+ $this->structure .= chr(0) . chr(0); // ref to strtbl
+
+ $this->structure .= chr($charset);
+
+ // strtbl
+ $this->structure .= chr(strlen($dtd_string)) .
$dtd_string;
+ }
+
+ function end_tag($parser, $tag)
+ {
+ $code = $this->last_tag_code;
+
+ $this->_print_last_tag();
+
+ if($code === NULL || $code & WBXML_CONTENT_BIT)
+ {
+ $this->structure .= chr(WBXML_END);
+ }
+
+ $poped_ns = array_pop($this->namespaces);
+ $end_ns = end($this->namespaces);
+
+ if($poped_ns != $end_ns)
+ {
+ list($code_space, $code_page) =
+ isset($GLOBALS['namespaces'][$end_ns]) ?
+ $GLOBALS['namespaces'][$end_ns] :
array(0xFD1, 0);
+
+ $this->structure .= chr(WBXML_SWITCH) .
chr($code_page);
+ }
+ }
+
+ function start_tag($parser, $tag, $attrs)
+ {
+ $last_ns = end($this->namespaces);
+
+ if(isset($attrs['XMLNS']) && $attrs['XMLNS'])
+ {
+ $this->namespaces[] = $attrs['XMLNS'];
+ }
+ else
+ {
+ $this->namespaces[] = end($this->namespaces);
+ }
+
+ $current_ns = end($this->namespaces);
+
+ list($code_space, $code_page) =
+ isset($GLOBALS['namespaces'][$current_ns]) ?
+ $GLOBALS['namespaces'][$current_ns] :
array(0xFD1, 0);
+
+ if($this->last_tag_code)
+ {
+ $this->last_tag_code |= WBXML_CONTENT_BIT;
+ $this->_print_last_tag();
+ }
+
+ if($last_ns != $current_ns)
+ {
+ $this->structure .= chr(WBXML_SWITCH) .
chr($code_page);
+ }
+
+
if(isset($GLOBALS['wbxml_tag_to_code'][$code_space][$code_page]
+ [strtoupper($tag)]) &&
$GLOBALS['wbxml_tag_to_code']
+ [$code_space][$code_page][strtoupper($tag)])
+ {
+ $this->last_tag_code =
$GLOBALS['wbxml_tag_to_code']
+
[$code_space][$code_page][strtoupper($tag)];
+ $this->last_attributes = $attrs;
+ }
+ else
+ {
+ // todo: set literal in last_tag_code, tag name
in payload
+ }
+ }
+
+ function raw($data)
+ {
+ $this->structure .= $data;
+ }
+
+ function data($parser, $data)
+ {
+ if($this->last_tag_code)
+ {
+ $this->last_tag_code |= WBXML_CONTENT_BIT;
+ $this->_print_last_tag();
+ }
+
+ if(!is_null($data))
+ {
+ $this->structure .= chr(WBXML_OPAQUE) .
+ $this->_build_mb_uint32(strlen($data))
. $data;
+ }
+ }
+
+ /**
+ * Build multi-byte int from int.
+ *
+ * @param $number Integer to encode to multi-byte convention.
+ */
+ function _build_mb_uint32($number)
+ {
+ $last_seven_bits = $number & 0x7F;
+ $number >>= 7;
+
+ $mb_uint32 = chr($last_seven_bits);
+
+ while($number > 0)
+ {
+ // 0x7F = 01111111
+ $last_seven_bits = $number & 0x7F;
+ $number >>= 7;
+
+ // 0x80 = 10000000
+ $mb_uint32 = chr(0x80 | $last_seven_bits) .
$mb_uint32;
+ }
+
+ return $mb_uint32;
+ }
+ }
+?>
Index: inc/class.syncml_wbxml_parser.inc.php
===================================================================
RCS file: inc/class.syncml_wbxml_parser.inc.php
diff -N inc/class.syncml_wbxml_parser.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.syncml_wbxml_parser.inc.php 16 Aug 2007 23:58:00 -0000
1.1
@@ -0,0 +1,283 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * SyncML interface
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package syncml
+ * @version $Id: class.syncml_wbxml_parser.inc.php,v 1.1 2007/08/16
23:58:00 johang Exp $
+ */
+
+ require_once 'inc/wbxml_code_spaces.inc.php';
+
+ /**
+ * WBXML parser.
+ */
+ class syncml_wbxml_parser
+ {
+ var $tag_code_page = 0;
+ var $attribute_code_page = 0;
+ var $code_space;
+
+ var $raw_data;
+ var $mapper;
+ var $closing_nodes = array();
+
+ var $string_table = array();
+ var $charset;
+ var $publicid, $publicid_ref;
+ var $version;
+
+ /**
+ * Parse a WBXML document to XML array.
+ *
+ * @param $raw_data Array with one byte per element.
+ * @param $mapper Object receiving parser events.
+ * @return array XML array of WBXML document.
+ */
+ function parse($raw_data, $mapper)
+ {
+ $this->raw_data = $raw_data;
+ $this->mapper = &$mapper;
+
+ $this->parse_start();
+
+ $this->parse_body();
+
+ return $mapper->structure;
+ }
+
+ function parse_start()
+ {
+ $this->version = $this->read_uint8();
+
+ $this->publicid = $this->read_mb_uint32();
+
+ if(!$this->publicid)
+ {
+ $this->publicid_ref = $this->read_mb_uint32();
+ }
+
+ $this->charset = $this->read_mb_uint32();
+
+ // string table parsing follows
+
+ if(!current($this->raw_data))
+ {
+ return;
+ }
+
+ $length = $this->read_mb_uint32();
+
+ $buffer = '';
+ $start = 0;
+
+ for($i = 0; $i < $length; $i++)
+ {
+ $byte = $this->read_uint8();
+
+ if($byte === 0)
+ {
+ $this->string_table[$start] = $buffer;
+ $buffer = '';
+ $start = $i + 1;
+ }
+ else
+ {
+ $buffer .= chr($byte);
+ }
+ }
+
+ if(strlen($buffer) > 0)
+ {
+ $this->string_table[$start] = $buffer;
+ }
+
+ if(!is_null($this->publicid_ref))
+ {
+ $this->code_space = $GLOBALS['publicid']
+
[$this->string_table[$this->publicid_ref]];
+ }
+ else
+ {
+ $this->code_space = $this->publicid;
+ }
+ }
+
+ function parse_body()
+ {
+ $tag = $this->read_uint8();
+
+ while($tag !== NULL)
+ {
+ switch($tag)
+ {
+ case WBXML_SWITCH:
+ $this->tag_code_page =
$this->read_uint8();
+ break;
+ case WBXML_END:
+ $this->mapper->end_tag(
+ NULL,
array_pop($this->closing_nodes));
+ break;
+ case WBXML_STR_T:
+ $this->mapper->data(
+
$this->string_table[$this->read_mb_uint32()]);
+ break;
+ case WBXML_STR_I:
+ $this->mapper->data(NULL,
$this->read_inline_string());
+ break;
+ case WBXML_OPAQUE:
+ $this->mapper->data(NULL,
$this->read_opaque_string());
+ break;
+ default:
+ $attributes = array();
+ $tag_code = $tag &
+ ~(WBXML_ATTRIBUTE_BIT |
WBXML_CONTENT_BIT);
+
+ if($tag_code == WBXML_LITERAL)
+ {
+ $index =
$this->read_mb_uint32();
+ $tag_name =
$this->string_table[$index];
+ }
+ else
+ {
+ $tag_name =
$GLOBALS['wbxml_code_to_tag']
+
[$this->code_space][$this->tag_code_page]
+ [$tag_code];
+ }
+
+ $this->closing_nodes[] =
$tag_name;
+
+ if($tag & WBXML_ATTRIBUTE_BIT)
+ {
+ $attributes =
$this->read_attributes();
+ }
+
+ $this->mapper->start_tag(NULL,
$tag_name, $attributes);
+
+ if(!($tag & WBXML_CONTENT_BIT))
+ {
+
$this->mapper->end_tag(NULL, $tag_name);
+
array_pop($this->closing_nodes);
+ }
+ }
+
+ $tag = $this->read_uint8();
+ }
+ }
+
+ function read_inline_string()
+ {
+ $buffer = '';
+
+ do
+ {
+ $byte = $this->read_uint8();
+ $buffer .= chr($byte);
+ } while($byte > 0);
+
+ return substr($buffer, 0, -1);
+ }
+
+ function read_opaque_string()
+ {
+ $length = $this->read_mb_uint32();
+
+ $buffer = '';
+
+ for(; $length > 0; $length--)
+ {
+ $buffer .= chr($this->read_uint8());
+ }
+
+ return $buffer;
+ }
+
+ /**
+ * Read attributes.
+ *
+ * @return array Attribute name as key, attributes value as
value.
+ */
+ function read_attributes()
+ {
+ $attributes = array();
+ $buffer_name = '';
+ $buffer_value = '';
+
+ $byte = $this->read_uint8();
+
+ while($byte != WBXML_END);
+ {
+ switch($byte)
+ {
+ case WBXML_SWITCH:
+ $this->attribute_code_page =
$this->read_uint8();
+ break;
+ case WBXML_STR_T:
+ $buffer_value .=
+
$this->string_table[$this->read_mb_uint32()];
+ break;
+ case WBXML_STR_I:
+ $buffer_value .=
$this->read_inline_string();
+ break;
+ case WBXML_OPAQUE:
+ $buffer_value .=
$this->read_opaque_string();
+ break;
+ case WBXML_END:
+ $attributes[$buffer_name] =
$buffer_value;
+ $buffer_value = '';
+ break;
+ case WBXML_LITERAL:
+ $attributes[$buffer_name] =
$buffer_value;
+ $buffer_name =
+
$this->string_table[$this->read_mb_uint32()];
+ $buffer_value = '';
+ break;
+ default:
+ if($byte & WBXML_ATTRIBUTE_BIT)
+ {
+ // todo: attribute
value space
+ $buffer_value .= NULL;
+ }
+ else
+ {
+ // todo: attribute name
space
+
$attributes[$buffer_name] = $buffer_value;
+ $buffer_name = NULL;
+ $buffer_value = '';
+ }
+ break;
+ }
+
+ $byte = $this->read_uint8();
+ }
+
+ $attributes[$buffer_name] = $buffer_value;
+
+ return $attributes;
+ }
+
+ function read_uint8()
+ {
+ $h = each($this->raw_data);
+
+ return $h === FALSE ? NULL : $h['value'];
+ }
+
+ function read_mb_uint32()
+ {
+ $y = 0;
+
+ do
+ {
+ list(, $x) = each($this->raw_data);
+ $y <<= 7;
+ $y |= $x & 0x7F;
+ } while($x & 0x80);
+
+ return $y;
+ }
+ }
+?>
Index: inc/class.syncml_wbxml_response.inc.php
===================================================================
RCS file: inc/class.syncml_wbxml_response.inc.php
diff -N inc/class.syncml_wbxml_response.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.syncml_wbxml_response.inc.php 16 Aug 2007 23:58:00 -0000
1.1
@@ -0,0 +1,63 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * SyncML interface
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package syncml
+ * @version $Id: class.syncml_wbxml_response.inc.php,v 1.1 2007/08/16
23:58:00 johang Exp $
+ */
+
+ require_once 'class.syncml_response.inc.php';
+ require_once 'class.syncml_wbxml_encoder.inc.php';
+
+ require_once 'class.xml_parser.inc.php';
+
+ class syncml_wbxml_response extends syncml_response
+ {
+ var $xml_parser;
+
+ function syncml_wbxml_response()
+ {
+ $this->root_namespace = '-//SYNCML//DTD SyncML 1.1//EN';
+
+ $this->xml_parser = new xml_parser();
+ }
+
+ function print_response()
+ {
+ $encoder = new syncml_wbxml_encoder();
+
+ $encoder->header(
+ 0x02, $this->root_namespace, 0x04);
+
+ $encoder->start_tag(NULL, 'SyncML', array());
+ $encoder->data(NULL, NULL);
+ $encoder->raw($this->filter(
+ '<SyncHdr>' . $this->header .
$this->header_cred .
+ '</SyncHdr>'));
+ $encoder->start_tag(NULL, 'SyncBody', array());
+ $encoder->data(NULL, NULL);
+ $encoder->raw(implode('', $this->commands));
+ $encoder->start_tag(NULL, 'Final', array());
+ $encoder->end_tag(NULL, 'Final');
+ $encoder->end_tag(NULL, 'SyncBody');
+ $encoder->end_tag(NULL, 'SyncML');
+
+ echo $encoder->structure;
+ }
+
+ function filter($data)
+ {
+ return $this->xml_parser->parse($data, new
syncml_wbxml_encoder());
+ }
+
+ function set_syncml_namespace_version($version)
+ {
+ $this->root_namespace = sprintf(
+ '-//SYNCML//DTD SyncML %s//EN', $version);
+ }
+ }
+?>
Index: inc/class.xml_parser.inc.php
===================================================================
RCS file: inc/class.xml_parser.inc.php
diff -N inc/class.xml_parser.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.xml_parser.inc.php 16 Aug 2007 23:58:01 -0000 1.1
@@ -0,0 +1,44 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * SyncML interface
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package syncml
+ * @version $Id: class.xml_parser.inc.php,v 1.1 2007/08/16 23:58:01
johang Exp $
+ */
+
+ require_once 'inc/functions.inc.php';
+
+ class xml_parser
+ {
+ function parse($data, $mapper)
+ {
+ $encoding = syncml_parse_encoding($data);
+
+ if($encoding)
+ {
+ $parser = xml_parser_create($encoding);
+ }
+ else
+ {
+ $parser = xml_parser_create();
+ }
+
+ xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE,
0);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING,
1);
+
+ xml_set_object($parser, $mapper);
+
+ xml_set_element_handler($parser, 'start_tag',
'end_tag');
+ xml_set_character_data_handler($parser, 'data');
+
+ xml_parse($parser, $data);
+ xml_parser_free($parser);
+
+ return $mapper->structure;
+ }
+ }
+?>
Index: inc/wbxml_code_spaces.inc.php
===================================================================
RCS file: inc/wbxml_code_spaces.inc.php
diff -N inc/wbxml_code_spaces.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/wbxml_code_spaces.inc.php 16 Aug 2007 23:58:01 -0000 1.1
@@ -0,0 +1,166 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * SyncML interface
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package syncml
+ * @version $Id: wbxml_code_spaces.inc.php,v 1.1 2007/08/16 23:58:01
johang Exp $
+ */
+
+ $GLOBALS['wbxml_code_to_tag'] = array
+ (
+ 0xFD1 => array
+ (
+ 0x00 => array
+ (
+ 0x05 => 'ADD',
+ 0x06 => 'ALERT',
+ 0x07 => 'ARCHIVE',
+ 0x08 => 'ATOMIC',
+ 0x09 => 'CHAL',
+ 0x0A => 'CMD',
+ 0x0B => 'CMDID',
+ 0x0C => 'CMDREF',
+ 0x0D => 'COPY',
+ 0x0E => 'CRED',
+ 0x0F => 'DATA',
+ 0x10 => 'DELETE',
+ 0x11 => 'EXEC',
+ 0x12 => 'FINAL',
+ 0x13 => 'GET',
+ 0x14 => 'ITEM',
+ 0x15 => 'LANG',
+ 0x16 => 'LOCNAME',
+ 0x17 => 'LOCURI',
+ 0x18 => 'MAP',
+ 0x19 => 'MAPITEM',
+ 0x1A => 'META',
+ 0x1B => 'MSGID',
+ 0x1C => 'MSGREF',
+ 0x1D => 'NORESP',
+ 0x1E => 'NORESULTS',
+ 0x1F => 'PUT',
+ 0x20 => 'REPLACE',
+ 0x21 => 'RESPURI',
+ 0x22 => 'RESULTS',
+ 0x23 => 'SEARCH',
+ 0x24 => 'SEQUENCE',
+ 0x25 => 'SESSIONID',
+ 0x26 => 'SFTDEL',
+ 0x27 => 'SOURCE',
+ 0x28 => 'SOURCEREF',
+ 0x29 => 'STATUS',
+ 0x2A => 'SYNC',
+ 0x2B => 'SYNCBODY',
+ 0x2C => 'SYNCHDR',
+ 0x2D => 'SYNCML',
+ 0x2E => 'TARGET',
+ 0x2F => 'TARGETREF',
+ // (0x30 is reserved for some reason)
+ 0x31 => 'VERDTD',
+ 0x32 => 'VERPROTO',
+ 0x33 => 'NUMBEROFCHANGES',
+ 0x34 => 'MOREDATA'
+ ),
+ 0x01 => array
+ (
+ 0x05 => 'ANCHOR',
+ 0x06 => 'EMI',
+ 0x07 => 'FORMAT',
+ 0x08 => 'FREEID',
+ 0x09 => 'FREEMEM',
+ 0x0A => 'LAST',
+ 0x0B => 'MARK',
+ 0x0C => 'MAXMSGSIZE',
+ 0x0D => 'MEM',
+ 0x0E => 'METINF',
+ 0x0F => 'NEXT',
+ 0x10 => 'NEXTNONCE',
+ 0x11 => 'SHAREDMEM',
+ 0x12 => 'SIZE',
+ 0x13 => 'TYPE',
+ 0x14 => 'VERSION',
+ 0x15 => 'MAXOBJSIZE'
+ )
+ ),
+ 0xFD2 => array
+ (
+ 0x00 => array
+ (
+ 0x05 => 'CTCAP',
+ 0x06 => 'CTTYPE',
+ 0x07 => 'DATASTORE',
+ 0x08 => 'DATATYPE',
+ 0x09 => 'DEVID',
+ 0x0A => 'DEVINF',
+ 0x0B => 'DEVTYP',
+ 0x0C => 'DISPLAYNAME',
+ 0x0D => 'DSMEM',
+ 0x0E => 'EXT',
+ 0x0F => 'FWV',
+ 0x10 => 'HWV',
+ 0x11 => 'MAN',
+ 0x12 => 'MAXGUIDSIZE',
+ 0x13 => 'MAXID',
+ 0x14 => 'MAXMEM',
+ 0x15 => 'MOD',
+ 0x16 => 'OEM',
+ 0x17 => 'PARAMNAME',
+ 0x18 => 'PROPNAME',
+ 0x19 => 'RX',
+ 0x1A => 'RX-PREF',
+ 0x1B => 'SHAREDMEM',
+ 0x1C => 'SIZE',
+ 0x1D => 'SOURCEREF',
+ 0x1E => 'SWV',
+ 0x1F => 'SYNCCAP',
+ 0x20 => 'SYNCTYPE',
+ 0x21 => 'TX',
+ 0x22 => 'TX-PREF',
+ 0x23 => 'VALENUM',
+ 0x24 => 'VERCT',
+ 0x25 => 'VERDTD',
+ 0x26 => 'XNAM',
+ 0x27 => 'XVAL',
+ 0x28 => 'UTC',
+ 0x29 => 'SUPPORTNUMBEROFCHANGES',
+ // (again, 0x30 is reserved)
+ 0x2A => 'SUPPORTLARGEOBJS'
+ )
+ )
+ );
+
+ $GLOBALS['wbxml_tag_to_code'] = array
+ (
+ 0xFD1 => array
+ (
+ 0x00 => array_flip($wbxml_code_to_tag[0xFD1][0x00]),
+ 0x01 => array_flip($wbxml_code_to_tag[0xFD1][0x01]),
+ ),
+ 0xFD2 => array
+ (
+ 0x00 => array_flip($wbxml_code_to_tag[0xFD2][0x00])
+ )
+ );
+
+ $GLOBALS['publicid'] = array
+ (
+ '-//SYNCML//DTD SyncML 1.1//EN' => 0xFD1,
+ '-//SYNCML//DTD SyncML 1.0//EN' => 0xFD1,
+ '-//SYNCML//DTD MetInf 1.1//EN' => 0xFD1,
+ '-//SYNCML//DTD MetInf 1.0//EN' => 0xFD1,
+ '-//SYNCML//DTD DevInf 1.1//EN' => 0xFD2,
+ '-//SYNCML//DTD DevInf 1.0//EN' => 0xFD2
+ );
+
+ $GLOBALS['namespaces'] = array
+ (
+ 'syncml' => array(0xFD1, 0x00),
+ 'syncml:SYNCML1.1' => array(0xFD1, 0x00),
+ 'syncml:metinf' => array(0xFD1, 0x01),
+ 'syncml:devinf' => array(0xFD2, 0x00)
+ );
+?>
Index: inc/class.syncml_xml_parser.inc.php
===================================================================
RCS file: inc/class.syncml_xml_parser.inc.php
diff -N inc/class.syncml_xml_parser.inc.php
--- inc/class.syncml_xml_parser.inc.php 5 Aug 2007 17:15:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
-<?php
- /**
- * phpGroupWare (http://phpgroupware.org/)
- * SyncML interface
- *
- * @author Johan Gunnarsson <address@hidden>
- * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
- * @license GNU General Public License
- * @package syncml
- * @version $ $
- */
-
- require_once 'inc/functions.inc.php';
-
- class syncml_xml_parser
- {
- function parse($data, $mapper)
- {
- $encoding = syncml_parse_encoding($data);
-
- if($encoding)
- {
- $parser = xml_parser_create($encoding);
- }
- else
- {
- $parser = xml_parser_create();
- }
-
- xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE,
0);
- xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING,
1);
-
- xml_set_object($parser, $mapper);
-
- xml_set_element_handler($parser, 'start_tag',
'end_tag');
- xml_set_character_data_handler($parser, 'data');
-
- xml_parse($parser, $data);
- xml_parser_free($parser);
-
- return $mapper->structure;
- }
- }
-?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] syncml syncml.php inc/class.syncml_command_get....,
Johan Gunnarsson <=