fixed handling of too long syncml id's

This commit is contained in:
Lars Kneschke 2007-06-25 08:55:20 +00:00
parent ef1e1721dc
commit 495abdd139
6 changed files with 48 additions and 13 deletions

View File

@ -484,7 +484,7 @@ class Horde_SyncML_SyncMLBody extends Horde_SyncML_ContentHandler {
$state = & $_SESSION['SyncML.state']; $state = & $_SESSION['SyncML.state'];
// <SyncML><SyncBody><[Command]> // <SyncML><SyncBody><[Command]>
Horde::logMessage('SyncML['. session_id() ."]: found command $element ", __FILE__, __LINE__, PEAR_LOG_DEBUG); #Horde::logMessage('SyncML['. session_id() ."]: found command $element ", __FILE__, __LINE__, PEAR_LOG_DEBUG);
$this->_currentCommand = Horde_SyncML_Command::factory($element); $this->_currentCommand = Horde_SyncML_Command::factory($element);
$this->_currentCommand->startElement($uri, $element, $attrs); $this->_currentCommand->startElement($uri, $element, $attrs);

View File

@ -117,6 +117,7 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_
$output->startElement($state->getURI(), 'Source', $attrs); $output->startElement($state->getURI(), 'Source', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs); $output->startElement($state->getURI(), 'LocURI', $attrs);
$chars = substr($this->_locURI,0,39); $chars = substr($this->_locURI,0,39);
$state->setUIDMapping($this->_locURI, $chars);
$output->characters($chars); $output->characters($chars);
$output->endElement($state->getURI(), 'LocURI'); $output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Source'); $output->endElement($state->getURI(), 'Source');

View File

@ -203,6 +203,11 @@ class Horde_SyncML_State {
// stores if we already requested the deviceinfo // stores if we already requested the deviceinfo
var $_devinfoRequested = false; var $_devinfoRequested = false;
/*
* store the mappings of egw uids to client uids
*/
var $_uidMappings = array();
/** /**
* Creates a new instance of Horde_SyncML_State. * Creates a new instance of Horde_SyncML_State.
*/ */
@ -217,6 +222,24 @@ class Horde_SyncML_State {
$this->isAuthorized = false; $this->isAuthorized = false;
} }
/**
* store the sent global uid
*/
function setUIDMapping($_realEgwUid, $_sentEgwUid) {
$this->_uidMappings[$_sentEgwUid] = $_realEgwUid;
}
/**
* retrieve the real egw uid for a given send uid
*/
function getUIDMapping($_sentEgwUid) {
if(isset($this->_uidMappings[$_sentEgwUid])) {
return $this->_uidMappings[$_sentEgwUid];
}
return false;
}
/** /**
* Returns the DataTree used as persistence layer for SyncML. The * Returns the DataTree used as persistence layer for SyncML. The

View File

@ -4,7 +4,12 @@ include_once dirname(__FILE__).'/State.php';
class EGW_SyncML_State extends Horde_SyncML_State class EGW_SyncML_State extends Horde_SyncML_State
{ {
var $table_devinfo = 'egw_syncmldevinfo'; var $table_devinfo = 'egw_syncmldevinfo';
/*
* store the mappings of egw uids to client uids
*/
var $uidMappings = array();
/** /**
* Returns the timestamp (if set) of the last change to the * Returns the timestamp (if set) of the last change to the
@ -323,22 +328,28 @@ class EGW_SyncML_State extends Horde_SyncML_State
* have different syncs with different devices. If an entry * have different syncs with different devices. If an entry
* already exists, it is overwritten. * already exists, it is overwritten.
*/ */
function setUID($type, $locid, $guid, $ts=0) function setUID($type, $locid, $_guid, $ts=0)
{ {
#Horde::logMessage("SyncML: setUID $type, $locid, $guid, $ts ", __FILE__, __LINE__, PEAR_LOG_DEBUG);
#Horde::logMessage("SyncML: setUID ". $this->getUIDMapping($guid), __FILE__, __LINE__, PEAR_LOG_DEBUG);
// fix $guid, it maybe was to long for some devices // fix $guid, it maybe was to long for some devices
// format is appname-id-systemid // format is appname-id-systemid
$guidParts = explode('-',$guid); #$guidParts = explode('-',$guid);
if(count($guidParts) == 3) #if(count($guidParts) == 3) {
{ # $guid = $GLOBALS['egw']->common->generate_uid($guidParts[0],$guidParts[1]);
$guid = $GLOBALS['egw']->common->generate_uid($guidParts[0],$guidParts[1]); #}
}
if($ts == 0) $guid = $this->getUIDMapping($_guid);
{ if($guid === false) {
Horde::logMessage("SyncML: setUID $type, $locid, $guid something went wrong!!! Mapping not found.", __FILE__, __LINE__, PEAR_LOG_INFO);
return false;
}
Horde::logMessage("SyncML: setUID $_guid => $guid", __FILE__, __LINE__, PEAR_LOG_DEBUG);
if($ts == 0) {
$ts = time(); $ts = time();
} }
#Horde::logMessage("SyncML: setUID $type, $locid, $guid, $ts ".count($guidParts), __FILE__, __LINE__, PEAR_LOG_DEBUG); Horde::logMessage("SyncML: setUID $type, $locid, $guid, $ts ", __FILE__, __LINE__, PEAR_LOG_DEBUG);
$db = clone($GLOBALS['egw']->db); $db = clone($GLOBALS['egw']->db);

View File

@ -44,7 +44,7 @@ class Horde_SyncML_Sync_RefreshFromServerSync extends Horde_SyncML_Sync_TwoWaySy
$cmd = &new Horde_SyncML_Command_Sync_ContentSyncElement(); $cmd = &new Horde_SyncML_Command_Sync_ContentSyncElement();
$c = $registry->call($hordeType . '/export', array('guid' => $guid, 'contentType' => $contentType)); $c = $registry->call($hordeType . '/export', array('guid' => $guid, 'contentType' => $contentType));
Horde::logMessage("SyncML: slowsync add to client $c", __FILE__, __LINE__, PEAR_LOG_DEBUG); Horde::logMessage("SyncML: slowsync add $guid to client ". print_r($c, true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
if (!is_a($c, 'PEAR_Error')) { if (!is_a($c, 'PEAR_Error')) {
$cmd->setContent($c); $cmd->setContent($c);
if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') { if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') {

View File

@ -46,7 +46,7 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
$cmd = &new Horde_SyncML_Command_Sync_ContentSyncElement(); $cmd = &new Horde_SyncML_Command_Sync_ContentSyncElement();
$c = $registry->call($hordeType . '/export', array('guid' => $guid, 'contentType' => $contentType)); $c = $registry->call($hordeType . '/export', array('guid' => $guid, 'contentType' => $contentType));
Horde::logMessage("SyncML: slowsync add to client $c", __FILE__, __LINE__, PEAR_LOG_DEBUG); #Horde::logMessage("SyncML: slowsync add guid $guid to client ". print_r($c, true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
if (!is_a($c, 'PEAR_Error')) { if (!is_a($c, 'PEAR_Error')) {
$cmd->setContent($c); $cmd->setContent($c);
if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') { if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') {