From: Philip Van Hoof Date: Tue, 25 Sep 2007 10:57:01 +0000 (+0000) Subject: Reconnect and forget password when changing account settings X-Git-Tag: git_migration_finished~2304 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=9294f75945324f42d262eccd7496f9272890abe7 Reconnect and forget password when changing account settings pmo-trunk-r3406 --- diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 43e5287..87d5277 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -741,6 +741,38 @@ get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *canc return pwd; } +void +modest_tny_account_store_forget_already_asked (ModestTnyAccountStore *self, TnyAccount *account) +{ + g_return_if_fail (account); + + ModestTnyAccountStorePrivate *priv; + gchar *pwd = NULL; + gpointer pwd_ptr = NULL; + gboolean already_asked = FALSE; + + const gchar *server_account_name = tny_account_get_id (account); + + priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self); + + /* This hash map stores passwords, including passwords that are not stored in gconf. */ + pwd_ptr = (gpointer)&pwd; /* pwd_ptr so the compiler does not complained about + * type-punned ptrs...*/ + already_asked = priv->password_hash && + g_hash_table_lookup_extended (priv->password_hash, + server_account_name, + NULL, + (gpointer*)&pwd_ptr); + + if (already_asked) { + g_hash_table_remove (priv->password_hash, server_account_name); + g_free (pwd); + pwd = NULL; + } + + return; +} + /* tinymail calls this if the connection failed due to an incorrect password. * And it seems to call this for any general connection failure. */ static void diff --git a/src/modest-tny-account-store.h b/src/modest-tny-account-store.h index 76fbe91..336359e 100644 --- a/src/modest-tny-account-store.h +++ b/src/modest-tny-account-store.h @@ -169,6 +169,15 @@ TnySessionCamel* modest_tny_account_store_get_session (TnyAccountStore *se **/ TnyAccount * modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self); +/** modest_tny_account_store_forget_already_asked: + * @self: a TnyAccountStore instance + * @account: the account to forget the already asked status for + * + * Forget the already asked status of an account + **/ +void modest_tny_account_store_forget_already_asked (ModestTnyAccountStore *self, TnyAccount *account); + + G_END_DECLS #endif /* __MODEST_TNY_ACCOUNT_STORE_H__ */ diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 3f24610..61ab31d 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -610,10 +610,19 @@ modest_tny_account_update_from_account (TnyAccount *tny_account, ModestAccountMg /* If the account was online, reconnect to apply the changes */ conn_status = tny_account_get_connection_status (tny_account); if (conn_status != TNY_CONNECTION_STATUS_DISCONNECTED) { + TnyAccountStore *account_store = NULL; /* The callback will have an error for you if the reconnect * failed. Please handle it (this is TODO). */ + account_store = TNY_ACCOUNT_STORE(g_object_get_data (G_OBJECT(tny_account), + "account_store")); + + if (account_store) { + modest_tny_account_store_forget_already_asked (MODEST_TNY_ACCOUNT_STORE (account_store), + tny_account); + } + tny_camel_account_set_online (TNY_CAMEL_ACCOUNT(tny_account), TRUE, set_online_callback, "online"); }