2007-05-08 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Tue, 8 May 2007 13:05:36 +0000 (13:05 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 8 May 2007 13:05:36 +0000 (13:05 +0000)
* src/modest-account-mgr-helpers.h:
        * src/modest-account-mgr-helpers.c:
        Added modest_account_mgr_get_display_name(),
        modest_server_account_get_username(),
        modest_server_account_set_username(),
        modest_server_account_set_password(),
        modest_server_account_get_hostname() functions so we do not need to
        use the conf API directly.

        * src/maemo/modest-main-window.c: (connect_signals):
        Actually connect ot the ModestAccountStore::request-password signal,
        so that we show the dialog when the password is requested by Tinymail,
        for isntance if it is empty.

        * src/modest-marshal.list:
        * src/modest-tny-account-store.c:
        (modest_tny_account_store_class_init), (get_password),
        (modest_tny_account_store_alert):
        * src/modest-tny-account-store.h:
        * src/modest-ui-actions.h:
        * src/modest-ui-actions.c:
        (modest_ui_actions_on_password_requested):
        Change the signal parameters, so it is obvious that we are providing
        the non human-readable server name, and receiving both the username
        and password, though changing of the username is not yet implemented.
        Change the dialog UI to match the Maemo UI specifications, with #idfefing
        for the GNOME version.

        This should fix the projects.maemo.org bug NB#56209, though it does not
        work on Bora, because the gconf_client_get() for the password fails
        immediately after we save it with gconf_client_set().

pmo-trunk-r1786

ChangeLog2
src/maemo/modest-main-window.c
src/modest-account-mgr-helpers.c
src/modest-account-mgr-helpers.h
src/modest-marshal.list
src/modest-tny-account-store.c
src/modest-tny-account-store.h
src/modest-ui-actions.c
src/modest-ui-actions.h

index d448754..24d8ad9 100644 (file)
@@ -1,5 +1,39 @@
 2007-05-08  Murray Cumming  <murrayc@murrayc.com>
 
 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(),
+       modest_server_account_get_username(),
+       modest_server_account_set_username(),
+       modest_server_account_set_password(),
+       modest_server_account_get_hostname() functions so we do not need to 
+       use the conf API directly.
+       
+       * src/maemo/modest-main-window.c: (connect_signals):
+       Actually connect ot the ModestAccountStore::request-password signal, 
+       so that we show the dialog when the password is requested by Tinymail, 
+       for isntance if it is empty.
+
+       * src/modest-marshal.list:
+       * src/modest-tny-account-store.c:
+       (modest_tny_account_store_class_init), (get_password),
+       (modest_tny_account_store_alert):
+       * src/modest-tny-account-store.h:
+       * src/modest-ui-actions.h:
+       * src/modest-ui-actions.c:
+       (modest_ui_actions_on_password_requested):
+       Change the signal parameters, so it is obvious that we are providing 
+       the non human-readable server name, and receiving both the username 
+       and password, though changing of the username is not yet implemented.
+       Change the dialog UI to match the Maemo UI specifications, with #idfefing 
+       for the GNOME version.
+       
+       This should fix the projects.maemo.org bug NB#56209, though it does not 
+       work on Bora, because the gconf_client_get() for the password fails 
+       immediately after we save it with gconf_client_set().
+
+2007-05-08  Murray Cumming  <murrayc@murrayc.com>
+
        * configure.ac:
        * src/Makefile.am: Reverted the use of AM_CONDITIONAL(), because it 
        caused an undefined symbol error:
        * configure.ac:
        * src/Makefile.am: Reverted the use of AM_CONDITIONAL(), because it 
        caused an undefined symbol error:
index e757a1a..b9ec7f8 100644 (file)
@@ -422,6 +422,10 @@ connect_signals (ModestMainWindow *self)
                          G_CALLBACK (on_account_update),
                          self);
 
                          G_CALLBACK (on_account_update),
                          self);
 
+       /* Account store */
+       g_signal_connect (G_OBJECT (modest_runtime_get_account_store()), "password_requested",
+                         G_CALLBACK (modest_ui_actions_on_password_requested), self);
+                         
        /* Device */
        g_signal_connect (G_OBJECT(modest_runtime_get_device()), "connection_changed",
                          G_CALLBACK(on_connection_changed), self);
        /* Device */
        g_signal_connect (G_OBJECT(modest_runtime_get_device()), "connection_changed",
                          G_CALLBACK(on_connection_changed), self);
