dovecot-2.2: imapc: Nonexistent mailboxes were returned as selec...
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 20 03:26:33 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/4cea936d57f2
changeset: 14496:4cea936d57f2
user: Timo Sirainen <tss at iki.fi>
date: Mon Apr 23 12:52:59 2012 +0300
description:
imapc: Nonexistent mailboxes were returned as selectable mailboxes.
diffstat:
src/lib-storage/index/imapc/imapc-list.c | 3 +++
src/lib-storage/mailbox-tree.c | 30 ++++++++++++++++++++++--------
src/lib-storage/mailbox-tree.h | 3 ++-
3 files changed, 27 insertions(+), 9 deletions(-)
diffs (132 lines):
diff -r 03f44d61d582 -r 4cea936d57f2 src/lib-storage/index/imapc/imapc-list.c
--- a/src/lib-storage/index/imapc/imapc-list.c Fri Apr 20 22:27:01 2012 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.c Mon Apr 23 12:52:59 2012 +0300
@@ -33,6 +33,7 @@
list->list.pool = pool;
/* separator is set when storage is created */
list->mailboxes = mailbox_tree_init('\0');
+ mailbox_tree_set_parents_nonexistent(list->mailboxes);
return &list->list;
}
@@ -362,6 +363,7 @@
imapc_command_sendf(cmd, "LIST \"\" %s", pattern);
mailbox_tree_deinit(&list->mailboxes);
list->mailboxes = mailbox_tree_init(list->sep);
+ mailbox_tree_set_parents_nonexistent(list->mailboxes);
imapc_simple_run(&ctx);
if (ctx.ret == 0) {
@@ -436,6 +438,7 @@
ctx->info.ns = _list->ns;
ctx->tree = mailbox_tree_init(sep);
+ mailbox_tree_set_parents_nonexistent(ctx->tree);
imapc_list_build_match_tree(ctx);
if (list->list.ns->prefix_len > 0) {
diff -r 03f44d61d582 -r 4cea936d57f2 src/lib-storage/mailbox-tree.c
--- a/src/lib-storage/mailbox-tree.c Fri Apr 20 22:27:01 2012 +0300
+++ b/src/lib-storage/mailbox-tree.c Mon Apr 23 12:52:59 2012 +0300
@@ -8,6 +8,8 @@
struct mailbox_tree_context {
pool_t pool;
char separator;
+ bool parents_nonexistent;
+
struct mailbox_node *nodes;
};
@@ -49,6 +51,11 @@
tree->separator = separator;
}
+void mailbox_tree_set_parents_nonexistent(struct mailbox_tree_context *tree)
+{
+ tree->parents_nonexistent = TRUE;
+}
+
void mailbox_tree_clear(struct mailbox_tree_context *tree)
{
p_clear(tree->pool);
@@ -57,14 +64,13 @@
static struct mailbox_node *
mailbox_tree_traverse(struct mailbox_tree_context *tree, const char *path,
- bool create, bool *created)
+ bool create, bool *created_r)
{
struct mailbox_node **node, *parent;
const char *name;
string_t *str;
- if (created != NULL)
- *created = FALSE;
+ *created_r = FALSE;
if (path == NULL)
return tree->nodes;
@@ -101,9 +107,10 @@
*node = p_new(tree->pool, struct mailbox_node, 1);
(*node)->parent = parent;
(*node)->name = p_strdup(tree->pool, name);
+ if (tree->parents_nonexistent)
+ (*node)->flags = MAILBOX_NONEXISTENT;
- if (created != NULL)
- *created = TRUE;
+ *created_r = TRUE;
}
if (*path == '\0')
@@ -120,13 +127,19 @@
struct mailbox_node *
mailbox_tree_get(struct mailbox_tree_context *tree, const char *path,
- bool *created)
+ bool *created_r)
{
struct mailbox_node *node;
+ bool created;
T_BEGIN {
- node = mailbox_tree_traverse(tree, path, TRUE, created);
+ node = mailbox_tree_traverse(tree, path, TRUE, &created);
} T_END;
+ if (created && tree->parents_nonexistent)
+ node->flags = 0;
+
+ if (created_r != NULL)
+ *created_r = created;
return node;
}
@@ -134,9 +147,10 @@
mailbox_tree_lookup(struct mailbox_tree_context *tree, const char *path)
{
struct mailbox_node *node;
+ bool created;
T_BEGIN {
- node = mailbox_tree_traverse(tree, path, FALSE, NULL);
+ node = mailbox_tree_traverse(tree, path, FALSE, &created);
} T_END;
return node;
}
diff -r 03f44d61d582 -r 4cea936d57f2 src/lib-storage/mailbox-tree.h
--- a/src/lib-storage/mailbox-tree.h Fri Apr 20 22:27:01 2012 +0300
+++ b/src/lib-storage/mailbox-tree.h Mon Apr 23 12:52:59 2012 +0300
@@ -17,11 +17,12 @@
void mailbox_tree_set_separator(struct mailbox_tree_context *tree,
char separator);
+void mailbox_tree_set_parents_nonexistent(struct mailbox_tree_context *tree);
void mailbox_tree_clear(struct mailbox_tree_context *tree);
struct mailbox_node *
mailbox_tree_get(struct mailbox_tree_context *tree, const char *path,
- bool *created);
+ bool *created_r);
struct mailbox_node *
mailbox_tree_lookup(struct mailbox_tree_context *tree, const char *path);
More information about the dovecot-cvs
mailing list