struct imapc_mailbox_list_iterate_context {
struct mailbox_list_iterate_context ctx;
struct mailbox_tree_iterate_context *iter;
- struct imap_match_glob *glob;
struct mailbox_info info;
bool failed;
};
ctx = i_new(struct imapc_mailbox_list_iterate_context, 1);
ctx->ctx.list = _list;
ctx->ctx.flags = flags;
+ ctx->ctx.glob = imap_match_init_multiple(default_pool, patterns,
+ FALSE, sep);
+ array_create(&ctx->ctx.module_contexts, default_pool, sizeof(void *), 5);
+
ctx->info.ns = _list->ns;
- ctx->glob = imap_match_init_multiple(default_pool, patterns,
- FALSE, sep);
if (imapc_list_refresh(list, flags) < 0)
ctx->failed = TRUE;
else {
return NULL;
while ((node = mailbox_tree_iterate_next(ctx->iter, &name)) != NULL) {
- if (imap_match(ctx->glob, name) == IMAP_MATCH_YES) {
+ if (imap_match(ctx->ctx.glob, name) == IMAP_MATCH_YES) {
ctx->info.flags &= ~(MAILBOX_CHILDREN |
MAILBOX_NOCHILDREN);
if (node->children == NULL)
if (ctx->iter != NULL)
mailbox_tree_iterate_deinit(&ctx->iter);
- imap_match_deinit(&ctx->glob);
+ imap_match_deinit(&ctx->ctx.glob);
+ array_free(&ctx->ctx.module_contexts);
i_free(ctx);
return ret;
}
struct shared_mailbox_list_iterate_context {
struct mailbox_list_iterate_context ctx;
struct mail_namespace *cur_ns;
- struct imap_match_glob *glob;
struct mailbox_info info;
};
ctx = i_new(struct shared_mailbox_list_iterate_context, 1);
ctx->ctx.list = list;
ctx->ctx.flags = flags;
+ ctx->ctx.glob = imap_match_init_multiple(default_pool, patterns,
+ FALSE, sep);
+ array_create(&ctx->ctx.module_contexts, default_pool, sizeof(void *), 5);
+
ctx->cur_ns = list->ns->user->namespaces;
ctx->info.ns = list->ns;
ctx->info.flags = MAILBOX_NONEXISTENT;
- ctx->glob = imap_match_init_multiple(default_pool, patterns,
- FALSE, sep);
return &ctx->ctx;
}
prefix matches without the trailing separator */
i_assert(ns->prefix_len > 0);
ctx->info.name = t_strndup(ns->prefix, ns->prefix_len - 1);
- if (imap_match(ctx->glob, ctx->info.name) == IMAP_MATCH_YES) {
+ if (imap_match(ctx->ctx.glob, ctx->info.name) == IMAP_MATCH_YES) {
ctx->cur_ns = ns->next;
return &ctx->info;
}
struct shared_mailbox_list_iterate_context *ctx =
(struct shared_mailbox_list_iterate_context *)_ctx;
- imap_match_deinit(&ctx->glob);
+ imap_match_deinit(&ctx->ctx.glob);
+ array_free(&ctx->ctx.module_contexts);
i_free(ctx);
return 0;
}
struct mailbox_list_iterate_context ctx;
ARRAY_DEFINE(valid_patterns, char *);
- struct imap_match_glob *glob;
struct mailbox_tree_context *subs_tree;
struct mailbox_tree_iterate_context *tree_iter;
char sep;
ctx = i_new(struct fs_list_iterate_context, 1);
ctx->ctx.list = _list;
ctx->ctx.flags = flags;
+ array_create(&ctx->ctx.module_contexts, default_pool, sizeof(void *), 5);
+
ctx->info_pool = pool_alloconly_create("fs list", 1024);
ctx->next = fs_list_next;
ctx->sep = mail_namespace_get_sep(_list->ns);
return &ctx->ctx;
}
patterns = (const void *)array_idx(&ctx->valid_patterns, 0);
- ctx->glob = imap_match_init_multiple(default_pool, patterns, TRUE,
- ctx->sep);
+ ctx->ctx.glob = imap_match_init_multiple(default_pool, patterns, TRUE,
+ ctx->sep);
if ((flags & (MAILBOX_LIST_ITER_SELECT_SUBSCRIBED |
MAILBOX_LIST_ITER_RETURN_SUBSCRIBED)) != 0) {
mailboxes. Build a mailbox tree of all the subscriptions. */
ctx->subs_tree = mailbox_tree_init(ctx->sep);
if (mailbox_list_subscriptions_fill(&ctx->ctx, ctx->subs_tree,
- ctx->glob, FALSE) < 0) {
+ ctx->ctx.glob, FALSE) < 0) {
ctx->ctx.failed = TRUE;
return &ctx->ctx;
}
mailbox_tree_deinit(&ctx->subs_tree);
if (ctx->info_pool != NULL)
pool_unref(&ctx->info_pool);
- if (ctx->glob != NULL)
- imap_match_deinit(&ctx->glob);
+ if (ctx->ctx.glob != NULL)
+ imap_match_deinit(&ctx->ctx.glob);
+ array_free(&ctx->ctx.module_contexts);
i_free(ctx);
return ret;
int ret;
vpath = t_strdup_printf("%s%c", list_path, ctx->sep);
- match2 = imap_match(ctx->glob, vpath);
+ match2 = imap_match(ctx->ctx.glob, vpath);
if (match == IMAP_MATCH_YES)
ctx->info.name = p_strdup(ctx->info_pool, list_path);
/* check the pattern */
list_path = t_strconcat(ctx->dir->virtual_path, fname, NULL);
- match = imap_match(ctx->glob, list_path);
+ match = imap_match(ctx->ctx.glob, list_path);
if (match != IMAP_MATCH_YES && (match & IMAP_MATCH_CHILDREN) == 0 &&
!ctx->dir->delayed_send)
return 0;
if (!ctx->inbox_found &&
(ctx->ctx.list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 &&
- ((ctx->glob != NULL &&
- imap_match(ctx->glob,
+ ((ctx->ctx.glob != NULL &&
+ imap_match(ctx->ctx.glob,
fs_list_get_inbox_vname(ctx)) == IMAP_MATCH_YES) ||
ctx->inbox_match)) {
/* INBOX wasn't seen while listing other mailboxes. It might
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
+#include "array.h"
#include "str.h"
#include "ioloop.h"
#include "unlink-directory.h"
struct maildir_mailbox_list *list =
(struct maildir_mailbox_list *)_list;
struct maildir_list_iterate_context *ctx;
- struct imap_match_glob *glob;
pool_t pool;
char ns_sep = mail_namespace_get_sep(_list->ns);
int ret;
ctx = p_new(pool, struct maildir_list_iterate_context, 1);
ctx->ctx.list = _list;
ctx->ctx.flags = flags;
+ ctx->ctx.glob = imap_match_init_multiple(pool, patterns, TRUE, ns_sep);
+ array_create(&ctx->ctx.module_contexts, pool, sizeof(void *), 5);
+
ctx->pool = pool;
ctx->tree_ctx = mailbox_tree_init(ns_sep);
ctx->info.ns = _list->ns;
ctx->prefix_char = strcmp(_list->name, MAILBOX_LIST_NAME_IMAPDIR) == 0 ?
'\0' : list->sep;
- glob = imap_match_init_multiple(pool, patterns, TRUE, ns_sep);
-
ctx->dir = _list->set.root_dir;
if ((flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) {
/* Listing only subscribed mailboxes.
Flags are set later if needed. */
if (mailbox_list_subscriptions_fill(&ctx->ctx, ctx->tree_ctx,
- glob, FALSE) < 0) {
+ ctx->ctx.glob, FALSE) < 0) {
ctx->ctx.failed = TRUE;
return &ctx->ctx;
}
(flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0;
T_BEGIN {
- ret = maildir_fill_readdir(ctx, glob, update_only);
+ ret = maildir_fill_readdir(ctx, ctx->ctx.glob,
+ update_only);
} T_END;
if (ret < 0) {
ctx->ctx.failed = TRUE;
/* we're listing all mailboxes but we want to know
\Subscribed flags */
if (mailbox_list_subscriptions_fill(&ctx->ctx, ctx->tree_ctx,
- glob, TRUE) < 0) {
+ ctx->ctx.glob, TRUE) < 0) {
ctx->ctx.failed = TRUE;
return &ctx->ctx;
}
/* Copyright (c) 2006-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
+#include "array.h"
+#include "imap-match.h"
#include "mailbox-list-private.h"
#define MAILBOX_LIST_NAME_NONE "none"
static struct mailbox_list_iterate_context *
none_list_iter_init(struct mailbox_list *list,
- const char *const *patterns ATTR_UNUSED,
+ const char *const *patterns,
enum mailbox_list_iter_flags flags)
{
struct mailbox_list_iterate_context *ctx;
ctx = i_new(struct mailbox_list_iterate_context, 1);
ctx->list = list;
ctx->flags = flags;
+ ctx->glob = imap_match_init_multiple(default_pool, patterns, TRUE,
+ mail_namespace_get_sep(list->ns));
+ array_create(&ctx->module_contexts, default_pool, sizeof(void *), 5);
return ctx;
}
static int
none_list_iter_deinit(struct mailbox_list_iterate_context *ctx)
{
+ array_free(&ctx->module_contexts);
+ imap_match_deinit(&ctx->glob);
i_free(ctx);
return 0;
}
unsigned int index_root_dir_created:1;
};
+union mailbox_list_iterate_module_context {
+ struct mailbox_list_module_register *reg;
+};
+
struct mailbox_list_iterate_context {
struct mailbox_list *list;
enum mailbox_list_iter_flags flags;
bool failed;
+
+ struct imap_match_glob *glob;
+
+ ARRAY_DEFINE(module_contexts,
+ union mailbox_list_iterate_module_context *);
};
struct mailbox_list_iter_update_context {