[evolution] Adapt to CamelService API changes.



commit 98f39d7ee0581aaa28c33564d9d6b27aa23028fa
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat May 19 11:11:58 2012 -0400

    Adapt to CamelService API changes.
    
    em_utils_connect_service_sync() and em_utils_disconnect_service_sync()
    are no longer needed.  CamelService itself now effectively does what
    these functions were doing.

 libemail-engine/e-mail-session-utils.c |    8 ++---
 libemail-engine/e-mail-session.c       |    6 ++--
 libemail-engine/e-mail-store-utils.c   |   13 +++----
 libemail-engine/e-mail-utils.c         |   58 --------------------------------
 libemail-engine/e-mail-utils.h         |    8 ----
 libemail-engine/mail-ops.c             |   12 +++---
 mail/em-folder-utils.c                 |    4 +-
 modules/mail/e-mail-shell-view.c       |    4 +-
 8 files changed, 22 insertions(+), 91 deletions(-)
---
diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c
index 403ba57..de1dec1 100644
--- a/libemail-engine/e-mail-session-utils.c
+++ b/libemail-engine/e-mail-session-utils.c
@@ -426,8 +426,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
 		if (status != CAMEL_SERVICE_CONNECTED) {
 			did_connect = TRUE;
 
-			/* XXX This API does not allow for cancellation. */
-			em_utils_connect_service_sync (
+			camel_service_connect_sync (
 				service, cancellable, &error);
 
 			if (error != NULL) {
@@ -447,7 +446,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
 			context->recipients, cancellable, &error);
 
 		if (did_connect)
-			em_utils_disconnect_service_sync (
+			camel_service_disconnect_sync (
 				service, error == NULL,
 				cancellable, error ? NULL : &error);
 
@@ -896,9 +895,8 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session,
 	message = _("Unsubscribing from folder '%s'");
 	camel_operation_push_message (cancellable, message, folder_name);
 
-	/* FIXME This should take our GCancellable. */
 	success =
-		em_utils_connect_service_sync (
+		camel_service_connect_sync (
 			CAMEL_SERVICE (store), cancellable, error) &&
 		camel_subscribable_unsubscribe_folder_sync (
 			CAMEL_SUBSCRIBABLE (store),
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c
index 475f802..bc72e98 100644
--- a/libemail-engine/e-mail-session.c
+++ b/libemail-engine/e-mail-session.c
@@ -695,7 +695,7 @@ mail_session_add_vfolder_store (EMailSession *session)
 	g_return_if_fail (CAMEL_IS_SERVICE (service));
 
 	camel_service_set_display_name (service, _("Search Folders"));
-	em_utils_connect_service_sync (service, NULL, NULL);
+	camel_service_connect_sync (service, NULL, NULL);
 
 	/* XXX There's more configuration to do in vfolder_load_storage()
 	 *     but it requires an EMailBackend, which we don't have access
@@ -1710,7 +1710,7 @@ e_mail_session_get_inbox_sync (EMailSession *session,
 	if (!CAMEL_IS_STORE (service))
 		return NULL;
 
-	if (!em_utils_connect_service_sync (service, cancellable, error))
+	if (!camel_service_connect_sync (service, cancellable, error))
 		return NULL;
 
 	return camel_store_get_inbox_folder_sync (
@@ -1809,7 +1809,7 @@ e_mail_session_get_trash_sync (EMailSession *session,
 	if (!CAMEL_IS_STORE (service))
 		return NULL;
 
-	if (!em_utils_connect_service_sync (service, cancellable, error))
+	if (!camel_service_connect_sync (service, cancellable, error))
 		return NULL;
 
 	return camel_store_get_trash_folder_sync (
diff --git a/libemail-engine/e-mail-store-utils.c b/libemail-engine/e-mail-store-utils.c
index 9719c0d..bfb1ed5 100644
--- a/libemail-engine/e-mail-store-utils.c
+++ b/libemail-engine/e-mail-store-utils.c
@@ -180,7 +180,8 @@ mail_store_go_offline_thread (GSimpleAsyncResult *simple,
 				disco_store, CAMEL_DISCO_STORE_OFFLINE,
 				cancellable, &error);
 		else
-			em_utils_disconnect_service_sync (service, TRUE, cancellable, &error);
+			camel_service_disconnect_sync (
+				service, TRUE, cancellable, &error);
 
 	} else if (CAMEL_IS_OFFLINE_STORE (store)) {
 		CamelOfflineStore *offline_store;
@@ -190,8 +191,10 @@ mail_store_go_offline_thread (GSimpleAsyncResult *simple,
 		camel_offline_store_set_online_sync (
 			offline_store, FALSE, cancellable, &error);
 
-	} else
-		em_utils_disconnect_service_sync (service, TRUE, cancellable, &error);
+	} else {
+		camel_service_disconnect_sync (
+			service, TRUE, cancellable, &error);
+	}
 
 	if (error != NULL)
 		g_simple_async_result_take_error (simple, error);
@@ -210,10 +213,6 @@ e_mail_store_go_offline (CamelStore *store,
 
 	g_return_if_fail (CAMEL_IS_STORE (store));
 
-	/* Cancel any pending connect first so the set_offline_op
-	 * thread won't get queued behind a hung connect op. */
-	camel_service_cancel_connect (CAMEL_SERVICE (store));
-
 	simple = g_simple_async_result_new (
 		G_OBJECT (store), callback,
 		user_data, e_mail_store_go_offline);
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index d9eee72..61ef8d6 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -1001,64 +1001,6 @@ exit:
 	return account;
 }
 
-static void
-cancel_service_connect_cb (GCancellable *cancellable,
-                           CamelService *service)
-{
-	g_return_if_fail (CAMEL_IS_SERVICE (service));
-
-	camel_service_cancel_connect (service);
-}
-
-gboolean
-em_utils_connect_service_sync (CamelService *service,
-                               GCancellable *cancellable,
-                               GError **error)
-{
-	gboolean res;
-	gulong handler_id = 0;
-
-	g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
-
-	if (cancellable != NULL)
-		handler_id = g_cancellable_connect (
-			cancellable,
-			G_CALLBACK (cancel_service_connect_cb),
-			service, NULL);
-
-	res = camel_service_connect_sync (service, error);
-
-	if (handler_id)
-		g_cancellable_disconnect (cancellable, handler_id);
-
-	return res;
-}
-
-gboolean
-em_utils_disconnect_service_sync (CamelService *service,
-                                  gboolean clean,
-                                  GCancellable *cancellable,
-                                  GError **error)
-{
-	gboolean res;
-	gulong handler_id = 0;
-
-	g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
-
-	if (cancellable != NULL)
-		handler_id = g_cancellable_connect (
-			cancellable,
-			G_CALLBACK (cancel_service_connect_cb),
-			service, NULL);
-
-	res = camel_service_disconnect_sync (service, clean, error);
-
-	if (handler_id)
-		g_cancellable_disconnect (cancellable, handler_id);
-
-	return res;
-}
-
 /**
  * em_utils_uids_free:
  * @uids: array of uids
diff --git a/libemail-engine/e-mail-utils.h b/libemail-engine/e-mail-utils.h
index 144f13d..ca8ed01 100644
--- a/libemail-engine/e-mail-utils.h
+++ b/libemail-engine/e-mail-utils.h
@@ -41,14 +41,6 @@ EAccount *	em_utils_guess_account_with_recipients
 void		emu_remove_from_mail_cache	(const GSList *addresses);
 void		emu_remove_from_mail_cache_1	(const gchar *address);
 void		emu_free_mail_cache		(void);
-gboolean	em_utils_connect_service_sync	(CamelService *service,
-						 GCancellable *cancellable,
-						 GError **error);
-gboolean	em_utils_disconnect_service_sync
-						(CamelService *service,
-						 gboolean clean,
-						 GCancellable *cancellable,
-						 GError **error);
 void		em_utils_uids_free		(GPtrArray *uids);
 gboolean	em_utils_is_local_delivery_mbox_file
 						(CamelURL *url);
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index 3374629..217f75d 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -380,7 +380,7 @@ exit:
 	/* also disconnect if not a local delivery mbox;
 	 * there is no need to keep the connection alive forever */
 	if (!is_local_delivery)
-		em_utils_disconnect_service_sync (
+		camel_service_disconnect_sync (
 			service, TRUE, cancellable, NULL);
 }
 
@@ -606,7 +606,7 @@ mail_send_message (struct _send_queue_msg *m,
 	}
 
 	if (camel_address_length (recipients) > 0) {
-		if (!em_utils_connect_service_sync (
+		if (!camel_service_connect_sync (
 			CAMEL_SERVICE (transport), cancellable, error))
 			goto exit;
 
@@ -1624,7 +1624,7 @@ empty_trash_exec (struct _empty_trash_msg *m,
 	service = CAMEL_SERVICE (m->store);
 	uid = camel_service_get_uid (service);
 
-	if (!em_utils_connect_service_sync (service, cancellable, error))
+	if (!camel_service_connect_sync (service, cancellable, error))
 		return;
 
 	trash = camel_store_get_trash_folder_sync (
@@ -1712,10 +1712,10 @@ disconnect_service_desc (struct _disconnect_msg *m)
 
 static void
 disconnect_service_exec (struct _disconnect_msg *m,
-                    GCancellable *cancellable,
-                    GError **error)
+                         GCancellable *cancellable,
+                         GError **error)
 {
-	em_utils_disconnect_service_sync (
+	camel_service_disconnect_sync (
 		CAMEL_SERVICE (m->store), TRUE, cancellable, error);
 }
 
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index 5264d1d..ddce87b 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -349,7 +349,7 @@ emfu_copy_folder_selected (EMailSession *session,
 		goto fail;
 
 	service = CAMEL_SERVICE (cfd->source_store);
-	em_utils_connect_service_sync (service, NULL, &local_error);
+	camel_service_connect_sync (service, NULL, &local_error);
 
 	if (local_error != NULL) {
 		e_alert_submit (
@@ -381,7 +381,7 @@ emfu_copy_folder_selected (EMailSession *session,
 		tostore = NULL;
 
 	if (tostore != NULL)
-		em_utils_connect_service_sync (
+		camel_service_connect_sync (
 			CAMEL_SERVICE (tostore), NULL, &local_error);
 
 	if (local_error != NULL) {
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 6db9445..1f459eb 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -554,7 +554,7 @@ all_accounts:
 	/* FIXME Complete lack of error checking here. */
 	service = camel_session_get_service (
 		CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
-	em_utils_connect_service_sync (service, NULL, NULL);
+	camel_service_connect_sync (service, NULL, NULL);
 
 	search_folder = (CamelVeeFolder *) camel_vee_folder_new (
 		CAMEL_STORE (service), _("All Account Search"),
@@ -715,7 +715,7 @@ current_account:
 	/* FIXME Complete lack of error checking here. */
 	service = camel_session_get_service (
 		CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
-	em_utils_connect_service_sync (service, NULL, NULL);
+	camel_service_connect_sync (service, NULL, NULL);
 
 	search_folder = (CamelVeeFolder *) camel_vee_folder_new (
 		CAMEL_STORE (service), _("Account Search"),



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