* Added a new parametter to modest_platform_show_information_banner that...
authorSergio Villar Senin <svillar@igalia.com>
Mon, 24 Mar 2008 18:03:11 +0000 (18:03 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 24 Mar 2008 18:03:11 +0000 (18:03 +0000)
        * Fixes NB#81756, show the proper error note when the SMTP password is missing

pmo-trunk-r4339

src/dbus_api/modest-dbus-callbacks.c
src/gnome/modest-platform.c
src/maemo/modest-address-book.c
src/maemo/modest-platform.c
src/modest-platform.h
src/modest-tny-account-store.c
src/modest-ui-actions.c
src/widgets/modest-global-settings-dialog.c

index 14cbbfe..241221a 100644 (file)
@@ -1780,7 +1780,7 @@ notify_error_in_dbus_callback (gpointer user_data)
 static gboolean
 notify_msg_not_found_in_idle (gpointer user_data)
 {
-       modest_platform_run_information_dialog (NULL, _("mail_ni_ui_folder_get_msg_folder_error"));
+       modest_platform_run_information_dialog (NULL, _("mail_ni_ui_folder_get_msg_folder_error"), FALSE);
 
        return FALSE;
 }
index 39bf4d4..41feb01 100644 (file)
@@ -222,7 +222,8 @@ modest_platform_run_confirmation_dialog_with_buttons (GtkWindow *parent_window,
 
 void
 modest_platform_run_information_dialog (GtkWindow *parent_window,
-                                       const gchar *message)
+                                       const gchar *message,
+                                       gboolean block)
 {
        GtkWidget *dialog;
 
index 0f81b8a..be1db54 100644 (file)
@@ -875,7 +875,7 @@ resolve_address (const gchar *address, GSList **resolved_addresses, gchar **cont
 
        if (resolved_contacts == NULL) {
                /* no matching contacts for the search string */
-               modest_platform_run_information_dialog (NULL, _("mcen_nc_no_matching_contacts"));
+               modest_platform_run_information_dialog (NULL, _("mcen_nc_no_matching_contacts"), FALSE);
                return FALSE;
        }
 
index 4324559..2881ffb 100644 (file)
@@ -350,7 +350,7 @@ modest_platform_activate_file (const gchar *path, const gchar *mime_type)
        if (result != 1)
                result = hildon_mime_open_file (con, uri_path);
        if (result != 1)
-               modest_platform_run_information_dialog (NULL, _("mcen_ni_noregistered_viewer"));
+               modest_platform_run_information_dialog (NULL, _("mcen_ni_noregistered_viewer"), FALSE);
        
        return result != 1;
 }
@@ -1043,7 +1043,8 @@ modest_platform_run_yes_no_dialog (GtkWindow *parent_window,
 
 void
 modest_platform_run_information_dialog (GtkWindow *parent_window,
-                                       const gchar *message)
+                                       const gchar *message,
+                                       gboolean block)
 {
        GtkWidget *note;
        
@@ -1051,15 +1052,22 @@ modest_platform_run_information_dialog (GtkWindow *parent_window,
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
                                     GTK_WINDOW (note));
        
-       g_signal_connect_swapped (note,
-                                 "response", 
-                                 G_CALLBACK (on_destroy_dialog),
-                                 note);
-
-       gtk_widget_show_all (note);
-}
+       if (block) {
+               gtk_dialog_run (GTK_DIALOG (note));
+       
+               on_destroy_dialog (GTK_DIALOG (note));
 
+               while (gtk_events_pending ())
+                       gtk_main_iteration ();
+       } else {
+               g_signal_connect_swapped (note,
+                                         "response", 
+                                         G_CALLBACK (on_destroy_dialog),
+                                         note);
 
+               gtk_widget_show_all (note);
+       }
+}
 
 typedef struct _ConnectAndWaitData {
        GMutex *mutex;
@@ -1893,7 +1901,7 @@ modest_platform_run_alert_dialog (const gchar* prompt,
        } else {
                /* Just show the error text and use the default response: */
                modest_platform_run_information_dialog (GTK_WINDOW (main_win), 
-                                                       prompt);
+                                                       prompt, FALSE);
        }
        return retval;
 }
index 6af81c4..a4cb411 100644 (file)
@@ -230,11 +230,13 @@ gint      modest_platform_run_yes_no_dialog      (GtkWindow *parent_window,
  * modest_platform_run_information_dialog:
  * @parent_window: the parent #GtkWindow of the dialog
  * @message: the message to show
+ * @block: whether or not the dialog should block the main loop or not while running
  * 
  * shows an information dialog
  **/
 void      modest_platform_run_information_dialog       (GtkWindow *parent_window,
-                                                       const gchar *message);
+                                                       const gchar *message,
+                                                       gboolean block);
 
 /**
  * modest_platform_run_sort_dialog:
index 3e278c4..7a925af 100644 (file)
@@ -550,10 +550,6 @@ show_wrong_password_dialog (TnyAccount *account)
 static gchar*
 get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *cancel)
 {
-       /* TODO: Settting cancel to FALSE does not actually cancel everything.
-        * We still get multiple requests afterwards, so we end up showing the 
-        * same dialogs repeatedly.
-        */       
        const TnyAccountStore *account_store = NULL;
        ModestTnyAccountStore *self = NULL;
        ModestTnyAccountStorePrivate *priv;
