diff options
author | Milan Crha <mcrha@redhat.com> | 2011-07-02 02:01:45 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2011-07-02 02:01:45 +0800 |
commit | 7c6aa944e224b4f938cad03bc6531bc5430c9cdb (patch) | |
tree | 65613f6ce5e64f12c945557ab1dd99ea36ac4b4e /mail/em-utils.c | |
parent | 6d8542a62879bd8b6f06e2679fc9f846ba497935 (diff) | |
download | gsoc2013-evolution-7c6aa944e224b4f938cad03bc6531bc5430c9cdb.tar.gz gsoc2013-evolution-7c6aa944e224b4f938cad03bc6531bc5430c9cdb.tar.zst gsoc2013-evolution-7c6aa944e224b4f938cad03bc6531bc5430c9cdb.zip |
Bug #650671 - Service connect/disconnect not cancelled properly
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r-- | mail/em-utils.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c index 3239b87214..a106a0ce04 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2289,3 +2289,52 @@ em_utils_is_local_delivery_mbox_file (CamelURL *url) g_file_test (url->path, G_FILE_TEST_EXISTS) && !g_file_test (url->path, G_FILE_TEST_IS_DIR); } + +static void +cancel_service_connect_cb (GCancellable *cancellable, CamelService *service) +{ + g_return_if_fail (service != NULL); + 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 (service != NULL, FALSE); + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + + if (cancellable) + 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 (service != NULL, FALSE); + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + + if (cancellable) + 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; +} |