Subject: [lemonade] How to update UNSEEN count in case of an IMAP client which implements Partial Download of Message Headers (i.e, downloading headers chunk by chunk)

From: allam sureshkumar <[email-masked]>
Date: Wed, 9 Mar 2011 12:43:49 +0530

Hi all,

If a client implements Partial Download of Message Headers (i.e, downloading
headers chunk by chunk whenever user requests), how do we update the unread
count in the following two cases:
(Keeping in mind that we cannot get calculate UNSEEN count by traversing
header list because we do not download complete header list)

*
1.When a folder is selected :*
  In SELECT command's response we cannot get the total UNSEEN count (the
UNSEEN count in response gives the sequence number of first occurrence of an
UNSEEN message but not the total unseen).

 I m not sure how and in which case the sequence number of first occurrence
of an UNSEEN msg is useful to any client, instead the total UNSEEN count
would be handy.

*2. During idle updates* *:*
  For example a message header that was not downloaded by Client is being
deleted at server by some other client, then in IDLE update we get the
expunged response,
  but we do not know whether its seen or unseen and hence cannot update the
UNSEEN count.

 Can we get UNSEEN count in IDLE updates whenever UNSEEN count is modified
?  (similar to EXISTS response in idle updates)

One way to handle the above two cases is to send STATUS command to get the
UNSEEN count, but RFC 3501 suggests not to send STATUS command when a folder
is selected.

What RFC 3501 says

*Note: " The STATUS command is intended to access the
status of mailboxes other than the currently selected
mailbox. Because the STATUS command can cause the
mailbox to be opened internally, and because this
information is available by other means on the selected
mailbox, the STATUS command SHOULD NOT be used on the
currently selected mailbox*."

So can you please suggest how to get UNSEEN in the above two cases.

Thanks and Regards,
Suresh Kumar.

---

From: Timo Sirainen <[email-masked]>
Date: Wed, 09 Mar 2011 18:57:05 +0200

On Wed, 2011-03-09 at 12:43 +0530, allam sureshkumar wrote:

> If a client implements Partial Download of Message Headers (i.e,
> downloading headers chunk by chunk whenever user requests), how do we
> update the unread count in the following two cases:

After SELECTing mailbox, issue SEARCH UNSEEN command and remember which
messages are unseen. Then you can keep the number of unseen messages
up-to-date by updating the list when you get untagged FETCH FLAGS
updates.

---

From: Barry Leiba <[email-masked]>
Date: Wed, 9 Mar 2011 11:59:33 -0500

> of an UNSEEN msg is useful to any client, instead the total UNSEEN count

History: The original idea in IMAP was that the client might show the
user a message list starting at the first (oldest) unseen message and
continuing to newer messages.  Suppose the mailbox has 9,000 messages
and message 8,548 is the first unseen one.  The client might then
fetch information only about messages 8548 to 9000 (perhaps in batches
of 50 or 100).

Whether or not your client (or any you can imagine) might do it that
way, that was the design point.

The way to get the list of unseen messages is to use SEARCH UNSEEN
after SELECT.  There are also extensions to SEARCH (see RFC 4731) that
let you get just the COUNT if you don't want the list.

> 2. During idle updates :

If, when you SELECT the mailbox, you do SEARCH UNSEEN and keep track
of which messages are unseen (updating it as your client views the
messages and as you see FLAGS updates from the server), you will
always know which are UNSEEN.  Caching information about the messages
in the selected mailbox is key to an IMAP client's success.

Barry

---

From: allam sureshkumar <[email-masked]>
Date: Mon, 14 Mar 2011 13:28:36 +0530

[email-masked]

On Mon, Mar 14, 2011 at 1:23 PM, allam sureshkumar <
[email-masked]> wrote:

> Hi ,
>
> Firstly, thank you for your valuable suggestions.
>
>  SEARCH UNSEEN i think is a good idea , but the problem is
>     1. Gmail  does not update the client about the FETCH FLAG updates.
> (Gmail's IDLE, updates only about new mails and expunges)
>     2. ESEARCH capability is not being advertised by Gmail.
>
> (AOL supports above two features, but most people use GMAIL :-( ).
>
> Considering the above two problems ,
> What do you think is a better way to get UNSEEN count.
> a. SEARCH UNSEEN and then count all the messages in response to get total
> UNSEEN
>           (or)
> b. send STATUS command
>
>
> If we assume that gmail supports ESEARCH in future, in this case what do u
> think is a better way to get UNSEEN count
> a. SEARCH RETURN (COUNT) UNSEEN
>         (or)
> b. send STATUS command.
>
> (or is there any alternative way (apart from the above two) to get UNSEEN
> count)
>
> (Note: We cache the message header information of the messages when the
> user scrolls down to view older messages, but
>  we don't cache *all* the UNSEEN uids because, we will have an overhead of
> keeping these unseen uids updated for any change from client or from
> server).
>
>
> Thanks and Regards,
> Suresh Kumar.
>
> On Wed, Mar 9, 2011 at 10:29 PM, Barry Leiba <[email-masked]>wrote:
>