index 20ed6a6..6f5038d 100644 (file)
@@ -57,6 +57,13 @@ gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar*
        return result;
 }
 
        return result;
 }
 
+gchar* modest_account_mgr_get_display_name (ModestAccountMgr *self, 
+       const gchar* name)
+{
+       return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_DISPLAY_NAME, FALSE);
+}
+
+
 
 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name, 
        gboolean* use_signature)
 
 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name, 
        gboolean* use_signature)
@@ -244,7 +251,36 @@ gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
        return result;
 }
                                         
        return result;
 }
                                         
-                                        
+gchar*
+modest_server_account_get_username (ModestAccountMgr *self, const gchar* account_name)
+{
+       return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_USERNAME, 
+               TRUE /* server account */);
+}
+
+void
+modest_server_account_set_username (ModestAccountMgr *self, const gchar* account_name, 
+       const gchar* username)
+{
+       modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME, 
+               username, TRUE /* server account */);
+}
+
+void
+modest_server_account_set_password (ModestAccountMgr *self, const gchar* account_name, 
+       const gchar* password)
+{
+       modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD, 
+               password, TRUE /* server account */);
+}
+       
+gchar*
+modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account_name)
+{
+       return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_HOSTNAME, 
+               TRUE /* server account */);
+}
 
 static ModestProtocol
 get_secure_auth_for_conf_string(const gchar* value)
 
 static ModestProtocol
 get_secure_auth_for_conf_string(const gchar* value)
index 60d91ef..29c3938 100644 (file)
@@ -164,6 +164,17 @@ gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* na
 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
 
 /**
 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
 
 /**
+ * modest_account_mgr_get_display_name:
+ * @self: a ModestAccountMgr instance
+ * @name: the account name to check
+ *
+ * Return the human-readable account title for this account, or NULL.
+ */
+gchar* modest_account_mgr_get_display_name (ModestAccountMgr *self, 
+       const gchar* name);
+
+
+/**
  * modest_account_mgr_set_signature
  * @self: a ModestAccountMgr instance
  * @name: the account name to check
  * modest_account_mgr_set_signature
  * @self: a ModestAccountMgr instance
  * @name: the account name to check
@@ -229,7 +240,58 @@ gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *s
  */                     
 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
                                         const gchar* connection_name);
  */                     
 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
                                         const gchar* connection_name);
