[Dovecot] 1.0-test58

Andrey Panin pazke at donpac.ru
Sat Dec 18 12:56:08 EET 2004


On 352, 12 17, 2004 at 03:55:30PM +0200, Timo Sirainen wrote:
> On Fri, 2004-12-17 at 14:16 +0300, Andrey Panin wrote:
> > On 351, 12 16, 2004 at 03:58:16AM +0200, Timo Sirainen wrote:
> > >
> > - Added pop3_uidl_format setting. No need to patch sources anymore if 
> > > you don't want the default.
> > 
> > Attached small patch adds Courier 0.x UIDL compatibiliy code.
> 
> There is one problem. It may return the ":2,flags" part as well which
> isn't wanted in UIDL. It might be useful for things like implementing
> Maildir++ quota in a plugin though..

Forgot about that.

> POP3 code shouldn't either assume that ':' and everything after it
> should be removed. Hmm. Perhaps just use a different name than
> MAIL_FETCH_FILE_NAME. But there's not much point in having a
> maildir-specific MAIL_FETCH_BASE_FILE_NAME either. Maybe
> MAIL_FETCH_SPECIAL_UIDL?

I vote for MAIL_FETCH_SPECIAL_UIDL. Does attached patch looks better ?

> All solutions I can think of just feel dirty :)

Backward compatibility, ughhm :)

