changeset 3765:ce76b6b8ff11 HEAD

UID STORE command must return UID parameter in FETCH replies.
author Timo Sirainen <tss@iki.fi>
date Sun, 25 Dec 2005 13:24:45 +0200
parents 852274ab176d
children 395bc6e93222
files src/imap/cmd-append.c src/imap/cmd-check.c src/imap/cmd-copy.c src/imap/cmd-expunge.c src/imap/cmd-fetch.c src/imap/cmd-idle.c src/imap/cmd-noop.c src/imap/cmd-search.c src/imap/cmd-sort.c src/imap/cmd-store.c src/imap/cmd-thread.c src/imap/imap-sync.c src/imap/imap-sync.h
diffstat 13 files changed, 36 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-append.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-append.c	Sun Dec 25 13:24:45 2005 +0200
@@ -212,7 +212,7 @@
 			0 : MAILBOX_SYNC_FLAG_FAST;
 
 		cmd_append_finish(ctx);
-		return cmd_sync(cmd, sync_flags, "OK Append completed.");
+		return cmd_sync(cmd, sync_flags, 0, "OK Append completed.");
 	}
 
 	if (!validate_args(args, &flags_list, &internal_date_str,
--- a/src/imap/cmd-check.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-check.c	Sun Dec 25 13:24:45 2005 +0200
@@ -9,5 +9,5 @@
 		return TRUE;
 
 	return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FULL_READ |
-			MAILBOX_SYNC_FLAG_FULL_WRITE, "OK Check completed.");
+			MAILBOX_SYNC_FLAG_FULL_WRITE, 0, "OK Check completed.");
 }
--- a/src/imap/cmd-copy.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-copy.c	Sun Dec 25 13:24:45 2005 +0200
@@ -106,10 +106,10 @@
 	}
 
 	if (ret > 0)
