changeset 3876:a291d41bc50d HEAD

Fixes to returning namespace root with "" mask.
author Timo Sirainen <tss@iki.fi>
date Sat, 14 Jan 2006 19:10:02 +0200
parents e5abc07d843f
children 0d0fad3fb5e9
files src/imap/cmd-list.c src/imap/namespace.c src/imap/namespace.h
diffstat 3 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-list.c	Sat Jan 14 18:48:52 2006 +0200
+++ b/src/imap/cmd-list.c	Sat Jan 14 19:10:02 2006 +0200
@@ -444,7 +444,7 @@
 		   concept which probably no other client uses than Pine.
 		   Just try our best to emulate UW-IMAP behavior and hopefully
 		   we're fine. */
-		ns = namespace_find(client->namespaces, &ref);
+		ns = namespace_find_visible(client->namespaces, &ref);
 		if (ns == NULL) {
 			const char *empty = "";
 			ns = namespace_find(client->namespaces, &empty);
--- a/src/imap/namespace.c	Sat Jan 14 18:48:52 2006 +0200
+++ b/src/imap/namespace.c	Sat Jan 14 19:10:02 2006 +0200
@@ -193,9 +193,12 @@
 	return ret;
 }
 
-struct namespace *
-namespace_find(struct namespace *namespaces, const char **mailbox)
+static struct namespace *
+namespace_find_int(struct namespace *namespaces, const char **mailbox,
+		   int show_hidden)
 {
+#define CHECK_VISIBILITY(ns, show_hidden) \
+	((!(ns)->hidden) || (show_hidden))
         struct namespace *ns = namespaces;
 	const char *box = *mailbox;
 	struct namespace *best = NULL;
@@ -207,7 +210,7 @@
 		/* find the INBOX namespace */
 		*mailbox = "INBOX";
 		while (ns != NULL) {
-			if (ns->inbox)
+			if (ns->inbox && CHECK_VISIBILITY(ns, show_hidden))
 				return ns;
 			if (*ns->prefix == '\0')
 				best = ns;
@@ -220,7 +223,8 @@
 		if (ns->prefix_len >= best_len &&
 		    (strncmp(ns->prefix, box, ns->prefix_len) == 0 ||
 		     (inbox && strncmp(ns->prefix, "INBOX", 5) == 0 &&
-		      strncmp(ns->prefix+5, box+5, ns->prefix_len-5) == 0))) {
+		      strncmp(ns->prefix+5, box+5, ns->prefix_len-5) == 0)) &&
+		    CHECK_VISIBILITY(ns, show_hidden)) {
 			best = ns;
 			best_len = ns->prefix_len;
 		}
@@ -237,3 +241,15 @@
 
 	return best;
 }
+
+struct namespace *
+namespace_find(struct namespace *namespaces, const char **mailbox)
+{
+	return namespace_find_int(namespaces, mailbox, TRUE);
+}
+
+struct namespace *
+namespace_find_visible(struct namespace *namespaces, const char **mailbox)
+{
+	return namespace_find_int(namespaces, mailbox, FALSE);
+}
--- a/src/imap/namespace.h	Sat Jan 14 18:48:52 2006 +0200
+++ b/src/imap/namespace.h	Sat Jan 14 19:10:02 2006 +0200
@@ -27,5 +27,7 @@
 
 struct namespace *
 namespace_find(struct namespace *namespaces, const char **mailbox);
+struct namespace *
+namespace_find_visible(struct namespace *namespaces, const char **mailbox);
 
 #endif