[evolution-mapi] Bug #579185 - Can't setup SSL connection



commit 22d81d477cf866370de3e8972249e78d246950e7
Author: Milan Crha <mcrha redhat com>
Date:   Mon May 31 19:33:42 2010 +0200

    Bug #579185 - Can't setup SSL connection

 .../exchange-mapi-account-listener.c               |    4 ++-
 .../exchange-mapi-account-setup.c                  |   37 ++++++++++++++++++--
 src/libexchangemapi/exchange-mapi-connection.c     |    5 ++-
 src/libexchangemapi/exchange-mapi-connection.h     |    7 +++-
 4 files changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.c b/src/account-setup-eplugin/exchange-mapi-account-listener.c
index e94b212..93fa84f 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.c
@@ -713,7 +713,9 @@ create_profile_entry (CamelURL *url, EAccount *account)
 		g_free (key);
 
 		if (password) {
-			status = exchange_mapi_create_profile (url->user, password, camel_url_get_param (url, "domain"), url->host, NULL, NULL, NULL);
+			guint32 cp_flags = (camel_url_get_param (url, "ssl") && g_str_equal (camel_url_get_param (url, "ssl"), "1")) ? CREATE_PROFILE_FLAG_USE_SSL : CREATE_PROFILE_FLAG_NONE;
+
+			status = exchange_mapi_create_profile (url->user, password, camel_url_get_param (url, "domain"), url->host, cp_flags, NULL, NULL, NULL);
 			if (status) {
 				/* profile was created, try to connect to the server */
 				ExchangeMapiConnection *conn;
diff --git a/src/account-setup-eplugin/exchange-mapi-account-setup.c b/src/account-setup-eplugin/exchange-mapi-account-setup.c
index a67449d..b23674d 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-setup.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-setup.c
@@ -215,6 +215,7 @@ validate_credentials (GtkWidget *widget, EConfig *config)
 
 	if (!url->user || !*url->user || !url->host || !*url->host || !domain_name || !*domain_name) {
 		e_notice (NULL, GTK_MESSAGE_ERROR, "%s", _("Server, username and domain name cannot be empty. Please fill them with correct values."));
+		camel_url_free (url);
 		return;
 	}
 
@@ -234,11 +235,11 @@ validate_credentials (GtkWidget *widget, EConfig *config)
 
 	/*Can there be a account without password ?*/
 	if (password && *password && domain_name && *domain_name && *url->user && *url->host) {
+		guint32 cp_flags = (camel_url_get_param (url, "ssl") && g_str_equal (camel_url_get_param (url, "ssl"), "1")) ? CREATE_PROFILE_FLAG_USE_SSL : CREATE_PROFILE_FLAG_NONE;
 		gchar *error_msg = NULL;
 		gboolean status = exchange_mapi_create_profile (url->user, password, domain_name,
-								url->host, &error_msg,
-								(mapi_profile_callback_t) create_profile_callback,
-								url->user);
+								url->host, cp_flags, &error_msg,
+								(mapi_profile_callback_t) create_profile_callback, url->user);
 		if (status) {
 			/* profile was created, try to connect to the server */
 			ExchangeMapiConnection *conn;
@@ -317,6 +318,25 @@ domain_entry_changed(GtkWidget *entry, EConfig *config)
 	camel_url_free (url);
 }
 
+static void
+secure_check_toggled (GtkWidget *check, EConfig *config)
+{
+	EMConfigTargetAccount *target = (EMConfigTargetAccount *)(config->target);
+	CamelURL *url = NULL;
+	gchar *url_string = NULL;
+
+	url = camel_url_new (e_account_get_string (target->account, E_ACCOUNT_SOURCE_URL), NULL);
+
+	camel_url_set_param (url, "ssl", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)) ? "1" : NULL);
+
+	url_string = camel_url_to_string (url, 0);
+	e_account_set_string (target->account, E_ACCOUNT_SOURCE_URL, url_string);
+	e_account_set_string (target->account, E_ACCOUNT_TRANSPORT_URL, url_string);
+	g_free (url_string);
+
+	camel_url_free (url);
+}
+
 GtkWidget *
 org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData *data)
 {
@@ -336,7 +356,10 @@ org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData
 		GtkWidget *label;
 		GtkWidget *domain_name;
 		GtkWidget *auth_button;
+		GtkWidget *secure_conn;
 		const gchar *domain_value = camel_url_get_param (url, "domain");
+		const gchar *use_ssl = camel_url_get_param (url, "ssl");
+
 		g_object_get (data->parent, "n-rows", &row, NULL);
 
 		/* Domain name & Authenticate Button */
@@ -358,6 +381,14 @@ org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData
 		gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
 		gtk_widget_show_all (GTK_WIDGET (hbox));
 		gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (hbox), 1, 2, row, row+1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+
+		row++;
+
+		secure_conn = gtk_check_button_new_with_mnemonic (_("_Use secure connection"));
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (secure_conn), use_ssl && g_str_equal (use_ssl, "1"));
+		g_signal_connect (secure_conn, "toggled", G_CALLBACK (secure_check_toggled), data->config);
+		gtk_widget_show (secure_conn);
+		gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (secure_conn), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
 	}
 
 	camel_url_free (url);
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 684864e..fc3c99e 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -3404,7 +3404,7 @@ mapi_profile_load (const gchar *profname, const gchar *password)
 
 gboolean
 exchange_mapi_create_profile (const gchar *username, const gchar *password, const gchar *domain,
-			      const gchar *server, gchar **error_msg,
+			      const gchar *server, guint32 flags, gchar **error_msg,
 			      mapi_profile_callback_t callback, gpointer data)
 {
 	enum MAPISTATUS	retval;
@@ -3442,6 +3442,9 @@ exchange_mapi_create_profile (const gchar *username, const gchar *password, cons
 	mapi_profile_add_string_attr(profname, "workstation", workstation);
 	mapi_profile_add_string_attr(profname, "domain", domain);
 
+	if ((flags & CREATE_PROFILE_FLAG_USE_SSL) != 0)
+		mapi_profile_add_string_attr (profname, "seal", "true");
+
 	/* This is only convenient here and should be replaced at some point */
 	mapi_profile_add_string_attr(profname, "codepage", "0x4e4");
 	mapi_profile_add_string_attr(profname, "language", "0x409");
diff --git a/src/libexchangemapi/exchange-mapi-connection.h b/src/libexchangemapi/exchange-mapi-connection.h
index cfd3b41..5f31a5d 100644
--- a/src/libexchangemapi/exchange-mapi-connection.h
+++ b/src/libexchangemapi/exchange-mapi-connection.h
@@ -224,8 +224,13 @@ gboolean		exchange_mapi_connection_events_unsubscribe (ExchangeMapiConnection *c
 
 /* profile functions */
 
+enum {
+	CREATE_PROFILE_FLAG_NONE = 0,
+	CREATE_PROFILE_FLAG_USE_SSL = (1 << 0)
+};
+
 gboolean		exchange_mapi_create_profile (const gchar *username, const gchar *password,
-				       const gchar *domain, const gchar *server,
+				       const gchar *domain, const gchar *server, guint32 flags,
 				       gchar **error_msg, mapi_profile_callback_t cb, gpointer data);
 
 gboolean		exchange_mapi_delete_profile (const gchar *profile);



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