dovecot: Forgot to add in last mailbox list API commit.

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 29 16:35:33 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/f22a7228dab8
changeset: 5831:f22a7228dab8
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 29 16:35:29 2007 +0300
description:
Forgot to add in last mailbox list API commit.

diffstat:

2 files changed, 110 insertions(+)
src/lib-storage/list/mailbox-list-subscriptions.c |   98 +++++++++++++++++++++
src/lib-storage/list/mailbox-list-subscriptions.h |   12 ++

diffs (118 lines):

diff -r 0a08fa294c3b -r f22a7228dab8 src/lib-storage/list/mailbox-list-subscriptions.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-storage/list/mailbox-list-subscriptions.c	Fri Jun 29 16:35:29 2007 +0300
@@ -0,0 +1,98 @@
+/* Copyright (C) 2002-2007 Timo Sirainen */
+
+#include "lib.h"
+#include "imap-match.h"
+#include "mailbox-tree.h"
+#include "subscription-file.h"
+#include "mailbox-list-private.h"
+#include "mailbox-list-subscriptions.h"
+
+static void nodes_add_child_subscribed(struct mailbox_node *node)
+{
+	while (node != NULL) {
+		if (node->children != NULL) {
+			node->flags |= MAILBOX_MATCHED |
+				MAILBOX_CHILD_SUBSCRIBED;
+		}
+		node = node->next;
+	}
+}
+
+int mailbox_list_subscriptions_fill(struct mailbox_list_iterate_context *ctx,
+				    struct mailbox_tree_context *tree_ctx,
+				    struct imap_match_glob *glob,
+				    bool update_only)
+{
+	struct subsfile_list_context *subsfile_ctx;
+	const char *path, *name, *p;
+	struct mailbox_node *node;
+	char hierarchy_sep;
+	bool created, add_flags;
+
+	add_flags = update_only ||
+		(ctx->flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) == 0;
+
+	path = t_strconcat(ctx->list->set.control_dir != NULL ?
+			   ctx->list->set.control_dir :
+			   ctx->list->set.root_dir,
+			   "/", ctx->list->set.subscription_fname, NULL);
+	subsfile_ctx = subsfile_list_init(ctx->list, path);
+
+	hierarchy_sep = ctx->list->hierarchy_sep;
+	while ((name = subsfile_list_next(subsfile_ctx)) != NULL) {
+		created = FALSE;
+		switch (imap_match(glob, name)) {
+		case IMAP_MATCH_YES:
+			node = update_only ?
+				mailbox_tree_lookup(tree_ctx, name) :
+				mailbox_tree_get(tree_ctx, name, &created);
+			if (created && add_flags) {
+				node->flags = MAILBOX_NONEXISTENT |
+					MAILBOX_NOCHILDREN;
+			}
+			if (node != NULL) {
+				if (!update_only)
+					node->flags |= MAILBOX_MATCHED;
+				node->flags |= MAILBOX_SUBSCRIBED;
+			}
+			break;
+		case IMAP_MATCH_PARENT:
+			/* child matched */
+			if ((ctx->flags &
+			     MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) == 0)
+				break;
+
+			while ((p = strrchr(name, hierarchy_sep)) != NULL) {
+				name = t_strdup_until(name, p);
+				if (imap_match(glob, name) > 0)
+					break;
+			}
+			i_assert(p != NULL);
+
+			node = update_only ?
+				mailbox_tree_lookup(tree_ctx, name) :
+				mailbox_tree_get(tree_ctx, name, &created);
+			if (created && add_flags)
+				node->flags = MAILBOX_NONEXISTENT;
+			if (node != NULL) {
+				if (!update_only)
+					node->flags |= MAILBOX_MATCHED;
+				node->flags |= MAILBOX_CHILDREN |
+					MAILBOX_CHILD_SUBSCRIBED;
+				node->flags &= ~MAILBOX_NOCHILDREN;
+			}
+			break;
+		default:
+			break;
+		}
+	}
+
+	if ((ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0 &&
+	    (ctx->flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0) {
+		struct mailbox_node *nodes =
+			mailbox_tree_get(tree_ctx, NULL, NULL);
+
+		nodes_add_child_subscribed(nodes);
+	}
+	return subsfile_list_deinit(subsfile_ctx);
+}
diff -r 0a08fa294c3b -r f22a7228dab8 src/lib-storage/list/mailbox-list-subscriptions.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-storage/list/mailbox-list-subscriptions.h	Fri Jun 29 16:35:29 2007 +0300
@@ -0,0 +1,12 @@
+#ifndef __MAILBOX_LIST_SUBSCRIPTIONS_H
+#define __MAILBOX_LIST_SUBSCRIPTIONS_H
+
+struct mailbox_list_iterate_context;
+struct mailbox_tree_context;
+
+int mailbox_list_subscriptions_fill(struct mailbox_list_iterate_context *ctx,
+				    struct mailbox_tree_context *tree_ctx,
+				    struct imap_match_glob *glob,
+				    bool update_only);
+
+#endif


More information about the dovecot-cvs mailing list