[evolution-groupwise] Adapt to CamelService API changes.



commit fb68fad817fff527f998506424f647f2989cbdbb
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat May 19 14:52:05 2012 -0400

    Adapt to CamelService API changes.

 src/camel/camel-groupwise-folder.c        |   69 ++----------------------
 src/camel/camel-groupwise-store.c         |   83 +++++-----------------------
 src/camel/gwsend/camel-gwsend-transport.c |   17 +-----
 3 files changed, 22 insertions(+), 147 deletions(-)
---
diff --git a/src/camel/camel-groupwise-folder.c b/src/camel/camel-groupwise-folder.c
index 6c4b95d..933c457 100644
--- a/src/camel/camel-groupwise-folder.c
+++ b/src/camel/camel-groupwise-folder.c
@@ -735,12 +735,8 @@ groupwise_sync (CamelFolder *folder,
 	if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (gw_store)))
 		return groupwise_sync_summary (folder, error);
 
-	camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-	if (!camel_groupwise_store_connected (gw_store, cancellable, NULL)) {
-		camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (!camel_groupwise_store_connected (gw_store, cancellable, NULL))
 		return TRUE;
-	}
-	camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	cnc = cnc_lookup (gw_store->priv);
 	container_id =  camel_groupwise_store_container_id_lookup (gw_store, full_name);
@@ -818,7 +814,6 @@ groupwise_sync (CamelFolder *folder,
 					}
 
 					if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
