/** * Synchronizes the current mailbox cache with the server (using CONDSTORE * or QRESYNC). */ protected function _condstoreSync() { $mbox_ob = $this->_mailboxOb(); /* Check that modseqs are available in mailbox. */ if (!($highestmodseq = $mbox_ob->getStatus(Horde_Imap_Client::STATUS_HIGHESTMODSEQ)) || !($modseq = $this->_updateModSeq($highestmodseq))) { $mbox_ob->sync = true; } if ($mbox_ob->sync) { return; } $uids_ob = $this->getIdsOb($this->_cache->get($this->_selected, array(), array(), $mbox_ob->getStatus(Horde_Imap_Client::STATUS_UIDVALIDITY))); if (!count($uids_ob)) { $mbox_ob->sync = true; return; } /* Are we caching flags? */ if (array_key_exists(Horde_Imap_Client::FETCH_FLAGS, $this->_cacheFields())) { $fquery = new Horde_Imap_Client_Fetch_Query(); $fquery->flags(); /* Update flags in cache. Cache will be updated in _fetch(). */ $this->_fetch(new Horde_Imap_Client_Fetch_Results(), array(array('_query' => $fquery, 'changedsince' => $modseq, 'ids' => $uids_ob))); } /* Search for deleted messages, and remove from cache. */ $vanished = $this->vanished($this->_selected, $modseq, array('ids' => $uids_ob)); $disappear = array_diff($uids_ob->ids, $vanished->ids); if (!empty($disappear)) { $this->_deleteMsgs($this->_selected, $this->getIdsOb($disappear)); } $mbox_ob->sync = true; }
/** * Synchronizes the current mailbox cache with the server. */ protected function _syncMailbox() { $status = $this->status($this->_selected, Horde_Imap_Client::STATUS_UIDVALIDITY | Horde_Imap_Client::STATUS_HIGHESTMODSEQ); /* Check that modseqs are available in mailbox. */ if (empty($status['highestmodseq'])) { return; } /* Grab all flags updated since the cached modseq. */ $md = $this->_cache->getMetaData($this->_selected, $status['uidvalidity'], array(self::CACHE_MODSEQ)); if (!isset($md[self::CACHE_MODSEQ]) || $md[self::CACHE_MODSEQ] == $status['highestmodseq']) { return; } $uids = $this->_cache->get($this->_selected, array(), array(), $status['uidvalidity']); if (!empty($uids)) { $uids_ob = $this->getIdsOb($uids); /* Are we caching flags? */ if (array_key_exists(Horde_Imap_Client::FETCH_FLAGS, $this->_cacheFields())) { $fquery = new Horde_Imap_Client_Fetch_Query(); $fquery->flags(); /* Update flags in cache. Cache will be updated in _fetch(). */ $this->_fetch(new Horde_Imap_Client_Fetch_Results(), $fquery, array('changedsince' => $md[self::CACHE_MODSEQ], 'ids' => $uids_ob)); } /* Search for deleted messages, and remove from cache. */ $squery = new Horde_Imap_Client_Search_Query(); $squery->ids($this->getIdsOb($uids_ob->range_string)); $search = $this->search($this->_selected, $squery, array('nocache' => true)); $deleted = array_diff($uids_ob->ids, $search['match']->ids); if (!empty($deleted)) { $this->_deleteMsgs($this->_selected, $deleted); } } $this->_updateMetaData($this->_selected, array(self::CACHE_MODSEQ => $status['highestmodseq']), $status['uidvalidity']); }