dovecot-2.0: lib-storage: Added MAIL_FETCH_POP3_ORDER special fi...

dovecot at dovecot.org dovecot at dovecot.org
Wed May 4 12:44:27 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/bf0a80c91536
changeset: 12766:bf0a80c91536
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 04 11:42:17 2011 +0200
description:
lib-storage: Added MAIL_FETCH_POP3_ORDER special field and implemented for Maildir.
The idea is that this specifies the order of messages when accessing via
POP3. This is useful when migrating both POP3 and IMAP users from servers
where their message ordering differes and they still want to be preserved.

diffstat:

 src/lib-storage/index/index-mail.c              |   1 +
 src/lib-storage/index/maildir/maildir-mail.c    |  11 ++++++++++-
 src/lib-storage/index/maildir/maildir-uidlist.h |   5 +++++
 src/lib-storage/mail-storage.h                  |   3 ++-
 4 files changed, 18 insertions(+), 2 deletions(-)

diffs (67 lines):

diff -r 869795a295b5 -r bf0a80c91536 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Wed May 04 10:17:27 2011 +0200
+++ b/src/lib-storage/index/index-mail.c	Wed May 04 11:42:17 2011 +0200
@@ -1076,6 +1076,7 @@
 	case MAIL_FETCH_SEARCH_SCORE:
 	case MAIL_FETCH_GUID:
 	case MAIL_FETCH_HEADER_MD5:
+	case MAIL_FETCH_POP3_ORDER:
 		*value_r = "";
 		return 0;
 	case MAIL_FETCH_MAILBOX_NAME:
diff -r 869795a295b5 -r bf0a80c91536 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c	Wed May 04 10:17:27 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Wed May 04 11:42:17 2011 +0200
@@ -471,7 +471,7 @@
 {
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
-	const char *path, *fname = NULL, *end, *guid, *uidl;
+	const char *path, *fname = NULL, *end, *guid, *uidl, *order;
 
 	switch (field) {
 	case MAIL_FETCH_GUID:
@@ -536,6 +536,15 @@
 			*value_r = p_strdup(mail->data_pool, uidl);
 		}
 		return 0;
+	case MAIL_FETCH_POP3_ORDER:
+		order = maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid,
+					MAILDIR_UIDLIST_REC_EXT_POP3_ORDER);
+		if (order == NULL) {
+			*value_r = "";
+		} else {
+			*value_r = p_strdup(mail->data_pool, order);
+		}
+		return 0;
 	default:
 		return index_mail_get_special(_mail, field, value_r);
 	}
diff -r 869795a295b5 -r bf0a80c91536 src/lib-storage/index/maildir/maildir-uidlist.h
--- a/src/lib-storage/index/maildir/maildir-uidlist.h	Wed May 04 10:17:27 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.h	Wed May 04 11:42:17 2011 +0200
@@ -48,6 +48,11 @@
 	MAILDIR_UIDLIST_REC_EXT_VSIZE		= 'W',
 	/* POP3 UIDL overriding the default format */
 	MAILDIR_UIDLIST_REC_EXT_POP3_UIDL	= 'P',
+	/* POP3 message ordering number. Lower numbered messages are listed
+	   first. Messages without ordering number are listed after them.
+	   The idea is to be able to preserve POP3 UIDL list and IMAP UIDs
+	   perfectly when migrating from other servers. */
+	MAILDIR_UIDLIST_REC_EXT_POP3_ORDER	= 'O',
 	/* Message GUID (default is the base filename) */
 	MAILDIR_UIDLIST_REC_EXT_GUID		= 'G'
 };
diff -r 869795a295b5 -r bf0a80c91536 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h	Wed May 04 10:17:27 2011 +0200
+++ b/src/lib-storage/mail-storage.h	Wed May 04 11:42:17 2011 +0200
@@ -125,7 +125,8 @@
 	MAIL_FETCH_UIDL_BACKEND		= 0x00040000,
 	MAIL_FETCH_MAILBOX_NAME		= 0x00080000,
 	MAIL_FETCH_SEARCH_SCORE		= 0x00100000,
-	MAIL_FETCH_GUID			= 0x00200000
+	MAIL_FETCH_GUID			= 0x00200000,
+	MAIL_FETCH_POP3_ORDER		= 0x00400000
 };
 
 enum mailbox_transaction_flags {


More information about the dovecot-cvs mailing list