[dovecot-cvs] dovecot/src/imap cmd-list.c,1.32,1.33

cras at procontrol.fi cras at procontrol.fi
Tue Nov 25 14:50:30 EET 2003


Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv24928

Modified Files:
	cmd-list.c 
Log Message:
LSUB should never show \HasChildren flags.



Index: cmd-list.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-list.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- cmd-list.c	17 Nov 2003 18:03:21 -0000	1.32
+++ cmd-list.c	25 Nov 2003 12:50:28 -0000	1.33
@@ -8,26 +8,31 @@
 #include "commands.h"
 #include "namespace.h"
 
+enum {
+	_MAILBOX_LIST_HIDE_CHILDREN	= 0x1000000,
+	_MAILBOX_LIST_LISTEXT		= 0x0800000
+};
+
 static const char *
-mailbox_flags2str(enum mailbox_flags flags, enum mailbox_list_flags list_flags,
-		  int listext)
+mailbox_flags2str(enum mailbox_flags flags, enum mailbox_list_flags list_flags)
 {
 	const char *str;
 
 	if (flags & MAILBOX_PLACEHOLDER) {
 		i_assert((flags & ~MAILBOX_CHILDREN) == MAILBOX_PLACEHOLDER);
 
-		if (!listext)
+		if ((list_flags & _MAILBOX_LIST_LISTEXT) == 0)
 			flags = MAILBOX_NOSELECT;
 		flags |= MAILBOX_CHILDREN;
 	}
-	if ((flags & MAILBOX_NONEXISTENT) != 0 && !listext)
+	if ((flags & MAILBOX_NONEXISTENT) != 0 &&
+	    (list_flags & _MAILBOX_LIST_LISTEXT) == 0) {
 		flags |= MAILBOX_NOSELECT;
+		flags &= ~MAILBOX_NONEXISTENT;
+	}
 
-	if (listext && (list_flags & MAILBOX_LIST_CHILDREN) == 0) {
-		/* LISTEXT used and we didn't want children info */
+	if ((list_flags & _MAILBOX_LIST_HIDE_CHILDREN) != 0)
 		flags &= ~(MAILBOX_CHILDREN|MAILBOX_NOCHILDREN);
-	}
 
 	str = t_strconcat(
 		(flags & MAILBOX_NOSELECT) ? " \\Noselect" : "",
@@ -45,7 +50,7 @@
 
 static int mailbox_list(struct client *client, struct mail_storage *storage,
 			const char *mask, const char *sep, const char *reply,
-			enum mailbox_list_flags list_flags, int listext)
+			enum mailbox_list_flags list_flags)
 {
 	struct mailbox_list_context *ctx;
 	struct mailbox_list *list;
@@ -59,7 +64,7 @@
 	while ((list = storage->list_mailbox_next(ctx)) != NULL) {
 		str_truncate(str, 0);
 		str_printfa(str, "* %s (%s) \"%s\" ", reply,
-			    mailbox_flags2str(list->flags, list_flags, listext),
+			    mailbox_flags2str(list->flags, list_flags),
 			    sep);
 		if (strcasecmp(list->name, "INBOX") == 0)
 			str_append(str, "INBOX");
@@ -107,25 +112,29 @@
         enum mailbox_list_flags list_flags;
 	const char *ref, *mask;
 	char sep_chr, sep[3];
-	int failed, listext;
+	int failed;
 
 	/* [(<options>)] <reference> <mailbox wildcards> */
 	if (!client_read_args(client, 0, 0, &args))
 		return FALSE;
 
-	listext = FALSE;
-	if (lsub)
-		list_flags = MAILBOX_LIST_SUBSCRIBED | MAILBOX_LIST_FAST_FLAGS;
-	else {
+	if (lsub) {
+		/* LSUB - we don't care about flags */
+		list_flags = MAILBOX_LIST_SUBSCRIBED | MAILBOX_LIST_FAST_FLAGS |
+			_MAILBOX_LIST_HIDE_CHILDREN;
+	} else if (args[0].type != IMAP_ARG_LIST) {
+		/* LIST - allow children flags, but don't require them */
 		list_flags = 0;
-		if (args[0].type == IMAP_ARG_LIST) {
-			listext = TRUE;
-			if (!parse_list_flags(client,
-					      IMAP_ARG_LIST(&args[0])->args,
-					      &list_flags))
-				return TRUE;
-			args++;
-		}
+	} else {
+		list_flags = _MAILBOX_LIST_LISTEXT;
+		if (!parse_list_flags(client, IMAP_ARG_LIST(&args[0])->args,
+				      &list_flags))
+			return TRUE;
+		args++;
+
+		/* don't show children flags unless explicitly specified */
+		if ((list_flags & MAILBOX_LIST_CHILDREN) == 0)
+			list_flags |= _MAILBOX_LIST_HIDE_CHILDREN;
 	}
 
 	ref = imap_arg_string(&args[0]);
@@ -176,8 +185,7 @@
 		}
 
 		failed = !mailbox_list(client, storage, mask, sep,
-				       lsub ? "LSUB" : "LIST",
-				       list_flags, listext);
+				       lsub ? "LSUB" : "LIST", list_flags);
 	}
 
 	if (failed)



More information about the dovecot-cvs mailing list