-                                        
+
+
+/**
+ * modest_server_account_get_username:
+ * @self: a ModestAccountMgr instance
+ * @account_name: The name of a server account.
+ *
+ * Gets the username this server account.
+ *
+ * Returns: The username.
+ */
+gchar*
+modest_server_account_get_username (ModestAccountMgr *self, const gchar* account_name);
+
+/**
+ * modest_server_account_set_username:
+ * @self: a ModestAccountMgr instance
+ * @account_name: The name of a server account.
+ * @username: The new username.
+ *
+ * Sets the username this server account.
+ */
+void
+modest_server_account_set_username (ModestAccountMgr *self, const gchar* account_name, 
+       const gchar* username);
+
+/**
+ * modest_server_account_set_password:
+ * @self: a ModestAccountMgr instance
+ * @account_name: The name of a server account.
+ * @password: The new password.
+ *
+ * Sets the password this server account.
+ */
+void
+modest_server_account_set_password (ModestAccountMgr *self, const gchar* account_name, 
+       const gchar* password);
+                        
+
+/**
+ * modest_server_account_modest_server_account_get_hostnameget_username:
+ * @self: a ModestAccountMgr instance
+ * @account_name: The name of a server account.
+ *
+ * Gets the hostname this server account.
+ *
+ * Returns: The hostname.
+ */
+gchar*
+modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account_name);
+
+
 /**
  * modest_server_account_get_secure_auth:
  * @self: a ModestAccountMgr instance
 /**
  * modest_server_account_get_secure_auth:
  * @self: a ModestAccountMgr instance
index efa3bdf..6fcf0e2 100644 (file)
@@ -1,6 +1,6 @@
 VOID:POINTER,POINTER
 VOID:POINTER,POINTER,POINTER
 VOID:POINTER,POINTER
 VOID:POINTER,POINTER,POINTER
-VOID:STRING,POINTER,POINTER,POINTER
+VOID:STRING,POINTER,POINTER,POINTER,POINTER
 VOID:POINTER,BOOL
 VOID:STRING,INT
 VOID:STRING,INT,INT
 VOID:POINTER,BOOL
 VOID:STRING,INT
 VOID:STRING,INT,INT
index e8fd54d..2ae87a7 100644 (file)
@@ -158,8 +158,8 @@ modest_tny_account_store_class_init (ModestTnyAccountStoreClass *klass)
                               G_SIGNAL_RUN_FIRST,
                               G_STRUCT_OFFSET(ModestTnyAccountStoreClass, password_requested),
                               NULL, NULL,
                               G_SIGNAL_RUN_FIRST,
                               G_STRUCT_OFFSET(ModestTnyAccountStoreClass, password_requested),
                               NULL, NULL,
-                              modest_marshal_VOID__STRING_POINTER_POINTER_POINTER,
-                              G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER,
+                              modest_marshal_VOID__STRING_POINTER_POINTER_POINTER_POINTER,
+                              G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER,
                               G_TYPE_POINTER);
 }
 
                               G_TYPE_POINTER);
 }
 
@@ -253,15 +253,16 @@ get_account_store_for_account (TnyAccount *account)
                                                           "account_store"));
 }
 
                                                           "account_store"));
 }
 
+/* This callback will be called by Tinymail when it needs the password.
+ * Note that TnyAccount here will be the server account. */
 static gchar*
 get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
 {
 static gchar*
 get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
 {
-       /* printf("DEBUG: %s\n", __FUNCTION__); */
-       
        const gchar *key;
        const TnyAccountStore *account_store;
        ModestTnyAccountStore *self;
        ModestTnyAccountStorePrivate *priv;
        const gchar *key;
        const TnyAccountStore *account_store;
        ModestTnyAccountStore *self;
        ModestTnyAccountStorePrivate *priv;
+       gchar *username = NULL;
        gchar *pwd = NULL;
        gpointer pwd_ptr;
        gboolean already_asked;
        gchar *pwd = NULL;
        gpointer pwd_ptr;
        gboolean already_asked;
@@ -283,20 +284,20 @@ get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
        /* if the password is not already there, try ModestConf */
        if (!already_asked) {
                pwd  = modest_account_mgr_get_string (priv->account_mgr,
        /* if the password is not already there, try ModestConf */
        if (!already_asked) {
                pwd  = modest_account_mgr_get_string (priv->account_mgr,
-                                                     key, MODEST_ACCOUNT_PASSWORD,TRUE);
+                                                     key, MODEST_ACCOUNT_PASSWORD, TRUE);
                g_hash_table_insert (priv->password_hash, g_strdup (key), g_strdup (pwd));
        }
 
        /* if it was already asked, it must have been wrong, so ask again */
        if (already_asked || !pwd || strlen(pwd) == 0) {
                g_hash_table_insert (priv->password_hash, g_strdup (key), g_strdup (pwd));
        }
 
        /* if it was already asked, it must have been wrong, so ask again */
        if (already_asked || !pwd || strlen(pwd) == 0) {
-
                /* we don't have it yet. Get the password from the user */
                /* we don't have it yet. Get the password from the user */
-               const gchar* name = tny_account_get_name (account);
+               const gchar* account_id = tny_account_get_id (account);
                gboolean remember = FALSE;
                pwd = NULL;
                
                g_signal_emit (G_OBJECT(self), signals[PASSWORD_REQUESTED_SIGNAL], 0,
                gboolean remember = FALSE;
                pwd = NULL;
                
                g_signal_emit (G_OBJECT(self), signals[PASSWORD_REQUESTED_SIGNAL], 0,
-                              name, &pwd, cancel, &remember);
+                              account_id, /* server_account_name */
+                              &username, &pwd, cancel, &remember);
                
                if (!*cancel) {
                        if (remember)
                
                if (!*cancel) {
                        if (remember)
@@ -310,9 +311,14 @@ 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_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;
  
        } else
                *cancel = FALSE;
  
@@ -610,6 +616,7 @@ modest_tny_account_store_alert (TnyAccountStore *self, TnyAlertType type,
                                const GError *error)
 {
        g_return_val_if_fail (error, FALSE);
                                const GError *error)
 {
        g_return_val_if_fail (error, FALSE);
+       g_return_val_if_fail (error->domain == TNY_ACCOUNT_ERROR, FALSE);
        
        printf("DEBUG: %s: error->message=%s\n", __FUNCTION__, error->message);
        
        
        printf("DEBUG: %s: error->message=%s\n", __FUNCTION__, error->message);
        
@@ -635,7 +642,6 @@ modest_tny_account_store_alert (TnyAccountStore *self, TnyAlertType type,
        switch (error->code)
        {
                case TNY_ACCOUNT_ERROR_TRY_CONNECT:
        switch (error->code)
        {
                case TNY_ACCOUNT_ERROR_TRY_CONNECT:
-                       /* Use a Logical ID: */
                        prompt = _("Modest account not yet fully configured");
                        break;
                default:
                        prompt = _("Modest account not yet fully configured");
                        break;
                default:
index 3ae4f27..4910603 100644 (file)
@@ -68,7 +68,8 @@ struct _ModestTnyAccountStoreClass {
                                      const gchar *account_name,
                                      gpointer user_data);
        void (*password_requested)    (ModestTnyAccountStore *self,
                                      const gchar *account_name,
                                      gpointer user_data);
        void (*password_requested)    (ModestTnyAccountStore *self,
-                                      const gchar *account_name,
+                                      const gchar *server_account_name,
+                                      gchar **username,
                                       gchar **password,
                                       gboolean *remember,
                                       gboolean *cancel,
                                       gchar **password,
                                       gboolean *remember,
                                       gboolean *cancel,
index 56eb343..da6c4ca 100644 (file)
@@ -46,6 +46,7 @@
 
 #ifdef MODEST_PLATFORM_MAEMO
 #include "maemo/modest-osso-state-saving.h"
 
 #ifdef MODEST_PLATFORM_MAEMO
 #include "maemo/modest-osso-state-saving.h"
+#include "maemo/modest-maemo-ui-constants.h"
 #endif /* MODEST_PLATFORM_MAEMO */
 
 
 #endif /* MODEST_PLATFORM_MAEMO */
 
 
@@ -1650,17 +1651,30 @@ modest_ui_actions_on_move_folder_to_trash_folder (GtkAction *action, ModestMainW
 
 void
 modest_ui_actions_on_password_requested (TnyAccountStore *account_store, 
 
 void
 modest_ui_actions_on_password_requested (TnyAccountStore *account_store, 
-                                        const gchar* account_name,
+                                        const gchar* server_account_name,
+                                        gchar **username,
                                         gchar **password, 
                                         gboolean *cancel, 
                                         gboolean *remember,
                                         ModestMainWindow *main_window)
 {
                                         gchar **password, 
                                         gboolean *cancel, 
                                         gboolean *remember,
                                         ModestMainWindow *main_window)
 {
-       /* printf("DEBUG: %s\n", __FUNCTION__); */
-       gchar *txt;
-       GtkWidget *dialog, *entry, *remember_pass_check;
-
-       dialog = gtk_dialog_new_with_buttons (_("Password requested"),
+       g_return_if_fail(server_account_name);
+       /* printf("DEBUG: %s: server_account_name=%s\n", __FUNCTION__, server_account_name); */
+       
+#ifdef MODEST_PLATFORM_MAEMO
+       /* Maemo uses a different (awkward) button order,
+        * It should probably just use gtk_alternative_dialog_button_order ().
+        */
+       GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
+                                             NULL,
+                                             GTK_DIALOG_MODAL,
+                                             GTK_STOCK_OK,
+                                             GTK_RESPONSE_ACCEPT,
+                                             GTK_STOCK_CANCEL,
+                                             GTK_RESPONSE_REJECT,
+                                             NULL);
+#else
+       GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
                                              NULL,
                                              GTK_DIALOG_MODAL,
                                              GTK_STOCK_CANCEL,
                                              NULL,
                                              GTK_DIALOG_MODAL,
                                              GTK_STOCK_CANCEL,
@@ -1668,38 +1682,114 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                              GTK_STOCK_OK,
                                              GTK_RESPONSE_ACCEPT,
                                              NULL);
                                              GTK_STOCK_OK,
                                              GTK_RESPONSE_ACCEPT,
                                              NULL);
+#endif /* MODEST_PLATFORM_MAEMO */
+
        gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(main_window));
        
        gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(main_window));
        
-       txt = g_strdup_printf (_("Please enter your password for %s"), account_name);
+       gchar *server_name = modest_server_account_get_hostname (
+               modest_runtime_get_account_mgr(), server_account_name);
+       
+       /* This causes a warning because the logical ID has no %s in it, 
+        * though the translation does, but there is not much we can do about that: */
+       gchar *txt = g_strdup_printf (_("mail_ia_password_info"), server_name);
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt),
                            FALSE, FALSE, 0);
        g_free (txt);
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt),
                            FALSE, FALSE, 0);
        g_free (txt);
+       g_free (server_name);
+       server_name = NULL;
 
 
-       entry = gtk_entry_new_with_max_length (40);
-       gtk_entry_set_visibility (GTK_ENTRY(entry), FALSE);
-       gtk_entry_set_invisible_char (GTK_ENTRY(entry), 0x2022); /* bullet unichar */
+       /* username: */
+       gchar *initial_username = modest_server_account_get_username (
+               modest_runtime_get_account_mgr(), server_account_name);
        
        
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry,
-                           TRUE, FALSE, 0);    
-
+       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);
+       
+#ifdef MODEST_PLATFORM_MAEMO
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_username), HILDON_GTK_INPUT_MODE_FULL);
+       
+       /* Create a size group to be used by all captions.
+        * Note that HildonCaption does not create a default size group if we do not specify one.
+        * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
+       GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+       
+       GtkWidget *caption = hildon_caption_new (sizegroup, 
+               _("mail_fi_username"), entry_username, NULL, HILDON_CAPTION_MANDATORY);
+       gtk_widget_show (entry_username);
+       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption, 
+               FALSE, FALSE, MODEST_MARGIN_HALF);
+       gtk_widget_show (caption);
+#else 
+       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_username,
+                           TRUE, FALSE, 0);
+#endif /* MODEST_PLATFORM_MAEMO */     
+                           
+       /* password: */
+       GtkWidget *entry_password = gtk_entry_new ();
+       gtk_entry_set_visibility (GTK_ENTRY(entry_password), FALSE);
+       gtk_entry_set_invisible_char (GTK_ENTRY(entry_password), 0x2022); /* bullet unichar */
+       
+#ifdef MODEST_PLATFORM_MAEMO
+       /* Auto-capitalization is the default, so let's turn it off: */
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password), HILDON_GTK_INPUT_MODE_FULL);
+       
+       caption = hildon_caption_new (sizegroup, 
+               _("mail_fi_password"), entry_password, NULL, HILDON_CAPTION_MANDATORY);
+       gtk_widget_show (entry_password);
+       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption, 
+               FALSE, FALSE, MODEST_MARGIN_HALF);
+       gtk_widget_show (caption);
+#else 
+       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_password,
+                           TRUE, FALSE, 0);
+#endif /* MODEST_PLATFORM_MAEMO */     
+                               
+/* This is not in the Maemo UI spec:
        remember_pass_check = gtk_check_button_new_with_label (_("Remember password"));
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check,
                            TRUE, FALSE, 0);
        remember_pass_check = gtk_check_button_new_with_label (_("Remember password"));
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check,
                            TRUE, FALSE, 0);
+*/
 
        gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
        
        if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
 
        gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
        
        if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
