Автор: Michael J Rubinsky (mrubinsk@horde.org)
Наследование: extends Horde_ActiveSync_Folder_Base, implements Serializable
Пример #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;
 }
Пример #2
0
 public function testSerializationWithoutImapCompression()
 {
     $folder = new Horde_ActiveSync_Folder_Imap('Trash', Horde_ActiveSync::CLASS_EMAIL);
     $status = array(Horde_ActiveSync_Folder_Imap::UIDVALIDITY => 100, Horde_ActiveSync_Folder_Imap::UIDNEXT => 47654, Horde_ActiveSync_Folder_Imap::HIGHESTMODSEQ => 200);
     $fixture = array(46653, 46654, 46655, 46656, 46657, 46658, 46659, 46660, 46661, 46662, 46663, 46664, 46665, 46666, 46667, 46668, 46669, 46670, 46671, 46672, 46673, 46674, 46675, 46676, 46677, 46678, 46679, 46680, 46681, 46682, 46691, 46692, 46693, 46694, 46695, 46696, 46697, 46698, 46699, 46700, 46701, 46702, 46703, 46704, 46705, 46706, 46707, 46708, 46709, 46710, 46711, 46712, 46713, 46714, 46715, 46716, 46717, 46718, 46719, 46720, 46721, 46723, 46724, 46725, 46726, 46727, 46728, 46729, 46730, 46731, 46732, 46733, 46734, 46735, 46736, 46737, 46738, 46739, 46740, 46741, 46742, 46743, 46744, 46745, 46746, 46747, 46748, 46749, 46750, 46751, 46752, 46753, 46754, 46755, 46756, 46757, 46758, 46759, 46760, 46761, 46762, 46763, 46764, 46765, 46766, 46767, 46768, 46769, 46770, 46771, 46772, 46773, 46774, 46775, 46776, 46777, 46778, 46779, 46780, 46781, 46782, 46783, 46784, 46785, 46786);
     $folder->setChanges($fixture);
     $folder->setStatus($status);
     $folder->updateState();
     $serialized = serialize($folder);
     $folder = unserialize($serialized);
     $this->assertEquals($fixture, $folder->messages());
 }