dovecot-2.0: doveadm: Ignore non-selectable mailboxes for most c...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 21 17:46:24 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/08b879b79236
changeset: 11592:08b879b79236
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 21 15:46:21 2010 +0100
description:
doveadm: Ignore non-selectable mailboxes for most commands.

diffstat:

 src/doveadm/doveadm-mail-list-iter.c |  19 +++++++++++++++++++
 src/doveadm/doveadm-mail-list-iter.h |   6 ++++++
 src/doveadm/doveadm-mail-mailbox.c   |   3 ++-
 3 files changed, 27 insertions(+), 1 deletions(-)

diffs (83 lines):

diff -r 4e54843f11d0 -r 08b879b79236 src/doveadm/doveadm-mail-list-iter.c
--- a/src/doveadm/doveadm-mail-list-iter.c	Mon Jun 21 15:34:48 2010 +0100
+++ b/src/doveadm/doveadm-mail-list-iter.c	Mon Jun 21 15:46:21 2010 +0100
@@ -13,6 +13,7 @@
 	enum mailbox_list_iter_flags iter_flags;
 
 	struct mailbox_list_iterate_context *iter;
+	bool only_selectable;
 };
 
 static int
@@ -72,6 +73,7 @@
 	}
 	(void)array_append_space(&patterns);
 
+	iter->only_selectable = TRUE;
 	iter->iter_flags = iter_flags;
 	iter->iter = mailbox_list_iter_init_namespaces(user->namespaces,
 						       array_idx(&patterns, 0),
@@ -80,6 +82,18 @@
 	return iter;
 }
 
+struct doveadm_mail_list_iter *
+doveadm_mail_list_iter_full_init(struct mail_user *user,
+				 struct mail_search_args *search_args,
+				 enum mailbox_list_iter_flags iter_flags)
+{
+	struct doveadm_mail_list_iter *iter;
+
+	iter = doveadm_mail_list_iter_init(user, search_args, iter_flags);
+	iter->only_selectable = FALSE;
+	return iter;
+}
+
 void doveadm_mail_list_iter_deinit(struct doveadm_mail_list_iter **_iter)
 {
 	struct doveadm_mail_list_iter *iter = *_iter;
@@ -98,6 +112,11 @@
 	unsigned int len;
 
 	while ((info = mailbox_list_iter_next(iter->iter)) != NULL) {
+		if ((info->flags & (MAILBOX_NOSELECT |
+				    MAILBOX_NONEXISTENT)) != 0) {
+			if (iter->only_selectable)
+				continue;
+		}
 		len = strlen(info->name);
 		if (len > 0 && info->name[len-1] == info->ns->sep) {
 			/* when listing "foo/%" it lists "foo/". skip it. */
diff -r 4e54843f11d0 -r 08b879b79236 src/doveadm/doveadm-mail-list-iter.h
--- a/src/doveadm/doveadm-mail-list-iter.h	Mon Jun 21 15:34:48 2010 +0100
+++ b/src/doveadm/doveadm-mail-list-iter.h	Mon Jun 21 15:46:21 2010 +0100
@@ -1,10 +1,16 @@
 #ifndef DOVEADM_MAIL_LIST_ITER_H
 #define DOVEADM_MAIL_LIST_ITER_H
 
+/* List only selectable mailboxes */
 struct doveadm_mail_list_iter *
 doveadm_mail_list_iter_init(struct mail_user *user,
 			    struct mail_search_args *search_args,
 			    enum mailbox_list_iter_flags iter_flags);
+/* List all mailboxes */
+struct doveadm_mail_list_iter *
+doveadm_mail_list_iter_full_init(struct mail_user *user,
+				 struct mail_search_args *search_args,
+				 enum mailbox_list_iter_flags iter_flags);
 void doveadm_mail_list_iter_deinit(struct doveadm_mail_list_iter **iter);
 
 const struct mailbox_info *
diff -r 4e54843f11d0 -r 08b879b79236 src/doveadm/doveadm-mail-mailbox.c
--- a/src/doveadm/doveadm-mail-mailbox.c	Mon Jun 21 15:34:48 2010 +0100
+++ b/src/doveadm/doveadm-mail-mailbox.c	Mon Jun 21 15:46:21 2010 +0100
@@ -120,7 +120,8 @@
 	if (ctx->ctx.subscriptions)
 		iter_flags |= MAILBOX_LIST_ITER_SELECT_SUBSCRIBED;
 
-	iter = doveadm_mail_list_iter_init(user, ctx->search_args, iter_flags);
+	iter = doveadm_mail_list_iter_full_init(user, ctx->search_args,
+						iter_flags);
 	while ((info = doveadm_mail_list_iter_next(iter)) != NULL) {
 		str_truncate(str, 0);
 		if (ctx->mutf7 || imap_utf7_to_utf8(info->name, str) < 0)


More information about the dovecot-cvs mailing list