Reconnect and forget password when changing account settings
authorPhilip Van Hoof <philip@codeminded.be>
Tue, 25 Sep 2007 10:57:01 +0000 (10:57 +0000)
committerPhilip Van Hoof <philip@codeminded.be>
Tue, 25 Sep 2007 10:57:01 +0000 (10:57 +0000)
pmo-trunk-r3406

src/modest-tny-account-store.c
src/modest-tny-account-store.h
src/modest-tny-account.c

index 43e5287..87d5277 100644 (file)
@@ -741,6 +741,38 @@ get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *canc
        return pwd;
 }
 
        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
 /* 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
index 76fbe91..336359e 100644 (file)
@@ -169,6 +169,15 @@ TnySessionCamel*    modest_tny_account_store_get_session    (TnyAccountStore *se
  **/
 TnyAccount * modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self);
 
  **/
 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__ */
 G_END_DECLS
 
 #endif /* __MODEST_TNY_ACCOUNT_STORE_H__ */
index 3f24610..61ab31d 100644 (file)
@@ -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) {
        /* 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). */
 
 
                /* 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");
        }
                tny_camel_account_set_online (TNY_CAMEL_ACCOUNT(tny_account), TRUE, 
                        set_online_callback,  "online");
        }