dovecot-2.2: fs layout: Kludge to show INBOX/INBOX mailbox when ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 20 11:09:52 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/7a1f49b588a8
changeset: 14932:7a1f49b588a8
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Aug 14 03:03:26 2012 +0300
description:
fs layout: Kludge to show INBOX/INBOX mailbox when necessary.
This happens with one prefix="" namespace and another prefix=INBOX/
namespace when the INBOX mailbox itself has children.

diffstat:

 src/lib-storage/list/mailbox-list-fs-iter.c |  32 ++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 5 deletions(-)

diffs (77 lines):

diff -r b0f744014aca -r 7a1f49b588a8 src/lib-storage/list/mailbox-list-fs-iter.c
--- a/src/lib-storage/list/mailbox-list-fs-iter.c	Tue Aug 14 03:02:02 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-fs-iter.c	Tue Aug 14 03:03:26 2012 +0300
@@ -49,6 +49,7 @@
 	struct list_dir_context *dir;
 
 	unsigned int inbox_found:1;
+	unsigned int list_inbox_inbox:1;
 };
 
 static int
@@ -526,7 +527,8 @@
 	return ret;
 }
 
-static void inbox_flags_set(struct fs_list_iterate_context *ctx)
+static void inbox_flags_set(struct fs_list_iterate_context *ctx,
+			    enum imap_match_result child_dir_match)
 {
 	struct mail_namespace *ns = ctx->ctx.list->ns;
 
@@ -541,8 +543,19 @@
 		   with INBOX = /var/inbox/%u/Maildir, root = ~/Maildir:
 		   ~/Maildir/INBOX/foo/ shows up as <prefix>/INBOX/foo and
 		   INBOX can't directly have any children. */
-		ctx->info.flags &= ~MAILBOX_CHILDREN;
-		ctx->info.flags |= MAILBOX_NOINFERIORS;
+		if (ns->prefix_len == 6 &&
+		    strncasecmp(ns->prefix, "INBOX", ns->prefix_len-1) == 0 &&
+		    (ctx->info.flags & MAILBOX_CHILDREN) != 0 &&
+		    (child_dir_match & IMAP_MATCH_CHILDREN) != 0) {
+			/* except, INBOX/ prefix is once again a special case.
+			   we're now listing both the namespace prefix and the
+			   INBOX. we're now doing a LIST INBOX/%, so we'll need
+			   to create a fake \NoSelect INBOX/INBOX */
+			ctx->list_inbox_inbox = TRUE;
+		} else {
+			ctx->info.flags &= ~MAILBOX_CHILDREN;
+			ctx->info.flags |= MAILBOX_NOINFERIORS;
+		}
 	}
 }
 
@@ -570,7 +583,7 @@
 	    (ctx->info.flags & MAILBOX_NONEXISTENT) != 0)
 		return FALSE;
 
-	inbox_flags_set(ctx);
+	inbox_flags_set(ctx, 0);
 	/* we got here because we didn't see INBOX among other mailboxes,
 	   which means it has no children. */
 	ctx->info.flags |= MAILBOX_NOCHILDREN;
@@ -645,7 +658,7 @@
 			}
 			return 0;
 		}
-		inbox_flags_set(ctx);
+		inbox_flags_set(ctx, child_dir_match);
 		ctx->inbox_found = TRUE;
 	} else if (strcmp(storage_name, "INBOX") == 0 &&
 		   (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
@@ -704,6 +717,15 @@
 			fs_list_next_root(ctx);
 	}
 
+	if (ctx->list_inbox_inbox) {
+		ctx->info.flags = MAILBOX_CHILDREN | MAILBOX_NOSELECT;
+		ctx->info.name =
+			p_strconcat(ctx->info_pool,
+				    ctx->ctx.list->ns->prefix, "INBOX", NULL);
+		ctx->list_inbox_inbox = FALSE;
+		if (imap_match(ctx->ctx.glob, ctx->info.name) == IMAP_MATCH_YES)
+			return 1;
+	}
 	if (!ctx->inbox_found && ctx->ctx.glob != NULL &&
 	    (ctx->ctx.list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 &&
 	    imap_match(ctx->ctx.glob,


More information about the dovecot-cvs mailing list