final syncml fixes

This commit is contained in:
Lars Kneschke 2006-01-14 08:29:23 +00:00
parent 4d403c0457
commit 08d3e484dc
6 changed files with 57 additions and 64 deletions

View File

@ -312,7 +312,6 @@ class Horde_SyncML_SyncMLHdr extends Horde_SyncML_ContentHandler {
$uri = $state->getURI();
$uriMeta = $state->getURIMeta();
$output->startElement($uri, 'SyncHdr', $attrs);
$output->startElement($uri, 'VerDTD', $attrs);

View File

@ -85,11 +85,11 @@ class Horde_SyncML_Command_Get extends Horde_SyncML_Command {
$output->startElement($state->getURIDevInf() , 'DevTyp', $attrs);
$output->characters('server');
$output->endElement($state->getURIDevInf() , 'DevTyp', $attrs);
$this->_writeDataStore('notes', 'text/x-vnote', '1.1', $output,
$this->_writeDataStore('./notes', 'text/x-vnote', '1.1', $output,
array('text/plain' => '1.0'));
$this->_writeDataStore('contacts', 'text/x-vcard', '2.1', $output);
$this->_writeDataStore('tasks', 'text/x-vcalendar', '1.0', $output);
$this->_writeDataStore('calendar', 'text/x-vcalendar', '1.0', $output);
$this->_writeDataStore('./contacts', 'text/x-vcard', '2.1', $output);
$this->_writeDataStore('./tasks', 'text/x-vcalendar', '1.0', $output);
$this->_writeDataStore('./calendar', 'text/x-vcalendar', '1.0', $output);
$output->endElement($state->getURIDevInf() , 'DevInf', $attrs);
$output->endElement($state->getURI(), 'Data');

View File

@ -97,58 +97,60 @@ class Horde_SyncML_Command_Sync extends Horde_Syncml_Command {
$state = $_SESSION['SyncML.state'];
if($state->getSyncStatus() == CLIENT_SYNC_FINNISHED || $state->getSyncStatus() == SERVER_SYNC_DATA_PENDING)
{
##############
$state->setSyncStatus(SERVER_SYNC_DATA_PENDING);
$targets = $state->getTargets();
Horde::logMessage('SyncML: starting sync to client '.$targets[0], __FILE__, __LINE__, PEAR_LOG_DEBUG);
$attrs = array();
$deviceInfo = $state->getClientDeviceInfo();
$state->setSyncStatus(SERVER_SYNC_DATA_PENDING);
$targets = $state->getTargets();
Horde::logMessage('SyncML: starting sync to client '.$targets[0], __FILE__, __LINE__, PEAR_LOG_DEBUG);
$attrs = array();
foreach($targets as $target)
{
$sync = $state->getSync($target);
$output->startElement($state->getURI(), 'Sync', $attrs);
$output->startElement($state->getURI(), 'CmdID', $attrs);
$output->characters($currentCmdID);
$currentCmdID++;
$output->endElement($state->getURI(), 'CmdID');
$output->startElement($state->getURI(), 'Target', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs);
$chars = $sync->_sourceLocURI;
$output->characters($chars);
$output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Target');
$output->startElement($state->getURI(), 'Source', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs);
#$chars = $sync->_targetLocURI;
$chars = (isset($sync->_targetLocURIParameters) ? $sync->_targetLocURI.'?/'.$sync->_targetLocURIParameters : $sync->_targetLocURI);
$output->characters($chars);
$output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Source');
if(!$sync->_syncDataLoaded)
foreach($targets as $target)
{
$numberOfItems = $sync->loadData();
$output->startElement($state->getURI(), 'NumberOfChanged', $attrs);
$output->characters($numberOfItems);
$output->endElement($state->getURI(), 'NumberOfChanged');
$sync = $state->getSync($target);
$output->startElement($state->getURI(), 'Sync', $attrs);
$output->startElement($state->getURI(), 'CmdID', $attrs);
$output->characters($currentCmdID);
$currentCmdID++;
$output->endElement($state->getURI(), 'CmdID');
$output->startElement($state->getURI(), 'Target', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs);
$chars = $sync->_sourceLocURI;
$output->characters($chars);
$output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Target');
$output->startElement($state->getURI(), 'Source', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs);
#$chars = $sync->_targetLocURI;
$chars = (isset($sync->_targetLocURIParameters) ? $sync->_targetLocURI.'?/'.$sync->_targetLocURIParameters : $sync->_targetLocURI);
$output->characters($chars);
$output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Source');
if(!$sync->_syncDataLoaded)
{
$numberOfItems = $sync->loadData();
if($deviceInfo['supportNumberOfChanges'])
{
$output->startElement($state->getURI(), 'NumberOfChanged', $attrs);
$output->characters($numberOfItems);
$output->endElement($state->getURI(), 'NumberOfChanged');
}
}
$currentCmdID = $sync->endSync($currentCmdID, $output);
$output->endElement($state->getURI(), 'Sync');
break;
}
$currentCmdID = $sync->endSync($currentCmdID, $output);
// no syncs left
if($state->getTargets() === FALSE)
$state->setSyncStatus(SERVER_SYNC_FINNISHED);
$output->endElement($state->getURI(), 'Sync');
break;
}
#
// no syncs left
if($state->getTargets() === FALSE)
$state->setSyncStatus(SERVER_SYNC_FINNISHED);
Horde::logMessage('SyncML: syncStatus(server_sync_finnished) '. $state->getSyncStatus, __FILE__, __LINE__, PEAR_LOG_DEBUG);
#############################
}
return $currentCmdID;

View File

@ -117,7 +117,7 @@ define('RESPONSE_COMMAND_FAILED', 500);
// define('RESPONSE_COMMAND_FAILED', 515);
define('RESPONSE_ATOMIC_ROLL_BACK_FAILED', 516);
define('NAME_SPACE_URI_SYNCML', 'SYNCML:SYNCML1.0');
define('NAME_SPACE_URI_SYNCML', 'syncml:syncml1.0');
define('NAME_SPACE_URI_SYNCML_1_1', 'syncml:syncml1.1');
define('NAME_SPACE_URI_METINF', 'syncml:metinf');
define('NAME_SPACE_URI_METINF_1_1', 'syncml:metinf1.1');

View File

@ -45,7 +45,8 @@ class XML_WBXML_DTD_SyncMLMetInf extends XML_WBXML_DTD {
$this->setTag(0x14, "Version"); // 0x01
if ($this->version == 0) {
$this->setCodePage(0, '-//SYNCML//DTD SyncML 1.0//EN', 'syncml:SYNCML1.0');
#$this->setCodePage(0, '-//SYNCML//DTD SyncML 1.0//EN', 'syncml:SYNCML1.0');
$this->setCodePage(0, '-//SYNCML//DTD SyncML 1.0//EN', 'syncml:syncml1.0');
$this->setCodePage(1, '-//SYNCML//DTD MetInf 1.0//EN', 'syncml:metinf');
$this->setURI('syncml:metinf');
} else {

View File

@ -96,7 +96,6 @@ class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
*/
function writeHeader($uri)
{
error_log("getInstanceURI($uri)");
$this->_dtd = &$this->_dtdManager->getInstanceURI($uri);
$dpiString = $this->_dtd->getDPI();
@ -213,8 +212,6 @@ class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
function startElement($uri, $name, $attributes)
{
error_log("startElement::: <$name>");
# error_log(" subparser is:: ".$this->_subParser);
if ($this->_subParser == null) {
if (!$this->_hasWrittenHeader) {
$this->writeHeader($uri);
@ -252,7 +249,6 @@ class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
function characters($chars)
{
$chars = trim($chars);
error_log("characters ::: ".$chars);
if (strlen($chars)) {
/* We definitely don't want any whitespace. */
@ -284,7 +280,6 @@ class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
}
$t = $this->_dtd->toTagInt($name);
# error_log("writeTag ::: -> $name $t");
if ($t == -1) {
$i = $this->_stringTable->get($name);
if ($i == null) {
@ -355,11 +350,8 @@ class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
function endElement($uri, $name)
{
error_log("endElement ::: </$name>");
# error_log(" subparser is: ".$this->_subParser);
if ($this->_subParser == null) {
$this->_output .= chr(XML_WBXML_GLOBAL_TOKEN_END);
# error_log(" _output is: ".strlen($this->_output));
} else {
$this->_subParser->endElement($uri, $name);
$this->_subParserStack--;
@ -384,13 +376,12 @@ class XML_WBXML_Encoder extends XML_WBXML_ContentHandler {
function changecodepage($uri)
{
# error_log("changecodepage::: $uri");
// @todo: this is a hack!
if (!preg_match('/1\.1$/', $uri)) {
// what's the reason for this hack???? Lars
if ($uri != 'syncml:devinf' && $uri != 'syncml:metinf' && $uri != 'syncml:syncml1.0' && !preg_match('/1\.1$/', $uri)) {
$uri .= '1.1';
}
$cp = $this->_dtd->toCodePageURI($uri);
# error_log("--- \$cp:: $cp");
if (strlen($cp)) {
$this->_dtd = &$this->_dtdManager->getInstanceURI($uri);