[Dovecot] qpopper UIDLs and migrating to dovecot/maildir
Chris Wakelin
c.d.wakelin at reading.ac.uk
Mon Sep 5 12:36:43 EEST 2005
OK, here's the patch against dovecot-1.0-stable. (I just applied it to
dovecot-stable-20050901. My version of stable has a few more patches
applied, so I needed to apply the patch to a clean version!)
Best Wishes,
Chris
grant beattie wrote:
> On Sun, Sep 04, 2005 at 12:30:27AM +0100, Chris Wakelin wrote:
>
>
>>Right! Here's a patch against dovecot-1.0.alpha1 which adds an extra option:
>>
>>pop3_reuse_xuidl = yes
>>
>>which if set will use the contents of the (first) X-UIDL header, if it
>>exists, instead of the result of expanding pop3_uidl_format. It will use
>>pop3_uidl_format if there is no X-UIDL header.
>>
>>This is typically for people migrating from Qpopper who don't want their
>>users to get all the mail they've left on the server a second time, but
>>should also work for any other POP server that happens to write X-UIDL
>>headers, if any such exist ;)
>>
>>I've only done rudimentary testing, but it seems to work! I also have a
>>version of the patch for dovecot-1.0-stable (which is what we'll be
>>using next week!) if anybody's interested (only minor differences, use
>>'mail->get_header(mail, "X-UIDL")' instead of
>>'mail_get_first_header(ctx->mail, "X-UIDL")')
>
>
> this is great stuff, thanks!
>
> I'm using the 1.0alpha1 diff and it seems to be working fine so far.
> as we will probably be running 1.0 stable in production, would you
> mind forwarding me the diff against 1.0 stable?
>
> this is an extremely useful feature, making it even easier to migrate
> from alternate POP3 servers than Dovecot already is. :)
>
> grant.
>
--
--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
Christopher Wakelin, c.d.wakelin at reading.ac.uk
IT Services Centre, The University of Reading, Tel: +44 (0)118 378 8439
Whiteknights, Reading, RG6 2AF, UK Fax: +44 (0)118 975 3094
-------------- next part --------------
diff -ruN dovecot-1.0-stable.orig/src/master/mail-process.c dovecot-1.0-stable/src/master/mail-process.c
--- dovecot-1.0-stable.orig/src/master/mail-process.c Tue Feb 8 10:30:11 2005
+++ dovecot-1.0-stable/src/master/mail-process.c Mon Sep 5 10:29:22 2005
@@ -220,6 +220,8 @@
env_put("FULL_FILESYSTEM_ACCESS=1");
if (set->pop3_no_flag_updates)
env_put("POP3_NO_FLAG_UPDATES=1");
+ if (set->pop3_reuse_xuidl)
+ env_put("POP3_REUSE_XUIDL=1");
if (set->mbox_dirty_syncs)
env_put("MBOX_DIRTY_SYNCS=1");
if (set->mbox_very_dirty_syncs)
diff -ruN dovecot-1.0-stable.orig/src/master/master-settings.c dovecot-1.0-stable/src/master/master-settings.c
--- dovecot-1.0-stable.orig/src/master/master-settings.c Sun Aug 7 14:00:41 2005
+++ dovecot-1.0-stable/src/master/master-settings.c Mon Sep 5 10:29:22 2005
@@ -125,6 +125,7 @@
/* pop3 */
DEF(SET_BOOL, pop3_no_flag_updates),
DEF(SET_BOOL, pop3_enable_last),
+ DEF(SET_BOOL, pop3_reuse_xuidl),
DEF(SET_STR, pop3_uidl_format),
DEF(SET_STR, pop3_client_workarounds),
@@ -297,6 +298,7 @@
/* pop3 */
MEMBER(pop3_no_flag_updates) FALSE,
MEMBER(pop3_enable_last) FALSE,
+ MEMBER(pop3_reuse_xuidl) FALSE,
MEMBER(pop3_uidl_format) "%v.%u",
MEMBER(pop3_client_workarounds) NULL,
diff -ruN dovecot-1.0-stable.orig/src/master/master-settings.h dovecot-1.0-stable/src/master/master-settings.h
--- dovecot-1.0-stable.orig/src/master/master-settings.h Mon Jan 31 16:37:55 2005
+++ dovecot-1.0-stable/src/master/master-settings.h Mon Sep 5 10:29:22 2005
@@ -96,6 +96,7 @@
/* pop3 */
int pop3_no_flag_updates;
int pop3_enable_last;
+ int pop3_reuse_xuidl;
const char *pop3_uidl_format;
const char *pop3_client_workarounds;
diff -ruN dovecot-1.0-stable.orig/src/pop3/commands.c dovecot-1.0-stable/src/pop3/commands.c
--- dovecot-1.0-stable.orig/src/pop3/commands.c Sun May 8 10:45:32 2005
+++ dovecot-1.0-stable/src/pop3/commands.c Mon Sep 5 10:29:22 2005
@@ -489,6 +489,7 @@
struct var_expand_table *tab;
struct mail *mail;
string_t *str;
+ const char *xuidl;
int ret, found = FALSE;
tab = t_malloc(sizeof(static_tab));
@@ -532,7 +533,15 @@
str_truncate(str, 0);
str_printfa(str, ctx->message == 0 ? "%u " : "+OK %u ",
mail->seq);
- var_expand(str, uidl_format, tab);
+ if (reuse_xuidl) {
+ xuidl=mail->get_header(mail, "X-UIDL");
+ if (xuidl != NULL)
+ str_append(str, xuidl);
+ else
+ var_expand(str, uidl_format, tab);
+ }
+ else
+ var_expand(str, uidl_format, tab);
ret = client_send_line(client, "%s", str_c(str));
t_pop();
diff -ruN dovecot-1.0-stable.orig/src/pop3/common.h dovecot-1.0-stable/src/pop3/common.h
--- dovecot-1.0-stable.orig/src/pop3/common.h Mon Jan 31 16:37:55 2005
+++ dovecot-1.0-stable/src/pop3/common.h Mon Sep 5 10:29:22 2005
@@ -18,7 +18,7 @@
extern struct ioloop *ioloop;
extern enum client_workarounds client_workarounds;
-extern int enable_last_command, no_flag_updates;
+extern int enable_last_command, no_flag_updates, reuse_xuidl;
extern const char *uidl_format;
extern enum uidl_keys uidl_keymask;
diff -ruN dovecot-1.0-stable.orig/src/pop3/main.c dovecot-1.0-stable/src/pop3/main.c
--- dovecot-1.0-stable.orig/src/pop3/main.c Mon Jan 31 16:37:55 2005
+++ dovecot-1.0-stable/src/pop3/main.c Mon Sep 5 10:29:22 2005
@@ -41,6 +41,7 @@
enum client_workarounds client_workarounds = 0;
int enable_last_command = FALSE;
int no_flag_updates = FALSE;
+int reuse_xuidl = FALSE;
const char *uidl_format;
enum uidl_keys uidl_keymask;
@@ -166,6 +167,7 @@
parse_workarounds();
enable_last_command = getenv("POP3_ENABLE_LAST") != NULL;
no_flag_updates = getenv("POP3_NO_FLAG_UPDATES") != NULL;
+ reuse_xuidl = getenv("POP3_REUSE_XUIDL") != NULL;
uidl_format = getenv("POP3_UIDL_FORMAT");
if (uidl_format == NULL)
More information about the dovecot
mailing list