From 735dcde161756062d6866b421e40ae198fe8eda3 Mon Sep 17 00:00:00 2001 From: Lars Kneschke Date: Mon, 16 Jan 2006 09:49:51 +0000 Subject: [PATCH] different SyncML fixes --- phpgwapi/inc/horde/Horde/SyncML.php | 5 +- .../inc/horde/Horde/SyncML/Command/Sync.php | 1 + phpgwapi/inc/horde/Horde/SyncML/State_egw.php | 22 +++---- .../SyncML/Sync/OneWayFromServerSync.php | 61 +------------------ 4 files changed, 18 insertions(+), 71 deletions(-) diff --git a/phpgwapi/inc/horde/Horde/SyncML.php b/phpgwapi/inc/horde/Horde/SyncML.php index b16083a33b..be3550cd62 100644 --- a/phpgwapi/inc/horde/Horde/SyncML.php +++ b/phpgwapi/inc/horde/Horde/SyncML.php @@ -571,7 +571,10 @@ class Horde_SyncML_SyncMLBody extends Horde_SyncML_ContentHandler { $this->_output->startElement($state->getURI(), 'Meta', $attrs); $this->_output->startElement($state->getURIMeta(), 'Type', $attrs); - $this->_output->characters('application/vnd.syncml-devinf+xml'); + if(is_a($this->_output, 'XML_WBXML_Encoder')) + $this->_output->characters('application/vnd.syncml-devinf+wbxml'); + else + $this->_output->characters('application/vnd.syncml-devinf+xml'); $this->_output->endElement($state->getURIMeta(), 'Type'); $this->_output->endElement($state->getURI(), 'Meta'); diff --git a/phpgwapi/inc/horde/Horde/SyncML/Command/Sync.php b/phpgwapi/inc/horde/Horde/SyncML/Command/Sync.php index 6521a3c018..bf900e7c58 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/Command/Sync.php +++ b/phpgwapi/inc/horde/Horde/SyncML/Command/Sync.php @@ -5,6 +5,7 @@ include_once 'Horde/SyncML/Command.php'; include_once 'Horde/SyncML/Command/Sync/SyncElement.php'; include_once 'Horde/SyncML/Sync/TwoWaySync.php'; include_once 'Horde/SyncML/Sync/SlowSync.php'; +include_once 'Horde/SyncML/Sync/OneWayFromServerSync.php'; /** * $Horde: framework/SyncML/SyncML/Command/Sync.php,v 1.17 2004/07/03 15:21:14 chuck Exp $ diff --git a/phpgwapi/inc/horde/Horde/SyncML/State_egw.php b/phpgwapi/inc/horde/Horde/SyncML/State_egw.php index a9b5914101..3fdb4df99f 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/State_egw.php +++ b/phpgwapi/inc/horde/Horde/SyncML/State_egw.php @@ -47,7 +47,7 @@ class EGW_SyncML_State extends Horde_SyncML_State { $deviceID = $this->_locName . $this->_sourceURI; - $db = clone($GLOBALS['phpgw']->db); + $db = clone($GLOBALS['egw']->db); $cols = array ( @@ -105,7 +105,7 @@ class EGW_SyncML_State extends Horde_SyncML_State Horde::logMessage('SyncML: search GlobalUID for ' . $mapID .' / '.$locid, __FILE__, __LINE__, PEAR_LOG_DEBUG); - $db = clone($GLOBALS['phpgw']->db); + $db = clone($GLOBALS['egw']->db); $cols = array('map_guid'); @@ -136,7 +136,7 @@ class EGW_SyncML_State extends Horde_SyncML_State { $mapID = $this->_locName . $this->_sourceURI . $type; - $db = clone($GLOBALS['phpgw']->db); + $db = clone($GLOBALS['egw']->db); $cols = array('map_locuid'); @@ -168,7 +168,7 @@ class EGW_SyncML_State extends Horde_SyncML_State { $deviceID = $this->_locName . $this->_sourceURI; - $db = clone($GLOBALS['phpgw']->db); + $db = clone($GLOBALS['egw']->db); $cols = array('sync_serverts','sync_clientts'); @@ -213,7 +213,7 @@ class EGW_SyncML_State extends Horde_SyncML_State Horde::logMessage('SyncML: Authenticate ' . $this->_locName . ' - ' . $this->_password, __FILE__, __LINE__, PEAR_LOG_DEBUG); - if($GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($this->_locName,$this->_password,'text','u')) + if($GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($this->_locName,$this->_password,'text','u')) { $this->_isAuthorized = true; Horde::logMessage('SyncML_EGW: Authentication of ' . $this->_locName . '/' . $GLOBALS['sessionid'] . ' succeded' , __FILE__, __LINE__, PEAR_LOG_DEBUG); @@ -228,7 +228,7 @@ class EGW_SyncML_State extends Horde_SyncML_State { // store sessionID in a variable, because ->verify maybe resets that value $sessionID = session_id(); - if(!$GLOBALS['phpgw']->session->verify($sessionID, 'staticsyncmlkp3')) + if(!$GLOBALS['egw']->session->verify($sessionID, 'staticsyncmlkp3')) Horde::logMessage('SyncML_EGW: egw session('.$sessionID.') not verified ' , __FILE__, __LINE__, PEAR_LOG_DEBUG); } @@ -244,7 +244,7 @@ class EGW_SyncML_State extends Horde_SyncML_State { $mapID = $this->_locName . $this->_sourceURI . $type; - $db = clone($GLOBALS['phpgw']->db); + $db = clone($GLOBALS['egw']->db); $cols = array('map_guid'); @@ -287,7 +287,7 @@ class EGW_SyncML_State extends Horde_SyncML_State $guidParts = explode('-',$guid); if(count($guidParts) == 3) { - $guid = $GLOBALS['phpgw']->common->generate_uid($guidParts[0],$guidParts[1]); + $guid = $GLOBALS['egw']->common->generate_uid($guidParts[0],$guidParts[1]); } if($ts == 0) @@ -297,7 +297,7 @@ class EGW_SyncML_State extends Horde_SyncML_State Horde::logMessage("SyncML: setUID $type, $locid, $guid, $ts ".count($guidParts), __FILE__, __LINE__, PEAR_LOG_DEBUG); - $db = clone($GLOBALS['phpgw']->db); + $db = clone($GLOBALS['egw']->db); $mapID = $this->_locName . $this->_sourceURI . $type; @@ -349,7 +349,7 @@ class EGW_SyncML_State extends Horde_SyncML_State 'dev_id' => $deviceID, ); - $GLOBALS['phpgw']->db->insert('egw_syncmldevinfo',$data,$where); + $GLOBALS['egw']->db->insert('egw_syncmldevinfo', $data, $where, __LINE__, __FILE__); } /** @@ -383,7 +383,7 @@ class EGW_SyncML_State extends Horde_SyncML_State 'sync_clientts' => $this->_clientAnchorNext[$type] ); - $GLOBALS['phpgw']->db->insert('egw_syncmlsummary', $data, $where, __LINE__, __FILE__); + $GLOBALS['egw']->db->insert('egw_syncmlsummary', $data, $where, __LINE__, __FILE__); } } diff --git a/phpgwapi/inc/horde/Horde/SyncML/Sync/OneWayFromServerSync.php b/phpgwapi/inc/horde/Horde/SyncML/Sync/OneWayFromServerSync.php index 71f98f5231..65f963b48f 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/Sync/OneWayFromServerSync.php +++ b/phpgwapi/inc/horde/Horde/SyncML/Sync/OneWayFromServerSync.php @@ -1,6 +1,6 @@ _targetLocURI; - $hordeType = str_replace('./','',$syncType); - - if(!$adds = &$state->getAddedItems($hordeType)) - { - Horde::logMessage("SyncML: reading list of added items", __FILE__, __LINE__, PEAR_LOG_DEBUG); - $adds = $registry->call($hordeType, '/list', array()); - $adds = &$state->getAddedItems($hordeType); - } - Horde::logMessage("SyncML: ....... ".count($adds).' items to send ..............', __FILE__, __LINE__, PEAR_LOG_DEBUG); - - Horde::logMessage("SyncML: starting OneWayFromServerSync ($hordeType)", __FILE__, __LINE__, PEAR_LOG_DEBUG); - - #foreach ($adds as $guid) { - while($guid = array_shift($adds)) - { - $contentType = $state->getPreferedContentTypeClient($this->_sourceLocURI); - - $cmd = &new Horde_SyncML_Command_Sync_ContentSyncElement(); - $c = $registry->call($hordeType . '/export', - array('guid' => $guid, - 'contentType' => $contentType - ) - ); - if (!is_a($c, 'PEAR_Error')) { - // Item in history but not in database. Strange, but - // can happen. -#LK $cmd->setContent($state->convertServer2Client($c, $contentType)); - $cmd->setContent($c); - $cmd->setContentType($contentType['ContentType']); - $cmd->setSourceURI($guid); - $currentCmdID = $cmd->outputCommand($currentCmdID, $output, 'Add'); - $state->log('Server-Add'); - - $syncItems++; - // return if we have to much data - if($syncItems >= MAX_ENTRIES) - { - $state->setMoreDataPending(); - return $currentCmdID; - } - } - } - Horde::logMessage("SyncML: handling OneWayFromServerSync done ".$currentCmdID, __FILE__, __LINE__, PEAR_LOG_DEBUG); - - return $currentCmdID; - } - +class Horde_SyncML_Sync_OneWayFromServerSync extends Horde_SyncML_Sync_TwoWaySync { }