[evolution-data-server] CamelSubscribable: Connect before [un]subscribing.



commit b7d300b2976545bf511b441beb538d502c644dbe
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Jul 8 12:16:54 2012 -0400

    CamelSubscribable: Connect before [un]subscribing.

 camel/camel-subscribable.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/camel/camel-subscribable.c b/camel/camel-subscribable.c
index 1e82529..ceb18d0 100644
--- a/camel/camel-subscribable.c
+++ b/camel/camel-subscribable.c
@@ -373,12 +373,16 @@ camel_subscribable_subscribe_folder_sync (CamelSubscribable *subscribable,
 
 	/* Check for cancellation after locking. */
 	if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
-		camel_store_unlock (
-			CAMEL_STORE (subscribable),
-			CAMEL_STORE_FOLDER_LOCK);
-		return FALSE;
+		success = FALSE;
+		goto exit;
 	}
 
+	/* Need to establish a connection before subscribing. */
+	success = camel_service_connect_sync (
+		CAMEL_SERVICE (subscribable), cancellable, error);
+	if (!success)
+		goto exit;
+
 	message = _("Subscribing to folder '%s'");
 	camel_operation_push_message (cancellable, message, folder_name);
 
@@ -389,6 +393,7 @@ camel_subscribable_subscribe_folder_sync (CamelSubscribable *subscribable,
 
 	camel_operation_pop_message (cancellable);
 
+exit:
 	camel_store_unlock (
 		CAMEL_STORE (subscribable),
 		CAMEL_STORE_FOLDER_LOCK);
@@ -500,12 +505,16 @@ camel_subscribable_unsubscribe_folder_sync (CamelSubscribable *subscribable,
 
 	/* Check for cancellation after locking. */
 	if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
-		camel_store_unlock (
-			CAMEL_STORE (subscribable),
-			CAMEL_STORE_FOLDER_LOCK);
-		return FALSE;
+		success = FALSE;
+		goto exit;
 	}
 
+	/* Need to establish a connection before unsubscribing. */
+	success = camel_service_connect_sync (
+		CAMEL_SERVICE (subscribable), cancellable, error);
+	if (!success)
+		goto exit;
+
 	message = _("Unsubscribing from folder '%s'");
 	camel_operation_push_message (cancellable, message, folder_name);
 
@@ -520,6 +529,7 @@ camel_subscribable_unsubscribe_folder_sync (CamelSubscribable *subscribable,
 
 	camel_operation_pop_message (cancellable);
 
+exit:
 	camel_store_unlock (
 		CAMEL_STORE (subscribable),
 		CAMEL_STORE_FOLDER_LOCK);



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