2007-05-08 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Tue, 8 May 2007 14:21:32 +0000 (14:21 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 8 May 2007 14:21:32 +0000 (14:21 +0000)
* src/modest-tny-account-store.c: (get_password):
        * src/modest-ui-actions.c:
        (modest_ui_actions_on_password_requested):
        Allow the username to be changed too, though there is more work to
        be done on exactly how this behaves.

pmo-trunk-r1787

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

index 24d8ad9..8eac102 100644 (file)
@@ -1,5 +1,13 @@
 2007-05-08  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/modest-tny-account-store.c: (get_password):
+       * src/modest-ui-actions.c:
+       (modest_ui_actions_on_password_requested):
+       Allow the username to be changed too, though there is more work to 
+       be done on exactly how this behaves.
+
+2007-05-08  Murray Cumming  <murrayc@murrayc.com>
+
        * src/modest-account-mgr-helpers.h:
        * src/modest-account-mgr-helpers.c:
        Added modest_account_mgr_get_display_name(),
index 2ae87a7..0932392 100644 (file)
@@ -273,6 +273,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? */
        /* 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...*/
@@ -295,6 +296,9 @@ get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
                gboolean remember = FALSE;
                pwd = NULL;
                
+               /* Note that we ignore the returned username here,
+                * because it is enough that it will be stored in gconf 
+                * by the signal handler. */
                g_signal_emit (G_OBJECT(self), signals[PASSWORD_REQUESTED_SIGNAL], 0,
                               account_id, /* server_account_name */
                               &username, &pwd, cancel, &remember);
index da6c4ca..a1f3d9e 100644 (file)
@@ -1705,8 +1705,9 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
        GtkWidget *entry_username = gtk_entry_new ();
        if (initial_username)
                gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username);
-        /* TODO: Allow the username to be changed here. */
-       gtk_widget_set_sensitive (entry_username, FALSE);
+       /* TODO: Dim this if a connection has ever succeeded with this username,
+        * as per the UI spec: */
+       /* gtk_widget_set_sensitive (entry_username, FALSE); */
        
 #ifdef MODEST_PLATFORM_MAEMO
        /* Auto-capitalization is the default, so let's turn it off: */
@@ -1757,9 +1758,25 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
        gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
        
        if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
-               if (username)
+               if (username) {
                        *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
                        
+                       modest_server_account_set_username (
+                                modest_runtime_get_account_mgr(), server_account_name, 
+                                *username);
+                                
+                       const gboolean username_was_changed = 
+                               (strcmp (*username, initial_username) != 0);
+                       if (username_was_changed) {
+                               /* To actually use a changed username, 
+                                * we must reset the connection, according to pvanhoof.
+                                * This _might_ be a sensible way to do that: */
+                                TnyDevice *device = modest_runtime_get_device();
+                                tny_device_force_offline (device);
+                                tny_device_force_online (device);
+                       }
+               }
+                       
                if (password) {
                        *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password)));
                        
@@ -1773,6 +1790,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                
                if (cancel)
                        *cancel   = FALSE;
+                       
        } else {
                if (username)
                        *username = NULL;