From 4b58f113f8d5399f103db891f0faa2a0deae7450 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 8 Dec 2010 18:49:59 +0100 Subject: Bug #633702 - Forget password when saving account without "Remember password" --- mail/em-account-editor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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 #include +#include #include "shell/e-shell.h" #include "e-util/e-util.h" @@ -3624,6 +3625,47 @@ em_account_editor_check (EMAccountEditor *emae, const gchar *page) return emae_check_complete ((EConfig *)emae->config, page, emae); } +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) { @@ -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); -- cgit v1.2.3