[evolution-mapi] Adapt to Evolution's EMConfig API changes.



commit cdf7e4cdc8852a76a6aa3b30ade40b554e3acf9f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Nov 6 12:16:32 2011 -0500

    Adapt to Evolution's EMConfig API changes.

 .../e-mapi-account-settings.c                      |   37 ++--
 src/account-setup-eplugin/e-mapi-account-setup.c   |  245 ++++++++++----------
 .../org-gnome-exchange-mapi.eplug.xml              |    8 +-
 3 files changed, 139 insertions(+), 151 deletions(-)
---
diff --git a/src/account-setup-eplugin/e-mapi-account-settings.c b/src/account-setup-eplugin/e-mapi-account-settings.c
index 54db85f..0d0b662 100644
--- a/src/account-setup-eplugin/e-mapi-account-settings.c
+++ b/src/account-setup-eplugin/e-mapi-account-settings.c
@@ -209,19 +209,13 @@ mapi_settings_run_folder_size_dialog (const gchar *profile, gpointer data)
 }
 
 static void
-folder_size_clicked (GtkButton *button, EAccount *account)
+folder_size_clicked (GtkButton *button,
+                     CamelMapiSettings *mapi_settings)
 {
-	CamelURL *url;
+	const gchar *profile;
 
-	g_return_if_fail (account != NULL);
-	g_return_if_fail (E_IS_ACCOUNT (account));
-
-	url = camel_url_new (e_account_get_string (account,  E_ACCOUNT_SOURCE_URL), NULL);
-	g_return_if_fail (url != NULL);
-
-	mapi_settings_run_folder_size_dialog (camel_url_get_param (url, "profile"), NULL);
-
-	camel_url_free (url);
+	profile = camel_mapi_settings_get_profile (mapi_settings);
+	mapi_settings_run_folder_size_dialog (profile, NULL);
 }
 
 static void
@@ -328,9 +322,7 @@ folder_size_actions_update_cb (EShellView *shell_view, GtkActionEntry *entries)
 GtkWidget *
 org_gnome_e_mapi_settings (EPlugin *epl, EConfigHookItemFactoryData *data)
 {
-	EMConfigTargetAccount *target_account;
-	CamelURL *url;
-	const gchar *source_url;
+	EMConfigTargetSettings *target_account;
 	GtkGrid *vsettings;
 
 	/* Miscelleneous setting */
@@ -340,16 +332,15 @@ org_gnome_e_mapi_settings (EPlugin *epl, EConfigHookItemFactoryData *data)
 	GtkLabel *lbl_fsize;
 	GtkButton *btn_fsize;
 
-	target_account = (EMConfigTargetAccount *)data->config->target;
+	target_account = (EMConfigTargetSettings *)data->config->target;
 
-	source_url = e_account_get_string (target_account->modified_account,  E_ACCOUNT_SOURCE_URL);
-
-	url = camel_url_new(source_url, NULL);
-	if (url == NULL || strcmp(url->protocol, "mapi") != 0) {
-		if (url)
-			camel_url_free(url);
+	if (!CAMEL_IS_MAPI_SETTINGS (target_account->storage_settings))
 		return NULL;
-	}
+
+	/* Verify the storage and transport settings are shared. */
+	g_warn_if_fail (
+		target_account->storage_settings ==
+		target_account->transport_settings);
 
 	vsettings = GTK_GRID (g_object_new (GTK_TYPE_GRID, "column-homogeneous", FALSE, "column-spacing", 6, "orientation", GTK_ORIENTATION_VERTICAL, NULL));
 	gtk_container_set_border_width (GTK_CONTAINER (vsettings), 12);
@@ -371,7 +362,7 @@ org_gnome_e_mapi_settings (EPlugin *epl, EConfigHookItemFactoryData *data)
 					      _("View the size of all Exchange folders"), NULL);
 	gtk_misc_set_alignment (GTK_MISC (lbl_fsize), 0, 0.5);
 	btn_fsize = (GtkButton*) g_object_new (GTK_TYPE_BUTTON, "label", _("Folder Size"), NULL);
