From fcbe2e5dd5a41b842681f24a5a6f711c457a4ed2 Mon Sep 17 00:00:00 2001 From: Lars Kneschke Date: Thu, 1 Jun 2006 13:38:37 +0000 Subject: [PATCH] SyncML fixes --- .../SyncML/Command/Sync/ContentSyncElement.php | 13 +++++++++++++ phpgwapi/inc/horde/Horde/SyncML/State_egw.php | 11 +++++++++-- phpgwapi/inc/horde/Horde/SyncML/Sync/SlowSync.php | 3 +++ phpgwapi/inc/horde/Horde/SyncML/Sync/TwoWaySync.php | 10 ++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/phpgwapi/inc/horde/Horde/SyncML/Command/Sync/ContentSyncElement.php b/phpgwapi/inc/horde/Horde/SyncML/Command/Sync/ContentSyncElement.php index ffa14efe5d..517bbedb0a 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/Command/Sync/ContentSyncElement.php +++ b/phpgwapi/inc/horde/Horde/SyncML/Command/Sync/ContentSyncElement.php @@ -56,6 +56,11 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_ $this->_contentType = $c; } + function setContentFormat($_format) + { + $this->_contentFormat = $_format; + } + function getContentType() { return $this->_contentType; @@ -116,6 +121,14 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_ $output->endElement($state->getURI(), 'LocURI'); $output->endElement($state->getURI(), 'Source'); } + + if(isset($this->_contentFormat)) { + $output->startElement($state->getURI(), 'Meta', $attrs); + $output->startElement($state->getURIMeta(), 'Format', $attrs); + $output->characters($this->_contentFormat); + $output->endElement($state->getURIMeta(), 'Format'); + $output->endElement($state->getURI(), 'Meta'); + } if ($this->_targetURI != null) { $output->startElement($state->getURI(), 'Target', $attrs); diff --git a/phpgwapi/inc/horde/Horde/SyncML/State_egw.php b/phpgwapi/inc/horde/Horde/SyncML/State_egw.php index e1916ac19f..3bfc501d68 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/State_egw.php +++ b/phpgwapi/inc/horde/Horde/SyncML/State_egw.php @@ -309,18 +309,25 @@ class EGW_SyncML_State extends Horde_SyncML_State $mapID = $this->_locName . $this->_sourceURI . $type; + // delete all client id's + $where = array( + 'map_id' => $mapID, + 'map_locuid' => $locid, + ); + $db->delete('egw_contentmap', $where, __LINE__, __FILE__); + + // delete all egw id's $where = array( 'map_id' => $mapID, 'map_guid' => $guid, ); + $db->delete('egw_contentmap', $where, __LINE__, __FILE__); $data = $where + array( 'map_locuid' => $locid, 'map_timestamp' => $ts, 'map_expired' => 0, ); - - $db->delete('egw_contentmap', $where, __LINE__, __FILE__); $db->insert('egw_contentmap', $data, $where, __LINE__, __FILE__); #Horde::logMessage("SyncML: setUID $type, $locid, $guid, $ts $mapID", __FILE__, __LINE__, PEAR_LOG_DEBUG); diff --git a/phpgwapi/inc/horde/Horde/SyncML/Sync/SlowSync.php b/phpgwapi/inc/horde/Horde/SyncML/Sync/SlowSync.php index 9798adc563..c048196a9d 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/Sync/SlowSync.php +++ b/phpgwapi/inc/horde/Horde/SyncML/Sync/SlowSync.php @@ -73,6 +73,9 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync { // can happen. #LK $cmd->setContent($state->convertServer2Client($c, $contentType)); $cmd->setContent($c); + if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') { + $cmd->setContentFormat('b64'); + } $cmd->setContentType($contentType['ContentType']); $cmd->setSourceURI($guid); $currentCmdID = $cmd->outputCommand($currentCmdID, $output, 'Add'); diff --git a/phpgwapi/inc/horde/Horde/SyncML/Sync/TwoWaySync.php b/phpgwapi/inc/horde/Horde/SyncML/Sync/TwoWaySync.php index 384a5c9b72..901cca881e 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/Sync/TwoWaySync.php +++ b/phpgwapi/inc/horde/Horde/SyncML/Sync/TwoWaySync.php @@ -99,11 +99,14 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync { $cmd->setSourceURI($guid); $cmd->setTargetURI($locid); $cmd->setContentType($contentType['ContentType']); + if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') { + $cmd->setContentFormat('b64'); + } $currentCmdID = $cmd->outputCommand($currentCmdID, $output, 'Replace'); $state->log('Server-Replace'); // return if we have to much data - if(++$counter >= MAX_ENTRIES && $hordeType != 'sifcalender' && $hordeType != 'sifcontacts' &&$hordeType != 'siftasks') { + if(++$counter >= MAX_ENTRIES && $hordeType != 'sifcalendar' && $hordeType != 'sifcontacts' && $hordeType != 'siftasks') { $state->setSyncStatus(SERVER_SYNC_DATA_PENDING); return $currentCmdID; } @@ -194,13 +197,16 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync { if (!is_a($c, 'PEAR_Error')) { // Item in history but not in database. Strange, but can happen. $cmd->setContent($c); + if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') { + $cmd->setContentFormat('b64'); + } $cmd->setContentType($contentType['ContentType']); $cmd->setSourceURI($guid); $currentCmdID = $cmd->outputCommand($currentCmdID, $output, 'Add'); $state->log('Server-Add'); // return if we have to much data - if(++$counter >= MAX_ENTRIES && $hordeType != 'sifcalender' && $hordeType != 'sifcontacts' &&$hordeType != 'siftasks') { + if(++$counter >= MAX_ENTRIES && $hordeType != 'sifcalendar' && $hordeType != 'sifcontacts' &&$hordeType != 'siftasks') { $state->setSyncStatus(SERVER_SYNC_DATA_PENDING); return $currentCmdID; }