changeset 2996:9219e788d774 HEAD

Added %f pop3_uidl_format for maildir. Patch by Andrey Panin.
author Timo Sirainen <tss@iki.fi>
date Sun, 19 Dec 2004 08:36:12 +0200
parents de524f4a1075
children c64674a0a92a
files dovecot-example.conf src/lib-storage/index/index-mail.c src/lib-storage/index/maildir/maildir-mail.c src/lib-storage/mail-storage.h src/pop3/commands.c src/pop3/common.h src/pop3/main.c
diffstat 7 files changed, 34 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dovecot-example.conf	Sun Dec 19 07:49:26 2004 +0200
+++ b/dovecot-example.conf	Sun Dec 19 08:36:12 2004 +0200
@@ -450,10 +450,11 @@
   #  %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
--- a/src/lib-storage/index/index-mail.c	Sun Dec 19 07:49:26 2004 +0200
+++ b/src/lib-storage/index/index-mail.c	Sun Dec 19 08:36:12 2004 +0200
@@ -580,6 +580,7 @@
 			index_mail_headers_get_envelope(mail);
 		return data->envelope;
 	case MAIL_FETCH_FROM_ENVELOPE:
+	case MAIL_FETCH_UIDL_FILE_NAME:
 		return NULL;
 	case MAIL_FETCH_HEADER_MD5:
 		if (mail_index_lookup_ext(mail->trans->trans_view, data->seq,
--- a/src/lib-storage/index/maildir/maildir-mail.c	Sun Dec 19 07:49:26 2004 +0200
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Sun Dec 19 08:36:12 2004 +0200
@@ -145,6 +145,23 @@
 	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;
+	const char *fname, *end;
+
+	if (field == MAIL_FETCH_UIDL_FILE_NAME) {
+	    	fname = maildir_uidlist_lookup(mail->ibox->uidlist,
+					       mail->mail.uid, &flags);
+		end = strchr(fname, ':');
+		return end == NULL ? fname : t_strdup_until(fname, end);
+	}
+
+	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 +240,7 @@
 	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
 };
--- a/src/lib-storage/mail-storage.h	Sun Dec 19 07:49:26 2004 +0200
+++ b/src/lib-storage/mail-storage.h	Sun Dec 19 08:36:12 2004 +0200
@@ -83,7 +83,8 @@
 	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_UIDL_FILE_NAME	= 0x00020000
 };
 
 enum mailbox_sync_flags {
--- a/src/pop3/commands.c	Sun Dec 19 07:49:26 2004 +0200
+++ b/src/pop3/commands.c	Sun Dec 19 08:36:12 2004 +0200
@@ -483,6 +483,7 @@
 		{ 'v', NULL },
 		{ 'u', NULL },
 		{ 'm', NULL },
+		{ 'f', NULL },
 		{ '\0', NULL }
 	};
 	struct var_expand_table *tab;
@@ -512,6 +513,11 @@
 			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_UIDL_FILE_NAME);
+		}
 
 		str_truncate(str, 0);
 		str_printfa(str, ctx->message == 0 ? "%u " : "+OK %u ",
--- a/src/pop3/common.h	Sun Dec 19 07:49:26 2004 +0200
+++ b/src/pop3/common.h	Sun Dec 19 08:36:12 2004 +0200
@@ -12,7 +12,8 @@
 enum uidl_keys {
 	UIDL_UIDVALIDITY	= 0x01,
 	UIDL_UID		= 0x02,
-	UIDL_MD5		= 0x04
+	UIDL_MD5		= 0x04,
+	UIDL_FILE_NAME		= 0x08
 };
 
 extern struct ioloop *ioloop;
--- a/src/pop3/main.c	Sun Dec 19 07:49:26 2004 +0200
+++ b/src/pop3/main.c	Sun Dec 19 08:36:12 2004 +0200
@@ -87,6 +87,9 @@
 			case 'm':
 				mask |= UIDL_MD5;
 				break;
+			case 'f':
+				mask |= UIDL_FILE_NAME;
+				break;
 			}
 		}
 	}