-	g_signal_connect (btn_fsize, "clicked", G_CALLBACK (folder_size_clicked), target_account->modified_account);
+	g_signal_connect (btn_fsize, "clicked", G_CALLBACK (folder_size_clicked), target_account->storage_settings);
 	gtk_table_attach_defaults (tbl_misc, GTK_WIDGET (lbl_fsize), 0, 1, 0, 1);
 	gtk_table_attach (tbl_misc, GTK_WIDGET (btn_fsize), 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
 
diff --git a/src/account-setup-eplugin/e-mapi-account-setup.c b/src/account-setup-eplugin/e-mapi-account-setup.c
index fb59ce8..8cb042c 100644
--- a/src/account-setup-eplugin/e-mapi-account-setup.c
+++ b/src/account-setup-eplugin/e-mapi-account-setup.c
@@ -245,30 +245,32 @@ create_profile_callback (struct SRowSet *rowset, gconstpointer data)
 
 static char*
 prompt_password(const gchar *user, const gchar *host, const gchar *key,
-		EMConfigTargetAccount *account)
+		EMConfigTargetSettings *account)
 {
 	int pw_flags = E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET;
 	gchar *password, *title;
-	gboolean save;
+	gboolean save = TRUE;
 
-	password = e_passwords_get_password (NULL, key);
-	save = e_account_get_bool (account->modified_account,
-				   E_ACCOUNT_SOURCE_SAVE_PASSWD);
 	title = g_strdup_printf (_("Enter Password for %s %s"), user, host);
 	password = e_passwords_ask_password (title, NULL, key, title, pw_flags,
 					     &save, NULL);
 	g_free (title);
+
 	return password;
 }
 
 static void
 validate_credentials (GtkWidget *widget, EConfig *config)
 {
-	EMConfigTargetAccount *target_account = (EMConfigTargetAccount *)(config->target);
+	EMConfigTargetSettings *target_account = (EMConfigTargetSettings *)(config->target);
 	CamelURL *url = NULL;
 	gchar *key = NULL;
 	EMapiProfileData empd = { 0 };
+	CamelSettings *settings;
 	CamelMapiSettings *mapi_settings;
+	CamelNetworkSettings *network_settings;
+	const gchar *host;
+	const gchar *user;
 	GError *error = NULL;
 
 	if (!e_shell_get_online (e_shell_get_default ())) {
@@ -276,22 +278,25 @@ validate_credentials (GtkWidget *widget, EConfig *config)
 		return;
 	}
 
-	url = camel_url_new (e_account_get_string (target_account->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
-	mapi_settings = CAMEL_MAPI_SETTINGS (target_account->settings);
+	settings = target_account->storage_settings;
+	mapi_settings = CAMEL_MAPI_SETTINGS (settings);
+	network_settings = CAMEL_NETWORK_SETTINGS (settings);
+
+	host = camel_network_settings_get_host (network_settings);
+	user = camel_network_settings_get_user (network_settings);
 
 	/* Silently remove domain part from a username when user enters it as such.
 	   This change will be visible in the UI on new edit open. */
-	if (url->user && strchr (url->user, '\\')) {
-		gchar *tmp, *at;
+	if (user != NULL && strchr (user, '\\') != NULL) {
+		gchar *at;
 
-		at = strrchr (url->user, '\\') + 1;
-		tmp = g_strdup (at);
-		camel_url_set_user (url, tmp);
-		g_free (tmp);
+		at = strrchr (user, '\\') + 1;
+		camel_network_settings_set_user (network_settings, at);
+		user = camel_network_settings_get_user (network_settings);
 	}
 
-	empd.server = url->host;
-	empd.username = url->user;
+	empd.server = host;
+	empd.username = user;
 	e_mapi_util_profiledata_from_settings (&empd, mapi_settings);
 
 	if (!empd.username || !*(empd.username)
@@ -299,15 +304,17 @@ validate_credentials (GtkWidget *widget, EConfig *config)
 	    || ((!empd.domain || !*(empd.domain))
 		&& !empd.krb_sso)) {
 		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;
 	} else if (empd.krb_sso && (!empd.krb_realm || !*(empd.krb_realm))) {
 		e_notice (NULL, GTK_MESSAGE_ERROR, "%s", _("Realm name cannot be empty when kerberos is selected. Please fill them with correct values."));
-		camel_url_free (url);
 		return;
 	}
 
+	url = g_malloc0 (sizeof (CamelURL));
+	camel_settings_save_to_url (settings, url);
 	key = camel_url_to_string (url, CAMEL_URL_HIDE_PARAMS);
+	camel_url_free (url);
+
 	if (empd.krb_sso) {
 		e_mapi_util_trigger_krb_auth (&empd, &error);
 	} else {
@@ -370,137 +377,127 @@ validate_credentials (GtkWidget *widget, EConfig *config)
 
 	g_free (empd.password);
 	g_free (key);
-	camel_url_free (url);
 }
 
 GtkWidget *
 org_gnome_e_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData *data)
 {
-	EMConfigTargetAccount *target_account;
+	EMConfigTargetSettings *target_account;
 	CamelSettings *settings;
-	CamelURL *url;
 	GtkWidget *hgrid = NULL;
+	GtkWidget *label;
+	GtkWidget *domain_name;
+	GtkWidget *realm_name;
+	GtkWidget *auth_button;
+	GtkWidget *secure_conn;
+	GtkWidget *krb_sso;
 	gint row;
 
-	target_account = (EMConfigTargetAccount *)data->config->target;
-	settings = target_account->settings;
-	url = camel_url_new(e_account_get_string(target_account->modified_account, E_ACCOUNT_SOURCE_URL), NULL);
+	target_account = (EMConfigTargetSettings *)data->config->target;
+	settings = target_account->storage_settings;
 
-	/* is NULL on New Account creation */
-	if (url == NULL)
+	if (!CAMEL_IS_MAPI_SETTINGS (settings))
 		return NULL;
 
-	if (!g_ascii_strcasecmp (url->protocol, "mapi")) {
-		GtkWidget *label;
-		GtkWidget *domain_name;
-		GtkWidget *realm_name;
-		GtkWidget *auth_button;
-		GtkWidget *secure_conn;
-		GtkWidget *krb_sso;
-
-		g_object_get (data->parent, "n-rows", &row, NULL);
-
-		/* Domain name & Authenticate Button */
-		hgrid = g_object_new (GTK_TYPE_GRID, "column-homogeneous", FALSE, "column-spacing", 6, "orientation", GTK_ORIENTATION_HORIZONTAL, NULL);
-		label = gtk_label_new_with_mnemonic (_("_Domain name:"));
-		gtk_widget_show (label);
-
-		domain_name = gtk_entry_new ();
-		gtk_label_set_mnemonic_widget (GTK_LABEL (label), domain_name);
-		gtk_container_add (GTK_CONTAINER (hgrid), domain_name);
-		g_object_bind_property (
-			settings, "domain",
-			domain_name, "text",
-			G_BINDING_BIDIRECTIONAL |
-			G_BINDING_SYNC_CREATE);
-
-		auth_button = gtk_button_new_with_mnemonic (_("_Authenticate"));
-		gtk_container_add (GTK_CONTAINER (hgrid), auth_button);
-		g_signal_connect (auth_button, "clicked",  G_CALLBACK (validate_credentials), data->config);
-
-		gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
-		gtk_widget_show_all (GTK_WIDGET (hgrid));
-		gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (hgrid), 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_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);
-
-		g_object_bind_property_full (
-			settings, "security-method",
-			secure_conn, "active",
-			G_BINDING_BIDIRECTIONAL |
-			G_BINDING_SYNC_CREATE,
-			transform_security_method_to_boolean,
-			transform_boolean_to_security_method,
-			NULL, (GDestroyNotify) NULL);
-
-		row++;
-		krb_sso = gtk_check_button_new_with_mnemonic (_("_Kerberos authentication"));
-
-		g_object_bind_property (
-			settings, "kerberos",
-			krb_sso, "active",
-			G_BINDING_BIDIRECTIONAL |
-			G_BINDING_SYNC_CREATE);
-		gtk_widget_show (krb_sso);
-		gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (krb_sso), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
-
-		row++;
-		label = gtk_label_new_with_mnemonic (_("_Realm name:"));
-		gtk_widget_show (label);
-
-		g_object_bind_property (
-			settings, "kerberos",
-			label, "sensitive",
-			G_BINDING_SYNC_CREATE);
-
-		realm_name = gtk_entry_new ();
-		gtk_label_set_mnemonic_widget (GTK_LABEL (label), realm_name);
-		gtk_widget_show (realm_name);
-
-		g_object_bind_property (
-			settings, "realm",
-			realm_name, "text",
-			G_BINDING_BIDIRECTIONAL |
-			G_BINDING_SYNC_CREATE);
-
-		g_object_bind_property (
-			settings, "kerberos",
-			realm_name, "sensitive",
-			G_BINDING_SYNC_CREATE);
-
-		gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row + 1, 0, 0, 0, 0);
-		gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (realm_name), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
-	}
+	g_object_get (data->parent, "n-rows", &row, NULL);
+
+	/* Domain name & Authenticate Button */
+	hgrid = g_object_new (GTK_TYPE_GRID, "column-homogeneous", FALSE, "column-spacing", 6, "orientation", GTK_ORIENTATION_HORIZONTAL, NULL);
+	label = gtk_label_new_with_mnemonic (_("_Domain name:"));
+	gtk_widget_show (label);
+
+	domain_name = gtk_entry_new ();
+	gtk_label_set_mnemonic_widget (GTK_LABEL (label), domain_name);
+	gtk_container_add (GTK_CONTAINER (hgrid), domain_name);
+	g_object_bind_property (
+		settings, "domain",
+		domain_name, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	auth_button = gtk_button_new_with_mnemonic (_("_Authenticate"));
+	gtk_container_add (GTK_CONTAINER (hgrid), auth_button);
+	g_signal_connect (auth_button, "clicked",  G_CALLBACK (validate_credentials), data->config);
+
+	gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
+	gtk_widget_show_all (GTK_WIDGET (hgrid));
+	gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (hgrid), 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_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);
+
+	g_object_bind_property_full (
+		settings, "security-method",
+		secure_conn, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		transform_security_method_to_boolean,
+		transform_boolean_to_security_method,
+		NULL, (GDestroyNotify) NULL);
+
+	row++;
+	krb_sso = gtk_check_button_new_with_mnemonic (_("_Kerberos authentication"));
+
+	g_object_bind_property (
+		settings, "kerberos",
+		krb_sso, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+	gtk_widget_show (krb_sso);
+	gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (krb_sso), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+
+	row++;
+	label = gtk_label_new_with_mnemonic (_("_Realm name:"));
+	gtk_widget_show (label);
+
+	g_object_bind_property (
+		settings, "kerberos",
+		label, "sensitive",
+		G_BINDING_SYNC_CREATE);
+
+	realm_name = gtk_entry_new ();
+	gtk_label_set_mnemonic_widget (GTK_LABEL (label), realm_name);
+	gtk_widget_show (realm_name);
+
+	g_object_bind_property (
+		settings, "realm",
+		realm_name, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		settings, "kerberos",
+		realm_name, "sensitive",
+		G_BINDING_SYNC_CREATE);
+
+	gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row + 1, 0, 0, 0, 0);
+	gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (realm_name), 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
 
-	camel_url_free (url);
 	return hgrid;
 }
 
 gboolean
 org_gnome_e_mapi_check_options(EPlugin *epl, EConfigHookPageCheckData *data)
 {
-	EMConfigTargetAccount *target = (EMConfigTargetAccount *)(data->config->target);
+	EMConfigTargetSettings *target = (EMConfigTargetSettings *)(data->config->target);
+	CamelMapiSettings *mapi_settings;
 	gboolean status = TRUE;
 
-	if (data->pageid != NULL && g_ascii_strcasecmp (data->pageid, "10.receive") == 0) {
-		CamelURL *url = camel_url_new (e_account_get_string(target->modified_account,
-								    E_ACCOUNT_SOURCE_URL), NULL);
+	if (!CAMEL_IS_MAPI_SETTINGS (target->storage_settings))
+		return TRUE;
 
-		if (url && url->protocol && g_ascii_strcasecmp (url->protocol, "mapi") == 0) {
-			const gchar *profile = NULL;
+	mapi_settings = CAMEL_MAPI_SETTINGS (target->storage_settings);
 
-			/* We assume that if the profile is set, then the setting is valid. */
-			profile = camel_mapi_settings_get_profile (CAMEL_MAPI_SETTINGS (target->settings));
+	if (data->pageid != NULL && g_ascii_strcasecmp (data->pageid, "10.receive") == 0) {
+		const gchar *profile = NULL;
 
-			/* Profile not set. Do not proceed with account creation.*/
-			status = (profile != NULL && *profile != '\0');
-		}
+		/* We assume that if the profile is set, then the setting is valid. */
+		profile = camel_mapi_settings_get_profile (mapi_settings);
 
-		if (url)
-			camel_url_free(url);
+		/* Profile not set. Do not proceed with account creation.*/
+		status = (profile != NULL && *profile != '\0');
 	}
 
 	return status;
diff --git a/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml b/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml
index 11ffa74..30207c4 100644
--- a/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml
+++ b/src/account-setup-eplugin/org-gnome-exchange-mapi.eplug.xml
@@ -10,7 +10,7 @@
 
 		<hook class="org.gnome.evolution.mail.config:1.0">
 			<group 
-				target="account" 
+				target="settings" 
 				id="org.gnome.evolution.mail.config.accountWizard" 
 				check="org_gnome_e_mapi_check_options">
 				<item 
@@ -21,7 +21,7 @@
 		</hook>
 		<hook class="org.gnome.evolution.mail.config:1.0">
 			<group 
-				target="account" 
+				target="settings" 
 				id="org.gnome.evolution.mail.config.accountAssistant" 
 				check="org_gnome_e_mapi_check_options">
 				<item 
@@ -32,7 +32,7 @@
 		</hook>
 		<hook class="org.gnome.evolution.mail.config:1.0">
 			<group 
-				target="account" 
+				target="settings" 
 				id="org.gnome.evolution.mail.config.accountEditor" 
 				check="org_gnome_e_mapi_check_options">
 				<item 
@@ -43,7 +43,7 @@
 		</hook>
 		<hook class="org.gnome.evolution.mail.config:1.0">
       		      <group 
-			 target="account" 
+			 target="settings" 
 			 id="org.gnome.evolution.mail.config.accountEditor"
 			 check="org_gnome_e_mapi_check_options">
 			<item type="page" 



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