$seenfolders = $this->_state->getKnownFolders();
$this->_logger->debug('[Horde_ActiveSync::handleFolderSync] newSyncKey: ' . $newsynckey);
+ /* Track if we have changes or not */
+ $changes = false;
+
/* Deal with folder hierarchy changes */
if ($this->_decoder->getElementStartTag(Horde_ActiveSync::FOLDERHIERARCHY_CHANGES)) {
// Ignore <Count> if present
case SYNC_ADD:
case SYNC_MODIFY:
$serverid = $importer->importFolderChange($folder);
+ $changes = true;
break;
case SYNC_REMOVE:
$serverid = $importer->importFolderDeletion($folder);
+ $changes = true;
break;
}
$this->_encoder->endTag();
$this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_SYNCKEY);
- $this->_encoder->content($newsynckey);
+ $this->_encoder->content((($changes || $exporter->count > 0) ? $newsynckey : $synckey));
$this->_encoder->endTag();
$this->_encoder->startTag(Horde_ActiveSync::FOLDERHIERARCHY_CHANGES);
$this->_encoder->startTag(Horde_ActiveSync::SYNC_SYNCHRONIZE);
$this->_encoder->startTag(Horde_ActiveSync::SYNC_FOLDERS);
foreach ($collections as $collection) {
+ /* Get new synckey if needed */
+ $changecount = 0;
+ if (isset($collection['getchanges'])) {
+ $filtertype = isset($collection['filtertype']) ? $collection['filtertype'] : false;
+ $exporter = new Horde_ActiveSync_Connector_Exporter($this->_encoder, $collection['class']);
+ $sync = $this->_driver->getSyncObject();
+ $sync->init($this->_state, $exporter, $collection);
+ $changecount = $sync->getChangeCount();
+ }
/* Get new synckey if needed */
if (isset($collection['importedchanges']) ||
- isset($collection['getchanges']) ||
+ $changecount > 0 ||
$collection['synckey'] == '0') {
try {
$collection['newsynckey'] = $this->_state->getNewSyncKey($collection['synckey']);
/* Send server changes to PIM */
if (isset($collection['getchanges'])) {
- $filtertype = isset($collection['filtertype']) ? $collection['filtertype'] : false;
- $exporter = new Horde_ActiveSync_Connector_Exporter($this->_encoder, $collection['class']);
- $sync = $this->_driver->getSyncObject();
- $sync->init($this->_state, $exporter, $collection);
- $changecount = $sync->getChangeCount();
+ /* Changecount and exporter initialized above */
if (!empty($collection['windowsize']) && $changecount > $collection['windowsize']) {
$this->_encoder->startTag(Horde_ActiveSync::SYNC_MOREAVAILABLE, false, true);
}