[dovecot-cvs] dovecot/src/imap cmd-list.c,1.44,1.45

cras at dovecot.org cras at dovecot.org
Fri Mar 18 21:46:01 EET 2005


Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv7099

Modified Files:
	cmd-list.c 
Log Message:
We weren't returning "root name" properly with LIST <ref> "".



Index: cmd-list.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-list.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- cmd-list.c	5 Feb 2005 18:07:26 -0000	1.44
+++ cmd-list.c	18 Mar 2005 19:45:59 -0000	1.45
@@ -366,7 +366,11 @@
 	}
 
 	if (*mask == '\0' && !lsub) {
-		/* special request to return the hierarchy delimiter */
+		/* special request to return the hierarchy delimiter and
+		   mailbox root name. Mailbox root name is somewhat strange
+		   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);
 		if (ns == NULL) {
 			const char *empty = "";
@@ -374,9 +378,29 @@
 		}
 
 		if (ns != NULL) {
-			client_send_line(client, t_strconcat(
-				"* LIST (\\Noselect) \"", ns->sep_str,
-				"\" \"\"", NULL));
+			string_t *str = t_str_new(64);
+
+			str_printfa(str, "* LIST (\\Noselect) \"%s\" ",
+				    ns->sep_str);
+			if (*ns->prefix != '\0' && !ns->hidden) {
+				/* public namespace, use it as the root name */
+				imap_quote_append_string(str, ns->prefix,
+							 FALSE);
+			} else {
+				/* private namespace, or empty namespace
+				   prefix. use the mailbox name's first part
+				   as the root. */
+				const char *p = strchr(ref, ns->sep);
+
+				if (p == NULL)
+					str_append(str, "\"\"");
+				else {
+					imap_quote_append_string(str,
+						t_strdup_until(ref, p + 1),
+						FALSE);
+				}
+			}
+			client_send_line(client, str_c(str));
 		}
 		client_send_tagline(cmd, "OK List completed.");
 	} else {



More information about the dovecot-cvs mailing list