various syncml fixes

- when doing slowsync we don't update the entries anymore. we just add the needed mapping to the database.
- improved handing of deviceinfo
This commit is contained in:
Lars Kneschke 2006-08-15 14:42:13 +00:00
parent 072b6966d2
commit 45200da684
9 changed files with 802 additions and 767 deletions

View File

@ -493,12 +493,6 @@ class Horde_SyncML_SyncMLBody extends Horde_SyncML_ContentHandler {
switch($element)
{
# case 'Final':
# if($state->getClientSyncStatus() == 1)
# {
# $state->setClientSyncStatus(2);
# }
# break;
case 'Sync':
$state->setSyncStatus(CLIENT_SYNC_STARTED);
Horde::logMessage('SyncML['. session_id() .']: syncStatus(client sync started) ' . $state->getSyncStatus(), __FILE__, __LINE__, PEAR_LOG_DEBUG);

View File

@ -78,8 +78,7 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
if($this->_alert < ALERT_RESULT_ALERT)
{
if($this->_alert < ALERT_RESULT_ALERT) {
$type = $this->_targetLocURI;
@ -121,6 +120,7 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
if(isset($this->_targetLocURIParameters))
$sync->_targetLocURIParameters = $this->_targetLocURIParameters;
$state->setSync($this->_targetLocURI, $sync);
$state->removeAllUID($this->_targetLocURI);
}
$status = &new Horde_SyncML_Command_Status($code, 'Alert');
@ -196,10 +196,46 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
$output->endElement($state->getURI(), 'Item');
$output->endElement($state->getURI(), 'Alert');
// still needed? lars
$state->_sendFinal = true;
$currentCmdID++;
if($state->_devinfoRequested == false &&
$this->_sourceLocURI != null &&
is_a($state->getPreferedContentTypeClient($this->_sourceLocURI), 'PEAR_Error')) {
$output->startElement($state->getURI(), 'Get', $attrs);
$output->startElement($state->getURI(), 'CmdID', $attrs);
$output->characters($currentCmdID);
$currentCmdID++;
$output->endElement($state->getURI(), 'CmdID');
$output->startElement($state->getURI(), 'Meta', $attrs);
$output->startElement($state->getURIMeta(), 'Type', $attrs);
if(is_a($output, 'XML_WBXML_Encoder')) {
$output->characters('application/vnd.syncml-devinf+wbxml');
} else {
$output->characters('application/vnd.syncml-devinf+xml');
}
$output->endElement($state->getURIMeta(), 'Type');
$output->endElement($state->getURI(), 'Meta');
$output->startElement($state->getURI(), 'Item', $attrs);
$output->startElement($state->getURI(), 'Target', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs);
$output->characters(($state->getVersion() == 0) ? './devinf10' : './devinf11');
$output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Target');
$output->endElement($state->getURI(), 'Item');
$output->endElement($state->getURI(), 'Get');
$state->_devinfoRequested = true;
}
}
} elseif ($this->_alert == ALERT_NEXT_MESSAGE) {
$status = &new Horde_SyncML_Command_Status(RESPONSE_OK, 'Alert');
$status->setCmdRef($this->_cmdID);
@ -215,9 +251,6 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
$state->setAlert222Received(true);
#if($state->getSyncStatus() > CLIENT_SYNC_STARTED && $state->getSyncStatus() < CLIENT_SYNC_ACKNOWLEDGED) {
# $state->setSyncStatus(CLIENT_SYNC_ACKNOWLEDGED);
#}
} else {
$status = &new Horde_SyncML_Command_Status(RESPONSE_OK, 'Alert');
$status->setCmdRef($this->_cmdID);
@ -230,46 +263,6 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
$currentCmdID = $status->output($currentCmdID, $output);
}
/* else
{
if ($state->isAuthorized()) {
$output->startElement($state->getURI(), 'Alert', $attrs);
$output->startElement($state->getURI(), 'CmdID', $attrs);
$chars = $currentCmdID;
$output->characters($chars);
$output->endElement($state->getURI(), 'CmdID');
$output->startElement($state->getURI(), 'Data', $attrs);
$chars = $this->_alert;
$output->characters($chars);
$output->endElement($state->getURI(), 'Data');
$output->startElement($state->getURI(), 'Item', $attrs);
if ($this->_sourceLocURI != null) {
$output->startElement($state->getURI(), 'Target', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs);
$chars = $this->_sourceLocURI;
$output->characters($chars);
$output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Target');
}
if ($this->_targetLocURI != null) {
$output->startElement($state->getURI(), 'Source', $attrs);
$output->startElement($state->getURI(), 'LocURI', $attrs);
$chars = (isset($this->_targetLocURIParameters) ? $this->_targetLocURI.'?/'.$this->_targetLocURIParameters : $this->_targetLocURI);
$output->characters($chars);
$output->endElement($state->getURI(), 'LocURI');
$output->endElement($state->getURI(), 'Source');
}
$output->endElement($state->getURI(), 'Item');
$output->endElement($state->getURI(), 'Alert');
$currentCmdID++;
}
}*/
return $currentCmdID;
}
@ -338,17 +331,24 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
$sync->_targetLocURI = $this->_targetLocURI;
$sync->_sourceLocURI = $this->_sourceLocURI;
if(isset($this->_targetLocURIParameters))
if(isset($this->_targetLocURIParameters)) {
$sync->_targetLocURIParameters = $this->_targetLocURIParameters;
}
$state->setSync($this->_targetLocURI, $sync);
if($this->_alert == ALERT_SLOW_SYNC) {
$state->removeAllUID($this->_targetLocURI);
}
}
break;
case 2:
if ($element == 'Data') {
$this->_alert = intval(trim($this->_chars));
}
break;
case 4:
@ -360,12 +360,12 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
$this->_targetLocURI = $targetLocURIData[0];
if(isset($targetLocURIData[1]))
{
if(isset($targetLocURIData[1])) {
$this->_targetLocURIParameters = $targetLocURIData[1];
}
}
}
break;
case 5:
@ -374,6 +374,7 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
} else if ($element == 'Last') {
$this->_metaAnchorLast = trim($this->_chars);
}
break;
}

