[Dovecot] [PATCH] Re: Do not update status on imap connections

Adrian Reber adrian at lisas.de
Thu Dec 11 10:24:13 EET 2008


On Wed, Dec 10, 2008 at 08:28:20PM +0100, Adrian Reber wrote:
> Does an option like "pop3_no_flag_updates = yes" also exist for imap?
> Is it maybe planned? Or should I just provide a patch?

Attached is a patch which adds the config option "imap_no_flag_updates".

The reason I am interested in this feature is that I do not want
"Status: O" added to all my new mails by the IMAP server, because if I
access the mailbox directly all my new mails are "Old" and I would like
them to stay "New".

In the patch I just copied all the parts "pop3_no_flag_updates" touches
to the corresponding imap parts. I hope I have not messed it up too much.

		Adrian
-------------- next part --------------
diff --git a/src/imap/cmd-select.c b/src/imap/cmd-select.c
index 43f801d..2d78f01 100644
--- a/src/imap/cmd-select.c
+++ b/src/imap/cmd-select.c
@@ -11,6 +11,7 @@ bool cmd_select_full(struct client_command_context *cmd, bool readonly)
 	struct mailbox *box;
 	struct mailbox_status status;
 	const char *mailbox;
+	enum mailbox_open_flags flags;
 
 	/* <mailbox> */
 	if (!client_read_string_args(cmd, 1, &mailbox))
@@ -29,8 +30,13 @@ bool cmd_select_full(struct client_command_context *cmd, bool readonly)
 	if (storage == NULL)
 		return TRUE;
 
-	box = mailbox_open(storage, mailbox, NULL, !readonly ? 0 :
-			   (MAILBOX_OPEN_READONLY | MAILBOX_OPEN_KEEP_RECENT));
+	flags = 0;
+	if (no_flag_updates)
+		flags |= MAILBOX_OPEN_KEEP_RECENT;
+	if (readonly)
+		flags |= (MAILBOX_OPEN_READONLY | MAILBOX_OPEN_KEEP_RECENT);
+
+	box = mailbox_open(storage, mailbox, NULL, flags);
 	if (box == NULL) {
 		client_send_storage_error(cmd, storage);
 		return TRUE;
diff --git a/src/imap/common.h b/src/imap/common.h
index 7ab28b4..c24d822 100644
--- a/src/imap/common.h
+++ b/src/imap/common.h
@@ -30,6 +30,7 @@ enum client_workarounds {
 extern struct ioloop *ioloop;
 extern unsigned int imap_max_line_length;
 extern enum client_workarounds client_workarounds;
+extern bool no_flag_updates;
 extern const char *logout_format;
 
 extern string_t *capability_string;
diff --git a/src/imap/main.c b/src/imap/main.c
index 8246fa3..6a403e3 100644
--- a/src/imap/main.c
+++ b/src/imap/main.c
@@ -42,6 +42,7 @@ struct ioloop *ioloop;
 unsigned int imap_max_line_length;
 enum client_workarounds client_workarounds = 0;
 const char *logout_format;
+bool no_flag_updates = FALSE;
 
 static struct io *log_io = NULL;
 static struct module *modules = NULL;
@@ -229,6 +230,7 @@ static void main_init(void)
 		logout_format = "bytes=%i/%o";
 
         parse_workarounds();
+	no_flag_updates = getenv("IMAP_NO_FLAG_UPDATES") != NULL;
 
 	namespace_pool = pool_alloconly_create("namespaces", 1024);
 	if (mail_namespaces_init(namespace_pool, user, &ns) < 0)
diff --git a/src/master/mail-process.c b/src/master/mail-process.c
index adacef5..75d21ef 100644
--- a/src/master/mail-process.c
+++ b/src/master/mail-process.c
@@ -318,6 +318,8 @@ mail_process_set_environment(struct settings *set, const char *mail,
 				    set->imap_client_workarounds, NULL));
 		env_put(t_strconcat("IMAP_LOGOUT_FORMAT=",
 				    set->imap_logout_format, NULL));
+		if (set->imap_no_flag_updates)
+			env_put("IMAP_NO_FLAG_UPDATES=1");
 	}
 	if (set->protocol == MAIL_PROTOCOL_POP3) {
 		env_put(t_strconcat("POP3_CLIENT_WORKAROUNDS=",
diff --git a/src/master/master-settings-defs.c b/src/master/master-settings-defs.c
index 8cb5671..3faa00d 100644
--- a/src/master/master-settings-defs.c
+++ b/src/master/master-settings-defs.c
@@ -114,6 +114,7 @@ static struct setting_def setting_defs[] = {
 	DEF_STR(imap_capability),
 	DEF_STR(imap_client_workarounds),
 	DEF_STR(imap_logout_format),
+	DEF_BOOL(imap_no_flag_updates),
 
 	/* pop3 */
 	DEF_BOOL(pop3_no_flag_updates),
diff --git a/src/master/master-settings.c b/src/master/master-settings.c
index 74b7fb7..e582604 100644
--- a/src/master/master-settings.c
+++ b/src/master/master-settings.c
@@ -280,6 +280,7 @@ struct settings default_settings = {
 	MEMBER(imap_capability) "",
 	MEMBER(imap_client_workarounds) "",
 	MEMBER(imap_logout_format) "bytes=%i/%o",
+	MEMBER(imap_no_flag_updates) FALSE,
 
 	/* pop3 */
 	MEMBER(pop3_no_flag_updates) FALSE,
diff --git a/src/master/master-settings.h b/src/master/master-settings.h
index 29da4e3..593817c 100644
--- a/src/master/master-settings.h
+++ b/src/master/master-settings.h
@@ -126,6 +126,7 @@ struct settings {
 	const char *imap_capability;
 	const char *imap_client_workarounds;
 	const char *imap_logout_format;
+	bool imap_no_flag_updates;
 
 	/* pop3 */
 	bool pop3_no_flag_updates;


More information about the dovecot mailing list