I agree that POP3 UIDs are not very efficient. Unlike IMAP, there is no
requirement that UIDs be numeric, much less strictly ascending.
The only thing that I can suggest to make POP3 UIDs work better than
fetching the entire map would be to cache UIDs from a previous session and
send UIDL with an message number value (instead of a NIL for the third
argument to pop3_send()). Take the number of messages that you get with
an open, and then do a binary division of the space until you find the
highest message number that has a UID that you had previously cached.
Assuming that the server does not do any sort of reordering of messages,
you could then presume that all messages with a lower POP3 message number
are "old" and all messages with a higher POP3 message number are "new".
Similar binary divisions may help in identifying deleted messages short of
fetching the entire map.
That's a pretty big assumption, but that's the best you can do with POP3.
Beware of too many RTTs. A binary division with 1000 messages can be as
many as 10 operations. Worse, if you have many new messages, you have to
do a separate UIDL command to get the UID for each new message if you wish
to avoid fetching the entire UID map.
That's the way it is in POP3.
IMAP UIDs are numeric and strictly ascending, so there are several
mathematical properties in the UID to message number relationship that you
can exploit in IMAP. IMAP also allows you to fetch UID and message number
ranges (POP3 only allows single message or complete map), which gives you
much better options for excessive RTT avoidance.
On Thu, 28 Feb 2008, Dister Kemp wrote:
Thanks Mark for your help. Sorry about my late reply, but was trying this
method and it did work.
My query on related lines (though not c-client related per se), is:
I find this technique of UID matching a bit arcane for POP
as in the case of a mailbox with 1000s of messages this process
of matching UIDs is a performance overhead. I was wondering
how this is done efficiently(if at all) by the other email clients out
there.
Appreciate your help again.
Dister
On Thu, Feb 21, 2008 at 7:10 AM, Mark Crispin <[EMAIL PROTECTED]> wrote:
POP3 UIDs (UIDL command) are not directly supported by c-client. You
would have to write your own routine that sends a UIDL command to the POP3
server and stores the returned UID strings someplace. For example, you
might add code that does something like this after the mail_exists() call
in pop3_open() in file pop3.c:
unsigned long msgno;
char *s,*uid,*r;
/* send UIDL command */
if (pop3_send (stream,"UIDL",NIL)
/* parse replies until "." line */
while ((s = net_getline (LOCAL->netstream) && strcmp (s,".") &&
(msgno = strtoul (s,&uid,10)) && uid &&
(uid = strtok_r (uid," ",&r))) {
stash_uid (msgno,uid); /* stash the returned UID */
fs_give ((void **) &s); /* return the line to free storage */
}
/* return any final line to free storage */
if (s) fs_give ((void **) &s);
Then write a stash_uid() routine that does whatever.
On Wed, 20 Feb 2008, Dister Kemp wrote:
Hello,
I am presently working on an email client on top of UW c-client.
I am trying to bring in leave mails on server feature as in many other
clients.
My interest lies in knowing if c-client supports POP UIDs and if so
where and how to manage these with c-client API.
I would also like to add in my thanks to the people behind this effort
(Mark Crispin and team) for providing this API which has been quite
a breeze to import till now.
Thanks
Dister
-- Mark --
http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.
-- Mark --
http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
_______________________________________________
Imap-uw mailing list
[email protected]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw