[evolution-mapi] Bug #668633 - Newly created folder even shown under Favorites



commit a15f7c1dcdd62ac491d801694eecc7ba400cb6e5
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jan 26 10:46:37 2012 +0100

    Bug #668633 - Newly created folder even shown under Favorites

 src/camel/camel-mapi-store-summary.c    |    6 ++++
 src/camel/camel-mapi-store.c            |   42 ++++++++++++++++++++----------
 src/libexchangemapi/e-mapi-connection.c |   12 ++++++++-
 3 files changed, 45 insertions(+), 15 deletions(-)
---
diff --git a/src/camel/camel-mapi-store-summary.c b/src/camel/camel-mapi-store-summary.c
index 8dbc45e..060f734 100644
--- a/src/camel/camel-mapi-store-summary.c
+++ b/src/camel/camel-mapi-store-summary.c
@@ -147,6 +147,12 @@ store_info_load (CamelStoreSummary *s, FILE *in)
 				g_free (msi->foreign_username);
 				msi->foreign_username = NULL;
 			}
+
+			/* personal folders are not subscribable */
+			if ((msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PERSONAL) != 0) {
+				si->flags &= ~(CAMEL_STORE_INFO_FOLDER_SUBSCRIBED | CAMEL_FOLDER_SUBSCRIBED);
+				msi->camel_folder_flags &= ~(CAMEL_STORE_INFO_FOLDER_SUBSCRIBED | CAMEL_FOLDER_SUBSCRIBED);
+			}
 		}
 
 		g_free (folder_id_str);
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index eb2e29c..40cd702 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -359,10 +359,7 @@ mapi_convert_to_folder_info (CamelMapiStore *store,
 		}
 	}
 
-	if (folder->category == E_MAPI_FOLDER_CATEGORY_PERSONAL)
-		fi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED; /*Set this default for mailbox.*/
-
-	if (folder->child_count <=0)
+	if (folder->child_count <= 0)
 		fi->flags |= CAMEL_FOLDER_NOCHILDREN;
 	/*
 	   parent_hash contains the "parent id <-> folder id" combination. So we form
@@ -493,7 +490,6 @@ mapi_folders_sync (CamelMapiStore *store, guint32 flags, GCancellable *cancellab
 		   them from an automatic removal */
 		if (((msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC) == 0 &&
 		    (msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_FOREIGN) == 0) ||
-		    (msi->info.flags & CAMEL_FOLDER_SUBSCRIBED) == 0 ||
 		    (msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC_REAL) != 0)
 			g_hash_table_insert (old_cache_folders, g_strdup (camel_store_info_path (store->summary, msi)), GINT_TO_POINTER (1));
 
