changeset 3210:2715077f9c3e HEAD

mailbox_name_equals() renamed to mailbox_equals(), which also now checks that mail storages match. Fixes problems with copying messages from one namespace to another between identically named mailboxes.
author Timo Sirainen <tss@iki.fi>
date Tue, 15 Mar 2005 23:52:07 +0200
parents 923ff19873d4
children 4f3e4c8e458f
files src/imap/cmd-append.c src/imap/cmd-copy.c src/imap/cmd-status.c src/imap/commands-util.c src/imap/commands-util.h
diffstat 5 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-append.c	Tue Mar 15 21:01:50 2005 +0200
+++ b/src/imap/cmd-append.c	Tue Mar 15 23:52:07 2005 +0200
@@ -356,7 +356,7 @@
 		return NULL;
 
 	if (cmd->client->mailbox != NULL &&
-	    mailbox_name_equals(mailbox_get_name(cmd->client->mailbox), name))
+	    mailbox_equals(cmd->client->mailbox, storage, name))
 		return cmd->client->mailbox;
 
 	box = mailbox_open(storage, name, MAILBOX_OPEN_FAST |
--- a/src/imap/cmd-copy.c	Tue Mar 15 21:01:50 2005 +0200
+++ b/src/imap/cmd-copy.c	Tue Mar 15 23:52:07 2005 +0200
@@ -71,7 +71,7 @@
 	if (storage == NULL)
 		return TRUE;
 
-	if (mailbox_name_equals(mailbox_get_name(client->mailbox), mailbox))
+	if (mailbox_equals(client->mailbox, storage, mailbox))
 		destbox = client->mailbox;
 	else {
 		destbox = mailbox_open(storage, mailbox, MAILBOX_OPEN_FAST |
--- a/src/imap/cmd-status.c	Tue Mar 15 21:01:50 2005 +0200
+++ b/src/imap/cmd-status.c	Tue Mar 15 23:52:07 2005 +0200
@@ -53,7 +53,7 @@
 	int failed;
 
 	if (client->mailbox != NULL &&
-	    mailbox_name_equals(mailbox_get_name(client->mailbox), mailbox)) {
+	    mailbox_equals(client->mailbox, storage, mailbox)) {
 		/* this mailbox is selected */
 		box = client->mailbox;
 	} else {
--- a/src/imap/commands-util.c	Tue Mar 15 21:01:50 2005 +0200
+++ b/src/imap/commands-util.c	Tue Mar 15 23:52:07 2005 +0200
@@ -310,12 +310,21 @@
 		dest->keywords[i] = p_strdup(dest->pool, keywords[i]);
 }
 
-int mailbox_name_equals(const char *box1, const char *box2)
+int mailbox_equals(struct mailbox *box1, struct mail_storage *storage2,
+		   const char *name2)
 {
-	if (strcmp(box1, box2) == 0)
+	struct mail_storage *storage1 = mailbox_get_storage(box1);
+	const char *name1;
+
+	if (storage1 != storage2)
+		return FALSE;
+
+        name1 = mailbox_get_name(box1);
+	if (strcmp(name1, name2) == 0)
 		return TRUE;
 
-	return strcasecmp(box1, "INBOX") == 0 && strcasecmp(box2, "INBOX") == 0;
+	return strcasecmp(name1, "INBOX") == 0 &&
+		strcasecmp(name2, "INBOX") == 0;
 }
 
 void msgset_generator_init(struct msgset_generator_context *ctx, string_t *str)
--- a/src/imap/commands-util.h	Tue Mar 15 21:01:50 2005 +0200
+++ b/src/imap/commands-util.h	Tue Mar 15 23:52:07 2005 +0200
@@ -52,7 +52,8 @@
 			  const char *const keywords[],
 			  unsigned int keywords_count);
 
-int mailbox_name_equals(const char *box1, const char *box2);
+int mailbox_equals(struct mailbox *box1, struct mail_storage *storage2,
+		   const char *name2);
 
 void msgset_generator_init(struct msgset_generator_context *ctx, string_t *str);
 void msgset_generator_next(struct msgset_generator_context *ctx, uint32_t uid);