]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added MAIL_FETCH_POP3_ORDER special field and implemented for Maildir.
authorTimo Sirainen <tss@iki.fi>
Wed, 4 May 2011 09:42:17 +0000 (11:42 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 4 May 2011 09:42:17 +0000 (11:42 +0200)
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.

src/lib-storage/index/index-mail.c
src/lib-storage/index/maildir/maildir-mail.c
src/lib-storage/index/maildir/maildir-uidlist.h
src/lib-storage/mail-storage.h

index efb4528c9b5aaadddd9989fe625266b0edf9b04b..5bb1ef2d9aa49768b040c51671dd58efb6924455 100644 (file)
@@ -1076,6 +1076,7 @@ int index_mail_get_special(struct mail *_mail,
        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:
index 492561ab321a8ce605e0ec4cd181666cf4422be7..8837cea675d453b0725e92e4fd41728c6d6910cf 100644 (file)
@@ -471,7 +471,7 @@ maildir_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
 {
        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 @@ maildir_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
                        *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);
        }
index f81400f5a660f4596febd2db79e684d4fc4804e3..9eb738917f1593cc8f81633d45daaebc735664cc 100644 (file)
@@ -48,6 +48,11 @@ enum maildir_uidlist_rec_ext_key {
        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'
 };
index 3b383fe99a45dcec22ea5bb405b0c69f7e51df70..a410c03ceef654c97cb776fec0d9d65278c39a41 100644 (file)
@@ -125,7 +125,8 @@ enum mail_fetch_field {
        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 {