From: Michael M Slusarz Date: Wed, 27 Jan 2010 18:21:24 +0000 (-0700) Subject: Add additional Horde_Imap_Client_Base::status() returns. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0bb07630d3d568fec99905babf4df9d43b8b56d9;p=horde.git Add additional Horde_Imap_Client_Base::status() returns. Add STATUS_LASTMODSEQ and STATUS_LASTMODSEQUIDS to quickly determine the list of changed UIDs in a mailbox if CONDSTORE is enabled. --- diff --git a/framework/Imap_Client/lib/Horde/Imap/Client.php b/framework/Imap_Client/lib/Horde/Imap/Client.php index c9408b0f9..3efd71fc4 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client.php @@ -95,7 +95,9 @@ class Horde_Imap_Client const STATUS_FLAGS = 128; const STATUS_PERMFLAGS = 256; const STATUS_HIGHESTMODSEQ = 512; - const STATUS_UIDNOTSTICKY = 1024; + const STATUS_LASTMODSEQ = 1024; + const STATUS_LASTMODSEQUIDS = 2048; + const STATUS_UIDNOTSTICKY = 4096; /* Constants for search() */ const SORT_ARRIVAL = 1; diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php index 97b35986a..78f67d05c 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php @@ -961,6 +961,24 @@ abstract class Horde_Imap_Client_Base * not available or the mailbox does not support * mod-sequences. * + * Flag: Horde_Imap_Client::STATUS_LASTMODSEQ + * Return key: 'lastmodseq' + * Return format: (integer) If the server supports the CONDSTORE IMAP + * extension, this will be the cached mod-sequence value + * of the mailbox when it was first opened if + * HIGHESTMODSEQ changed. Else 0 if CONDSTORE not + * available, the mailbox does not support mod-sequences, + * or the mod-sequence did not change. + * + * Flag: Horde_Imap_Client::STATUS_LASTMODSEQUIDS + * Return key: 'lastmodsequids' + * Return format: (array) If the server supports the CONDSTORE IMAP + * extension, this will be the list of UIDs changed in + * the mailbox when it was first opened if HIGHESTMODSEQ + * changed. Else an empty array if CONDSTORE not + * available, the mailbox does not support mod-sequences, + * or the mod-sequence did not change. + * * Flag: Horde_Imap_Client::STATUS_UIDNOTSTICKY * Return key: 'uidnotsticky' * Return format: (boolean) If the server supports the UIDPLUS IMAP @@ -1023,6 +1041,25 @@ abstract class Horde_Imap_Client_Base $flags &= ~Horde_Imap_Client::STATUS_UIDNOTSTICKY; } + /* Handle LASTMODSEQ related options. */ + if ($flags & Horde_Imap_Client::STATUS_LASTMODSEQ) { + $ret['lastmodseq'] = 0; + if (isset($this->_init['enabled']['CONDSTORE']) && + isset($this->_temp['lastmodseq'][$mailbox])) { + $ret['lastmodseq'] = $this->_temp['lastmodseq'][$mailbox]; + } + $flags &= ~Horde_Imap_Client::STATUS_LASTMODSEQ; + } + + if ($flags & Horde_Imap_Client::STATUS_LASTMODSEQUIDS) { + $ret['lastmodsequids'] = array(); + if (isset($this->_init['enabled']['CONDSTORE']) && + isset($this->_temp['lastmodsequids'][$mailbox])) { + $ret['lastmodsequids'] = $this->utils->fromSequenceString($this->_temp['lastmodsequids'][$mailbox]); + } + $flags &= ~Horde_Imap_Client::STATUS_LASTMODSEQUIDS; + } + if (!$flags) { return $ret; } @@ -2742,7 +2779,7 @@ abstract class Horde_Imap_Client_Base * 'mailbox' - (string) The mailbox to update. * DEFAULT: The selected mailbox. * 'seq' - (boolean) Is data stored with sequence numbers? - * DEFAULT: Data stored with UIDs. + * DEFAULT: Data stored with UIDs. * 'uidvalid' - (integer) The UID Validity number. * DEFAULT: UIDVALIDITY discovered via a status() call. * @@ -2860,6 +2897,10 @@ abstract class Horde_Imap_Client_Base $metadata = $this->_cache->getMetaData($mailbox, $uidvalid, array('HICmodseq')); if (!isset($metadata['HICmodseq']) || ($metadata['HICmodseq'] != $modseq)) { + $this->_temp['lastmodseq'][$mailbox] = $metadata['HICmodseq']; + if (count($tocache)) { + $this->_temp['lastmodsequids'][$mailbox] = $this->utils->toSequenceString(array_keys($tocache), array('nosort' => true)); + } $this->_updateMetaData($mailbox, array('HICmodseq' => $modseq), $uidvalid); } } diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index 65d826c9b..1007a9207 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -1175,7 +1175,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base Horde_Imap_Client::STATUS_UIDNOTSTICKY => 'uidnotsticky', ); - /* Don't include 'highestmodseq' return if server does not support it. + /* Don't include modseq returns if server does not support it. * OK to use queryCapability('CONDSTORE') here because we may not have * yet sent an enabling command. */ if ($this->queryCapability('CONDSTORE')) {