[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [18648] * Changes to logging.
From: |
Johan Gunnarsson |
Subject: |
[Phpgroupware-cvs] [18648] * Changes to logging. |
Date: |
Mon, 14 Jul 2008 22:07:38 +0000 |
Revision: 18648
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18648
Author: johang
Date: 2008-07-14 22:07:38 +0000 (Mon, 14 Jul 2008)
Log Message:
-----------
* Changes to logging.
* Constants for new encoding code.
* Update syncml_database_devinf to use new encoding code.
Modified Paths:
--------------
trunk/syncml/inc/class.somappings.inc.php
trunk/syncml/inc/class.syncml_database_devinf.inc.php
trunk/syncml/inc/class.syncml_session.inc.php
trunk/syncml/inc/constants.inc.php
Modified: trunk/syncml/inc/class.somappings.inc.php
===================================================================
--- trunk/syncml/inc/class.somappings.inc.php 2008-07-14 21:51:03 UTC (rev
18647)
+++ trunk/syncml/inc/class.somappings.inc.php 2008-07-14 22:07:38 UTC (rev
18648)
@@ -126,27 +126,27 @@
* @param $ch_id Channel ID of mapping. NULL to include all.
* @param $luid LUID of mapping. NULL to include all.
* @param $guid GUID of mapping. NULL to include all.
+ * @param $flag New value of flag.
* @return int Number of mappings updated.
*/
- function update_mapping($ch_id, $luid, $guid, $flag)
+ function update_mapping($source_id, $ch_id, $luid, $guid, $flag)
{
-
syncml_logger::get_instance()->log("update_mapping($ch_id, $luid, $guid,
$flag)");
- syncml_logger::get_instance()->log("
update_mapping :". '
- UPDATE phpgw_syncml_mappings SET dirty = \'' .
intval($flag) . '\' WHERE ' .
+ $query =
+ 'UPDATE phpgw_syncml_mappings ' .
+ sprintf("SET dirty = '%d' ", $flag) .
+ 'WHERE ' .
+ (!is_null($source_id) ?
+ 'source_id = \'' . $source_id .
'\' AND ' : '') .
(!is_null($ch_id) ?
'channel_id = \'' . $ch_id .
'\' AND ' : '') .
(!is_null($luid) ? 'luid = \'' . $luid
. '\' AND ' : '') .
(!is_null($guid) ? 'guid = \'' . $guid
. '\' AND ' : '') .
- '1 = 1');
- $GLOBALS['phpgw']->db->query('
- UPDATE phpgw_syncml_mappings SET dirty = \'' .
intval($flag) . '\' WHERE ' .
- (!is_null($ch_id) ?
- 'channel_id = \'' . $ch_id .
'\' AND ' : '') .
- (!is_null($luid) ? 'luid = \'' . $luid
. '\' AND ' : '') .
- (!is_null($guid) ? 'guid = \'' . $guid
. '\' AND ' : '') .
- '1 = 1',
- __LINE__, __FILE__);
+ '1 = 1';
+ syncml_logger::get_instance()->log_data('Query',
$query);
+
+ $GLOBALS['phpgw']->db->query($query, __LINE__,
__FILE__);
+
return $GLOBALS['phpgw']->db->affected_rows();
}
}
Modified: trunk/syncml/inc/class.syncml_database_devinf.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_database_devinf.inc.php 2008-07-14
21:51:03 UTC (rev 18647)
+++ trunk/syncml/inc/class.syncml_database_devinf.inc.php 2008-07-14
22:07:38 UTC (rev 18648)
@@ -12,8 +12,6 @@
require_once 'inc/functions.inc.php';
- require_once 'inc/class.xml_parser.inc.php';
-
/**
* A device information database.
*/
@@ -35,19 +33,40 @@
*/
function get_item($uri, $type)
{
+ syncml_logger::get_instance()->log("Get item $uri
($type)");
+
+ switch($type)
+ {
+ case 'application/vnd.syncml-devinf+wbxml':
+ $encoder = new syncml_wbxml_encoder();
+ break;
+ case 'application/vnd.syncml-devinf+xml':
+ $encoder = new syncml_xml_encoder();
+ break;
+ default:
+ return NULL;
+ }
+
+ syncml_logger::get_instance()->log_data('Got encoder',
+ get_class($encoder));
+
switch($uri)
{
case './devinf10':
- return syncml_wrap_data(
-
$this->_encode($this->_get_devinf_10(), $type, '1.0'),
- $type);
+ if($type ==
'application/vnd.syncml-devinf+wbxml')
+
$encoder->header('-//SYNCML//DTD DevInf 1.0//EN');
+ $this->_encode_devinf_10($encoder);
+ break;
case './devinf11':
- return syncml_wrap_data(
-
$this->_encode($this->_get_devinf_11(), $type, '1.1'),
- $type);
+ if($type ==
'application/vnd.syncml-devinf+wbxml')
+
$encoder->header('-//SYNCML//DTD DevInf 1.1//EN');
+ $this->_encode_devinf_11($encoder);
+ break;
default:
return NULL;
}
+
+ return $encoder->dump();
}
/**
@@ -60,92 +79,91 @@
*/
function put_item($uri, $data, $type)
{
- switch($uri)
- {
- case './devinf10':
- case './devinf11':
- return
$this->_put_devinf($this->_decode($data, $type));
- default:
- return FALSE;
- }
- }
+ syncml_logger::get_instance()->log("Put item $uri
($type)");
- /**
- * 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)
- {
- syncml_logger::get_instance()->log("Encoding $type,
$dtd_version");
-
switch($type)
{
case 'application/vnd.syncml-devinf+wbxml':
- switch($dtd_version)
- {
- case '1.1':
- $doctype = '<!DOCTYPE
SyncML PUBLIC "-//SYNCML//DTD SyncML 1.1//EN"
"http://www.syncml.org/docs/syncml_represent_v11_20020213.dtd">';
- break;
- case '1.0':
- default:
- $doctype = '<!DOCTYPE
SyncML PUBLIC "-//SYNCML//DTD SyncML 1.0//EN"
"http://www.syncml.org/docs/syncml_represent_v10_20001207.dtd">';
- }
-
- return wbxml_encode(
- '<?xml version="1.0"
encoding="UTF-8"?>' . $doctype .
- $data, 0x02, FALSE, FALSE);
+ $decoder = new syncml_wbxml_decoder();
+ break;
case 'application/vnd.syncml-devinf+xml':
- return $data;
+ $decoder = new syncml_xml_decoder();
+ break;
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':
- $parser = new xml_parser();
- return $parser->parse(
- wbxml_decode($data), new
xml_mapper());
- case 'application/vnd.syncml-devinf+xml':
- return $data;
- default:
- return NULL;
- }
+ syncml_logger::get_instance()->log_data('Got decoder',
+ get_class($decoder));
+
+ $this->_put_devinf($decoder->parse($data));
}
- function _get_devinf_10()
+ function _encode_devinf_10($enc)
{
- return
- '<DevInf xmlns="syncml:devinf">' .
- '<VerDTD>1.0</VerDTD>' .
- '<DevID>485749KR</DevID>' .
- '<DevTyp>server</DevTyp>' .
- '</DevInf>';
+ $enc->start('DevInf', 'syncml:devinf');
+ $enc->start('VerDTD');
+ $enc->data('1.0', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('DevId');
+ $enc->data('485749KR', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('DevTyp');
+ $enc->data('Server', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('DataStore');
+ $enc->end();
+ $enc->end();
}
- function _get_devinf_11()
+ function _encode_devinf_11($enc)
{
- return
- '<DevInf xmlns="syncml:devinf">' .
- '<VerDTD>1.1</VerDTD>' .
- '<DevID>485749KR</DevID>' .
- '<DevTyp>server</DevTyp>' .
- '<SupportLargeObjs/>' .
- '</DevInf>';
+ $enc->start('DevInf', 'syncml:devinf');
+ $enc->start('VerDTD');
+ $enc->data('1.1', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('DevID');
+ $enc->data('485749KR', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('DevTyp');
+ $enc->data('server', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->startend('SupportLargeObjs');
+ $enc->start('DataStore');
+ /*
+ $enc->start('SourceRef');
+ $enc->data('./contacts', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('DisplayName');
+ $enc->data('Contacts', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('Rx-Pref');
+ $enc->start('CTType');
+ $enc->data('text/x-vcalendar',
SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('VerCT');
+ $enc->data('2.0', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->end(); // Rx-Pref
+ $enc->start('Tx-Pref');
+ $enc->start('CTType');
+ $enc->data('text/x-vcalendar',
SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('VerCT');
+ $enc->data('2.0', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->end(); // Tx-Pref
+ $enc->start('SyncCap');
+ $enc->start('SyncType');
+ $enc->data('1', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->start('SyncType');
+ $enc->data('7', SYNCML_ENCODER_TYPE_INLINE);
+ $enc->end();
+ $enc->end(); // SyncCap
+ */
+ $enc->end(); // DataStore
+ $enc->end();
}
/**
Modified: trunk/syncml/inc/class.syncml_session.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_session.inc.php 2008-07-14 21:51:03 UTC
(rev 18647)
+++ trunk/syncml/inc/class.syncml_session.inc.php 2008-07-14 22:07:38 UTC
(rev 18648)
@@ -110,6 +110,9 @@
{
$next_anchors = $this->get_var('next_anchors');
+ syncml_logger::get_instance()->log_data('Next anchors',
+ $next_anchors);
+
if(is_array($next_anchors))
{
foreach($next_anchors as $channel_id => $nexts)
Modified: trunk/syncml/inc/constants.inc.php
===================================================================
--- trunk/syncml/inc/constants.inc.php 2008-07-14 21:51:03 UTC (rev 18647)
+++ trunk/syncml/inc/constants.inc.php 2008-07-14 22:07:38 UTC (rev 18648)
@@ -112,4 +112,12 @@
define('WBXML_LITERAL', 0x04);
define('WBXML_STR_T', 0x83);
define('WBXML_OPAQUE', 0xC3);
+
+ /**
+ *
+ */
+ define('SYNCML_ENCODER_TYPE_RAW', 1);
+ define('SYNCML_ENCODER_TYPE_CDATA', 2);
+ define('SYNCML_ENCODER_TYPE_INLINE', 3);
+ define('SYNCML_ENCODER_TYPE_OPAQUE', 4);
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [18648] * Changes to logging.,
Johan Gunnarsson <=