-               *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry)));
-               *cancel   = FALSE;
+               if (username)
+                       *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
+                       
+               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. */
+                       modest_server_account_set_password (
+                                modest_runtime_get_account_mgr(), server_account_name, 
+                                *password);
+               }
+               
+               if (cancel)
+                       *cancel   = FALSE;
        } else {
        } else {
-               *password = NULL;
-               *cancel   = TRUE;
+               if (username)
+                       *username = NULL;
+                       
+               if (password)
+                       *password = NULL;
+                       
+               if (cancel)
+                       *cancel   = TRUE;
        }
 
        }
 
+/* This is not in the Maemo UI spec:
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check)))
                *remember = TRUE;
        else
                *remember = FALSE;
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check)))
                *remember = TRUE;
        else
                *remember = FALSE;
+*/
 
        gtk_widget_destroy (dialog);
 }
 
        gtk_widget_destroy (dialog);
 }
index 3723ace..045e00c 100644 (file)
@@ -183,8 +183,8 @@ void     modest_ui_actions_on_connection_changed    (TnyDevice *device, gboolean
                                                     ModestMainWindow *main_window);
 
 void     modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                                     ModestMainWindow *main_window);
 
 void     modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
-                                                 const gchar* account_name,
-                                                 gchar **password,  gboolean *cancel, 
+                                                 const gchar* server_account_name,
+                                                 gchar **username, gchar **password, gboolean *cancel, 
                                                  gboolean *remember, ModestMainWindow *main_window);
 
 void     modest_ui_actions_on_undo                     (GtkAction *action,
                                                  gboolean *remember, ModestMainWindow *main_window);
 
 void     modest_ui_actions_on_undo                     (GtkAction *action,