dovecot-1.1: maildir++ LIST (subscribed): If listing finds a non...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 4 23:47:45 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/3d5379e33664
changeset: 7493:3d5379e33664
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 04 23:43:18 2008 +0300
description:
maildir++ LIST (subscribed): If listing finds a non-subscribed mailbox under
a subscribed one, mark the subscribed one as having children.

diffstat:

1 file changed, 30 insertions(+)
src/lib-storage/list/mailbox-list-maildir-iter.c |   30 ++++++++++++++++++++++

diffs (47 lines):

diff -r ae8a3595d707 -r 3d5379e33664 src/lib-storage/list/mailbox-list-maildir-iter.c
--- a/src/lib-storage/list/mailbox-list-maildir-iter.c	Sun May 04 23:09:14 2008 +0300
+++ b/src/lib-storage/list/mailbox-list-maildir-iter.c	Sun May 04 23:43:18 2008 +0300
@@ -89,6 +89,33 @@ maildir_fill_parents(struct maildir_list
 	}
 }
 
+static void maildir_set_children(struct maildir_list_iterate_context *ctx,
+				 string_t *mailbox)
+{
+	struct mailbox_node *node;
+	const char *p, *mailbox_c;
+	char hierarchy_sep;
+
+	if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0)
+		hierarchy_sep = ctx->ctx.list->ns->sep;
+	else
+		hierarchy_sep = ctx->ctx.list->ns->real_sep;
+
+	/* mark the first existing parent as containing children */
+	mailbox_c = str_c(mailbox);
+	while ((p = strrchr(mailbox_c, hierarchy_sep)) != NULL) {
+		str_truncate(mailbox, (size_t) (p-mailbox_c));
+		mailbox_c = str_c(mailbox);
+
+		node = mailbox_tree_lookup(ctx->tree_ctx, mailbox_c);
+		if (node != NULL) {
+			node->flags &= ~MAILBOX_NOCHILDREN;
+			node->flags |= MAILBOX_CHILDREN;
+			break;
+		}
+	}
+}
+
 static int
 maildir_fill_readdir(struct maildir_list_iterate_context *ctx,
 		     struct imap_match_glob *glob, bool update_only)
@@ -191,6 +218,9 @@ maildir_fill_readdir(struct maildir_list
 					node->flags |= MAILBOX_MATCHED;
 				node->flags |= flags;
 				node_fix_parents(node);
+			} else {
+				i_assert(update_only);
+				maildir_set_children(ctx, mailbox);
 			}
 		}
 	}


More information about the dovecot-cvs mailing list