From: Michael M Slusarz Date: Wed, 27 Jan 2010 18:32:09 +0000 (-0700) Subject: Catch flag changes in DIMP mailbox refreshes. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2152a3a3946414e8d2cab2ec78a99871744dd674;p=horde.git Catch flag changes in DIMP mailbox refreshes. Requires CONDSTORE support on the server. --- diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 75986aa56..854ad502b 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,8 @@ v5.0-git -------- +[mms] Catch flag changes from other IMAP clients when refreshing if CONDSTORE + is available on the IMAP server (DIMP). [mms] Improved forwarding options. [mms] Add support for LIST-STATUS IMAP extension. [mms] Add hook to allow determination of compose attachments MIME type. diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 85168a220..032cf49a3 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -821,6 +821,10 @@ class IMP_Mailbox /** * Returns a unique identifier for the current mailbox status. * + * This cache ID is guaranteed to change if messages are added/deleted from + * the mailbox. Additionally, if CONDSTORE is available on the remote + * IMAP server, this ID will change if flag information changes. + * * @return string The cache ID string, which will change when the * composition of the mailbox changes. */ diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index 38943c807..32c92f5c8 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -171,16 +171,24 @@ class IMP_Views_ListMessages } /* Get the cached list. */ - if (empty($args['cache'])) { - $cached = array(); - } else { + $cached = $changed = array(); + if (!empty($args['cache'])) { if ($is_search) { - $cached = Horde_Serialize::unserialize($args['cache'], Horde_Serialize::JSON); + $cached = array_flip(Horde_Serialize::unserialize($args['cache'], Horde_Serialize::JSON)); } else { $cached = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($args['cache']); - $cached = reset($cached); + $cached = array_flip(reset($cached)); + + /* Check for cached entires marked as changed via CONDSTORE + * IMAP extension. If changed, resend the entire entry to + * update the browser cache (done below). */ + if ($args['change']) { + $status = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_LASTMODSEQUIDS); + if (!empty($status['lastmodsequids'])) { + $changed = array_flip($status['lastmodsequids']); + } + } } - $cached = array_flip($cached); } if (!empty($args['search_unseen'])) { @@ -234,8 +242,10 @@ class IMP_Views_ListMessages foreach ($uidlist as $uid => $seq) { $msglist[$seq] = $sorted_list['s'][$seq]; $rowlist[$uid] = $seq; - if (!isset($cached[$uid])) { - $data[] = $seq; + /* Send browser message data if not already cached or if CONDSTORE + * has indiciated that data has changed. */ + if (!isset($cached[$uid]) || isset($changed[$uid])) { + $data[$seq] = 1; } } $result->rowlist = $rowlist; @@ -271,7 +281,7 @@ class IMP_Views_ListMessages } /* Build the overview list. */ - $result->data = $this->_getOverviewData($imp_mailbox, $mbox, $data, $is_search); + $result->data = $this->_getOverviewData($imp_mailbox, $mbox, array_keys($data), $is_search); /* Get unseen/thread information. */ if (!$is_search) {