# HG changeset patch # User Timo Sirainen # Date 1184698122 -10800 # Node ID d9abe04fc9ae5e1c174099c508b38248daba3421 # Parent 99aace97fb4ea91d149db7699dbce393f9fd0149 List non-subscribed mailboxes only if at least one child mailbox isn't listed. diff -r 99aace97fb4e -r d9abe04fc9ae src/lib-storage/list/mailbox-list-subscriptions.c --- 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;