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.
This commit is contained in:
Matthew Barnes
2012-05-19 11:11:58 -04:00
parent 98462b59ec
commit 98f39d7ee0
8 changed files with 22 additions and 91 deletions

View File

@ -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),

View File

@ -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 (

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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) {

View File

@ -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"),