dovecot-2.2: dbox: Added support for POP3 message order.
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 26 19:14:44 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/8ee242b6e417
changeset: 16394:8ee242b6e417
user: Timo Sirainen <tss at iki.fi>
date: Sun May 26 19:14:21 2013 +0300
description:
dbox: Added support for POP3 message order.
diffstat:
src/doveadm/doveadm-dump-dbox.c | 3 +++
src/lib-storage/index/dbox-common/dbox-file.h | 2 ++
src/lib-storage/index/dbox-common/dbox-mail.c | 23 ++++++++++++++++++++---
src/lib-storage/index/dbox-common/dbox-save.c | 4 ++++
src/lib-storage/index/index-mail.c | 5 +++++
src/lib-storage/index/index-mail.h | 1 +
6 files changed, 35 insertions(+), 3 deletions(-)
diffs (124 lines):
diff -r b9a312951881 -r 8ee242b6e417 src/doveadm/doveadm-dump-dbox.c
--- a/src/doveadm/doveadm-dump-dbox.c Sun May 26 19:04:00 2013 +0300
+++ b/src/doveadm/doveadm-dump-dbox.c Sun May 26 19:14:21 2013 +0300
@@ -148,6 +148,9 @@
case DBOX_METADATA_POP3_UIDL:
printf("msg.pop3-uidl = %s\n", line + 1);
break;
+ case DBOX_METADATA_POP3_ORDER:
+ printf("msg.pop3-order = %s\n", line + 1);
+ break;
case DBOX_METADATA_RECEIVED_TIME:
dump_timestamp(input, "msg.received", line + 1);
break;
diff -r b9a312951881 -r 8ee242b6e417 src/lib-storage/index/dbox-common/dbox-file.h
--- a/src/lib-storage/index/dbox-common/dbox-file.h Sun May 26 19:04:00 2013 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-file.h Sun May 26 19:14:21 2013 +0300
@@ -45,6 +45,8 @@
DBOX_METADATA_GUID = 'G',
/* POP3 UIDL overriding the default format */
DBOX_METADATA_POP3_UIDL = 'P',
+ /* POP3 message ordering (for migrated mails) */
+ DBOX_METADATA_POP3_ORDER = 'O',
/* Received UNIX timestamp in hex */
DBOX_METADATA_RECEIVED_TIME = 'R',
/* Physical message size in hex. Necessary only if it differs from
diff -r b9a312951881 -r 8ee242b6e417 src/lib-storage/index/dbox-common/dbox-mail.c
--- a/src/lib-storage/index/dbox-common/dbox-mail.c Sun May 26 19:04:00 2013 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-mail.c Sun May 26 19:14:21 2013 +0300
@@ -165,12 +165,19 @@
INDEX_STORAGE_CONTEXT(imail->mail.mail.box);
const char *value;
string_t *str;
+ uint32_t order;
str = str_new(imail->mail.data_pool, 64);
if (mail_cache_lookup_field(imail->mail.mail.transaction->cache_view,
str, imail->mail.mail.seq,
ibox->cache_fields[cache_field].idx) > 0) {
- *value_r = str_c(str);
+ if (cache_field != MAIL_CACHE_POP3_ORDER)
+ *value_r = str_c(str);
+ else {
+ i_assert(str_len(str) == sizeof(order));
+ memcpy(&order, str_data(str), sizeof(order));
+ *value_r = dec2str(order);
+ }
return 0;
}
@@ -179,8 +186,15 @@
if (value == NULL)
value = "";
- index_mail_cache_add_idx(imail, ibox->cache_fields[cache_field].idx,
- value, strlen(value)+1);
+ if (cache_field != MAIL_CACHE_POP3_ORDER) {
+ index_mail_cache_add_idx(imail, ibox->cache_fields[cache_field].idx,
+ value, strlen(value)+1);
+ } else {
+ if (str_to_uint(value, &order) < 0)
+ order = 0;
+ index_mail_cache_add_idx(imail, ibox->cache_fields[cache_field].idx,
+ &order, sizeof(order));
+ }
/* don't return pointer to dbox metadata directly, since it may
change unexpectedly */
@@ -202,6 +216,9 @@
case MAIL_FETCH_UIDL_BACKEND:
return dbox_get_cached_metadata(mail, DBOX_METADATA_POP3_UIDL,
MAIL_CACHE_POP3_UIDL, value_r);
+ case MAIL_FETCH_POP3_ORDER:
+ return dbox_get_cached_metadata(mail, DBOX_METADATA_POP3_ORDER,
+ MAIL_CACHE_POP3_ORDER, value_r);
case MAIL_FETCH_GUID:
return dbox_get_cached_metadata(mail, DBOX_METADATA_GUID,
MAIL_CACHE_GUID, value_r);
diff -r b9a312951881 -r 8ee242b6e417 src/lib-storage/index/dbox-common/dbox-save.c
--- a/src/lib-storage/index/dbox-common/dbox-save.c Sun May 26 19:04:00 2013 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-save.c Sun May 26 19:14:21 2013 +0300
@@ -164,6 +164,10 @@
str_printfa(str, "%c%s\n", DBOX_METADATA_POP3_UIDL,
mdata->pop3_uidl);
}
+ if (mdata->pop3_order != 0) {
+ str_printfa(str, "%c%u\n", DBOX_METADATA_POP3_ORDER,
+ mdata->pop3_order);
+ }
guid = mdata->guid;
if (guid != NULL)
diff -r b9a312951881 -r 8ee242b6e417 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Sun May 26 19:04:00 2013 +0300
+++ b/src/lib-storage/index/index-mail.c Sun May 26 19:14:21 2013 +0300
@@ -46,6 +46,9 @@
.type = MAIL_CACHE_FIELD_STRING },
{ .name = "pop3.uidl",
.type = MAIL_CACHE_FIELD_STRING },
+ { .name = "pop3.order",
+ .type = MAIL_CACHE_FIELD_FIXED_SIZE,
+ .field_size = sizeof(uint32_t) },
{ .name = "guid",
.type = MAIL_CACHE_FIELD_STRING },
{ .name = "mime.parts",
@@ -1871,6 +1874,8 @@
(void)mail_get_physical_size(mail, &size);
if ((cache & MAIL_FETCH_UIDL_BACKEND) != 0)
(void)mail_get_special(mail, MAIL_FETCH_UIDL_BACKEND, &str);
+ if ((cache & MAIL_FETCH_POP3_ORDER) != 0)
+ (void)mail_get_special(mail, MAIL_FETCH_POP3_ORDER, &str);
if ((cache & MAIL_FETCH_GUID) != 0)
(void)mail_get_special(mail, MAIL_FETCH_GUID, &str);
}
diff -r b9a312951881 -r 8ee242b6e417 src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h Sun May 26 19:04:00 2013 +0300
+++ b/src/lib-storage/index/index-mail.h Sun May 26 19:14:21 2013 +0300
@@ -19,6 +19,7 @@
MAIL_CACHE_IMAP_BODYSTRUCTURE,
MAIL_CACHE_IMAP_ENVELOPE,
MAIL_CACHE_POP3_UIDL,
+ MAIL_CACHE_POP3_ORDER,
MAIL_CACHE_GUID,
MAIL_CACHE_MESSAGE_PARTS,
MAIL_CACHE_BINARY_PARTS,
More information about the dovecot-cvs
mailing list