-- 
Andrey Panin		| Linux and UNIX system administrator
pazke at donpac.ru		| PGP key: wwwkeys.pgp.net
-------------- next part --------------
diff -urdpNX /usr/share/dontdiff -x debian -x lib-otp dovecot-1.0-test58.vanilla/dovecot-example.conf dovecot-1.0-test58/dovecot-example.conf
--- dovecot-1.0-test58.vanilla/dovecot-example.conf	2004-12-15 23:04:08.000000000 +0300
+++ dovecot-1.0-test58/dovecot-example.conf	2004-12-17 13:53:48.000000000 +0300
@@ -450,10 +450,11 @@ protocol pop3 {
   #  %v - Mailbox UIDVALIDITY
   #  %u - Mail UID
   #  %m - MD5 sum of the mailbox headers in hex (mbox only)
+  #  %f - filename (maildir only)
   #
   # If you want UIDL compatibility with other POP3 servers, use:
   #  UW's ipop3d         : %08Xv%08Xu
-  #  Courier version 0   : (maildir filename, not supported)
+  #  Courier version 0   : %f
   #  Courier version 1   : %u
   #  Courier version 2   : %v-%u
   #  Cyrus (old)         : %u
diff -urdpNX /usr/share/dontdiff -x debian -x lib-otp dovecot-1.0-test58.vanilla/src/lib-storage/index/index-mail.c dovecot-1.0-test58/src/lib-storage/index/index-mail.c
--- dovecot-1.0-test58.vanilla/src/lib-storage/index/index-mail.c	2004-12-15 22:57:00.000000000 +0300
+++ dovecot-1.0-test58/src/lib-storage/index/index-mail.c	2004-12-18 13:27:32.000000000 +0300
@@ -580,6 +580,8 @@ const char *index_mail_get_special(struc
 			index_mail_headers_get_envelope(mail);
 		return data->envelope;
 	case MAIL_FETCH_FROM_ENVELOPE:
+	case MAIL_FETCH_FILE_NAME:
+	case MAIL_FETCH_SPECIAL_UIDL:
 		return NULL;
 	case MAIL_FETCH_HEADER_MD5:
 		if (mail_index_lookup_ext(mail->trans->trans_view, data->seq,
diff -urdpNX /usr/share/dontdiff -x debian -x lib-otp dovecot-1.0-test58.vanilla/src/lib-storage/index/maildir/maildir-mail.c dovecot-1.0-test58/src/lib-storage/index/maildir/maildir-mail.c
--- dovecot-1.0-test58.vanilla/src/lib-storage/index/maildir/maildir-mail.c	2004-08-28 14:23:35.000000000 +0400
+++ dovecot-1.0-test58/src/lib-storage/index/maildir/maildir-mail.c	2004-12-18 13:26:00.000000000 +0300
@@ -145,6 +145,29 @@ static uoff_t maildir_mail_get_virtual_s
 	return index_mail_get_virtual_size(_mail);
 }
 
+static const char *
+maildir_mail_get_special(struct mail *_mail, enum mail_fetch_field field)
+{
+	struct index_mail *mail = (struct index_mail *)_mail;
+	enum maildir_uidlist_rec_flag flags;
+
+	if (field == MAIL_FETCH_FILE_NAME ||
+	    field == MAIL_FETCH_SPECIAL_UIDL) {
+	    	const char *fname = maildir_uidlist_lookup(mail->ibox->uidlist,
+							   mail->mail.uid, &flags);
+		if (field == MAIL_FETCH_SPECIAL_UIDL) {
+			char *end = strstr(fname, ":2,");
+
+			if (end != NULL)
+				return t_strdup_until(fname, end);
+		}
+
+		return fname;
+	}
+
+	return index_mail_get_special(_mail, field);
+}
+							
 static uoff_t maildir_mail_get_physical_size(struct mail *_mail)
 {
 	struct index_mail *mail = (struct index_mail *)_mail;
@@ -223,7 +246,7 @@ struct mail maildir_mail = {
 	index_mail_get_header,
 	index_mail_get_headers,
 	maildir_mail_get_stream,
-	index_mail_get_special,
+	maildir_mail_get_special,
 	index_mail_update_flags,
 	index_mail_expunge
 };
diff -urdpNX /usr/share/dontdiff -x debian -x lib-otp dovecot-1.0-test58.vanilla/src/lib-storage/mail-storage.h dovecot-1.0-test58/src/lib-storage/mail-storage.h
--- dovecot-1.0-test58.vanilla/src/lib-storage/mail-storage.h	2004-12-15 22:54:45.000000000 +0300
+++ dovecot-1.0-test58/src/lib-storage/mail-storage.h	2004-12-18 13:25:01.000000000 +0300
@@ -83,7 +83,9 @@ enum mail_fetch_field {
 	MAIL_FETCH_IMAP_BODYSTRUCTURE	= 0x00002000,
 	MAIL_FETCH_IMAP_ENVELOPE	= 0x00004000,
 	MAIL_FETCH_FROM_ENVELOPE	= 0x00008000,
-	MAIL_FETCH_HEADER_MD5		= 0x00010000
+	MAIL_FETCH_HEADER_MD5		= 0x00010000,
+	MAIL_FETCH_FILE_NAME		= 0x00020000,
+	MAIL_FETCH_SPECIAL_UIDL		= 0x00040000
 };
 
 enum mailbox_sync_flags {
diff -urdpNX /usr/share/dontdiff -x debian -x lib-otp dovecot-1.0-test58.vanilla/src/pop3/commands.c dovecot-1.0-test58/src/pop3/commands.c
--- dovecot-1.0-test58.vanilla/src/pop3/commands.c	2004-12-15 22:50:26.000000000 +0300
+++ dovecot-1.0-test58/src/pop3/commands.c	2004-12-18 13:48:16.000000000 +0300
@@ -483,6 +483,7 @@ static int list_uids_iter(struct client 
 		{ 'v', NULL },
 		{ 'u', NULL },
 		{ 'm', NULL },
+		{ 'f', NULL },
 		{ '\0', NULL }
 	};
 	struct var_expand_table *tab;
@@ -512,6 +513,10 @@ static int list_uids_iter(struct client 
 			tab[2].value =
 				mail->get_special(mail, MAIL_FETCH_HEADER_MD5);
 		}
+		if ((uidl_keymask & UIDL_FILE_NAME) != 0) {
+			tab[3].value =
+				mail->get_special(mail, MAIL_FETCH_SPECIAL_UIDL);
+		}
 
 		str_truncate(str, 0);
 		str_printfa(str, ctx->message == 0 ? "%u " : "+OK %u ",
diff -urdpNX /usr/share/dontdiff -x debian -x lib-otp dovecot-1.0-test58.vanilla/src/pop3/common.h dovecot-1.0-test58/src/pop3/common.h
--- dovecot-1.0-test58.vanilla/src/pop3/common.h	2004-12-15 22:37:45.000000000 +0300
+++ dovecot-1.0-test58/src/pop3/common.h	2004-12-17 13:35:59.000000000 +0300
@@ -12,7 +12,8 @@ enum client_workarounds {
 enum uidl_keys {
 	UIDL_UIDVALIDITY	= 0x01,
 	UIDL_UID		= 0x02,
-	UIDL_MD5		= 0x04
+	UIDL_MD5		= 0x04,
+	UIDL_FILE_NAME		= 0x08
 };
 
 extern struct ioloop *ioloop;
diff -urdpNX /usr/share/dontdiff -x debian -x lib-otp dovecot-1.0-test58.vanilla/src/pop3/main.c dovecot-1.0-test58/src/pop3/main.c
--- dovecot-1.0-test58.vanilla/src/pop3/main.c	2004-12-15 22:52:30.000000000 +0300
+++ dovecot-1.0-test58/src/pop3/main.c	2004-12-17 13:35:38.000000000 +0300
@@ -87,6 +87,9 @@ static enum uidl_keys parse_uidl_keymask
 			case 'm':
 				mask |= UIDL_MD5;
 				break;
+			case 'f':
+				mask |= UIDL_FILE_NAME;
+				break;
 			}
 		}
 	}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://dovecot.org/pipermail/dovecot/attachments/20041218/6cbc1254/attachment-0001.bin>


More information about the dovecot mailing list