dovecot: Code cleanups

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 27 20:21:04 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/3704fe78f2f9
changeset: 5806:3704fe78f2f9
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 27 16:51:59 2007 +0300
description:
Code cleanups

diffstat:

1 file changed, 31 insertions(+), 15 deletions(-)
src/imap/cmd-list.c |   46 +++++++++++++++++++++++++++++++---------------

diffs (63 lines):

diff -r 3fd09104fd77 -r 3704fe78f2f9 src/imap/cmd-list.c
--- a/src/imap/cmd-list.c	Wed Jun 27 16:38:07 2007 +0300
+++ b/src/imap/cmd-list.c	Wed Jun 27 16:51:59 2007 +0300
@@ -104,6 +104,34 @@ list_namespace_inbox(struct client *clie
 	}
 }
 
+static bool
+list_insert_ns_prefix(string_t *name_str, struct cmd_list_context *ctx,
+		      struct mailbox_info *info)
+{
+	if (strcasecmp(info->name, "INBOX") != 0) {
+		/* non-INBOX always has prefix */
+	} else if (!ctx->ns->inbox) {
+		/* INBOX from non-INBOX namespace. */
+		if (*ctx->ns->prefix == '\0') {
+			/* no namespace prefix, we can't list this */
+			return FALSE;
+		}
+	} else if (!ctx->match_inbox) {
+		/* The mask doesn't match INBOX (eg. prefix.%).
+		   We still want to list prefix.INBOX if it has
+		   children. Otherwise we don't want to list
+		   this INBOX at all. */
+		if ((info->flags & MAILBOX_CHILDREN) == 0)
+			return FALSE;
+	} else {
+		/* Listing INBOX from inbox=yes namespace.
+		   Don't insert the namespace prefix. */
+		return TRUE;
+	}
+	str_append(name_str, ctx->ns->prefix);
+	return TRUE;
+}
+
 static int
 list_namespace_mailboxes(struct client *client, struct cmd_list_context *ctx)
 {
@@ -122,21 +150,9 @@ list_namespace_mailboxes(struct client *
 	name_str = t_str_new(256);
 	while ((info = mailbox_list_iter_next(ctx->list_iter)) != NULL) {
 		str_truncate(name_str, 0);
-		if (ctx->ns->inbox && strcasecmp(info->name, "INBOX") == 0) {
-			/* Listing INBOX from inbox=yes namespace.
-			   Don't insert the namespace prefix. */
-			if (!ctx->match_inbox) {
-				/* The mask doesn't match INBOX (eg. prefix.%).
-				   We still want to list prefix.INBOX if it has
-				   children. Otherwise we don't want to list
-				   this INBOX at all. */
-				if ((info->flags & MAILBOX_CHILDREN) == 0)
-					continue;
-				str_append(name_str, ctx->ns->prefix);
-			}
-		} else {
-			str_append(name_str, ctx->ns->prefix);
-		}
+
+		if (!list_insert_ns_prefix(name_str, ctx, info))
+			continue;
 		str_append(name_str, info->name);
 
 		if (ctx->ns->sep != ctx->ns->real_sep) {


More information about the dovecot-cvs mailing list