CVSROOT: /sources/phpgroupware Module name: syncml Changes by: Johan Gunnarsson <johang> 07/09/03 12:42:18
Modified files: . : syncml.php docs : README.txt TODO.txt inc : class.syncml_command_alert.inc.php class.syncml_command_get.inc.php class.syncml_command_sync.inc.php class.syncml_command_synchdr.inc.php class.syncml_database_devinf.inc.php Log message: Enabling WBXML support and some fixes for that. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/syncml/syncml.php?cvsroot=phpgroupware&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/syncml/docs/README.txt?cvsroot=phpgroupware&r1=1.1&r2=1.2 http://cvs.savannah.gnu.org/viewcvs/syncml/docs/TODO.txt?cvsroot=phpgroupware&r1=1.1&r2=1.2 http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_alert.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_get.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_sync.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.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_database_devinf.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3 Patches: Index: syncml.php =================================================================== RCS file: /sources/phpgroupware/syncml/syncml.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- syncml.php 16 Aug 2007 23:58:00 -0000 1.4 +++ syncml.php 3 Sep 2007 12:42:17 -0000 1.5 @@ -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.4 2007/08/16 23:58:00 johang Exp $ + * @version $Id: syncml.php,v 1.5 2007/09/03 12:42:17 johang Exp $ */ ob_start(); @@ -48,34 +48,21 @@ switch($_SERVER['CONTENT_TYPE']) { + case 'application/vnd.syncml+wbxml': + $post_input = wbxml_decode($post_input); case 'application/vnd.syncml+xml': $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($input, + $header = $parser->parse($post_input, new xml_offset_mapper(array('SYNCML', 'SYNCHDR'))); $message->process_header($header); @@ -83,7 +70,7 @@ // the body - $body = $parser->parse($GLOBALS['HTTP_RAW_POST_DATA'], + $body = $parser->parse($post_input, new xml_offset_mapper(array('SYNCML', 'SYNCBODY'))); $message->process_body($body); @@ -95,6 +82,24 @@ $response->print_response(); + switch($_SERVER['CONTENT_TYPE']) + { + case 'application/vnd.syncml+wbxml': + // remove the <?xml ... ?> tag + $xml = substr(ob_get_clean(), 38); + ob_start(); + // replace some bogus FPI values + echo str_replace( + array( + chr(0x02) . chr(0xA4) . chr(0x01) . chr(0x6A), + chr(0x02) . chr(0xA4) . chr(0x02) . chr(0x6A)), + array( + chr(0x02) . chr(0x9F) . chr(0x51) . chr(0x6A), + chr(0x02) . chr(0x9F) . chr(0x52) . chr(0x6A)), + wbxml_encode($xml, 0x02, FALSE, FALSE) + ); + } + header('Content-Type: ' . $_SERVER['CONTENT_TYPE']); header('Content-Length: ' . ob_get_length()); Index: docs/README.txt =================================================================== RCS file: /sources/phpgroupware/syncml/docs/README.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- docs/README.txt 20 Aug 2007 18:51:56 -0000 1.1 +++ docs/README.txt 3 Sep 2007 12:42:17 -0000 1.2 @@ -88,7 +88,8 @@ versions up to 1.1.2. Support for SyncML 1.2 is planned but not yet implemented. -There is no support for WBXML right now. This is also planned. +There is support for WBXML, but you need the PECL WBXML package available +from here: http://pecl.php.net/package/wbxml. URI to SyncML server is http://host/path/to/phpgw/syncml/syncml.php. Index: docs/TODO.txt =================================================================== RCS file: /sources/phpgroupware/syncml/docs/TODO.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- docs/TODO.txt 20 Aug 2007 18:51:56 -0000 1.1 +++ docs/TODO.txt 3 Sep 2007 12:42:18 -0000 1.2 @@ -2,7 +2,7 @@ Stuff to do in the SyncML module. -* WBXML support. +* Native PHP WBXML support. * SyncML 1.2 support. * Per-database authentication. * Logging and debugging tools. Index: inc/class.syncml_command_alert.inc.php =================================================================== RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_alert.inc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- inc/class.syncml_command_alert.inc.php 5 Aug 2007 17:15:40 -0000 1.2 +++ inc/class.syncml_command_alert.inc.php 3 Sep 2007 12:42:18 -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_alert.inc.php,v 1.2 2007/08/05 17:15:40 johang Exp $ + * @version $Id: class.syncml_command_alert.inc.php,v 1.3 2007/09/03 12:42:18 johang Exp $ */ require_once 'inc/class.sochannel.inc.php'; @@ -135,8 +135,8 @@ $cmdid = $response->add_alert( $status[1], array( - 'trg_uri' => $this->item[0]['target']['locuri'], - 'src_uri' => $this->item[0]['source']['locuri'], + 'trg_uri' => $this->item[0]['source']['locuri'], + 'src_uri' => $this->item[0]['target']['locuri'], 'meta' => array( 'last' => empty($phpgw_last) ? NULL : $phpgw_last, Index: inc/class.syncml_command_get.inc.php =================================================================== RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_get.inc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- inc/class.syncml_command_get.inc.php 16 Aug 2007 23:58:00 -0000 1.2 +++ inc/class.syncml_command_get.inc.php 3 Sep 2007 12:42:18 -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_get.inc.php,v 1.2 2007/08/16 23:58:00 johang Exp $ + * @version $Id: class.syncml_command_get.inc.php,v 1.3 2007/09/03 12:42:18 johang Exp $ */ require_once 'inc/class.syncml_command.inc.php'; @@ -43,11 +43,10 @@ { // 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: @@ -93,7 +92,7 @@ $response->add_result( $this->cmdid, $session->msgid, NULL, NULL, - $this->meta['type'], array( + 'application/vnd.syncml-devinf+wbxml', array( array( 'src_uri' => $item['target']['locuri'], 'data' => $result Index: inc/class.syncml_command_sync.inc.php =================================================================== RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_sync.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_sync.inc.php 30 Jul 2007 13:04:39 -0000 1.1.1.1 +++ inc/class.syncml_command_sync.inc.php 3 Sep 2007 12:42:18 -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_sync.inc.php,v 1.1.1.1 2007/07/30 13:04:39 johang Exp $ + * @version $Id: class.syncml_command_sync.inc.php,v 1.2 2007/09/03 12:42:18 johang Exp $ */ /** @@ -41,7 +41,7 @@ } $open_channel = $session->get_open_channel( - $this->source['locuri'], $this->target['locuri']); + $this->target['locuri'], $this->source['locuri']); if($open_channel) { @@ -50,6 +50,8 @@ else { $database = NULL; + + // todo: break execution here. } foreach($this->_modifications as $modification) Index: inc/class.syncml_command_synchdr.inc.php =================================================================== RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_synchdr.inc.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- inc/class.syncml_command_synchdr.inc.php 27 Aug 2007 07:49:58 -0000 1.4 +++ inc/class.syncml_command_synchdr.inc.php 3 Sep 2007 12:42:18 -0000 1.5 @@ -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.4 2007/08/27 07:49:58 johang Exp $ + * @version $Id: class.syncml_command_synchdr.inc.php,v 1.5 2007/09/03 12:42:18 johang Exp $ */ require_once 'inc/class.syncml_command.inc.php'; @@ -216,7 +216,7 @@ isset($this->target['locuri']) ? $this->target['locuri'] : NULL, isset($this->source['locuri']) ? - $this->target['locuri'] : NULL, + $this->source['locuri'] : NULL, $code, $auth_type, $nonce ); } Index: inc/class.syncml_database_devinf.inc.php =================================================================== RCS file: /sources/phpgroupware/syncml/inc/class.syncml_database_devinf.inc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- inc/class.syncml_database_devinf.inc.php 16 Aug 2007 23:58:00 -0000 1.2 +++ inc/class.syncml_database_devinf.inc.php 3 Sep 2007 12:42:18 -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_database_devinf.inc.php,v 1.2 2007/08/16 23:58:00 johang Exp $ + * @version $Id: class.syncml_database_devinf.inc.php,v 1.3 2007/09/03 12:42:18 johang Exp $ */ require_once 'inc/functions.inc.php'; @@ -78,11 +78,6 @@ 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: @@ -103,9 +98,9 @@ switch($type) { case 'application/vnd.syncml-devinf+wbxml': - $mapper = new xml_mapper(); $parser = new wbxml_parser(); - return $parser->parse($data, $mapper); + return $parser->parse( + wbxml_decode($data), new xml_mapper()); case 'application/vnd.syncml-devinf+xml': return $data; default: _______________________________________________ phpGroupWare-cvs mailing list phpGroupWare-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs