aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-06-29 15:44:14 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:35 +0800
commit8faaef3ec6137974593d53b9ce64c8e2644ff844 (patch)
tree324e3c6c13e0b5afc7b58b223956fb097d21981d
parent3746b0f4ed8530c2fb9b6fb1d5f63c5366f08d3e (diff)
downloadgsoc2013-evolution-8faaef3ec6137974593d53b9ce64c8e2644ff844.tar.gz
gsoc2013-evolution-8faaef3ec6137974593d53b9ce64c8e2644ff844.tar.zst
gsoc2013-evolution-8faaef3ec6137974593d53b9ce64c8e2644ff844.zip
Bug #653618 - Sending email doesn't disconnect from a server
-rw-r--r--mail/e-mail-session-utils.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c
index 08270927f4..4e90a19ecf 100644
--- a/mail/e-mail-session-utils.c
+++ b/mail/e-mail-session-utils.c
@@ -405,6 +405,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
if (camel_address_length (context->recipients) > 0) {
CamelProvider *provider;
CamelService *service;
+ gboolean did_connect = FALSE;
service = camel_session_get_service (
CAMEL_SESSION (session), context->transport_uid);
@@ -418,11 +419,15 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
return;
}
- /* XXX This API does not allow for cancellation. */
- if (!camel_service_connect_sync (service, &error)) {
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
- return;
+ if (camel_service_get_connection_status (service) != CAMEL_SERVICE_CONNECTED) {
+ did_connect = TRUE;
+
+ /* XXX This API does not allow for cancellation. */
+ if (!camel_service_connect_sync (service, &error)) {
+ g_simple_async_result_set_from_error (simple, error);
+ g_error_free (error);
+ return;
+ }
}
provider = camel_service_get_provider (service);
@@ -435,6 +440,9 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
context->message, context->from,
context->recipients, cancellable, &error);
+ if (did_connect)
+ camel_service_disconnect_sync (service, error == NULL, error ? NULL : &error);
+
if (error != NULL) {
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);