--- evolution-data-server-1.1.5/camel/providers/imap/camel-imap-provider.c.sd	2004-12-06 07:43:07.000000000 +0000
+++ evolution-data-server-1.1.5/camel/providers/imap/camel-imap-provider.c	2005-02-09 22:16:43.000000000 +0000
@@ -55,6 +55,8 @@ CamelProviderConfEntry imap_conf_entries
 	{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
 	  N_("Folders") },
 	{ CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL,
+	  N_("Use list of subscribed folders"), "1" },
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "show_only_sub", "use_lsub",
 	  N_("_Show only subscribed folders"), "1" },
 	{ CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL,
 	  N_("O_verride server-supplied folder namespace"), "0" },
--- evolution-data-server-1.1.5/camel/providers/imap/camel-imap-store.c.sd	2005-02-04 03:09:23.000000000 +0000
+++ evolution-data-server-1.1.5/camel/providers/imap/camel-imap-store.c	2005-02-09 22:15:38.000000000 +0000
@@ -259,6 +259,8 @@ construct (CamelService *service, CamelS
 	imap_store->parameters = 0;
 	if (camel_url_get_param (url, "use_lsub"))
 		store->flags |= CAMEL_STORE_SUBSCRIPTIONS;
+	if (camel_url_get_param (url, "show_only_sub"))
+		imap_store->parameters |= IMAP_PARAM_SHOW_ONLY_SUB;
 	if (camel_url_get_param (url, "namespace")) {
 		imap_store->parameters |= IMAP_PARAM_OVERRIDE_NAMESPACE;
 		g_free(imap_store->namespace);
@@ -2519,6 +2521,8 @@ get_subscribed_folders (CamelImapStore *
 		if (!fi)
 			continue;
 
+		fi->flags |= CAMEL_FOLDER_SUBSCRIBED;
+
 		if (!imap_is_subfolder(fi->full_name, top)) {
 			camel_folder_info_free (fi);
 			continue;
@@ -2579,12 +2583,37 @@ get_folders_online (CamelImapStore *imap
 		list = response->untagged->pdata[i];
 		fi = parse_list_response_as_folder_info (imap_store, list);
 		if (fi) {
+			if (lsub)
+				fi->flags |= CAMEL_FOLDER_SUBSCRIBED;
 			g_ptr_array_add(folders, fi);
 			g_hash_table_insert(present, fi->full_name, fi);
 		}
 	}
 	camel_imap_response_free (imap_store, response);
 
+	/* If we're not asked for only subscribed folders, but subscriptions are available,
+	   issue LSUB _too_ and set CAMEL_FOLDER_SUBSCRIBED flag where appropriate */
+	if (!lsub && (CAMEL_STORE(imap_store)->flags & CAMEL_STORE_SUBSCRIPTIONS)) {
+		response = camel_imap_command (imap_store, NULL, ex,
+					       "%s \"\" %S", "LSUB", pattern);
+		if (!response)
+			goto out;
+
+		for (i = 0; i < response->untagged->len; i++) {
+			CamelFolderInfo *fi2;
+			list = response->untagged->pdata[i];
+			fi = parse_list_response_as_folder_info (imap_store, list);
+
+			/* Look up the original from the hash table and mark it subscribed. */
+			fi2 = g_hash_table_lookup(present, fi->full_name);
+			if (fi2)
+				fi2->flags |= CAMEL_FOLDER_SUBSCRIBED;
+
+			camel_folder_info_free(fi);
+		}
+		camel_imap_response_free (imap_store, response);
+	}
+
 	/* update our summary to match the server */
 	count = camel_store_summary_count((CamelStoreSummary *)imap_store->summary);
 	for (i=0;i<count;i++) {
@@ -2614,6 +2643,7 @@ get_folders_online (CamelImapStore *imap
 		}
 		camel_store_summary_info_free((CamelStoreSummary *)imap_store->summary, si);
 	}
+out:
 	g_hash_table_destroy(present);
 }
 
@@ -2696,9 +2726,13 @@ get_folder_counts(CamelImapStore *imap_s
 		q = g_slist_remove_link(q, q);
 
 		while (fi) {
-			/* ignore noselect folders, and check only inbox if we only check inbox */
+			/* ignore noselect folders, and show other folders if one of the following is true:
+                           - We are set to check all folders.
+                           - The folder is the INBOX.
+                           - The folder is a subscribed folder, we're set to use subscriptions but not to show only subscribed folders */
 			if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0
 			    && ( (imap_store->parameters & IMAP_PARAM_CHECK_ALL)
+				 || ((CAMEL_STORE(imap_store)->flags & CAMEL_STORE_SUBSCRIPTIONS) && !(imap_store->parameters & IMAP_PARAM_SHOW_ONLY_SUB) && (fi->flags & CAMEL_FOLDER_SUBSCRIBED))
 				 || g_ascii_strcasecmp(fi->full_name, "inbox") == 0) ) {
 
 				/* For the current folder, poke it to check for new	
@@ -2877,7 +2911,8 @@ get_folders(CamelStore *store, const cha
 	folders = g_ptr_array_new();
 	
 	/* first get working list of names */
-	get_folders_online (imap_store, name[0]?name:"%", folders, flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, ex);
+	get_folders_online (imap_store, name[0]?name:"%", folders,
+			    (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) && (imap_store->parameters & IMAP_PARAM_SHOW_ONLY_SUB), ex);
 	if (camel_exception_is_set(ex))
 		goto fail;
 	for (i=0; i<folders->len && !haveinbox; i++) {
@@ -2887,7 +2922,7 @@ get_folders(CamelStore *store, const cha
 
 	if (!haveinbox && top == imap_store->namespace) {
 		get_folders_online (imap_store, "INBOX", folders,
-				    flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, ex);
+				    (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) && (imap_store->parameters & IMAP_PARAM_SHOW_ONLY_SUB), ex);
 		
 		if (camel_exception_is_set (ex))
 			goto fail;
@@ -2922,7 +2957,7 @@ get_folders(CamelStore *store, const cha
 
 				real = camel_imap_store_summary_full_from_path(imap_store->summary, fi->full_name);
 				n = imap_concat(imap_store, real?real:fi->full_name, "%");
-				get_folders_online(imap_store, n, folders, flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, ex);
+				get_folders_online(imap_store, n, folders, (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) && (imap_store->parameters & IMAP_PARAM_SHOW_ONLY_SUB), ex);
 				g_free(n);
 				g_free(real);
 				
@@ -2969,7 +3004,7 @@ get_folder_info_online (CamelStore *stor
 
 	CAMEL_SERVICE_LOCK(store, connect_lock);
 
-	if ((flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)
+	if (((flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) && (imap_store->parameters & IMAP_PARAM_SHOW_ONLY_SUB))
 	    && !(imap_store->capabilities & IMAP_CAPABILITY_useful_lsub)
 	    && (imap_store->parameters & IMAP_PARAM_CHECK_ALL))
 		folders = get_subscribed_folders(imap_store, top, ex);
--- evolution-data-server-1.1.5/camel/providers/imap/camel-imap-store.h.sd	2005-02-04 03:09:23.000000000 +0000
+++ evolution-data-server-1.1.5/camel/providers/imap/camel-imap-store.h	2005-02-09 22:15:38.000000000 +0000
@@ -102,6 +102,7 @@ typedef enum {
 #define IMAP_PARAM_FILTER_INBOX			(1 << 2)
 #define IMAP_PARAM_FILTER_JUNK			(1 << 3)
 #define IMAP_PARAM_FILTER_JUNK_INBOX		(1 << 4)
+#define IMAP_PARAM_SHOW_ONLY_SUB		(1 << 5)
 
 struct _CamelImapStore {
 	CamelDiscoStore parent_object;	