@@ -614,12 +610,42 @@ get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *canc
                 * ask for it now. But if the password is wrong in the account settings, 
                 * then show a banner and the account settings dialog so it can be corrected:
                 */
+               ModestTransportStoreProtocol proto;
                const gboolean settings_have_password = 
                        modest_account_mgr_get_server_account_has_password (priv->account_mgr, server_account_name);
-               MODEST_DEBUG_BLOCK(
-                       printf ("%s: settings_have_password=%d\n",
-                               __FUNCTION__, settings_have_password);
-               );
+
+               /* Show an error and after that ask for a password */
+               proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account));
+               if (proto == MODEST_PROTOCOL_TRANSPORT_SMTP) {
+                       gchar *username = NULL, *msg = NULL;
+                       username = modest_account_mgr_get_server_account_username (priv->account_mgr,
+                                                                                  server_account_name);
+                       if (!username || strlen(username) == 0) {
+                               msg = g_strdup_printf (_("emev_ni_ui_smtp_userid_invalid"), 
+                                                      tny_account_get_name (account),
+                                                      tny_account_get_hostname (account));
+                       } else {
+                               gchar *password;
+                               password  = modest_account_mgr_get_server_account_password (priv->account_mgr,
+                                                                                           server_account_name);
+                               if (!password || strlen(password) == 0)
+                                       msg = g_strdup_printf (_("emev_ni_ui_smtp_passwd_invalid"), 
+                                                              tny_account_get_name (account),
+                                                              tny_account_get_hostname (account));
+                               else
+                                       msg = g_strdup_printf (_("emev_ni_ui_smtp_authentication_fail_error"), 
+                                                              tny_account_get_hostname (account));
+                               if (password)
+                                       g_free (password);
+                       }
+                       if (msg) {
+                               modest_platform_run_information_dialog (NULL, msg, TRUE);
+                               g_free (msg);
+                       }
+                       if (username)
+                               g_free (username);
+               }
+
                if (settings_have_password) {
                        /* The password must be wrong, so show the account settings dialog so it can be corrected: */
                        show_wrong_password_dialog (account);
index 3c66833..0616909 100644 (file)
@@ -427,7 +427,7 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                        msg = g_strdup_printf (_("mcen_nc_unable_to_delete_n_messages"), 
                                               opened_headers);
 
-                       modest_platform_run_information_dialog (GTK_WINDOW (win), (const gchar *) msg);
+                       modest_platform_run_information_dialog (GTK_WINDOW (win), (const gchar *) msg, FALSE);
                        
                        g_free (msg);
                        g_object_unref (header_list);
@@ -3108,7 +3108,8 @@ modest_ui_actions_delete_folder_error_handler (ModestMailOperation *mail_op,
        GObject *win = modest_mail_operation_get_source (mail_op);
 
        modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
-                                               _("mail_in_ui_folder_delete_error"));
+                                               _("mail_in_ui_folder_delete_error"),
+                                               FALSE);
        g_object_unref (win);
 }
 
@@ -3180,7 +3181,8 @@ delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
        /* Show an error if it's an account */
        if (!TNY_IS_FOLDER (folder)) {
                modest_platform_run_information_dialog (GTK_WINDOW (main_window),
-                                                       _("mail_in_ui_folder_delete_error"));
+                                                       _("mail_in_ui_folder_delete_error"),
+                                                       FALSE);
                g_object_unref (G_OBJECT (folder));
                return;
        }
@@ -4572,7 +4574,7 @@ modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
 
        /* Show notification dialog */
        win = modest_mail_operation_get_source (mail_op);
-       modest_platform_run_information_dialog ((GtkWindow *) win, _("mail_in_ui_folder_move_target_error"));
+       modest_platform_run_information_dialog ((GtkWindow *) win, _("mail_in_ui_folder_move_target_error"), FALSE);
        if (win)
                g_object_unref (win);
 }
@@ -5587,7 +5589,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self,
           should show the Accounts Settings dialog or the Connection
           specific SMTP server window */
 
-       modest_platform_run_information_dialog (NULL, message);
+       modest_platform_run_information_dialog (NULL, message, FALSE);
        g_free (message);
        g_object_unref (server_account);
 }
@@ -5673,7 +5675,7 @@ modest_ui_actions_on_account_connection_error (GtkWindow *parent_window,
        }
 
        if (error_note) {
-               modest_platform_run_information_dialog (parent_window, error_note);
+               modest_platform_run_information_dialog (parent_window, error_note, FALSE);
                g_free (error_note);
        }
 }
index 49acb1d..c3845fe 100644 (file)
@@ -455,10 +455,12 @@ on_response (GtkDialog *dialog,
                        saved = _modest_global_settings_dialog_save_conf (MODEST_GLOBAL_SETTINGS_DIALOG (dialog));
                        if (saved) {
                                modest_platform_run_information_dialog (GTK_WINDOW (user_data),
-                                                                       _("mcen_ib_advsetup_settings_saved"));
+                                                                       _("mcen_ib_advsetup_settings_saved"),
+                                                                       FALSE);
                        } else {
                                modest_platform_run_information_dialog (GTK_WINDOW (user_data),
-                                                                       _("mail_ib_setting_failed"));
+                                                                       _("mail_ib_setting_failed"),
+                                                                       FALSE);
                        }
                }
        } else {