changeset 11806:9ccfbed9c570

lib-storage: Show "foo/" style replies only for IMAP LIST command. Internally those replies just mess up things.
author Timo Sirainen <tss@iki.fi>
date Mon, 12 Jul 2010 21:15:34 +0100
parents 0a2dc81ed513
children ba450b2dcffa
files src/imap/cmd-list.c src/lib-storage/list/mailbox-list-fs-iter.c src/lib-storage/mailbox-list.h
diffstat 3 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-list.c	Mon Jul 12 20:38:47 2010 +0100
+++ b/src/imap/cmd-list.c	Mon Jul 12 21:15:34 2010 +0100
@@ -932,6 +932,7 @@
 		/* non-extended LIST - return children flags always */
 		ctx->list_flags |= MAILBOX_LIST_ITER_RETURN_CHILDREN;
 	}
+	ctx->list_flags |= MAILBOX_LIST_ITER_SHOW_EXISTING_PARENT;
 
 	if (!IMAP_ARG_IS_EOL(args)) {
 		client_send_command_error(cmd, "Extra arguments.");
--- a/src/lib-storage/list/mailbox-list-fs-iter.c	Mon Jul 12 20:38:47 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-fs-iter.c	Mon Jul 12 21:15:34 2010 +0100
@@ -517,6 +517,12 @@
 		delayed_send = TRUE;
 	}
 
+	if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SHOW_EXISTING_PARENT) == 0) {
+		/* LIST "" foo/% - we don't want to see foo/ returned */
+		delayed_send = FALSE;
+		match2 = IMAP_MATCH_CHILDREN;
+	}
+
 	if (scan_subdir) {
 		real_path = t_strconcat(ctx->dir->real_path, "/", fname, NULL);
 		ret = list_opendir(ctx, real_path, vpath, &dirp);
--- a/src/lib-storage/mailbox-list.h	Mon Jul 12 20:38:47 2010 +0100
+++ b/src/lib-storage/mailbox-list.h	Mon Jul 12 21:15:34 2010 +0100
@@ -61,6 +61,10 @@
 enum mailbox_list_iter_flags {
 	/* Ignore index file and ACLs (used by ACL plugin internally) */
 	MAILBOX_LIST_ITER_RAW_LIST		= 0x000001,
+	/* When listing "foo/%" and "foo" is an existing mailbox
+	   (maybe \noselect), have LIST also return "foo/" in the replies.
+	   This is needed by IMAP, but messes up internal code. */
+	MAILBOX_LIST_ITER_SHOW_EXISTING_PARENT	= 0x000002,
 	/* Don't list INBOX unless it actually exists */
 	MAILBOX_LIST_ITER_NO_AUTO_INBOX		= 0x000004,