Пример #1
0
 /**
  * Ping a mailbox. This detects only if any new messages have arrived in
  * the specified mailbox.
  *
  * @param Horde_ActiveSync_Folder_Imap $folder  The folder object.
  *
  * @return boolean  True if changes were detected, otherwise false.
  * @throws Horde_ActiveSync_Exception, Horde_ActiveSync_Exception_FolderGone
  */
 public function ping(Horde_ActiveSync_Folder_Imap $folder)
 {
     $mbox = new Horde_Imap_Client_Mailbox($folder->serverid());
     // Note: non-CONDSTORE servers will return a highestmodseq of 0
     $status_flags = Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDNEXT_FORCE | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_FORCE_REFRESH;
     // Get IMAP status.
     try {
         $status = $this->_getImapOb()->status($mbox, $status_flags);
     } catch (Horde_Imap_Client_Exception $e) {
         // See if the folder disappeared.
         if (!$this->_mailboxExists($mbox->utf8)) {
             throw new Horde_ActiveSync_Exception_FolderGone();
         }
         throw new Horde_ActiveSync_Exception($e);
     }
     // If we have per mailbox MODSEQ then we can pick up flag changes too.
     $modseq = $status[Horde_ActiveSync_Folder_Imap::HIGHESTMODSEQ];
     if ($modseq && $folder->modseq() > 0 && $folder->modseq() < $modseq) {
         return true;
     }
     // Increase in UIDNEXT is always a positive PING.
     if ($folder->uidnext() < $status['uidnext']) {
         return true;
     }
     // If the message count changes, something certainly changed.
     if ($folder->total_messages() != $status['messages']) {
         return true;
     }
     // Otherwise, no PING detectable changes present.
     return false;
 }