View File

@ -90,6 +90,7 @@ class Horde_SyncML_Command_Get extends Horde_SyncML_Command {
$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('./caltasks', 'text/x-vcalendar', '1.0', $output);
$output->endElement($state->getURIDevInf() , 'DevInf', $attrs);
$output->endElement($state->getURI(), 'Data');

View File

@ -42,9 +42,7 @@ class Horde_SyncML_Command_Put extends Horde_SyncML_Command {
var $_softwareVersion;
function endElement($uri, $element)
{
#Horde::logMessage('SyncML: put endelement ' . $element . ' stack ' . $this->_xmlStack, __FILE__, __LINE__, PEAR_LOG_DEBUG);
function endElement($uri, $element) {
switch ($this->_xmlStack) {
case 5:
switch($element) {
@ -56,30 +54,51 @@ class Horde_SyncML_Command_Put extends Horde_SyncML_Command {
'syncCapabilities' => $this->_syncCapabilities,
);
break;
case 'DevID':
$this->_deviceInfo['deviceID'] = trim($this->_chars);
break;
case 'DevTyp':
$this->_deviceInfo['deviceType'] = trim($this->_chars);
break;
case 'FwV':
$this->_deviceInfo['firmwareVersion'] = trim($this->_chars);
break;
case 'HwV':
$this->_deviceInfo['hardwareVersion'] = trim($this->_chars);
break;
case 'Man':
$this->_deviceInfo['manufacturer'] = trim($this->_chars);
break;
case 'Mod':
$this->_deviceInfo['model'] = trim($this->_chars);
break;
case 'OEM':
$this->_deviceInfo['oem'] = trim($this->_chars);
break;
case 'SwV':
$this->_deviceInfo['softwareVersion'] = trim($this->_chars);
break;
case 'SupportLargeObjs':
$this->_deviceInfo['supportLargeObjs'] = true;
break;
case 'SupportNumberOfChanges':
$this->_deviceInfo['supportNumberOfChanges'] = true;
break;
case 'UTC':
$this->_deviceInfo['UTC'] = true;
break;
case 'VerDTD':
$this->_deviceInfo['DTDVersion'] = trim($this->_chars);
break;
@ -90,15 +109,18 @@ class Horde_SyncML_Command_Put extends Horde_SyncML_Command {
case 'MaxGUIDSize':
$this->_maxGUIDSize = trim($this->_chars);
break;
case 'Rx-Pref':
$this->_rxPreference = array(
'contentType' => $this->_contentType,
'contentVersion' => $this->_contentVersion,
);
break;
case 'SourceRef':
$this->_sourceReference = trim($this->_chars);
break;
case 'Tx-Pref':
$this->_txPreference = array(
'contentType' => $this->_contentType,
@ -107,14 +129,17 @@ class Horde_SyncML_Command_Put extends Horde_SyncML_Command {
break;
}
break;
case 7:
switch($element) {
case 'CTType':
$this->_contentType = trim($this->_chars);
break;
case 'SyncType':
$this->_syncCapabilities[] = trim($this->_chars);
break;
case 'VerCT':
$this->_contentVersion = trim($this->_chars);
break;
@ -125,8 +150,7 @@ class Horde_SyncML_Command_Put extends Horde_SyncML_Command {
parent::endElement($uri, $element);
}
function output($currentCmdID, &$output )
{
function output($currentCmdID, &$output ) {
$state = &$_SESSION['SyncML.state'];
$status = &new Horde_SyncML_Command_Status((($state->isAuthorized()) ? RESPONSE_OK : RESPONSE_INVALID_CREDENTIALS), 'Put');
@ -136,10 +160,8 @@ class Horde_SyncML_Command_Put extends Horde_SyncML_Command {
$status->setSourceRef($ref);
if($state->isAuthorized())
{
if(count((array)$this->_deviceInfo) > 0)
{
if($state->isAuthorized()) {
if(count((array)$this->_deviceInfo) > 0) {
$state->setClientDeviceInfo($this->_deviceInfo);
$state->writeClientDeviceInfo();
}
@ -148,9 +170,7 @@ class Horde_SyncML_Command_Put extends Horde_SyncML_Command {
return $status->output($currentCmdID, $output);
}
function startElement($uri, $element, $attrs)
{
#Horde::logMessage('SyncML: put startelement ' . $element, __FILE__, __LINE__, PEAR_LOG_DEBUG);
function startElement($uri, $element, $attrs) {
parent::startElement($uri, $element, $attrs);
}

View File

@ -24,9 +24,9 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
var $_locSourceURI;
var $_deviceInfo;
function endElement($uri, $element)
{
function endElement($uri, $element) {
#Horde::logMessage('SyncML: put endelement ' . $element . ' stack ' . $this->_xmlStack, __FILE__, __LINE__, PEAR_LOG_DEBUG);
switch ($this->_xmlStack) {
case 5:
switch($element) {
@ -38,49 +38,74 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
'syncCapabilities' => $this->_syncCapabilities,
);
break;
case 'DevID':
$this->_deviceInfo['deviceID'] = trim($this->_chars);
break;
case 'DevTyp':
$this->_deviceInfo['deviceType'] = trim($this->_chars);
break;
case 'FwV':
$this->_deviceInfo['firmwareVersion'] = trim($this->_chars);
break;
case 'HwV':
$this->_deviceInfo['hardwareVersion'] = trim($this->_chars);
break;
case 'Man':
$this->_deviceInfo['manufacturer'] = trim($this->_chars);
break;
case 'Mod':
$this->_deviceInfo['model'] = trim($this->_chars);
break;
case 'OEM':
$this->_deviceInfo['oem'] = trim($this->_chars);
break;
case 'SwV':
$this->_deviceInfo['softwareVersion'] = trim($this->_chars);
break;
case 'SupportLargeObjs':
$this->_deviceInfo['supportLargeObjs'] = true;
break;
case 'SupportNumberOfChanges':
$this->_deviceInfo['supportNumberOfChanges'] = true;
break;
case 'UTC':
$this->_deviceInfo['UTC'] = true;
break;
case 'VerDTD':
$this->_deviceInfo['DTDVersion'] = trim($this->_chars);
break;
}
break;
case 6:
switch($element) {
case 'MaxGUIDSize':
$this->_maxGUIDSize = trim($this->_chars);
break;
case 'Rx-Pref':
$this->_rxPreference = array (
'contentType' => $this->_contentType,
'contentVersion' => $this->_contentVersion,
);
break;
case 'SourceRef':
$this->_sourceReference = trim($this->_chars);
break;
case 'Tx-Pref':
$this->_txPreference = array(
'contentType' => $this->_contentType,
@ -89,14 +114,17 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
break;
}
break;
case 7:
switch($element) {
case 'CTType':
$this->_contentType = trim($this->_chars);
break;
case 'SyncType':
$this->_syncCapabilities[] = trim($this->_chars);
break;
case 'VerCT':
$this->_contentVersion = trim($this->_chars);
break;
@ -107,11 +135,9 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
parent::endElement($uri, $element);
}
function output($currentCmdID, &$output)
{
if(!isset($this->_locSourceURI))
{
Horde::logMessage('SyncML: BIG TODO!!!!!!!!!!!!!!!!!! parse reply', __FILE__, __LINE__, PEAR_LOG_DEBUG);
function output($currentCmdID, &$output) {
if(!isset($this->_locSourceURI)) {
#Horde::logMessage('SyncML: BIG TODO!!!!!!!!!!!!!!!!!! parse reply', __FILE__, __LINE__, PEAR_LOG_DEBUG);
$state = &$_SESSION['SyncML.state'];
$status = &new Horde_SyncML_Command_Status((($state->isAuthorized()) ? RESPONSE_OK : RESPONSE_INVALID_CREDENTIALS), 'Results');
@ -121,20 +147,16 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
$status->setSourceRef($ref);
if($state->isAuthorized())
{
if(count((array)$this->_deviceInfo) > 0)
{
if($state->isAuthorized()) {
if(count((array)$this->_deviceInfo) > 0) {
$state->setClientDeviceInfo($this->_deviceInfo);
$state->writeClientDeviceInfo();
}
}
return $status->output($currentCmdID, $output);
}
else
{
Horde::logMessage('SyncML: BIG TODO!!!!!!!!!!!!!!!!!! generate reponse', __FILE__, __LINE__, PEAR_LOG_DEBUG);
} else {
#Horde::logMessage('SyncML: BIG TODO!!!!!!!!!!!!!!!!!! generate reponse', __FILE__, __LINE__, PEAR_LOG_DEBUG);
$state = $_SESSION['SyncML.state'];
$attrs = array();
@ -191,8 +213,7 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
*
* @param string $cmdRef New value of property cmdRef.
*/
function setCmdRef($cmdRef)
{
function setCmdRef($cmdRef) {
$this->_cmdRef = $cmdRef;
}
@ -201,8 +222,7 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
*
* @param string $type New value of property type.
*/
function setType($type)
{
function setType($type) {
$this->_type = $type;
}
@ -211,8 +231,7 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
*
* @param string $data New value of property data.
*/
function setData($data)
{
function setData($data) {
$this->_data = $data;
}
@ -221,9 +240,7 @@ class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
*
* @param string $locSourceURI New value of property locSourceURI.
*/
function setlocSourceURI($locSourceURI)
{
function setlocSourceURI($locSourceURI) {
$this->_locSourceURI = $locSourceURI;
}
}

View File

@ -200,6 +200,9 @@ class Horde_SyncML_State {
// stores if we received Alert 222 already
var $_receivedAlert222 = false;
// stores if we already requested the deviceinfo
var $_devinfoRequested = false;
/**
* Creates a new instance of Horde_SyncML_State.
*/
@ -625,20 +628,11 @@ class Horde_SyncML_State {
return $guid;
}
/**
* This function should use DevINF information.
*/
function getPreferedContentType($type)
{
# if ($type == 'contacts') {
# return 'text/x-vcard';
# } elseif ($type == 'notes') {
# return 'text/x-vnote';
# } elseif ($type == 'tasks') {
# return 'text/x-vcalendar';
# } elseif ($type == 'calendar') {
# return 'text/x-vcalendar';
# }
function getPreferedContentType($type) {
switch($type) {
case 'contacts':
case './contacts':
@ -681,30 +675,17 @@ class Horde_SyncML_State {
*
* This is passed as an option to the Horde API export functions.
*/
function getPreferedContentTypeClient($_sourceLocURI)
{
function getPreferedContentTypeClient($_sourceLocURI) {
$deviceInfo = $this->getClientDeviceInfo();
if(isset($deviceInfo['dataStore'][$_sourceLocURI]['rxPreference']['contentType']))
{
if(isset($deviceInfo['dataStore'][$_sourceLocURI]['rxPreference']['contentType'])) {
return array('ContentType' => $deviceInfo['dataStore'][$_sourceLocURI]['rxPreference']['contentType']);
}
Horde::logMessage('SyncML: sourceLocURI ' . $_sourceLocURI .' not found', __FILE__, __LINE__, PEAR_LOG_DEBUG);
return PEAR::raiseError(_('sourceLocURI not found'));
# elseif ($type == 'contacts') {
# return 'text/x-vcard';
# } elseif ($type == 'notes') {
# return array('ContentType' => 'text/x-vnote',
# 'ENCODING' => 'QUOTED-PRINTABLE',
# 'CHARSET' => 'UTF-8');
# } elseif ($type == 'tasks') {
# return 'text/x-vcalendar';
# } elseif ($type == 'calendar') {
# return array('ContentType' => 'text/x-vcalendar',
# 'ENCODING' => 'QUOTED-PRINTABLE',
# 'CHARSET' => 'UTF-8');
# }
}
function setClientAnchorNext($type, $a)

View File

@ -43,51 +43,63 @@ class EGW_SyncML_State extends Horde_SyncML_State
*
* a array containing all available infos about the device
*/
function getClientDeviceInfo()
{
$deviceID = $this->_locName . $this->_sourceURI;
function getClientDeviceInfo() {
$db = clone($GLOBALS['egw']->db);
$cols = array
(
$cols = array(
'owner_devid',
);
$where = array (
'owner_locname' => $this->_locName,
'owner_deviceid' => $this->_sourceURI,
);
$db->select('egw_syncmldeviceowner', $cols, $where, __LINE__, __FILE__);
if($db->next_record()) {
$deviceID = $db->f('owner_devid');
$cols = array(
'dev_dtdversion',
'dev_numberofchanges',
'dev_largeobjs',
'dev_swversion',
'dev_fwversion',
'dev_hwversion',
'dev_oem',
'dev_model',
'dev_manufacturer',
'dev_devicetype',
'dev_deviceid',
'dev_datastore',
'dev_utc',
);
$where = array
(
$where = array(
'dev_id' => $deviceID,
);
$db->select('egw_syncmldevinfo', $cols, $where, __LINE__, __FILE__);
if($db->next_record())
{
$devInfo = array
(
if($db->next_record()) {
$devInfo = array (
'DTDVersion' => $db->f('dev_dtdversion'),
'supportNumberOfChanges' => $db->f('dev_numberofchanges'),
'supportLargeObjs' => $db->f('dev_largeobjs'),
'UTC' => $db->f('dev_utc'),
'softwareVersion' => $db->f('dev_swversion'),
'hardwareVersion' => $db->f('dev_hwversion'),
'firmwareVersion' => $db->f('dev_fwversion'),
'oem' => $db->f('dev_oem'),
'model' => $db->f('dev_model'),
'manufacturer' => $db->f('dev_manufacturer'),
'deviceType' => $db->f('dev_devicetype'),
'deviceID' => $db->f('dev_deviceid'),
'dataStore' => unserialize($db->f('dev_datastore')),
);
return $devInfo;
}
}
return false;
}
@ -243,6 +255,29 @@ class EGW_SyncML_State extends Horde_SyncML_State
return $this->_isAuthorized;
}
/**
* Removes all locid<->guid mappings for the given type.
* Returns always true.
*/
function removeAllUID($type)
{
$mapID = $this->_locName . $this->_sourceURI . $type;
$db = clone($GLOBALS['egw']->db);
$cols = array('map_guid');
$where = array (
'map_id' => $mapID
);
Horde::logMessage("SyncML: state->removeAllUID(type=$type)", __FILE__, __LINE__, PEAR_LOG_DEBUG);
$db->delete('egw_contentmap', $where, __LINE__, __FILE__);
return true;
}
/**
* Removes the locid<->guid mapping for the given locid. Returns
* the guid that was removed or false if no mapping entry was
@ -256,23 +291,21 @@ class EGW_SyncML_State extends Horde_SyncML_State
$cols = array('map_guid');
$where = array
(
$where = array (
'map_id' => $mapID,
'map_locuid' => $locid
);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__);
if(!$db->next_record())
{
Horde::logMessage("SyncML: state->removeUID(type=$type,locid=$locid) : nothing to remove", __FILE__, __LINE__, PEAR_LOG_DEBUG);
if(!$db->next_record()) {
Horde::logMessage("SyncML: state->removeUID(type=$type,locid=$locid) : nothing to remove", __FILE__, __LINE__, PEAR_LOG_INFO);
return false;
}
$guid = $db->f('map_guid');
#Horde::logMessage("SyncML: state->removeUID(type=$type,locid=$locid) : removing guid:$guid", __FILE__, __LINE__, PEAR_LOG_DEBUG);
Horde::logMessage("SyncML: state->removeUID(type=$type,locid=$locid) : removing guid:$guid", __FILE__, __LINE__, PEAR_LOG_DEBUG);
$db->delete('egw_contentmap', $where, __LINE__, __FILE__);
@ -335,37 +368,70 @@ class EGW_SyncML_State extends Horde_SyncML_State
}
/**
* write clients device info to database
* writes clients deviceinfo into database
*/
function writeClientDeviceInfo()
{
function writeClientDeviceInfo() {
if (!isset($this->_clientDeviceInfo) || !is_array($this->_clientDeviceInfo)) {
return false;
}
$deviceID = $this->_locName . $this->_sourceURI;
$db = clone($GLOBALS['egw']->db);
$data = array
(
'dev_id' => $deviceID,
$cols = array(
'dev_id',
);
$softwareVersion = !empty($this->_clientDeviceInfo['softwareVersion']) ? $this->_clientDeviceInfo['softwareVersion'] : '';
$hardwareVersion = !empty($this->_clientDeviceInfo['hardwareVersion']) ? $this->_clientDeviceInfo['hardwareVersion'] : '';
$firmwareVersion = !empty($this->_clientDeviceInfo['firmwareVersion']) ? $this->_clientDeviceInfo['firmwareVersion'] : '';
$where = array (
'dev_model' => $this->_clientDeviceInfo['model'],
'dev_manufacturer' => $this->_clientDeviceInfo['manufacturer'],
'dev_swversion' => $softwareVersion,
'dev_hwversion' => $hardwareVersion,
'dev_fwversion' => $firmwareVersion,
);
$db->select('egw_syncmldevinfo', $cols, $where, __LINE__, __FILE__);
if($db->next_record()) {
$deviceID = $db->f('dev_id');
$data = array (
'dev_datastore' => serialize($this->_clientDeviceInfo['dataStore']),
);
$db->update('egw_syncmldevinfo', $data, $where, __LINE__, __FILE__);
} else {
$data = array (
'dev_dtdversion' => $this->_clientDeviceInfo['DTDVersion'],
'dev_numberofchanges' => $this->_clientDeviceInfo['supportNumberOfChanges'],
'dev_largeobjs' => $this->_clientDeviceInfo['supportLargeObjs'],
'dev_swversion' => $this->_clientDeviceInfo['softwareVersion'],
'dev_numberofchanges' => $this->_clientDeviceInfo['supportNumberOfChanges'] ? true : false,
'dev_largeobjs' => $this->_clientDeviceInfo['supportLargeObjs'] ? true : false,
'dev_utc' => $this->_clientDeviceInfo['UTC'] ? true : false,
'dev_swversion' => $softwareVersion,
'dev_hwversion' => $hardwareVersion,
'dev_fwversion' => $firmwareVersion,
'dev_oem' => $this->_clientDeviceInfo['oem'],
'dev_model' => $this->_clientDeviceInfo['model'],
'dev_manufacturer' => $this->_clientDeviceInfo['manufacturer'],
'dev_devicetype' => $this->_clientDeviceInfo['deviceType'],
'dev_deviceid' => $this->_clientDeviceInfo['deviceID'],
'dev_datastore' => serialize($this->_clientDeviceInfo['dataStore']),
);
$where = array
(
'dev_id' => $deviceID,
$db->insert('egw_syncmldevinfo', $data, $where, __LINE__, __FILE__);
$deviceID = $db->get_last_insert_id('egw_syncmldevinfo', 'dev_id');
}
$where = $data = array (
'owner_locname' => $this->_locName,
'owner_deviceid' => $this->_sourceURI,
'owner_devid' => $deviceID,
);
$GLOBALS['egw']->db->insert('egw_syncmldevinfo', $data, $where, __LINE__, __FILE__);
$db->insert('egw_syncmldeviceowner', $data, $where, __LINE__, __FILE__);
}
/**

View File

@ -33,23 +33,11 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
if(is_array($adds)) {
while($guid = array_shift($adds)) {
#$guid_ts = max($history->getTSforAction($guid, 'add'),$history->getTSforAction($guid, 'modify'));
$sync_ts = $state->getChangeTS($syncType, $guid);
#Horde::logMessage("SyncML: slowsync timestamp add: $guid sync_ts: $sync_ts anchorNext: ". $serverAnchorNext.' / '.time(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
// $sync_ts it got synced from client to server someone
// $sync_ts >= $serverAnchorNext it got synced from client to server in this sync package already
if ($sync_ts && $sync_ts >= $serverAnchorNext) {
// Change was done by us upon request of client.
// Don't mirror that back to the client.
//Horde::logMessage("SyncML: slowsync add: $guid ignored, came from client", __FILE__, __LINE__, PEAR_LOG_DEBUG);
if ($locID = $state->getLocID($syncType, $guid)) {
Horde::logMessage("SyncML: slowsync add to client: $guid ignored, already at client($locID)", __FILE__, __LINE__, PEAR_LOG_DEBUG);
continue;
}
#$locid = $state->getLocID($syncType, $guid);
// Create an Add request for client.
# LK $contentType = $state->getPreferedContentTypeClient($syncType);
$contentType = $state->getPreferedContentTypeClient($this->_sourceLocURI);
if(is_a($contentType, 'PEAR_Error')) {
// Client did not sent devinfo
@ -60,9 +48,6 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
$c = $registry->call($hordeType . '/export', array('guid' => $guid, 'contentType' => $contentType));
Horde::logMessage("SyncML: slowsync add to client $c", __FILE__, __LINE__, PEAR_LOG_DEBUG);
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);
if($hordeType == 'sifcalendar' || $hordeType == 'sifcontacts' || $hordeType == 'siftasks') {
$cmd->setContentFormat('b64');
@ -74,7 +59,6 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
$state->log('Server-Add');
// return if we have to much data
#Horde::logMessage("SyncML: ".' checking hordetype '.$hordeType , __FILE__, __LINE__, PEAR_LOG_DEBUG);
if(++$counter >= MAX_ENTRIES && $hordeType != 'sifcalendar' && $hordeType != 'sifcontacts' && $hordeType != 'siftasks') {
$state->setSyncStatus(SERVER_SYNC_DATA_PENDING);
return $currentCmdID;
@ -161,44 +145,17 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
}
$guid = false;
# if (is_a($command, 'Horde_SyncML_Command_Sync_Add')) {
# $guid = $registry->call($hordeType . '/import',
# array($state->convertClient2Server($syncItem->getContent(), $contentType), $contentType));
# if (!is_a($guid, 'PEAR_Error')) {
# $ts = $history->getTSforAction($guid, 'add');
# $state->setUID($type, $syncItem->getLocURI(), $guid, $ts);
# $state->log("Client-Add");
# #Horde::logMessage('SyncML: added client entry as ' . $guid, __FILE__, __LINE__, PEAR_LOG_DEBUG);
# } else {
# $state->log("Client-AddFailure");
# Horde::logMessage('SyncML: Error in adding client entry:' . $guid->message, __FILE__, __LINE__, PEAR_LOG_ERR);
# }
# } elseif (is_a($command, 'Horde_SyncML_Command_Sync_Replace')) {
#$guid = $state->getGlobalUID($type, $syncItem->getLocURI());
$guid = $registry->call($hordeType . '/search',
array($state->convertClient2Server($syncItem->getContent(), $contentType), $contentType));
Horde::logMessage('SyncML: found guid ' . $guid , __FILE__, __LINE__, PEAR_LOG_DEBUG);
$ok = false;
if ($guid) {
#Horde::logMessage('SyncML: locuri'. $syncItem->getLocURI() . ' guid ' . $guid , __FILE__, __LINE__, PEAR_LOG_ERR);
// Entry exists: replace current one.
$ok = $registry->call($hordeType . '/replace',
array($guid, $state->convertClient2Server($syncItem->getContent(), $contentType), $contentType));
if (!is_a($ok, 'PEAR_Error')) {
$ts = $history->getTSforAction($guid, 'modify');
$state->setUID($type, $syncItem->getLocURI(), $guid, $ts);
#Horde::logMessage('SyncML: replaced entry due to client request guid: '. $guid .' LocURI: '. $syncItem->getLocURI() .' ts: '. $ts, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$state->log("Client-Replace");
$ok = true;
} else {
// Entry may have been deleted; try adding it.
$ok = false;
}
}
if (!$ok) {
// Entry does not exist in map or database: add a new
// one.
if ($guid) {
# entry exists in database already. Just update the mapping
Horde::logMessage('SyncML: adding mapping for locuri:'. $syncItem->getLocURI() . ' and guid:' . $guid , __FILE__, __LINE__, PEAR_LOG_DEBUG);
$state->setUID($type, $syncItem->getLocURI(), $guid, mktime());
$state->log("Client-Replace");
} else {
# Entry does not exist in database: add a new one.
Horde::logMessage('SyncML: try to add contentype ' . $contentType .' to '. $hordeType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$guid = $registry->call($hordeType . '/import',
array($state->convertClient2Server($syncItem->getContent(), $contentType), $contentType));
@ -212,7 +169,6 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
$state->log("Client-AddFailure");
}
}
# }
}
return true;

View File

@ -19,6 +19,7 @@ include_once 'Horde/SyncML/Command/Sync/ContentSyncElement.php';
* @package Horde_SyncML
*/
class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
function endSync($currentCmdID, &$output) {
global $registry;
@ -35,12 +36,12 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
$output,
$refts);
if ($syncType == 'calendar' && $state->handleTasksInCalendar()) {
Horde::logMessage("SyncML: handling tasks in calendar sync", __FILE__, __LINE__, PEAR_LOG_DEBUG);
$currentCmdID = $this->handleSync($currentCmdID, 'tasks', $syncType,
$output, $refts);
}
#if ($syncType == 'calendar' && $state->handleTasksInCalendar()) {
# Horde::logMessage("SyncML: handling tasks in calendar sync", __FILE__, __LINE__, PEAR_LOG_DEBUG);
#
# $currentCmdID = $this->handleSync($currentCmdID, 'tasks', $syncType,
# $output, $refts);
#}
return $currentCmdID;
}
@ -219,15 +220,14 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
}
}
}
Horde::logMessage("SyncML: handling sync ".$currentCmdID, __FILE__, __LINE__, PEAR_LOG_DEBUG);
#Horde::logMessage("SyncML: handling sync ".$currentCmdID, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$state->clearSync($syncType);
return $currentCmdID;
}
function loadData()
{
function loadData() {
global $registry;
$state = &$_SESSION['SyncML.state'];
@ -250,5 +250,4 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
count($state->getDeletedItems($hordeType)) +
count($state->getAddedItems($hordeType));
}
}