-		return cmd_sync(cmd, sync_flags, "OK Copy completed.");
+		return cmd_sync(cmd, sync_flags, 0, "OK Copy completed.");
 	else if (ret == 0) {
 		/* some messages were expunged, sync them */
-		return cmd_sync(cmd, 0,
+		return cmd_sync(cmd, 0, 0,
 			"NO Some of the requested messages no longer exist.");
 	} else {
 		client_send_storage_error(cmd, storage);
--- a/src/imap/cmd-expunge.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-expunge.c	Sun Dec 25 13:24:45 2005 +0200
@@ -29,7 +29,7 @@
 		return TRUE;
 
 	if (imap_expunge(client->mailbox, search_arg))
-		return cmd_sync(cmd, 0, "OK Expunge completed.");
+		return cmd_sync(cmd, 0, 0, "OK Expunge completed.");
 	else {
 		client_send_storage_error(cmd,
 					  mailbox_get_storage(client->mailbox));
@@ -45,7 +45,7 @@
 		return TRUE;
 
 	if (imap_expunge(client->mailbox, NULL))
-		return cmd_sync(cmd, 0, "OK Expunge completed.");
+		return cmd_sync(cmd, 0, 0, "OK Expunge completed.");
 	else {
 		client_send_storage_error(cmd,
 					  mailbox_get_storage(client->mailbox));
--- a/src/imap/cmd-fetch.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-fetch.c	Sun Dec 25 13:24:45 2005 +0200
@@ -104,7 +104,7 @@
 	}
 
 	return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
-			(cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
+			(cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES), 0,
 			ok_message);
 }
 
--- a/src/imap/cmd-idle.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-idle.c	Sun Dec 25 13:24:45 2005 +0200
@@ -142,7 +142,7 @@
 		ctx->sync_pending = TRUE;
 	else {
 		ctx->sync_pending = FALSE;
-		ctx->sync_ctx = imap_sync_init(ctx->client, box, 0);
+		ctx->sync_ctx = imap_sync_init(ctx->client, box, 0, 0);
 		cmd_idle_continue(ctx->cmd);
 	}
 }
--- a/src/imap/cmd-noop.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-noop.c	Sun Dec 25 13:24:45 2005 +0200
@@ -5,5 +5,5 @@
 
 int cmd_noop(struct client_command_context *cmd)
 {
-	return cmd_sync(cmd, 0, "OK NOOP completed.");
+	return cmd_sync(cmd, 0, 0, "OK NOOP completed.");
 }
--- a/src/imap/cmd-search.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-search.c	Sun Dec 25 13:24:45 2005 +0200
@@ -101,7 +101,7 @@
 	} else if (imap_search(cmd, charset, sargs)) {
 		return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
 				(cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
-				"OK Search completed.");
+				0, "OK Search completed.");
 	} else {
 		client_send_storage_error(cmd,
 					  mailbox_get_storage(client->mailbox));
--- a/src/imap/cmd-sort.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-sort.c	Sun Dec 25 13:24:45 2005 +0200
@@ -124,7 +124,7 @@
 		pool_unref(pool);
 		return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
 				(cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
-				"OK Sort completed.");
+				0, "OK Sort completed.");
 	} else {
 		client_send_storage_error(cmd,
 					  mailbox_get_storage(client->mailbox));
--- a/src/imap/cmd-store.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-store.c	Sun Dec 25 13:24:45 2005 +0200
@@ -124,8 +124,15 @@
 	}
 
 	if (!failed) {
+		/* With UID STORE we have to return UID for the flags as well.
+		   Unfortunately we don't have the ability to separate those
+		   flag changes that were caused by UID STORE and those that
+		   came externally, so we'll just send the UID for all flag
+		   changes that we see. */
 		return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
 				(cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
+				cmd->uid && !silent ?
+				IMAP_SYNC_FLAG_SEND_UID : 0,
 				"OK Store completed.");
 	} else {
 		client_send_storage_error(cmd, mailbox_get_storage(box));
--- a/src/imap/cmd-thread.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/cmd-thread.c	Sun Dec 25 13:24:45 2005 +0200
@@ -67,7 +67,7 @@
 		pool_unref(pool);
 		return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST |
 				(cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
-				"OK Thread completed.");
+				0, "OK Thread completed.");
 	} else {
 		client_send_storage_error(cmd,
 					  mailbox_get_storage(client->mailbox));
--- a/src/imap/imap-sync.c	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/imap-sync.c	Sun Dec 25 13:24:45 2005 +0200
@@ -15,6 +15,7 @@
 struct imap_sync_context {
 	struct client *client;
 	struct mailbox *box;
+        enum imap_sync_flags imap_flags;
 
 	struct mailbox_transaction_context *t;
 	struct mailbox_sync_context *sync_ctx;
@@ -30,7 +31,7 @@
 
 struct imap_sync_context *
 imap_sync_init(struct client *client, struct mailbox *box,
-	       enum mailbox_sync_flags flags)
+	       enum imap_sync_flags imap_flags, enum mailbox_sync_flags flags)
 {
 	struct imap_sync_context *ctx;
 	struct mailbox_status status;
@@ -40,6 +41,7 @@
 	ctx = i_new(struct imap_sync_context, 1);
 	ctx->client = client;
 	ctx->box = box;
+	ctx->imap_flags = imap_flags;
 
 	ctx->sync_ctx = mailbox_sync_init(box, flags);
 	ctx->t = mailbox_transaction_begin(box, 0);
@@ -131,8 +133,12 @@
 				keywords = mail_get_keywords(ctx->mail);
 
 				str_truncate(str, 0);
-				str_printfa(str, "* %u FETCH (FLAGS (",
-					    ctx->seq);
+				str_printfa(str, "* %u FETCH (", ctx->seq);
+				if (ctx->imap_flags & IMAP_SYNC_FLAG_SEND_UID) {
+					str_printfa(str, "UID %u ",
+						    ctx->mail->uid);
+				}
+				str_append(str, "FLAGS (");
 				imap_write_flags(str, flags, keywords);
 				str_append(str, "))");
 
@@ -201,7 +207,7 @@
 }
 
 int cmd_sync(struct client_command_context *cmd, enum mailbox_sync_flags flags,
-	     const char *tagline)
+	     enum imap_sync_flags imap_flags, const char *tagline)
 {
         struct cmd_sync_context *ctx;
 
@@ -223,7 +229,7 @@
 	ctx = p_new(cmd->pool, struct cmd_sync_context, 1);
 	ctx->tagline = p_strdup(cmd->pool, tagline);
 	ctx->sync_ctx = imap_sync_init(cmd->client, cmd->client->mailbox,
-				       flags);
+				       imap_flags, flags);
 
 	cmd->func = cmd_sync_continue;
 	cmd->context = ctx;
--- a/src/imap/imap-sync.h	Sun Dec 25 13:05:28 2005 +0200
+++ b/src/imap/imap-sync.h	Sun Dec 25 13:24:45 2005 +0200
@@ -1,17 +1,21 @@
 #ifndef __IMAP_SYNC_H
 #define __IMAP_SYNC_H
 
+enum imap_sync_flags {
+	IMAP_SYNC_FLAG_SEND_UID	= 0x01
+};
+
 struct client;
 
 struct imap_sync_context *
 imap_sync_init(struct client *client, struct mailbox *box,
-	       enum mailbox_sync_flags flags);
+	       enum imap_sync_flags imap_flags, enum mailbox_sync_flags flags);
 int imap_sync_deinit(struct imap_sync_context *ctx);
 int imap_sync_more(struct imap_sync_context *ctx);
 
 int imap_sync_nonselected(struct mailbox *box, enum mailbox_sync_flags flags);
 
 int cmd_sync(struct client_command_context *cmd, enum mailbox_sync_flags flags,
-	     const char *tagline);
+	     enum imap_sync_flags imap_flags, const char *tagline);
 
 #endif