2007-05-08 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Tue, 8 May 2007 15:26:35 +0000 (15:26 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 8 May 2007 15:26:35 +0000 (15:26 +0000)
* src/modest-tny-account-store.c:
        (modest_tny_account_store_instance_init), (get_password):
        * src/modest-ui-actions.c:
        (modest_ui_actions_on_password_requested):
        Do not store the password in gconf, because this function is called
        for non-remembered passwords. Actually use the cached (in the hash map)
        password instead of releasing it.
        The password will now not be remembered if it is asked via the protected
        password dialog, as per the UI spec.

pmo-trunk-r1789

ChangeLog2
src/modest-tny-account-store.c
src/modest-ui-actions.c

index 0ffb212..ee2f1a2 100644 (file)
@@ -1,5 +1,17 @@
 2007-05-08  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/modest-tny-account-store.c:
+       (modest_tny_account_store_instance_init), (get_password):
+       * src/modest-ui-actions.c:
+       (modest_ui_actions_on_password_requested):
+       Do not store the password in gconf, because this function is called 
+       for non-remembered passwords. Actually use the cached (in the hash map) 
+       password instead of releasing it.
+       The password will now not be remembered if it is asked via the protected 
+       password dialog, as per the UI spec.
+
+2007-05-08  Murray Cumming  <murrayc@murrayc.com>
+
        * src/modest-defs.h:
        * src/modest-account-mgr-helpers.h:
        * src/modest-account-mgr-helpers.c:
index 9dcf364..a6a5e4f 100644 (file)
@@ -175,6 +175,10 @@ modest_tny_account_store_instance_init (ModestTnyAccountStore *obj)
        priv->session                = NULL;
        priv->device                 = NULL;
        
+       /* An in-memory store of passwords, 
+        * for passwords that are not remembered in the configuration,
+         * so they need to be asked for from the user once in each session:
+         */
        priv->password_hash          = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                              g_free, g_free);
 }
@@ -253,7 +257,8 @@ get_account_store_for_account (TnyAccount *account)
                                                           "account_store"));
 }
 
-/* This callback will be called by Tinymail when it needs the password.
+/* This callback will be called by Tinymail when it needs the password
+ * from the user, for instance if the password was not remembered.
  * Note that TnyAccount here will be the server account. */
 static gchar*
 get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
@@ -273,7 +278,7 @@ get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
        self = MODEST_TNY_ACCOUNT_STORE (account_store);
         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
        
-       /* TODO: What is this hash for? */
+       /* This hash map stores passwords, including passwords that are not stored in gconf. */
        /* is it in the hash? if it's already there, it must be wrong... */
        pwd_ptr = (gpointer)&pwd; /* pwd_ptr so the compiler does not complained about
                                   * type-punned ptrs...*/
@@ -315,14 +320,13 @@ get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
                        g_hash_table_insert (priv->password_hash, g_strdup (key), g_strdup(pwd));
                } else {
                        g_hash_table_remove (priv->password_hash, key);
+                       
+                       g_free (pwd);
+                       pwd = NULL;
                }
 
                g_free (username);
                username = NULL;
-               
-               g_free (pwd);
-               pwd = NULL;
-                       
        } else
                *cancel = FALSE;
  
index c3382eb..b5c53e7 100644 (file)
@@ -1783,12 +1783,13 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                if (password) {
                        *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password)));
                        
-                       /* TODO: It is strange that we must return this as well as set it in gconf.
-                        * That would only be useful if there was a remember-password preference, 
-                        * but there is no such preference at this time. */
+                       /* We do not save the password in the configuration, 
+                        * because this function is only called for passwords that should 
+                        * not be remembered:
                        modest_server_account_set_password (
                                 modest_runtime_get_account_mgr(), server_account_name, 
                                 *password);
+                       */
                }
                
                if (cancel)