improved handling of devinfo. Now we check if we have the needed datastore info for every alert. If we don't have them, we request the devinfo.

That's important for the synthesis client, which (can) send different datastore options, depending on the enabled datasources on the client.
This commit is contained in:
Lars Kneschke 2006-08-21 03:46:08 +00:00
parent 1037ac7d7f
commit be7cca8a44
3 changed files with 37 additions and 19 deletions

View File

@ -211,6 +211,8 @@ class Horde_SyncML_SyncMLHdr extends Horde_SyncML_ContentHandler {
#Horde::logMessage('SymcML: SyncHdr done. Try to load state from session.', __FILE__, __LINE__, PEAR_LOG_DEBUG);
$state = $this->getStateFromSession($this->_sourceURI, $this->_locName, $this->_sessionID);
Horde::logMessage('SyncML['. session_id() .']: package '.$this->_msgID.' +++++++++++++++++++++ started', __FILE__, __LINE__, PEAR_LOG_DEBUG);
$state->setVersion($this->_version);
$state->setMsgID($this->_msgID);
$state->setTargetURI($this->_targetURI);
@ -446,6 +448,7 @@ class Horde_SyncML_SyncMLBody extends Horde_SyncML_ContentHandler {
case 2:
$state = & $_SESSION['SyncML.state'];
$this->_actionCommands = false; // so far, we have not seen commands that require action from our side
$state->_sendFinal = false;
@ -481,6 +484,7 @@ class Horde_SyncML_SyncMLBody extends Horde_SyncML_ContentHandler {
$state = & $_SESSION['SyncML.state'];
// <SyncML><SyncBody><[Command]>
Horde::logMessage('SyncML['. session_id() ."]: found command $element ", __FILE__, __LINE__, PEAR_LOG_DEBUG);
$this->_currentCommand = Horde_SyncML_Command::factory($element);
$this->_currentCommand->startElement($uri, $element, $attrs);
@ -512,6 +516,8 @@ class Horde_SyncML_SyncMLBody extends Horde_SyncML_ContentHandler {
case 2:
// </SyncBody></SyncML>
$state = & $_SESSION['SyncML.state'];
Horde::logMessage('SyncML['. session_id() .']: package ----------------------- done', __FILE__, __LINE__, PEAR_LOG_DEBUG);
if($state->getSyncStatus() == CLIENT_SYNC_FINNISHED && $state->getAlert222Received() == true) {
$state->setSyncStatus(CLIENT_SYNC_ACKNOWLEDGED);
@ -579,7 +585,7 @@ class Horde_SyncML_SyncMLBody extends Horde_SyncML_ContentHandler {
$state->setSyncStatus(CLIENT_SYNC_ACKNOWLEDGED);
Horde::logMessage('SyncML['. session_id() .']: syncStatus(client sync acknowledged) '.$state->getSyncStatus(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
}
break;
case 3:

View File

@ -98,13 +98,13 @@ class Horde_SyncML_Command_Alert extends Horde_SyncML_Command {
$clientlast = $info['ClientAnchor'];
$state->setServerAnchorLast($type, $info['ServerAnchor']);
} else {
$clientlast = 0;
$clientlast === false;
$state->setServerAnchorLast($type, 0);
}
Horde::logMessage("SyncML: checking anchor \$clientlast " . $clientlast .' '. $this->_metaAnchorLast .' '. $clientlast == $this->_metaAnchorLast, __FILE__, __LINE__, PEAR_LOG_DEBUG);
// Set Server Anchor for this sync to current time.
$state->setServerAnchorNext($type,time());
if ($clientlast && $clientlast == $this->_metaAnchorLast) {
if ($clientlast !== false && $clientlast == $this->_metaAnchorLast) {
// Last Sync Anchor matches, TwoWaySync will do.
$code = RESPONSE_OK;
Horde::logMessage("SyncML: Anchor match, TwoWaySync since " . $clientlast, __FILE__, __LINE__, PEAR_LOG_DEBUG);

View File

@ -4,6 +4,8 @@ include_once dirname(__FILE__).'/State.php';
class EGW_SyncML_State extends Horde_SyncML_State
{
var $table_devinfo = 'egw_syncmldevinfo';
/**
* Returns the timestamp (if set) of the last change to the
* obj:guid, that was caused by the client. This is stored to
@ -25,7 +27,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
#Horde::logMessage('SyncML: getChangeTS for ' . $mapID .' / '. $guid, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
if($db->next_record())
{
@ -55,7 +57,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'owner_deviceid' => $this->_sourceURI,
);
$db->select('egw_syncmldeviceowner', $cols, $where, __LINE__, __FILE__);
$db->select('egw_syncmldeviceowner', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
if($db->next_record()) {
$deviceID = $db->f('owner_devid');
@ -79,7 +81,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'dev_id' => $deviceID,
);
$db->select('egw_syncmldevinfo', $cols, $where, __LINE__, __FILE__);
$db->select('egw_syncmldevinfo', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
if($db->next_record()) {
$devInfo = array (
@ -128,7 +130,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'map_expired' => 0,
);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
if($db->next_record())
{
@ -158,7 +160,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'map_guid' => $guid
);
Horde::logMessage('SyncML: search LocID for ' . $mapID .' / '.$guid, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
if($db->next_record())
{
@ -191,7 +193,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'sync_path' => $type
);
$db->select('egw_syncmlsummary', $cols, $where, __LINE__, __FILE__);
$db->select('egw_syncmlsummary', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
#Horde::logMessage("SyncML: get SYNCSummary for $deviceID", __FILE__, __LINE__, PEAR_LOG_DEBUG);
if($db->next_record())
@ -296,7 +298,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'map_locuid' => $locid
);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
if(!$db->next_record()) {
Horde::logMessage("SyncML: state->removeUID(type=$type,locid=$locid) : nothing to remove", __FILE__, __LINE__, PEAR_LOG_INFO);
@ -361,7 +363,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'map_timestamp' => $ts,
'map_expired' => 0,
);
$db->insert('egw_contentmap', $data, $where, __LINE__, __FILE__);
$db->insert('egw_contentmap', $data, $where, __LINE__, __FILE__, 'syncml');
#Horde::logMessage("SyncML: setUID $type, $locid, $guid, $ts $mapID", __FILE__, __LINE__, PEAR_LOG_DEBUG);
@ -376,13 +378,20 @@ class EGW_SyncML_State extends Horde_SyncML_State
}
$db = clone($GLOBALS['egw']->db);
$db->set_app('syncml');
if(!isset($this->size_dev_hwversion)) {
$tableDefDevInfo = $db->get_table_definitions('',$this->table_devinfo);
$this->size_dev_hwversion = $tableDefDevInfo['fd']['dev_hwversion']['precision'];
unset($tableDefDevInfo);
}
$cols = array(
'dev_id',
);
$softwareVersion = !empty($this->_clientDeviceInfo['softwareVersion']) ? $this->_clientDeviceInfo['softwareVersion'] : '';
$hardwareVersion = !empty($this->_clientDeviceInfo['hardwareVersion']) ? $this->_clientDeviceInfo['hardwareVersion'] : '';
$hardwareVersion = !empty($this->_clientDeviceInfo['hardwareVersion']) ? substr($this->_clientDeviceInfo['hardwareVersion'], 0, $this->size_dev_hwversion) : '';
$firmwareVersion = !empty($this->_clientDeviceInfo['firmwareVersion']) ? $this->_clientDeviceInfo['firmwareVersion'] : '';
$where = array (
@ -393,15 +402,14 @@ class EGW_SyncML_State extends Horde_SyncML_State
'dev_fwversion' => $firmwareVersion,
);
$db->select('egw_syncmldevinfo', $cols, $where, __LINE__, __FILE__);
$db->select('egw_syncmldevinfo', $cols, $where, __LINE__, __FILE__, false);
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 {
@ -419,18 +427,22 @@ class EGW_SyncML_State extends Horde_SyncML_State
'dev_devicetype' => $this->_clientDeviceInfo['deviceType'],
'dev_datastore' => serialize($this->_clientDeviceInfo['dataStore']),
);
$db->insert('egw_syncmldevinfo', $data, $where, __LINE__, __FILE__);
$deviceID = $db->get_last_insert_id('egw_syncmldevinfo', 'dev_id');
}
$where = $data = array (
$data = array (
'owner_locname' => $this->_locName,
'owner_deviceid' => $this->_sourceURI,
'owner_devid' => $deviceID,
);
$where = array (
'owner_locname' => $this->_locName,
'owner_deviceid' => $this->_sourceURI,
);
$db->insert('egw_syncmldeviceowner', $data, $where, __LINE__, __FILE__);
}
@ -465,7 +477,7 @@ class EGW_SyncML_State extends Horde_SyncML_State
'sync_clientts' => $this->_clientAnchorNext[$type]
);
$GLOBALS['egw']->db->insert('egw_syncmlsummary', $data, $where, __LINE__, __FILE__);
$GLOBALS['egw']->db->insert('egw_syncmlsummary', $data, $where, __LINE__, __FILE__, 'syncml');
}
}