dovecot-2.0: Added MAILBOX_LIST_ITER_NO_AUTO_INBOX for listing I...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jul 28 02:04:46 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/b56b06cdd1d7
changeset: 9683:b56b06cdd1d7
user: Timo Sirainen <tss at iki.fi>
date: Mon Jul 27 18:54:02 2009 -0400
description:
Added MAILBOX_LIST_ITER_NO_AUTO_INBOX for listing INBOX only when it already exists.
diffstat:
3 files changed, 57 insertions(+), 24 deletions(-)
src/lib-storage/list/mailbox-list-fs-iter.c | 1
src/lib-storage/list/mailbox-list-maildir-iter.c | 78 +++++++++++++++-------
src/lib-storage/mailbox-list.h | 2
diffs (119 lines):
diff -r 80cf689acdb4 -r b56b06cdd1d7 src/lib-storage/list/mailbox-list-fs-iter.c
--- a/src/lib-storage/list/mailbox-list-fs-iter.c Mon Jul 27 18:53:32 2009 -0400
+++ b/src/lib-storage/list/mailbox-list-fs-iter.c Mon Jul 27 18:54:02 2009 -0400
@@ -752,6 +752,7 @@ fs_list_next(struct fs_list_iterate_cont
}
if (!ctx->inbox_found &&
+ (ctx->ctx.flags & MAILBOX_LIST_ITER_NO_AUTO_INBOX) == 0 &&
(ctx->ctx.list->ns->flags & NAMESPACE_FLAG_INBOX) != 0 &&
((ctx->glob != NULL &&
imap_match(ctx->glob, "INBOX") == IMAP_MATCH_YES) ||
diff -r 80cf689acdb4 -r b56b06cdd1d7 src/lib-storage/list/mailbox-list-maildir-iter.c
--- a/src/lib-storage/list/mailbox-list-maildir-iter.c Mon Jul 27 18:53:32 2009 -0400
+++ b/src/lib-storage/list/mailbox-list-maildir-iter.c Mon Jul 27 18:54:02 2009 -0400
@@ -116,6 +116,53 @@ static void maildir_set_children(struct
}
static int
+maildir_fill_inbox(struct maildir_list_iterate_context *ctx,
+ const char *mailbox_name, struct imap_match_glob *glob,
+ bool update_only)
+{
+ const struct mailbox_list_settings *set = &ctx->ctx.list->set;
+ struct mailbox_node *node;
+ enum mailbox_info_flags flags;
+ enum imap_match_result match;
+ bool created;
+ int ret;
+
+ if ((ctx->ctx.flags & MAILBOX_LIST_ITER_NO_AUTO_INBOX) == 0) {
+ /* always show INBOX */
+ } else if (set->inbox_path != NULL &&
+ strcmp(set->inbox_path, set->root_dir) != 0) {
+ /* INBOX doesn't exist, since it wasn't listed */
+ update_only = TRUE;
+ } else {
+ /* INBOX is in Maildir root. show it only if it has already
+ been created */
+ ret = ctx->ctx.list->v.
+ iter_is_mailbox(&ctx->ctx, ctx->dir, "", mailbox_name,
+ MAILBOX_LIST_FILE_TYPE_UNKNOWN, &flags);
+ if (ret < 0)
+ return -1;
+ if (ret == 0)
+ update_only = TRUE;
+ }
+
+ created = FALSE;
+ node = update_only ?
+ mailbox_tree_lookup(ctx->tree_ctx, mailbox_name) :
+ mailbox_tree_get(ctx->tree_ctx, mailbox_name, &created);
+ if (created)
+ node->flags = MAILBOX_NOCHILDREN;
+ else if (node != NULL)
+ node->flags &= ~MAILBOX_NONEXISTENT;
+
+ match = imap_match(glob, mailbox_name);
+ if ((match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) != 0) {
+ if (!update_only)
+ node->flags |= MAILBOX_MATCHED;
+ }
+ return 0;
+}
+
+static int
maildir_fill_readdir(struct maildir_list_iterate_context *ctx,
struct imap_match_glob *glob, bool update_only)
{
@@ -234,31 +281,14 @@ maildir_fill_readdir(struct maildir_list
return -1;
}
- if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
+ if ((ns->flags & NAMESPACE_FLAG_INBOX) == 0)
+ return 0;
+ else {
/* make sure INBOX is listed */
- if (!virtual_names)
- mailbox_name = "INBOX";
- else {
- mailbox_name = mail_namespace_get_vname(ns, mailbox,
- "INBOX");
- }
-
- created = FALSE;
- node = update_only ?
- mailbox_tree_lookup(ctx->tree_ctx, mailbox_name) :
- mailbox_tree_get(ctx->tree_ctx, mailbox_name, &created);
- if (created)
- node->flags = MAILBOX_NOCHILDREN;
- else if (node != NULL)
- node->flags &= ~MAILBOX_NONEXISTENT;
-
- match = imap_match(glob, mailbox_name);
- if ((match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) != 0) {
- if (!update_only)
- node->flags |= MAILBOX_MATCHED;
- }
- }
- return 0;
+ mailbox_name = !virtual_names ? "INBOX" :
+ mail_namespace_get_vname(ns, mailbox, "INBOX");
+ return maildir_fill_inbox(ctx, mailbox_name, glob, update_only);
+ }
}
struct mailbox_list_iterate_context *
diff -r 80cf689acdb4 -r b56b06cdd1d7 src/lib-storage/mailbox-list.h
--- a/src/lib-storage/mailbox-list.h Mon Jul 27 18:53:32 2009 -0400
+++ b/src/lib-storage/mailbox-list.h Mon Jul 27 18:54:02 2009 -0400
@@ -49,6 +49,8 @@ enum mailbox_list_iter_flags {
/* For mailbox_list_iter_init_namespaces(): Skip namespaces that
have alias_for set. */
MAILBOX_LIST_ITER_SKIP_ALIASES = 0x000004,
+ /* Don't list INBOX unless it actually exists */
+ MAILBOX_LIST_ITER_NO_AUTO_INBOX = 0x000008,
/* List only subscribed mailboxes */
MAILBOX_LIST_ITER_SELECT_SUBSCRIBED = 0x000010,
More information about the dovecot-cvs
mailing list