dovecot-2.1: imap: Use mailbox_exists() to find out if namespace...

dovecot at dovecot.org dovecot at dovecot.org
Thu Mar 15 14:19:02 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/65a75939ac2c
changeset: 14313:65a75939ac2c
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Mar 15 14:18:55 2012 +0200
description:
imap: Use mailbox_exists() to find out if namespace prefix is selectable or not.
mailbox_list_mailbox() should be treated as an internal function, since
ACLs don't apply to it.

diffstat:

 src/imap/cmd-list.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r 55586f4a86f1 -r 65a75939ac2c src/imap/cmd-list.c
--- a/src/imap/cmd-list.c	Thu Mar 15 14:18:13 2012 +0200
+++ b/src/imap/cmd-list.c	Thu Mar 15 14:18:55 2012 +0200
@@ -273,6 +273,8 @@
 {
 	struct mail_namespace *const *listed;
 	const struct mailbox_settings *mailbox_set;
+	struct mailbox *box;
+	enum mailbox_existence existence;
 	unsigned int len;
 	enum mailbox_info_flags flags;
 	const char *name;
@@ -307,11 +309,18 @@
 
 		ctx->inbox_found = TRUE;
 		flags = list_get_inbox_flags(ctx);
-	} else if (same_ns &&
-		   mailbox_list_mailbox(ctx->ns->list, "", &flags) > 0) {
-		/* mailbox with namespace prefix exists */
+	} else if (!same_ns) {
+		/* parent */
+		flags = MAILBOX_NONEXISTENT;
 	} else {
-		flags = MAILBOX_NONEXISTENT;
+		/* see if namespace prefix is selectable */
+		box = mailbox_alloc(ctx->ns->list, name, 0);
+		if (mailbox_exists(box, TRUE, &existence) == 0 &&
+		    existence == MAILBOX_EXISTENCE_SELECT)
+			flags = MAILBOX_SELECT;
+		else
+			flags = MAILBOX_NONEXISTENT;
+		mailbox_free(&box);
 	}
 
 	if ((flags & MAILBOX_CHILDREN) == 0) {


More information about the dovecot-cvs mailing list