Skip to content

Commit

Permalink
Need to optionally pass the source id when asking for syncstamps.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 10, 2013
1 parent dfaa3e4 commit 3054c02
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
40 changes: 24 additions & 16 deletions framework/Core/lib/Horde/Core/ActiveSync/Connector.php
Expand Up @@ -215,14 +215,16 @@ public function calendar_delete($uid)
/**
* Return the timestamp for the last time $action was performed.
*
* @param string $uid The UID of the event we are interested in.
* @param string $action The action we are interested in (add, modify...)
* @param string $uid The UID of the event we are interested in.
* @param string $action The action we are interested in (add, modify...).
* @param string $calendar The calendar id, if not using multiplexed data.
*
* @return integer
*/
public function calendar_getActionTimestamp($uid, $action)
public function calendar_getActionTimestamp($uid, $action, $calendar = null)
{
return $this->_registry->calendar->getActionTimestamp($uid, $action, null, $this->hasFeature('modseq', 'calendar'));
return $this->_registry->calendar->getActionTimestamp(
$uid, $action, $calendar, $this->hasFeature('modseq', 'calendar'));
}

/**
Expand Down Expand Up @@ -296,14 +298,16 @@ public function contacts_delete($uid)
* Get the timestamp of the most recent occurance of $action for the
* specifed contact
*
* @param string $uid The UID of the contact to search
* @param string $action The action to lookup
* @param string $uid The UID of the contact to search.
* @param string $action The action to lookup.
* @param string $addressbook The addressbook id, if not using multiplex.
*
* @return integer
*/
public function contacts_getActionTimestamp($uid, $action)
public function contacts_getActionTimestamp($uid, $action, $addressbook = null)
{
return $this->_registry->contacts->getActionTimestamp($uid, $action, null, $this->hasFeature('modseq', 'contacts'));
return $this->_registry->contacts->getActionTimestamp(
$uid, $action, $addressbook, $this->hasFeature('modseq', 'contacts'));
}

/**
Expand Down Expand Up @@ -466,14 +470,16 @@ public function tasks_delete($id)
/**
* Return the timestamp or modseq for the last time $action was performed.
*
* @param string $uid The UID of the task we are interested in.
* @param string $action The action we are interested in (add, modify...)
* @param string $uid The UID of the task we are interested in.
* @param string $action The action we are interested in (add, modify...)
* @param string $tasklike The tasklist, if not using multiplexed data.
*
* @return integer
*/
public function tasks_getActionTimestamp($uid, $action)
public function tasks_getActionTimestamp($uid, $action, $tasklist = null)
{
return $this->_registry->tasks->getActionTimestamp($uid, $action, null, $this->hasFeature('modseq', 'tasks'));
return $this->_registry->tasks->getActionTimestamp(
$uid, $action, $tasklist, $this->hasFeature('modseq', 'tasks'));
}

/**
Expand Down Expand Up @@ -557,13 +563,15 @@ public function notes_delete($id)
*
* @param string $uid The UID of the task we are interested in.
* @param string $action The action we are interested in (add, modify...)
* @param string $notpad The notepad to use, if not using multiplex.
*
* @return integer
* @since 5.1
*/
public function notes_getActionTimestamp($uid, $action)
public function notes_getActionTimestamp($uid, $action, $notepad = null)
{
return $this->_registry->notes->getActionTimestamp($uid, $action, null, $this->hasFeature('modseq', 'notes'));
return $this->_registry->notes->getActionTimestamp(
$uid, $action, $notepad, $this->hasFeature('modseq', 'notes'));
}

/**
Expand Down Expand Up @@ -613,9 +621,9 @@ public function hasFeature($feature, $collection)
* @return integer The modseq value.
* @since 2.6.0
*/
public function getHighestModSeq($collection)
public function getHighestModSeq($collection, $id = null)
{
return $this->_registry->{$this->_getInterfaceFromCollectionId($collection)}->getHighestModSeq();
return $this->_registry->{$this->_getInterfaceFromCollectionId($collection)}->getHighestModSeq($id);
}

/**
Expand Down
18 changes: 13 additions & 5 deletions framework/Core/lib/Horde/Core/ActiveSync/Driver.php
Expand Up @@ -2661,6 +2661,10 @@ public function getFreebusy($user, array $options = array())
*/
public function getSyncStamp($collection, $last = null)
{
$this->_logger->info(sprintf(
'[%s] Horde_Core_ActiveSync_Driver::getSyncStamp(%s, %d);',
getmypid(), $collection, $last));

// For FolderSync (empty $collection) or Email collections, we don't care.
if (empty($collection)) {
return time();
Expand All @@ -2669,8 +2673,10 @@ public function getSyncStamp($collection, $last = null)
$parts = $this->_parseFolderId($collection);
if (is_array($parts)) {
$class = $parts[self::FOLDER_PART_CLASS];
$id = $parts[self::FOLDER_PART_ID];
} else {
$class = $parts;
$id = null;
}

if (!in_array($class, array(Horde_ActiveSync::CLASS_CALENDAR, Horde_ActiveSync::CLASS_NOTES, Horde_ActiveSync::CLASS_CONTACTS, Horde_ActiveSync::CLASS_TASKS))) {
Expand All @@ -2679,7 +2685,7 @@ public function getSyncStamp($collection, $last = null)


if ($this->_connector->hasFeature('modseq', $this->_classMap[$class])) {
$modseq = $this->_connector->getHighestModSeq($this->_classMap[$class]);
$modseq = $this->_connector->getHighestModSeq($this->_classMap[$class], $id);
// Sanity check - if the last syncstamp is higher then the
// current modification sequence, something is wrong. Could be
// the history backend just happend to have deleted the most recent
Expand Down Expand Up @@ -2766,21 +2772,23 @@ protected function _smartStatMessage($folderid, $id, $hint)
$folder_parts = $this->_parseFolderId($folderid);
if (count($folder_parts) == 2) {
$folder_class = $folder_parts[self::FOLDER_PART_CLASS];
$serverid = $folder_parts[self::FOLDER_PART_ID];
} else {
$folder_class = false;
$serverid = null;
}
switch ($folder_class) {
case Horde_ActiveSync::CLASS_CALENDAR:
$mod = $this->_connector->calendar_getActionTimestamp($id, 'modify');
$mod = $this->_connector->calendar_getActionTimestamp($id, 'modify', $serverid);
break;
case Horde_ActiveSync::CLASS_CONTACTS:
$mod = $this->_connector->contacts_getActionTimestamp($id, 'modify');
$mod = $this->_connector->contacts_getActionTimestamp($id, 'modify', $serverid);
break;
case Horde_ActiveSync::CLASS_TASKS:
$mod = $this->_connector->tasks_getActionTimestamp($id, 'modify');
$mod = $this->_connector->tasks_getActionTimestamp($id, 'modify', $serverid);
break;
case Horde_ActiveSync::CLASS_NOTES:
$mod = $this->_connector->notes_getActionTimestamp($id, 'modify');
$mod = $this->_connector->notes_getActionTimestamp($id, 'modify', $serverid);
break;
default:
try {
Expand Down

0 comments on commit 3054c02

Please sign in to comment.