[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [18647] * Fixes to logging.
From: |
Johan Gunnarsson |
Subject: |
[Phpgroupware-cvs] [18647] * Fixes to logging. |
Date: |
Mon, 14 Jul 2008 21:51:03 +0000 |
Revision: 18647
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18647
Author: johang
Date: 2008-07-14 21:51:03 +0000 (Mon, 14 Jul 2008)
Log Message:
-----------
* Fixes to logging.
* Update syncml_response to use new encoding code.
Modified Paths:
--------------
trunk/syncml/inc/class.syncml_command_alert.inc.php
trunk/syncml/inc/class.syncml_command_get.inc.php
trunk/syncml/inc/class.syncml_command_synchdr.inc.php
trunk/syncml/inc/class.syncml_logger.inc.php
trunk/syncml/inc/class.syncml_response.inc.php
Modified: trunk/syncml/inc/class.syncml_command_alert.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_command_alert.inc.php 2008-07-14 21:43:38 UTC
(rev 18646)
+++ trunk/syncml/inc/class.syncml_command_alert.inc.php 2008-07-14 21:51:03 UTC
(rev 18647)
@@ -72,16 +72,22 @@
$sodatabase = new syncml_sodatabase();
$sochannel = new syncml_sochannel();
-
syncml_logger::get_instance()->log_data("_process_sync_init item",
$this->item[0]);
+ syncml_logger::get_instance()->log_data("Item",
$this->item[0]);
+
$database = $sodatabase->get_database_by_uri(
$this->item[0]['target']['locuri']);
$database_id = $database['database_id'];
$owner_id = $database['account_id'];
- syncml_logger::get_instance()->log("_process_sync_init
user $database_id $owner_id ");
+
+ syncml_logger::get_instance()->log("User $owner_id");
+ syncml_logger::get_instance()->log("Database
$database_id");
+
$status = $this->validate_database(
$database_id, $owner_id, $session->account_id);
- syncml_logger::get_instance()->log("_process_sync_init
status $status ");
+
+ syncml_logger::get_instance()->log_data("Validated
database",
+ $status);
if(!$status)
{
@@ -91,9 +97,11 @@
$session->get_var('device_uri'));
$status = $this->validate_channel($device_last);
+
+
syncml_logger::get_instance()->log_data("Validated channel",
+ $status);
}
-
syncml_logger::get_instance()->log_data("_process_sync_init status", $status);
-
+
$response->add_status_with_anchor(
$this->cmdid, $session->msgid, 'Alert',
$this->item[0]['target']['locuri'],
@@ -104,15 +112,15 @@
if($status[0] == SYNCML_STATUS_OK ||
$status[0] == SYNCML_STATUS_REFRESHREQUIRED)
{
-
syncml_logger::get_instance()->log_data("_process_sync_init ok channel ",
$channel_id);
+ syncml_logger::get_instance()->log_data(
+ "OK or refresh for channel",
$channel_id);
+
if(!$channel_id)
{
$channel_id =
$sochannel->insert_channel(
$database_id,
$session->get_var('device_uri'));
}
-
-
syncml_logger::get_instance()->log_data("_process_sync_init channel ",
$channel_id);
-
+
$database = new syncml_database($channel_id);
$database->merge_changes();
unset($database);
@@ -185,6 +193,12 @@
$last = isset($this->item[0]['meta']['anchor']['last'])
?
$this->item[0]['meta']['anchor']['last'] : NULL;
+ syncml_logger::get_instance()->log_data(
+ "Saved device last", $device_last);
+
+ syncml_logger::get_instance()->log_data(
+ "Sent device last", $last);
+
if($last !== $device_last)
{
// sanity check failed. suggest slow sync if
not already
Modified: trunk/syncml/inc/class.syncml_command_get.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_command_get.inc.php 2008-07-14 21:43:38 UTC
(rev 18646)
+++ trunk/syncml/inc/class.syncml_command_get.inc.php 2008-07-14 21:51:03 UTC
(rev 18647)
@@ -64,6 +64,10 @@
foreach($this->item as $item)
{
+ syncml_logger::get_instance()->log(sprintf(
+ 'Getting item %s (%s)',
$item['target']['locuri'],
+ $this->meta['type']));
+
$result = $database->get_item(
$item['target']['locuri'],
$this->meta['type']);
Modified: trunk/syncml/inc/class.syncml_command_synchdr.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_command_synchdr.inc.php 2008-07-14
21:43:38 UTC (rev 18646)
+++ trunk/syncml/inc/class.syncml_command_synchdr.inc.php 2008-07-14
21:51:03 UTC (rev 18647)
@@ -75,22 +75,14 @@
min($this->meta['maxmsgsize'],
SYNCML_MAXMSGSIZE) :
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':
case 'SyncML/1.1':
break;
default:
- syncml_logger::get_instance()->log(
- "bad verproto: " .
$this->verproto);
+ syncml_logger::get_instance()->log_data(
+ 'Bad VERPROTO',
$this->verproto);
$this->handle_failure(
SYNCML_STATUS_PROTOCOLVERSIONNOTSUPPORTED,
$response, $session);
@@ -101,17 +93,24 @@
{
case '1.0':
case '1.1':
-
$response->set_syncml_namespace_version($this->verdtd);
break;
default:
- syncml_logger::get_instance()->log(
- "bad verdtd: " . $this->verdtd);
+ syncml_logger::get_instance()->log_data(
+ 'Bad VERDTD', $this->verdtd);
$this->handle_failure(
SYNCML_STATUS_DTDCOLVERSIONNOTSUPPORTED,
$response, $session);
return;
}
+ $response->set_header(
+ $this->verdtd, $this->verproto,
+ $this->sessionid, $this->msgid,
+ isset($this->respuri) ?
+ $this->respuri :
$this->source['locuri'], '',
+ $this->target['locuri'], ''
+ );
+
$sosession = new syncml_sosession();
$id = array
@@ -133,7 +132,7 @@
}
else
{
- syncml_logger::get_instance()->log("failed to
verify session");
+ syncml_logger::get_instance()->log("Failed to
verify session");
$tmp = $this->process_cred($session);
@@ -157,7 +156,7 @@
function handle_success(&$response, &$session)
{
- syncml_logger::get_instance()->log("auth success");
+ syncml_logger::get_instance()->log('Auth success');
$session->account_id =
$GLOBALS['phpgw']->session->account_id;
@@ -165,7 +164,7 @@
'session_data', 'syncml');
syncml_logger::get_instance()->log_data(
- "loaded session data", $session->session_data);
+ 'Loaded session data', $session->session_data);
$this->add_authentication_status(
SYNCML_STATUS_AUTHENTICATIONACCEPTED,
$response, $session);
@@ -180,7 +179,7 @@
*/
function handle_failure($code, &$response, &$session)
{
- syncml_logger::get_instance()->log("auth failure");
+ syncml_logger::get_instance()->log("Auth failure");
switch($code)
{
@@ -209,7 +208,7 @@
{
$auth_type = (isset($this->cred) &&
isset($this->cred['meta']['type'])) ?
- $this->cred['meta']['type'] : '';
+ $this->cred['meta']['type'] : NULL;
$nonce = NULL;
@@ -230,7 +229,7 @@
$this->target['locuri'] : NULL,
isset($this->source['locuri']) ?
$this->source['locuri'] : NULL,
- $code, $auth_type, $nonce
+ $code, 'b64', $auth_type, $nonce
);
}
Modified: trunk/syncml/inc/class.syncml_logger.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_logger.inc.php 2008-07-14 21:43:38 UTC
(rev 18646)
+++ trunk/syncml/inc/class.syncml_logger.inc.php 2008-07-14 21:51:03 UTC
(rev 18647)
@@ -45,7 +45,7 @@
if(SYNCML_DEBUG_MODE)
{
$trace = debug_backtrace();
- $frame = $trace[1];
+ $frame = isset($trace[1]) ? $trace[1] : array();
fwrite($this->handle, sprintf("%s::%s(), %s,
%s\n",
isset($frame['class']) ?
$frame['class'] : '',
@@ -69,7 +69,7 @@
if(SYNCML_DEBUG_MODE)
{
$trace = debug_backtrace();
- $frame = $trace[1];
+ $frame = isset($trace[1]) ? $trace[1] : array();
fwrite($this->handle, sprintf("%s::%s(), %s\n",
isset($frame['class']) ?
$frame['class'] : '',
Modified: trunk/syncml/inc/class.syncml_response.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_response.inc.php 2008-07-14 21:43:38 UTC
(rev 18646)
+++ trunk/syncml/inc/class.syncml_response.inc.php 2008-07-14 21:51:03 UTC
(rev 18647)
@@ -10,8 +10,6 @@
* @version $Id$
*/
- define('METINF', 'xmlns="syncml:metinf"');
-
class syncml_response
{
var $next_cmdid = 0;
@@ -22,42 +20,33 @@
var $is_final = FALSE;
var $global_status_code;
- var $root_namespace = '';
- var $header = '';
- var $header_cred = '';
- var $commands = array();
-
var $status_count = 0;
+ var $command_count = 0;
- function syncml_response()
- {
- }
+ var $header_verdtd;
+ var $header_verproto;
+ var $header_sessionid;
+ var $header_msgid;
+ var $header_target_locuri;
+ var $header_target_locname;
+ var $header_source_locuri;
+ var $header_source_locname;
- static function e($name, $cdata, $attrs = '')
+ var $pending_status_commands = array();
+
+ function syncml_response($encoder)
{
- return "<$name" . ($attrs ? ' ' . $attrs : '') .
- ($cdata === '' ? '/>' : ">$cdata</$name>");
+ $this->enc = $encoder;
}
function print_response()
{
- echo '<?xml version="1.0" encoding="UTF-8"?>';
- echo $this->doctype;
- echo '<SyncML xmlns="', $this->root_namespace, '">';
- echo '<SyncHdr>', $this->header, $this->header_cred,
'</SyncHdr>';
- echo '<SyncBody>', implode('', $this->commands);
- echo ($this->is_final ? '<Final/>' : ''), '</SyncBody>';
- echo '</SyncML>';
+ echo $this->enc->dump();
}
- function filter($data)
- {
- return $data;
- }
-
function status_commands_only()
{
- return $this->status_count == count($this->commands);
+ return $this->status_count > 0 && $this->command_count
== 0;
}
function set_max_size($size)
@@ -67,11 +56,9 @@
function get_size_left()
{
- return $this->max_size
- - array_sum(array_map('strlen',
$this->commands))
- - strlen($this->header)
- - strlen($this->header_cred)
- - 500;
+ // -500 is just a margin
+
+ return $this->max_size - $this->enc->get_length() - 500;
}
/**
@@ -114,261 +101,510 @@
return $this->next_cmdid;
}
- function add_result($cmdref, $msgref, $srcref, $trgref,
+ function encode_command_stuff($cmdid, $msgref, $cmdref, $cmd,
$sourceref,
+ $targetref)
+ {
+ $this->enc->start('CmdID');
+ $this->enc->data($cmdid, SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ if(!is_null($msgref))
+ {
+ $this->enc->start('MsgRef');
+ $this->enc->data($msgref,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(!is_null($cmdref))
+ {
+ $this->enc->start('CmdRef');
+ $this->enc->data($cmdref,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(!is_null($cmd))
+ {
+ $this->enc->start('Cmd');
+ $this->enc->data($cmd,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if($sourceref)
+ {
+ $this->enc->start('SourceRef');
+ $this->enc->data($sourceref,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if($targetref)
+ {
+ $this->enc->start('TargetRef');
+ $this->enc->data($targetref,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+ }
+
+ function add_result($cmdref, $msgref, $sourceref, $targetref,
$type, $items)
{
- $item_d = array_map(array($this, "get_item"), $items);
+ $this->command_count++;
- for($i = 0, $c = count($item_d); $i < $c; $i++)
+ $this->enc->start('Results');
+
+ $this->encode_command_stuff($this->get_next_cmdid(),
$msgref,
+ $cmdref, NULL, $sourceref, $targetref);
+
+ $this->encode_meta(array('type' => $type));
+
+ /*
+ $this->enc->start('Data');
+ $this->enc->data($code, SYNCML_ENCODER_TYPE_OPAQUE);
+ $this->enc->end();
+ */
+
+ foreach($items as $item)
{
- $item_d[$i] = '<Item>' . $item_d[$i] .
'</Item>';
+ //$this->enc->start('Item');
+ $this->encode_item($item);
+ //$this->enc->end();
}
- $this->commands[] = $this->filter(
- '<Results>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<MsgRef>' . $msgref . '</MsgRef>' .
- '<CmdRef>' . $cmdref . '</CmdRef>' .
- ((bool)$srcref ? self::e('SourceRef',
$srcref) : '') .
- ((bool)$trgref ? self::e('TargetRef',
$trgref) : '') .
- '<Meta>' .
- $this->get_meta(array('type' =>
$type)) .
- '</Meta>' .
- implode('', $item_d) .
- '</Results>'
- );
+ $this->enc->end();
}
function add_alert($code, $item, $supportlargeobj = FALSE)
{
+ $this->command_count++;
+
if(!$supportlargeobj && isset($item['meta']))
{
unset($item['meta']['maxobjsize']);
}
- $this->commands[] = $this->filter(
- '<Alert>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<Data>' . $code . '</Data>' .
- (is_array($item) ? self::e('Item',
- $this->get_item($item,
$supportlargeobj)) : '') .
- '</Alert>'
- );
+ $this->enc->start('Alert');
+
+ $this->encode_command_stuff($this->get_next_cmdid(),
NULL,
+ NULL, NULL, NULL, NULL);
+
+ $this->enc->start('Data');
+ $this->enc->data($code, SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->encode_item($item, $supportlargeobj);
+
+ $this->enc->end();
}
- function set_syncml_namespace_version($version)
+ function set_header($verdtd, $verproto, $sessionid, $msgid,
+ $target_locuri, $target_locname, $source_locuri,
$source_locname)
{
- switch($version)
- {
- case '1.1':
- $this->doctype = '<!DOCTYPE SyncML
PUBLIC "-//SYNCML//DTD SyncML 1.1//EN" "http://www.syncml.org/
-docs/syncml_represent_v11_20020213.dtd">';
- $this->root_namespace =
'SYNCML:SYNCML1.1';
- break;
- case '1.0':
- default:
- $this->doctype = '<!DOCTYPE SyncML
PUBLIC "-//SYNCML//DTD SyncML 1.0//EN"
"http://www.syncml.org/docs/syncml_represent_v10_20001207.dtd">';
- $this->root_namespace =
'SYNCML:SYNCML1.0';
- }
+ $this->header_verdtd = $verdtd;
+ $this->header_verproto = $verproto;
+ $this->header_sessionid = $sessionid;
+ $this->header_msgid = $msgid;
+ $this->header_target_locuri = $target_locuri;
+ $this->header_target_locname = $target_locname;
+ $this->header_source_locuri = $source_locuri;
+ $this->header_source_locname = $source_locname;
}
- function set_header($verdtd, $verproto, $sessionid, $msgid,
- $trg_lu, $trg_ln, $src_lu, $src_ln)
+ function encode_start($tag, $ns = NULL)
{
- $this->header =
- '<VerDTD>' . $verdtd . '</VerDTD>' .
- '<VerProto>' . $verproto . '</VerProto>' .
- '<SessionID>' . $sessionid . '</SessionID>' .
- '<MsgID>' . $msgid . '</MsgID>' .
- '<Target>' .
- '<LocURI>' . $trg_lu . '</LocURI>' .
- ((bool)$trg_ln ? self::e('LocName',
$trg_ln) : '') .
- '</Target>' .
- '<Source>' .
- '<LocURI>' . $src_lu . '</LocURI>' .
- ((bool)$src_ln ? self::e('LocName',
$src_ln) : '') .
- '</Source>';
+ $this->enc->start($tag, $ns);
}
- function set_header_cred($format, $type, $data)
+ function encode_end()
{
- $this->header_cred =
- '<Cred>' .
- '<Meta>' .
- '<Format
xmlns="syncml:metinf">' .
- $format .
- '</Format>' .
- '<Type xmlns="syncml:metinf">'
. $type . '</Type>' .
- '</Meta>' .
- '<Data>' . $data . '</Data>' .
- '</Cred>';
+ $this->enc->end();
}
- function add_status($cmdref, $msgref, $cmd, $trgref, $srcref,
$data,
- $item = NULL)
+ function encode_header()
{
+ $this->enc->start('SyncHdr');
+
+ $this->enc->start('VerDTD');
+ $this->enc->data($this->header_verdtd,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->enc->start('VerProto');
+ $this->enc->data($this->header_verproto,
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->enc->start('SessionID');
+ $this->enc->data($this->header_sessionid,
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->enc->start('MsgID');
+ $this->enc->data($this->header_msgid,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->encode_source_and_target(
+ $this->header_source_locuri,
+ $this->header_source_locname,
+ $this->header_target_locuri,
+ $this->header_target_locname);
+
+ $this->enc->end(); // SyncHdr
+ }
+
+ function add_status($cmdref, $msgref, $cmd, $targetref,
$sourceref,
+ $data, $item = NULL)
+ {
+ $this->encode_status($cmdref, $msgref, $cmd, $targetref,
+ $sourceref, $data, $item);
+ }
+
+ function encode_pendning_status_commands()
+ {
+ foreach($this->pending_status_commands as $status)
+ {
+ $this->status_count++;
+
+ extract($status);
+
+ $this->enc->start('Status');
+
+ $this->encode_command_stuff($cmdid, $msgref,
$cmdref, $cmd,
+ $sourceref, $targetref);
+
+ if(isset($data))
+ {
+ $this->enc->start('Data');
+ $this->enc->data($data,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(isset($chal_meta))
+ {
+ $this->enc->start('Chal');
+ $this->encode_meta($chal_meta);
+ $this->enc->end();
+ }
+
+ if(isset($item_data_anchor_next))
+ {
+ $this->enc->start('Item');
+ $this->enc->start('Data');
+ $this->enc->start('Anchor',
'syncml:metinf');
+ $this->enc->start('Next');
+ $this->enc->data($item_data_anchor_next,
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ $this->enc->end();
+ $this->enc->end();
+ $this->enc->end();
+ }
+
+ $this->enc->end();
+ }
+ }
+
+ function encode_status($cmdref, $msgref, $cmd, $targetref,
$sourceref,
+ $data, $item = NULL)
+ {
$this->status_count++;
- $this->commands[] = $this->filter(
- '<Status>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<CmdRef>' . $cmdref . '</CmdRef>' .
- '<Cmd>' . $cmd . '</Cmd>' .
- '<MsgRef>' . $msgref . '</MsgRef>' .
- ((bool)$srcref ? self::e('SourceRef',
$srcref) : '') .
- ((bool)$trgref ? self::e('TargetRef',
$trgref) : '') .
- '<Data>' . $data . '</Data>' .
- (is_array($item) ? self::e('Item',
- $this->get_item($item)) : '') .
- '</Status>'
- );
+ $this->enc->start('Status');
+
+ $this->encode_command_stuff($this->get_next_cmdid(),
$msgref,
+ $cmdref, $cmd, $targetref, $targetref);
+
+ $this->enc->start('Data');
+ $this->enc->data($data, SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ if($item)
+ {
+ $this->encode_item($item);
+ }
+
+ $this->enc->end();
}
+ function encode_source_and_target($source_locuri,
$source_locname,
+ $target_locuri, $target_locname)
+ {
+ if($target_locuri || $target_locname)
+ {
+ $this->enc->start('Target');
+
+ if($target_locuri)
+ {
+ $this->enc->start('LocURI');
+ $this->enc->data($target_locuri,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if($target_locname)
+ {
+ $this->enc->start('LocName');
+ $this->enc->data($target_locname,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ $this->enc->end(); // Target
+ }
+
+ if($source_locuri || $source_locname)
+ {
+ $this->enc->start('Source');
+
+ if($source_locuri)
+ {
+ $this->enc->start('LocURI');
+ $this->enc->data($source_locuri,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if($source_locname)
+ {
+ $this->enc->start('LocName');
+ $this->enc->data($source_locname,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ $this->enc->end(); // Source
+ }
+ }
+
/**
* Build "item" XML node.
*
* @param $item array Array of elements in the node.
* @return string The item XML node.
*/
- function get_item($item)
+ function encode_item($item)
{
- return
- (isset($item['trg_uri']) ? self::e('Target',
- '<LocURI>' . $item['trg_uri'] .
'</LocURI>' .
- (isset($item['trg_name']) ?
self::e('LocName',
- $item['trg_name']) : '')) : '')
.
- (isset($item['src_uri']) ? self::e('Source',
- '<LocURI>' . @$item['src_uri'] .
'</LocURI>' .
- (isset($item['src_name']) ?
self::e('LocName',
- $item['src_name']) : '')) : '')
.
- (isset($item['meta']) ? self::e('Meta',
- $this->get_meta($item['meta'])) : '') .
- (isset($item['data']) ? self::e('Data',
- /* '<![CDATA[' . */ @$item['data'] /* .
']]>' */) : '') .
- ((isset($item['moredata']) &&
$item['moredata']) ?
- self::e('MoreData', '') : '');
+ syncml_logger::get_instance()->log_data('X', $item);
+
+ $this->enc->start('Item');
+
+ $this->encode_source_and_target(
+ $item['src_uri'], $item['src_name'],
+ $item['trg_uri'], $item['trg_name']);
+
+ if(isset($item['meta']))
+ {
+ $this->encode_meta($item['meta']);
+ }
+
+ if(isset($item['data']))
+ {
+ $this->enc->start('Data');
+ $this->enc->data($item['data'],
SYNCML_ENCODER_TYPE_OPAQUE);
+ $this->enc->end();
+ }
+
+ if(isset($item['moredata']) && $item['moredata'])
+ {
+ $this->enc->start('MoreData');
+ $this->enc->end();
+ }
+
+ $this->enc->end();
}
- function get_meta($meta)
+ function encode_meta($meta)
{
- return
- (isset($meta['type']) ?
- self::e('Type', $meta['type'], METINF)
: '') .
- (isset($meta['next']) ? self::e('Anchor',
- '<Next>' . @$meta['next'] . '</Next>' .
- (isset($meta['last']) ? self::e('Last',
$meta['last'],
- METINF) : ''), METINF) : '') .
- (isset($meta['maxobjsize']) ?
- self::e('MaxObjSize',
$meta['maxobjsize'], METINF) : '') .
- (isset($meta['size']) ?
- self::e('Size', $meta['size'], METINF)
: '');
+ syncml_logger::get_instance()->log_data('metet', $meta);
+
+ $this->enc->start('Meta');
+
+ if(isset($meta['type']) && $meta['type'])
+ {
+ $this->enc->start('Type', 'syncml:metinf');
+ $this->enc->data($meta['type'],
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(isset($meta['next']) && $meta['next'])
+ {
+ $this->enc->start('Anchor', 'syncml:metinf');
+
+ $this->enc->start('Next');
+ $this->enc->data($meta['next'],
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ if(isset($meta['last']) && $meta['last'])
+ {
+ $this->enc->start('Last');
+ $this->enc->data($meta['last'],
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(isset($meta['format']) && $meta['format'])
+ {
+ $this->enc->start('Format');
+ $this->enc->data($meta['format'],
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ $this->enc->end(); // Anchor
+ }
+
+ if(isset($meta['maxobjsize']) && $meta['maxobjsize'])
+ {
+ $this->enc->start('MaxObjSize',
'syncml:metinf');
+ $this->enc->data($meta['maxobjsize'],
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(isset($meta['size']))
+ {
+ $this->enc->start('Size', 'syncml:metinf');
+ $this->enc->data(intval($meta['size']),
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(isset($meta['format']))
+ {
+ $this->enc->start('Format', 'syncml:metinf');
+ $this->enc->data($meta['format'],
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ if(isset($meta['nextnonce']))
+ {
+ $this->enc->start('NextNonce', 'syncml:metinf');
+ $this->enc->data($meta['nextnonce'],
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
+
+ $this->enc->end(); // Meta
}
- function add_status_with_chal($cmdref, $msgref, $cmd, $trgref,
- $srcref, $data, $type, $nonce = NULL)
+ function add_status_with_chal($cmdref, $msgref, $cmd,
$targetref,
+ $sourceref, $data, $format, $type, $nonce = NULL)
{
- $this->status_count++;
+ $x = $this->pending_status_commands[] = array(
+ 'cmdid' => $this->get_next_cmdid(),
+ 'cmdref' => $cmdref,
+ 'cmd' => $cmd,
+ 'msgref' => $msgref,
+ 'targetref' => $targetref,
+ 'sourceref' => $sourceref,
+ 'data' => $data,
+ 'chal_meta' => array(
+ 'type' => $type,
+ 'nextnonce' => $nonce,
+ 'format' => $format
+ )
+ );
- $this->commands[] = $this->filter(
- '<Status>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<CmdRef>' . $cmdref . '</CmdRef>' .
- '<Cmd>' . $cmd . '</Cmd>' .
- '<MsgRef>' . $msgref . '</MsgRef>' .
- ((bool)$srcref ? self::e('SourceRef',
$srcref) : '') .
- ((bool)$trgref ? self::e('TargetRef',
$trgref) : '') .
- '<Data>' . $data . '</Data>' .
- '<Chal>' .
- '<Meta>' .
- '<Type
xmlns="syncml:metinf">' .
- $type .
- '</Type>' .
- '<Format
xmlns="syncml:metinf">b64</Format>' .
- ($nonce ?
self::e('NextNonce',
-
base64_encode($nonce), METINF) : '') .
- '</Meta>' .
- '</Chal>' .
- '</Status>'
- );
+ syncml_logger::get_instance()->log_data('X', $x);
}
- function add_status_with_anchor($cmdref, $msgref, $cmd, $trgref,
- $srcref, $data, $next)
+ function add_status_with_anchor($cmdref, $msgref, $cmd,
$targetref,
+ $sourceref, $data, $next)
{
$this->status_count++;
- $this->commands[] = $this->filter(
- '<Status>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<CmdRef>' . $cmdref . '</CmdRef>' .
- '<Cmd>' . $cmd . '</Cmd>' .
- '<MsgRef>' . $msgref . '</MsgRef>' .
- ((bool)$srcref ? self::e('SourceRef',
$srcref) : '') .
- ((bool)$trgref ? self::e('TargetRef',
$trgref) : '') .
- '<Data>' . $data . '</Data>' .
- '<Item>' .
- '<Data>' .
- '<Anchor
xmlns="syncml:metinf">' .
- '<Next>' .
$next . '</Next>' .
- '</Anchor>' .
- '</Data>' .
- '</Item>' .
- '</Status>'
- );
+ $this->enc->start('Status');
+
+ $this->encode_command_stuff($this->get_next_cmdid(),
$msgref,
+ $cmdref, $cmd, $sourceref, $targetref);
+
+ $this->enc->start('Data');
+ $this->enc->data($data, SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->enc->start('Item');
+ $this->enc->start('Data');
+ $this->enc->start('Anchor', 'syncml:metinf');
+ $this->enc->start('Next');
+ $this->enc->data($next, SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ $this->enc->end();
+ $this->enc->end();
+ $this->enc->end();
+
+ $this->enc->end();
}
- function build_add($meta, $item, $last_chunk)
+ function add_add($meta, $item)
{
- return
- '<Add>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<Meta>' . $this->get_meta($meta) .
'</Meta>' .
- '<Item>' .
- $this->get_item($item) .
- (!$last_chunk ?
self::e('MoreData', '') : '') .
- '</Item>' .
- '</Add>';
+ $thia->command_count++;
+
+ $this->enc->start('Add');
+
+ $this->enc->start('CmdID');
+ $this->enc->data($this->get_next_cmdid(),
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->encode_meta($meta);
+
+ $this->encode_item($item);
+
+ $this->enc->end();
}
- function build_delete($item)
+ function add_delete($item)
{
- return
- '<Delete>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<Item>' . $this->get_item($item) .
'</Item>' .
- '</Delete>';
+ $thia->command_count++;
+
+ $this->enc->start('Delete');
+
+ $this->enc->start('CmdID');
+ $this->enc->data($this->get_next_cmdid(),
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->encode_item($item);
+
+ $this->enc->end();
}
- function build_replace($meta, $item, $last_chunk)
+ function add_replace($meta, $item, $last_chunk)
{
- return
- '<Replace>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<Meta>' . $this->get_meta($meta) .
'</Meta>' .
- '<Item>' .
- $this->get_item($item) .
- (!$last_chunk ?
self::e('MoreData', '') : '') .
- '</Item>' .
- '</Replace>';
+ $thia->command_count++;
+
+ $this->enc->start('Replace');
+
+ $this->enc->start('CmdID');
+ $this->enc->data($this->get_next_cmdid(),
+ SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+
+ $this->encode_meta($meta);
+
+ $this->encode_item($item);
+
+ $this->enc->end();
}
- function add_sync($trg_uri, $src_uri, $commands,
$supportnbrofchanges,
+ function add_sync_start($trg_uri, $src_uri,
$supportnbrofchanges,
$nbrofchanges)
{
- $this->commands[] = $this->filter(
- '<Sync>' .
- '<CmdID>' . $this->get_next_cmdid() .
'</CmdID>' .
- '<Target>' .
- '<LocURI>' . $trg_uri .
'</LocURI>' .
- '</Target>' .
- '<Source>' .
- '<LocURI>' . $src_uri .
'</LocURI>' .
- '</Source>' .
- ($supportnbrofchanges ?
self::e('NumberOfChanges',
- $nbrofchanges) : '') .
- implode('', $commands) .
- '</Sync>'
- );
+ $thia->command_count++;
+
+ $this->enc->start('Sync');
+
+ $this->enc->start('CmdID');
+ $this->enc->data($this->get_next_cmdid());
+ $this->enc->end();
+
+ $this->encode_source_and_target(
+ $trg_uri, NULL, $src_uri, NULL);
+
+ if($supportnbrofchanges)
+ {
+ $this->enc->start('NumberOfChanges');
+ $this->enc->data($nbrofchanges,
SYNCML_ENCODER_TYPE_INLINE);
+ $this->enc->end();
+ }
}
+
+ function add_sync_end()
+ {
+ $this->enc->end();
+ }
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [18647] * Fixes to logging.,
Johan Gunnarsson <=