aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-12-09 01:49:59 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:41:10 +0800
commit6ab6db65f8f9de784061f2d51df48c341711c30d (patch)
tree9686276e375894328ee36a8ab7fe3a8263c9e4f2
parentd7538d3b5dd21a5098c6176941101bac2e52d35b (diff)
downloadgsoc2013-evolution-6ab6db65f8f9de784061f2d51df48c341711c30d.tar
gsoc2013-evolution-6ab6db65f8f9de784061f2d51df48c341711c30d.tar.gz
gsoc2013-evolution-6ab6db65f8f9de784061f2d51df48c341711c30d.tar.bz2
gsoc2013-evolution-6ab6db65f8f9de784061f2d51df48c341711c30d.tar.lz
gsoc2013-evolution-6ab6db65f8f9de784061f2d51df48c341711c30d.tar.xz
gsoc2013-evolution-6ab6db65f8f9de784061f2d51df48c341711c30d.tar.zst
gsoc2013-evolution-6ab6db65f8f9de784061f2d51df48c341711c30d.zip
Bug #633702 - Forget password when saving account without "Remember password"
-rw-r--r--mail/em-account-editor.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 48c564c01f..6bc446ebd8 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -45,6 +45,7 @@
#include <stdarg.h>
#include <gconf/gconf-client.h>
+#include <libedataserverui/e-passwords.h>
#include "shell/e-shell.h"
#include "e-util/e-util.h"
@@ -3625,6 +3626,47 @@ em_account_editor_check (EMAccountEditor *emae, const gchar *page)
}
static void
+forget_password_if_needed (EAccount *original_account, EAccount *modified_account, e_account_item_t save_pass_itm, e_account_item_t url_itm)
+{
+ const gchar *orig_url, *modif_url;
+
+ g_return_if_fail (original_account != NULL);
+ g_return_if_fail (modified_account != NULL);
+
+ orig_url = e_account_get_string (original_account, url_itm);
+ modif_url = e_account_get_string (modified_account, url_itm);
+
+ if (orig_url && !*orig_url)
+ orig_url = NULL;
+
+ if (modif_url && !*modif_url)
+ modif_url = NULL;
+
+ if ((e_account_get_bool (original_account, save_pass_itm) != e_account_get_bool (modified_account, save_pass_itm)
+ && !e_account_get_bool (modified_account, save_pass_itm) && orig_url) ||
+ (orig_url && !modif_url)) {
+ CamelURL *url;
+ gchar *url_str;
+ const gchar *auth_domain;
+
+ url = camel_url_new (orig_url, NULL);
+ if (!url)
+ return;
+
+ auth_domain = camel_url_get_param (url, "auth-domain");
+ if (!auth_domain)
+ auth_domain = "Mail";
+
+ url_str = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+ if (url_str)
+ e_passwords_forget_password (auth_domain, url_str);
+
+ g_free (url_str);
+ camel_url_free (url);
+ }
+}
+
+static void
emae_commit (EConfig *ec, GSList *items, gpointer data)
{
EMAccountEditor *emae = data;
@@ -3640,6 +3682,9 @@ emae_commit (EConfig *ec, GSList *items, gpointer data)
if (original_account != NULL) {
d (printf ("Committing account '%s'\n", e_account_get_string (modified_account, E_ACCOUNT_NAME)));
+ forget_password_if_needed (original_account, modified_account, E_ACCOUNT_SOURCE_SAVE_PASSWD, E_ACCOUNT_SOURCE_URL);
+ forget_password_if_needed (original_account, modified_account, E_ACCOUNT_TRANSPORT_SAVE_PASSWD, E_ACCOUNT_TRANSPORT_URL);
+
e_account_import (original_account, modified_account);
account = original_account;
e_account_list_change (accounts, account);