@@ -749,14 +745,15 @@ mapi_get_folder_info_offline (CamelStore *store, const gchar *top,
 
 		/* Allow Mailbox and Favourites (Subscribed public folders) */
 		if (subscribed &&
-		    ((si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) == 0 ||
+		    (((si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) == 0 &&
+		     (msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PERSONAL) == 0) ||
 		    (!subscription_list && (msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC_REAL) != 0))) {
 			camel_store_summary_info_free (mapi_store->summary, si);
 			continue;
 		}
 
 		if (!subscription_list &&
-		    !(msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_MAIL) &&
+		    (msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_MAIL) == 0 &&
 		    (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) != 0 &&
 		    ((msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC) != 0 ||
 		     (msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_FOREIGN) != 0)) {
@@ -1656,6 +1653,15 @@ mapi_store_subscribe_folder_sync (CamelSubscribable *subscribable,
 	}
 
 	msi = (CamelMapiStoreInfo *) si;
+	if ((msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC) == 0) {
+		/* this is not a public folder, but MAPI supports subscribtions
+		   only on public folders, thus report success
+		*/
+
+		camel_store_summary_info_free (mapi_store->summary, si);
+
+		return TRUE;
+	}
 
 	path = g_strconcat (DISPLAY_NAME_FAVORITES, "/", use_folder_name, NULL);
 	si2 = camel_store_summary_path (mapi_store->summary, path);
@@ -1768,16 +1774,22 @@ mapi_store_unsubscribe_folder_sync (CamelSubscribable *subscribable,
 		CamelStoreInfo *si2 = camel_mapi_store_summary_get_folder_id (mapi_store->summary, msi->folder_id);
 
 		if (si2) {
+			CamelMapiStoreInfo *msi2 = (CamelMapiStoreInfo *) si2;
+
 			fi = mapi_build_folder_info (mapi_store, NULL, camel_store_info_path (mapi_store->summary, si2));
 			camel_subscribable_folder_unsubscribed (subscribable, fi);
 			camel_folder_info_free (fi);
 
-			/* remove also frees 'si2' */
-			camel_store_summary_remove (mapi_store->summary, si2);
-			camel_store_summary_touch (mapi_store->summary);
-			camel_store_summary_save (mapi_store->summary);
+			if ((msi2->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC) != 0 &&
+			    (msi2->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC_REAL) == 0) {
+				/* remove calls also free on 'si2' */
+				camel_store_summary_remove (mapi_store->summary, si2);
+				camel_store_summary_touch (mapi_store->summary);
+			} else {
+				camel_store_summary_info_free (mapi_store->summary, si2);
+			}
 		} else {
-			g_debug ("%s: Failed to find subscribed by folder ID\n", G_STRFUNC);
+			g_debug ("%s: Failed to find subscribed by folder ID", G_STRFUNC);
 		}
 	} else {
 		CamelSettings *settings;
@@ -1794,15 +1806,17 @@ mapi_store_unsubscribe_folder_sync (CamelSubscribable *subscribable,
 			error);
 	}
 
-	if ((msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC_REAL) == 0) {
+	if ((msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC) != 0 &&
+	    (msi->mapi_folder_flags & CAMEL_MAPI_STORE_FOLDER_FLAG_PUBLIC_REAL) == 0) {
 		/* remove calls also free on 'si' */
 		camel_store_summary_remove (mapi_store->summary, si);
 		camel_store_summary_touch (mapi_store->summary);
-		camel_store_summary_save (mapi_store->summary);
 	} else {
 		camel_store_summary_info_free (mapi_store->summary, si);
 	}
 
+	camel_store_summary_save (mapi_store->summary);
+
 	return res;
 }
 
diff --git a/src/libexchangemapi/e-mapi-connection.c b/src/libexchangemapi/e-mapi-connection.c
index b302783..617edc3 100644
--- a/src/libexchangemapi/e-mapi-connection.c
+++ b/src/libexchangemapi/e-mapi-connection.c
@@ -4632,6 +4632,9 @@ emc_open_folders (EMapiConnection *conn,
 
 	LOCK ();
 
+	mapi_object_init (obj_child_folder);
+	mapi_object_init (obj_parent_folder);
+
 	ms = OpenFolder (obj_store, child_fid, obj_child_folder);
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "OpenFolder-1", ms);
@@ -4641,6 +4644,7 @@ emc_open_folders (EMapiConnection *conn,
 	if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {
 		ms = MAPI_E_USER_CANCEL;
 		mapi_object_release (obj_child_folder);
+		mapi_object_init (obj_child_folder);
 		goto cleanup;
 	}
 
@@ -4649,12 +4653,14 @@ emc_open_folders (EMapiConnection *conn,
 		ms = MAPI_E_CALL_FAILED;
 		make_mapi_error (perror, "GetFolderProperties", ms);
 		mapi_object_release (obj_child_folder);
+		mapi_object_init (obj_child_folder);
 		goto cleanup;
 	}
 
 	if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {
 		ms = MAPI_E_USER_CANCEL;
 		mapi_object_release (obj_child_folder);
+		mapi_object_init (obj_child_folder);
 		goto cleanup;
 	}
 
@@ -4662,6 +4668,7 @@ emc_open_folders (EMapiConnection *conn,
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "OpenFolder-2", ms);
 		mapi_object_release (obj_child_folder);
+		mapi_object_init (obj_child_folder);
 		goto cleanup;
 	}
 
@@ -4702,10 +4709,13 @@ e_mapi_connection_remove_folder (EMapiConnection *conn,
 
 	LOCK ();
 
+	mapi_object_init (&obj_folder);
+	mapi_object_init (&obj_parent);
+
 	if (!emc_open_folders (conn, obj_store, fid_to_remove, &obj_folder, &obj_parent, cancellable, perror)) {
 		ms = MAPI_E_CALL_FAILED;
 		make_mapi_error (perror, "emc_open_folders", ms);
-		
+		goto cleanup;
 	}
 
 	if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]