[evolution] Bug #653618 - Sending email doesn't disconnect from a server



commit 28bd28a91147474395a62f180e229913fa547509
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 29 09:44:14 2011 +0200

    Bug #653618 - Sending email doesn't disconnect from a server

 mail/e-mail-session-utils.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c
index 0827092..4e90a19 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);



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