[evolution/gnome-3-4] Bug #676226 - Changing GOA mail account looses GOA key



commit 6b21e87c9f6dc2c0cb0503d72f6b49596c36d476
Author: Milan Crha <mcrha redhat com>
Date:   Thu May 17 14:10:15 2012 +0200

    Bug #676226 - Changing GOA mail account looses GOA key

 mail/em-account-editor.c                           |   41 ++++++++++++++++++++
 modules/online-accounts/e-online-accounts-google.c |    7 +++
 2 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 315121d..7b0d37a 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -5521,6 +5521,37 @@ setup_yahoo_calendar (EMAccountEditor *emae)
 }
 
 static void
+copy_param (GQuark key_id,
+            gpointer data,
+            gpointer user_data)
+{
+	GData **copy = user_data;
+
+	g_datalist_id_set_data_full (copy, key_id, g_strdup (data), g_free);
+}
+
+static void
+copy_original_url_parameters (CamelURL *copy_to_url,
+			      const gchar *copy_from)
+{
+	CamelURL *url;
+
+	g_return_if_fail (copy_to_url != NULL);
+
+	if (!copy_from || !*copy_from)
+		return;
+
+	url = camel_url_new (copy_from, NULL);
+	if (!url)
+		return;
+
+	if (url->params)
+		g_datalist_foreach (&url->params, copy_param, &copy_to_url->params);
+
+	camel_url_free (url);
+}
+
+static void
 emae_commit (EConfig *ec,
              EMAccountEditor *emae)
 {
@@ -5581,6 +5612,11 @@ emae_commit (EConfig *ec,
 		if (protocol != NULL)
 			camel_url_set_protocol (url, protocol);
 
+		/* the CamelSaslXOAUTH stores its data into parameters
+		   unknown to settings, thus copy these first and overwrite
+		   those known during save */
+		copy_original_url_parameters (url, modified_account->source->url);
+
 		if (settings != NULL)
 			camel_settings_save_to_url (settings, url);
 
@@ -5602,6 +5638,11 @@ emae_commit (EConfig *ec,
 	if (protocol != NULL)
 		camel_url_set_protocol (url, protocol);
 
+	/* the CamelSaslXOAUTH stores its data into parameters
+	   unknown to settings, thus copy these first and overwrite
+	   those known during save */
+	copy_original_url_parameters (url, modified_account->transport->url);
+
 	if (settings != NULL)
 		camel_settings_save_to_url (settings, url);
 
diff --git a/modules/online-accounts/e-online-accounts-google.c b/modules/online-accounts/e-online-accounts-google.c
index 2c64218..ab394f6 100644
--- a/modules/online-accounts/e-online-accounts-google.c
+++ b/modules/online-accounts/e-online-accounts-google.c
@@ -206,6 +206,13 @@ online_accounts_google_sync_mail (GoaObject *goa_object,
 	string = goa_account_get_id (goa_account);
 	camel_url_set_param (url, GOA_KEY, string);
 
+	if (new_account) {
+		e_account_set_bool (account, E_ACCOUNT_SOURCE_AUTO_CHECK, TRUE);
+		e_account_set_int (account, E_ACCOUNT_SOURCE_AUTO_CHECK_TIME, 10);
+
+		camel_url_set_param (url, "filter-inbox", "true");
+	}
+
 	g_free (account->source->url);
 	account->source->url = camel_url_to_string (url, 0);
 



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