Lines Matching refs:ctx
41 struct mailbox_list_index_iterate_context *ctx;
51 ctx = p_new(pool, struct mailbox_list_index_iterate_context, 1);
52 ctx->ctx.pool = pool;
53 ctx->ctx.list = list;
54 ctx->ctx.flags = flags;
55 ctx->ctx.glob = imap_match_init_multiple(pool, patterns, TRUE, ns_sep);
56 array_create(&ctx->ctx.module_contexts, pool, sizeof(void *), 5);
57 ctx->info_pool = pool_alloconly_create("mailbox list index iter info", 128);
58 ctx->ctx.index_iteration = TRUE;
61 ctx->info.ns = list->ns;
62 ctx->path = str_new(pool, 128);
63 ctx->next_node = ilist->mailbox_tree;
64 ctx->mailbox_pool = ilist->mailbox_pool;
65 pool_ref(ctx->mailbox_pool);
66 return &ctx->ctx;
70 mailbox_list_index_update_info(struct mailbox_list_index_iterate_context *ctx)
72 struct mailbox_list_index_node *node = ctx->next_node;
75 p_clear(ctx->info_pool);
77 str_truncate(ctx->path, ctx->parent_len);
82 str_append_c(ctx->path,
83 mailbox_list_get_hierarchy_sep(ctx->ctx.list));
85 str_append(ctx->path, node->name);
87 ctx->info.vname = mailbox_list_get_vname(ctx->ctx.list, str_c(ctx->path));
88 ctx->info.flags = node->children != NULL ?
90 if (strcmp(ctx->info.vname, "INBOX") != 0) {
92 ctx->info.vname = p_strdup(ctx->info_pool, ctx->info.vname);
93 } else if (!ctx->prefix_inbox_list) {
95 ctx->info.vname = "INBOX";
96 if (mail_namespace_is_inbox_noinferiors(ctx->info.ns)) {
97 ctx->info.flags &= ~(MAILBOX_CHILDREN|MAILBOX_NOCHILDREN);
98 ctx->info.flags |= MAILBOX_NOINFERIORS;
102 ctx->info.vname = p_strconcat(ctx->info_pool,
103 ctx->ctx.list->ns->prefix, "INBOX", NULL);
104 ctx->info.flags |= MAILBOX_NONEXISTENT;
107 ctx->info.flags |= MAILBOX_NONEXISTENT;
109 ctx->info.flags |= MAILBOX_NOSELECT;
111 ctx->info.flags |= MAILBOX_NOINFERIORS;
113 if ((ctx->ctx.flags & (MAILBOX_LIST_ITER_SELECT_SUBSCRIBED |
115 mailbox_list_set_subscription_flags(ctx->ctx.list,
116 ctx->info.vname,
117 &ctx->info.flags);
120 if ((ctx->ctx.flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) == 0) {
121 box = mailbox_alloc(ctx->ctx.list, ctx->info.vname, 0);
123 &ctx->info.flags);
129 mailbox_list_index_update_next(struct mailbox_list_index_iterate_context *ctx,
132 struct mailbox_list_index_node *node = ctx->next_node;
134 if (!ctx->prefix_inbox_list && ctx->ctx.list->ns->prefix_len > 0 &&
138 ctx->prefix_inbox_list = TRUE;
143 ctx->parent_len = str_len(ctx->path);
144 ctx->next_node = node->children;
149 ctx->parent_len -= strlen(node->name);
151 ctx->parent_len--;
155 ctx->next_node = NULL;
159 ctx->next_node = node->next;
164 iter_subscriptions_ok(struct mailbox_list_index_iterate_context *ctx)
166 if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0)
169 if ((ctx->info.flags & MAILBOX_SUBSCRIBED) != 0)
172 if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0 &&
173 (ctx->info.flags & MAILBOX_CHILD_SUBSCRIBED) != 0)
187 struct mailbox_list_index_iterate_context *ctx =
193 while (ctx->next_node != NULL) {
194 mailbox_list_index_update_info(ctx);
195 match = imap_match(_ctx->glob, ctx->info.vname);
199 if (match == IMAP_MATCH_YES && iter_subscriptions_ok(ctx)) {
205 mailbox_list_iter_try_delete_noselect(_ctx, &ctx->info,
206 str_c(ctx->path))) {
212 mailbox_list_index_update_next(ctx, TRUE);
213 return &ctx->info;
216 (ctx->info.flags & MAILBOX_CHILD_SUBSCRIBED) == 0) {
221 mailbox_list_index_update_next(ctx, follow_children);
232 struct mailbox_list_index_iterate_context *ctx =
234 int ret = ctx->failed ? -1 : 0;
236 pool_unref(&ctx->mailbox_pool);
237 pool_unref(&ctx->info_pool);