[evolution] Add encryption and authentication support for autoconfig



commit 242593df87629e19d4614266861ebb8f19004f01
Author: Gary Ching-Pang Lin <chingpang gmail com>
Date:   Mon Aug 23 11:49:29 2010 +0800

    Add encryption and authentication support for autoconfig
    
    Bug 625627 - Fail to send mail with smtp.live.com with autoconfig

 capplet/settings/mail-account-view.c |   36 ++++++++++++++++++++++++++----
 mail/em-account-editor.c             |   40 +++++++++++++++++++++++++++++++--
 mail/em-account-editor.h             |    4 +++
 3 files changed, 72 insertions(+), 8 deletions(-)
---
diff --git a/capplet/settings/mail-account-view.c b/capplet/settings/mail-account-view.c
index 4410fa4..7da2215 100644
--- a/capplet/settings/mail-account-view.c
+++ b/capplet/settings/mail-account-view.c
@@ -954,18 +954,44 @@ emae_check_servers (const gchar *email)
 	else
 		sdata->proto = provider->recv_type;
 	if (provider->recv_socket_type) {
-		if (g_ascii_strcasecmp(provider->recv_socket_type, "SSL") == 0)
+		if (g_ascii_strcasecmp(provider->recv_socket_type, "SSL") == 0) {
 			sdata->ssl = g_strdup("always");
-		else if (g_ascii_strcasecmp(provider->recv_socket_type, "secure") == 0)
+			sdata->recv_sock = g_strdup("always");
+		}
+		else if (g_ascii_strcasecmp(provider->recv_socket_type, "secure") == 0) {
 			sdata->ssl = g_strdup("always");
-		else if (g_ascii_strcasecmp(provider->recv_socket_type, "STARTTLS") == 0)
+			sdata->recv_sock = g_strdup("always");
+		}
+		else if (g_ascii_strcasecmp(provider->recv_socket_type, "STARTTLS") == 0) {
 			sdata->ssl = g_strdup("when-possible");
-		else if (g_ascii_strcasecmp(provider->recv_socket_type, "TLS") == 0)
+			sdata->recv_sock = g_strdup("when-possible");
+		}
+		else if (g_ascii_strcasecmp(provider->recv_socket_type, "TLS") == 0) {
 			sdata->ssl = g_strdup("when-possible");
-		else
+			sdata->recv_sock = g_strdup("when-possible");
+		}
+		else {
 			sdata->ssl = g_strdup("never");
+			sdata->recv_sock = g_strdup("never");
+		}
 
 	}
+
+	if (provider->send_socket_type) {
+		if (g_ascii_strcasecmp(provider->send_socket_type, "SSL") == 0)
+			sdata->send_sock = g_strdup("always");
+		else if (g_ascii_strcasecmp(provider->send_socket_type, "secure") == 0)
+			sdata->send_sock = g_strdup("always");
+		else if (g_ascii_strcasecmp(provider->send_socket_type, "STARTTLS") == 0)
+			sdata->send_sock = g_strdup("when-possible");
+		else if (g_ascii_strcasecmp(provider->send_socket_type, "TLS") == 0)
+			sdata->send_sock = g_strdup("when-possible");
+		else
+			sdata->send_sock = g_strdup("never");
+	}
+
+	sdata->send_auth = provider->send_auth;
+	sdata->recv_auth = provider->recv_auth;
 	sdata->send_user = provider->send_username;
 	sdata->recv_user = provider->recv_username;
 
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 99ba817..a6d624e 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -3325,6 +3325,29 @@ emae_check_servers (const gchar *email)
 	return NULL;
 }
 
+static void
+emae_check_set_authtype (GtkComboBox *dropdown, const gchar *auth)
+{
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	gint id;
+	gint children;
+
+	model = gtk_combo_box_get_model (dropdown);
+	children = gtk_tree_model_iter_n_children (model, NULL);
+	for (id = 0; id < children; id++)  {
+		CamelServiceAuthType *authtype;
+
+		gtk_tree_model_iter_nth_child (model, &iter, NULL, id);
+		gtk_tree_model_get (model, &iter, 1, &authtype, -1);
+		if (g_ascii_strcasecmp (authtype->authproto, auth) == 0)
+			break;
+	}
+
+	if (id < children)
+		gtk_combo_box_set_active (dropdown, id);
+}
+
 static gboolean
 emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data)
 {
@@ -3386,7 +3409,10 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data)
 						camel_url_set_user (url, user);
 					if (sdata != NULL) {
 						camel_url_set_protocol (url, sdata->proto);
-						camel_url_set_param (url, "use_ssl", sdata->ssl);
+						if (sdata->recv_sock && *sdata->recv_sock)
+							camel_url_set_param (url, "use_ssl", sdata->recv_sock);
+						else
+							camel_url_set_param (url, "use_ssl", sdata->ssl);
 						camel_url_set_host (url, sdata->recv);
 						if (sdata->recv_port && *sdata->recv_port)
 							camel_url_set_port (url, atoi(sdata->recv_port));
@@ -3398,6 +3424,8 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data)
 					g_free (uri);
 					uri = camel_url_to_string (url, 0);
 					e_account_set_string (account, E_ACCOUNT_SOURCE_URL, uri);
+					if (sdata != NULL && sdata->recv_auth && *sdata->recv_auth)
+						emae_check_set_authtype (emae->priv->source.authtype, sdata->recv_auth);
 
 					camel_url_free (url);
 				}
@@ -3423,7 +3451,10 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data)
 				if (sdata != NULL && uri && (url = camel_url_new (uri, NULL)) != NULL) {
 					refresh = TRUE;
 					camel_url_set_protocol (url, "smtp");
-					camel_url_set_param (url, "use_ssl", sdata->ssl);
+					if (sdata->send_sock && *sdata->send_sock)
+						camel_url_set_param (url, "use_ssl", sdata->send_sock);
+					else
+						camel_url_set_param (url, "use_ssl", sdata->ssl);
 					camel_url_set_host (url, sdata->send);
 					if (sdata->send_port && *sdata->send_port)
 						camel_url_set_port (url, atoi(sdata->send_port));
@@ -3437,7 +3468,10 @@ emae_check_complete (EConfig *ec, const gchar *pageid, gpointer data)
 					g_free (uri);
 					camel_url_free (url);
 					gtk_toggle_button_set_active (emae->priv->transport.needs_auth, TRUE);
-					emae_authtype_changed(emae->priv->transport.authtype, &emae->priv->transport);
+					if (sdata->send_auth && *sdata->send_auth)
+						emae_check_set_authtype (emae->priv->transport.authtype, sdata->send_auth);
+					else
+						emae_authtype_changed(emae->priv->transport.authtype, &emae->priv->transport);
 					uri = (gchar *)e_account_get_string (account, E_ACCOUNT_TRANSPORT_URL);
 				}
 			}
diff --git a/mail/em-account-editor.h b/mail/em-account-editor.h
index a8128af..64f514b 100644
--- a/mail/em-account-editor.h
+++ b/mail/em-account-editor.h
@@ -63,6 +63,10 @@ struct _server_data {
 	const gchar *recv_user;
 	const gchar *send_port;
 	const gchar *recv_port;
+	const gchar *send_sock;
+	const gchar *recv_sock;
+	const gchar *send_auth;
+	const gchar *recv_auth;
 };
 
 typedef enum {



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