changeset 6043:d9abe04fc9ae HEAD

List non-subscribed mailboxes only if at least one child mailbox isn't listed.
author Timo Sirainen <tss@iki.fi>
date Tue, 17 Jul 2007 21:48:42 +0300
parents 99aace97fb4e
children 3ca063521d9a
files src/lib-storage/list/mailbox-list-subscriptions.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-subscriptions.c	Tue Jul 17 21:30:33 2007 +0300
+++ b/src/lib-storage/list/mailbox-list-subscriptions.c	Tue Jul 17 21:48:42 2007 +0300
@@ -28,7 +28,7 @@
 	enum mailbox_info_flags create_flags, always_flags;
 	enum imap_match_result match;
 	const char *p;
-	bool created;
+	bool created, add_matched;
 
 	if ((ctx->list->ns->flags & NAMESPACE_FLAG_INBOX) == 0 ||
 	    strcasecmp(name, "INBOX") != 0) {
@@ -40,6 +40,7 @@
 			(ctx->flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) == 0) ?
 		(MAILBOX_NONEXISTENT | MAILBOX_NOCHILDREN) : 0;
 	always_flags = MAILBOX_SUBSCRIBED;
+	add_matched = TRUE;
 
 	t_push();
 	for (;;) {
@@ -55,12 +56,21 @@
 					node_fix_parents(node);
 			}
 			if (node != NULL) {
-				if (!update_only)
+				if (!update_only && add_matched)
 					node->flags |= MAILBOX_MATCHED;
 				node->flags |= always_flags;
 			}
-		} else if ((match & IMAP_MATCH_PARENT) == 0)
-			break;
+			/* We don't want to show the parent mailboxes unless
+			   something else matches them, but if they are matched
+			   we want to show them having child subscriptions */
+			add_matched = FALSE;
+		} else {
+			if ((match & IMAP_MATCH_PARENT) == 0)
+				break;
+			/* We've a (possibly) non-subscribed parent mailbox
+			   which has a subscribed child mailbox. Make sure we
+			   return the parent mailbox. */
+		}
 
 		if ((ctx->flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) == 0)
 			break;