-						camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 						/*
 							Sync up the READ changes before deleting the message.
@@ -843,7 +838,6 @@ groupwise_sync (CamelFolder *folder,
 						status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
 						if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
 							status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
-						camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 						if (status == E_GW_CONNECTION_STATUS_OK) {
 							gchar *uid;
 							while (deleted_items) {
@@ -876,7 +870,6 @@ groupwise_sync (CamelFolder *folder,
 		read_items = g_list_concat (read_items, deleted_read_items);
 
 	if (read_items) {
-		camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		status = e_gw_connection_mark_read (cnc, read_items);
 		if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
 			status = e_gw_connection_mark_read (cnc, read_items);
@@ -885,11 +878,9 @@ groupwise_sync (CamelFolder *folder,
 			sync_flags (folder, read_items);
 
 		g_list_free (read_items);
-		camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	}
 
 	if (deleted_items) {
-		camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		if (!strcmp (full_name, "Trash")) {
 			status = e_gw_connection_purge_selected_items (cnc, deleted_items);
 			if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
@@ -912,11 +903,9 @@ groupwise_sync (CamelFolder *folder,
 			}
 		}
 		g_list_free (deleted_items);
-		camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	}
 
 	if (unread_items) {
-		camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		status = e_gw_connection_mark_unread (cnc, unread_items);
 		if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
 			status = e_gw_connection_mark_unread (cnc, unread_items);
@@ -925,21 +914,16 @@ groupwise_sync (CamelFolder *folder,
 			sync_flags (folder, unread_items);
 
 		g_list_free (unread_items);
-		camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	}
 
 	if (expunge) {
-		camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		status = e_gw_connection_purge_deleted_items (cnc);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			g_message ("Purged deleted items in %s", camel_folder_get_display_name (folder));
 		}
-		camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	}
 
-	camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	success = groupwise_sync_summary (folder, error);
-	camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	camel_folder_changed (folder, changes);
 	camel_folder_change_info_free (changes);
@@ -1069,12 +1053,6 @@ update_update (CamelSession *session,
 
 	service = CAMEL_SERVICE (gw_store);
 
-	/* Hold the connect_lock.
-	 * In case if user went offline, don't do anything.
-	 * data->cnc would have become invalid, as the store disconnect unrefs it.
-	 */
-	camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-
 	conn_status = camel_service_get_connection_status (service);
 	if (!camel_offline_store_get_online (
 			CAMEL_OFFLINE_STORE (gw_store)) ||
@@ -1100,11 +1078,8 @@ update_update (CamelSession *session,
 
 	while (!done) {
 
-		if (camel_application_is_exiting) {
-				camel_service_unlock (
-					service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-				return;
-		}
+		if (camel_application_is_exiting)
+			return;
 
 		item_list = NULL;
 		status = e_gw_connection_get_all_mail_uids (data->cnc, data->container_id, cursor, FALSE, READ_CURSOR_MAX_IDS, position, &item_list);
@@ -1134,7 +1109,6 @@ update_update (CamelSession *session,
 	}
 	e_gw_connection_destroy_cursor (data->cnc, data->container_id, cursor);
 
-	camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 	/* Take out only the first part in the list until the @ since it is guaranteed
 	 * to be unique only until that symbol */
 
@@ -1160,7 +1134,6 @@ update_update (CamelSession *session,
 
 	return;
  end1:
-	camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 	camel_operation_pop_message (cancellable);
 	if (items_full_list) {
 		g_list_foreach (items_full_list, (GFunc) g_free, NULL);
@@ -1272,7 +1245,6 @@ groupwise_refresh_folder (CamelFolder *folder,
 	CamelSession *session;
 	CamelStore *parent_store;
 	gboolean is_proxy;
-	gboolean is_locked = TRUE;
 	gint status;
 	GList *list = NULL;
 	GSList *new_items = NULL, *modified_items = NULL, *merged = NULL;
@@ -1318,10 +1290,8 @@ groupwise_refresh_folder (CamelFolder *folder,
 		gw_folder->need_refresh = TRUE;
 	}
 
-	camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-
 	if (!camel_groupwise_store_connected (gw_store, cancellable, error))
-		goto end1;
+		return;
 
 	if (!strcmp (full_name, "Trash")) {
 		is_proxy = TRUE;
@@ -1407,9 +1377,6 @@ groupwise_refresh_folder (CamelFolder *folder,
 		update_summary_string (folder, new_sync_time);
 	}
 
-	camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-	is_locked = FALSE;
-
 	/*
 	 * The New and Modified items in the server have been updated in the summary.
 	 * Now we have to make sure that all the deleted items in the server are deleted
@@ -1441,10 +1408,6 @@ end2:
 	g_free (new_sync_time);
 	g_free (modified_sync_time);
 	g_free (container_id);
-end1:
-	if (is_locked)
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-	return;
 }
 
 static guint8 *
@@ -2365,13 +2328,7 @@ gw_update_all_items (CamelFolder *folder,
 	camel_folder_changed (folder, changes);
 
 	if (item_list) {
-		CamelStore *parent_store;
-
-		parent_store = camel_folder_get_parent_store (folder);
-
-		camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		gw_update_cache (folder, item_list, TRUE, cancellable, error);
-		camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 		g_list_foreach (item_list, (GFunc) g_free, NULL);
 		g_list_free (item_list);
@@ -2513,7 +2470,6 @@ groupwise_append_message_sync (CamelFolder *folder,
 	}
 	cnc = cnc_lookup (gw_store->priv);
 
-	camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	/*Get the container id*/
 	container_id = camel_groupwise_store_container_id_lookup (gw_store, full_name);
 
@@ -2540,7 +2496,6 @@ groupwise_append_message_sync (CamelFolder *folder,
 
 		if (appended_uid)
 			*appended_uid = NULL;
-		camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		return FALSE;
 	}
 
@@ -2555,14 +2510,12 @@ groupwise_append_message_sync (CamelFolder *folder,
 		if (appended_uid)
 			*appended_uid = NULL;
 
-		camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		return FALSE;
 	}
 
 	if (appended_uid)
 		*appended_uid = g_strdup (id);
 	g_free (id);
-	camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	return TRUE;
 }
@@ -2599,7 +2552,6 @@ groupwise_expunge_sync (CamelFolder *folder,
 		return TRUE;
 
 	if (!strcmp (full_name, "Trash")) {
-		camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		status = e_gw_connection_purge_deleted_items (cnc);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			camel_folder_freeze (folder);
@@ -2607,7 +2559,6 @@ groupwise_expunge_sync (CamelFolder *folder,
 			camel_folder_thaw (folder);
 		} else
 			g_warning ("Could not Empty Trash\n");
-		camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		return TRUE;
 	}
 
@@ -2631,9 +2582,7 @@ groupwise_expunge_sync (CamelFolder *folder,
 			}
 			if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
 				/* Read the FIXME below */
-				camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 				status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
-				camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 				if (status == E_GW_CONNECTION_STATUS_OK) {
 					gchar *uid;
 					while (deleted_items) {
@@ -2655,9 +2604,7 @@ groupwise_expunge_sync (CamelFolder *folder,
 
 	if (deleted_items) {
 		/* FIXME: Put these in a function and reuse it inside the above loop, here and in groupwise_sync*/
-		camel_service_lock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
-		camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			gchar *uid;
 			while (deleted_items) {
@@ -2940,7 +2887,6 @@ groupwise_transfer_messages_to_sync (CamelFolder *source,
 		source_container_id = NULL;
 	dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination_full_name);
 
-	camel_service_lock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	/* check for offline operation */
 	if (!camel_offline_store_get_online (offline)) {
 		CamelGroupwiseJournal *journal = (CamelGroupwiseJournal *) ((CamelGroupwiseFolder *) destination)->journal;
@@ -2981,7 +2927,6 @@ groupwise_transfer_messages_to_sync (CamelFolder *source,
 			}
 		}
 
-		camel_service_unlock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		return TRUE;
 	}
 
@@ -3021,9 +2966,7 @@ groupwise_transfer_messages_to_sync (CamelFolder *source,
 					 */
 
 					wrapper = g_list_prepend (wrapper, (gchar *) uid);
-					camel_service_lock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 					e_gw_connection_mark_read (cnc, wrapper);
-					camel_service_unlock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 					g_list_free (wrapper);
 					wrapper = NULL;
 				}
@@ -3037,9 +2980,7 @@ groupwise_transfer_messages_to_sync (CamelFolder *source,
 
 				if (unset_flags.bits & CAMEL_MESSAGE_SEEN) {
 					wrapper = g_list_prepend (wrapper, (gchar *) uid);
-					camel_service_lock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 					e_gw_connection_mark_unread (cnc, wrapper);
-					camel_service_unlock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 					g_list_free (wrapper);
 					wrapper = NULL;
 				}
@@ -3092,8 +3033,6 @@ groupwise_transfer_messages_to_sync (CamelFolder *source,
 
 	groupwise_store_set_current_folder (gw_store, source);
 
-	camel_service_unlock (CAMEL_SERVICE (source_parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-
 	return TRUE;
 }
 
diff --git a/src/camel/camel-groupwise-store.c b/src/camel/camel-groupwise-store.c
index 5db2c33..d68dcd4 100644
--- a/src/camel/camel-groupwise-store.c
+++ b/src/camel/camel-groupwise-store.c
@@ -154,9 +154,6 @@ void
 groupwise_store_set_current_folder (CamelGroupwiseStore *groupwise_store,
                                     CamelFolder *folder)
 {
-
-	camel_service_lock (CAMEL_SERVICE (groupwise_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-
 	if (groupwise_store->current_folder) {
 		g_object_unref (groupwise_store->current_folder);
 		groupwise_store->current_folder = NULL;
@@ -164,8 +161,6 @@ groupwise_store_set_current_folder (CamelGroupwiseStore *groupwise_store,
 
 	if (folder)
 		groupwise_store->current_folder = g_object_ref (folder);
-
-	camel_service_unlock (CAMEL_SERVICE (groupwise_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 }
 
 static gboolean
@@ -189,22 +184,16 @@ groupwise_connect_sync (CamelService *service,
 	if (status == CAMEL_SERVICE_DISCONNECTED)
 		return FALSE;
 
-	camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-
-	if (priv->cnc) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (priv->cnc)
 		return TRUE;
-	}
 
 	if (!check_for_connection (service, cancellable, error)) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-		camel_service_disconnect_sync (service, TRUE, NULL);
+		camel_service_disconnect_sync (service, TRUE, cancellable, NULL);
 		return FALSE;
 	}
 
 	if (!camel_session_authenticate_sync (session, service, NULL, cancellable, error)) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-		camel_service_disconnect_sync (service, TRUE, NULL);
+		camel_service_disconnect_sync (service, TRUE, cancellable, NULL);
 		return FALSE;
 	}
 
@@ -230,7 +219,6 @@ groupwise_connect_sync (CamelService *service,
 
 	camel_store_summary_save ((CamelStoreSummary *) store->summary);
 
-	camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 	if (E_IS_GW_CONNECTION (priv->cnc)) {
 		return TRUE;
 	}
@@ -290,7 +278,6 @@ groupwise_disconnect_sync (CamelService *service,
 	CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
 
 	if (clean) {
-		camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 		if (groupwise_store->priv && groupwise_store->priv->cnc) {
 			g_object_unref (groupwise_store->priv->cnc);
 			groupwise_store->priv->cnc = NULL;
@@ -299,8 +286,6 @@ groupwise_disconnect_sync (CamelService *service,
 		}
 
 		groupwise_store_set_current_folder (groupwise_store, NULL);
-
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 	}
 
 	/* groupwise_disconnect_cleanup (service, clean, ex); */
@@ -487,20 +472,14 @@ groupwise_store_get_folder_sync (CamelStore *store,
 	} else
 		g_clear_error (&local_error);
 
-	camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-
 	groupwise_store_set_current_folder (gw_store, NULL);
 
-	if (!camel_groupwise_store_connected (gw_store, cancellable, error)) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (!camel_groupwise_store_connected (gw_store, cancellable, error))
 		return NULL;
-	}
 
 	if (!E_IS_GW_CONNECTION ( priv->cnc)) {
-		if (!groupwise_connect_sync (service, cancellable, error)) {
-			camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+		if (!groupwise_connect_sync (service, cancellable, error))
 			return NULL;
-		}
 	}
 
 	container_id =	g_strdup (g_hash_table_lookup (priv->name_hash, folder_name));
@@ -510,7 +489,6 @@ groupwise_store_get_folder_sync (CamelStore *store,
 	g_free (storage_path);
 	folder = camel_gw_folder_new (store, folder_name, folder_dir, cancellable, NULL);
 	if (!folder) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 		g_set_error (
 			error, CAMEL_SERVICE_ERROR,
 			CAMEL_SERVICE_ERROR_INVALID,
@@ -544,7 +522,6 @@ groupwise_store_get_folder_sync (CamelStore *store,
 				&cursor);
 
 		if (status != E_GW_CONNECTION_STATUS_OK) {
-			camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 			g_free (container_id);
 			return NULL;
 		}
@@ -607,7 +584,6 @@ groupwise_store_get_folder_sync (CamelStore *store,
 	groupwise_store_set_current_folder (gw_store, folder);
 
 	g_free (container_id);
-	camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	return folder;
 }
@@ -635,18 +611,12 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store,
 	name = camel_folder_get_display_name (folder);
 	full_name = camel_folder_get_full_name (folder);
 
-	camel_service_lock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-
-	if (!camel_groupwise_store_connected (gw_store, cancellable, error)) {
-		camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (!camel_groupwise_store_connected (gw_store, cancellable, error))
 		return FALSE;
-	}
 
 	if (!E_IS_GW_CONNECTION ( priv->cnc)) {
-		if (!groupwise_connect_sync (CAMEL_SERVICE ((CamelStore *) gw_store), cancellable, error)) {
-			camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+		if (!groupwise_connect_sync (CAMEL_SERVICE ((CamelStore *) gw_store), cancellable, error))
 			return FALSE;
-		}
 	}
 
 	container_id =	g_strdup (g_hash_table_lookup (priv->name_hash, full_name));
@@ -675,9 +645,8 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store,
 									NULL,
 									&cursor);
 			if (status != E_GW_CONNECTION_STATUS_OK) {
-					camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-					g_free (container_id);
-					return FALSE;
+				g_free (container_id);
+				return FALSE;
 			}
 
 			camel_operation_push_message (
@@ -690,7 +659,6 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store,
 									cursor, FALSE,
 									CURSOR_ITEM_LIMIT, position, &list);
 					if (status != E_GW_CONNECTION_STATUS_OK) {
-							camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 							e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
 							camel_folder_summary_save_to_db (folder->summary, NULL);
 							g_set_error (
@@ -745,7 +713,6 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store,
 	groupwise_store_set_current_folder (gw_store, NULL);
 
 	g_free (container_id);
-	camel_service_unlock (CAMEL_SERVICE (gw_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	return TRUE;
 }
 
@@ -1017,21 +984,15 @@ groupwise_store_get_folder_info_sync (CamelStore *store,
 	/* Do not call groupwise_store_connected function as it would internall call folders_sync
 	 * to populate the hash table which is used for mapping container id */
 	if (!(camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))
-	    && camel_service_connect_sync ((CamelService *) store, error)))
+	    && camel_service_connect_sync ((CamelService *) store, cancellable, error)))
 		goto offline;
 
-	camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-
-	if (!groupwise_folders_sync (groupwise_store, cancellable, error)) {
-		camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (!groupwise_folders_sync (groupwise_store, cancellable, error))
 		return NULL;
-	}
 
 	camel_store_summary_touch ((CamelStoreSummary *) groupwise_store->summary);
 	camel_store_summary_save ((CamelStoreSummary *) groupwise_store->summary);
 
-	camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-
 offline:
 	info = groupwise_get_folder_info_offline (store, top, flags, error);
 	return info;
@@ -1052,7 +1013,6 @@ create_junk_folder (CamelStore *store)
 	parent_id = "";
 	/* TODO: check for offlining*/
 
-	camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0,  JUNK_PERSISTENCE);
 	if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
 		status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0,  JUNK_PERSISTENCE);
@@ -1069,7 +1029,6 @@ create_junk_folder (CamelStore *store)
 		g_hash_table_insert (priv->parent_hash, g_strdup (child_container_id), g_strdup (parent_id));
 		camel_store_folder_created (store, root);
 	}
-	camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	return root;
 }
@@ -1122,7 +1081,6 @@ groupwise_store_create_folder_sync (CamelStore *store,
 			return NULL;
 		}
 	}
-	camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 	status = e_gw_connection_create_folder (priv->cnc,parent_id,folder_name, &child_container_id);
 	if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
 		status = e_gw_connection_create_folder (priv->cnc,parent_id,folder_name, &child_container_id);
@@ -1136,7 +1094,7 @@ groupwise_store_create_folder_sync (CamelStore *store,
 
 		camel_store_folder_created (store, root);
 	}
-	camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+
 	return root;
 }
 
@@ -1151,12 +1109,8 @@ groupwise_store_delete_folder_sync (CamelStore *store,
 	EGwConnectionStatus status;
 	const gchar * container;
 
-	camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-
-	if (!camel_groupwise_store_connected (groupwise_store, cancellable, error)) {
-		camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (!camel_groupwise_store_connected (groupwise_store, cancellable, error))
 		return FALSE;
-	}
 
 	container = g_hash_table_lookup (priv->name_hash, folder_name);
 
@@ -1174,7 +1128,6 @@ groupwise_store_delete_folder_sync (CamelStore *store,
 
 		g_hash_table_remove (priv->parent_hash, container);
 	}
-	camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	return TRUE;
 }
@@ -1205,12 +1158,8 @@ groupwise_store_rename_folder_sync (CamelStore *store,
 		return FALSE;
 	}
 
-	camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-
-	if (!camel_groupwise_store_connected (groupwise_store, cancellable, error)) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (!camel_groupwise_store_connected (groupwise_store, cancellable, error))
 		return FALSE;
-	}
 
 	groupwise_store_set_current_folder (groupwise_store, NULL);
 
@@ -1227,7 +1176,6 @@ groupwise_store_rename_folder_sync (CamelStore *store,
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
 			_("Cannot rename GroupWise folder '%s' to '%s'"),
 			old_name, new_name);
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 		return FALSE;
 	}
 
@@ -1250,7 +1198,6 @@ groupwise_store_rename_folder_sync (CamelStore *store,
 
 	g_free (oldpath);
 	g_free (newpath);
-	camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	return TRUE;
 }
@@ -1361,7 +1308,7 @@ camel_groupwise_store_connected (CamelGroupwiseStore *store,
                                  GError **error)
 {
 	if (camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))
-	    && camel_service_connect_sync ((CamelService *) store, error)) {
+	    && camel_service_connect_sync ((CamelService *) store, cancellable, error)) {
 		CamelGroupwiseStore *gw_store = (CamelGroupwiseStore *) store;
 		CamelGroupwiseStorePrivate *priv = gw_store->priv;
 
diff --git a/src/camel/gwsend/camel-gwsend-transport.c b/src/camel/gwsend/camel-gwsend-transport.c
index ce13487..30a9228 100644
--- a/src/camel/gwsend/camel-gwsend-transport.c
+++ b/src/camel/gwsend/camel-gwsend-transport.c
@@ -213,22 +213,16 @@ gwsend_connect_sync (CamelService *service,
 	if (status == CAMEL_SERVICE_DISCONNECTED)
 		return FALSE;
 
-	camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-
-	if (priv->cnc) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+	if (priv->cnc)
 		return TRUE;
-	}
 
 	if (!check_for_connection (service, cancellable, error)) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-		camel_service_disconnect_sync (service, TRUE, NULL);
+		camel_service_disconnect_sync (service, TRUE, cancellable, NULL);
 		return FALSE;
 	}
 
 	if (!camel_session_authenticate_sync (session, service, NULL, cancellable, error)) {
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
-		camel_service_disconnect_sync (service, TRUE, NULL);
+		camel_service_disconnect_sync (service, TRUE, cancellable, NULL);
 		return FALSE;
 	}
 
@@ -240,7 +234,6 @@ gwsend_connect_sync (CamelService *service,
 
 	}
 
-	camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 	if (E_IS_GW_CONNECTION (priv->cnc)) {
 		camel_groupwise_transport_set_connection (service, priv->cnc);
 		return TRUE;
@@ -258,15 +251,11 @@ gwsend_disconnect_sync (CamelService *service,
 	CamelGwSendTransport *gw_transport = CAMEL_GWSEND_TRANSPORT (service);
 
 	if (clean) {
-		camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 		if (gw_transport->priv && gw_transport->priv->cnc) {
 			g_object_unref (gw_transport->priv->cnc);
 			gw_transport->priv->cnc = NULL;
 			camel_groupwise_transport_set_connection (service, NULL);
 		}
-
-
-		camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
 	}
 
 	/* groupwise_disconnect_cleanup (service, clean, ex); */



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