From 38d749525e49d48344543d54c7f60c044c347c3f Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Mon, 24 Mar 2008 18:03:11 +0000 Subject: [PATCH] * Added a new parametter to modest_platform_show_information_banner that allows the banner to block * Fixes NB#81756, show the proper error note when the SMTP password is missing pmo-trunk-r4339 --- src/dbus_api/modest-dbus-callbacks.c | 2 +- src/gnome/modest-platform.c | 3 +- src/maemo/modest-address-book.c | 2 +- src/maemo/modest-platform.c | 28 +++++++++++------- src/modest-platform.h | 4 ++- src/modest-tny-account-store.c | 42 ++++++++++++++++++++++----- src/modest-ui-actions.c | 14 +++++---- src/widgets/modest-global-settings-dialog.c | 6 ++-- 8 files changed, 71 insertions(+), 30 deletions(-) diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 14cbbfe..241221a 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -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; } diff --git a/src/gnome/modest-platform.c b/src/gnome/modest-platform.c index 39bf4d4..41feb01 100644 --- a/src/gnome/modest-platform.c +++ b/src/gnome/modest-platform.c @@ -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; diff --git a/src/maemo/modest-address-book.c b/src/maemo/modest-address-book.c index 0f81b8a..be1db54 100644 --- a/src/maemo/modest-address-book.c +++ b/src/maemo/modest-address-book.c @@ -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; } diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index 4324559..2881ffb 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -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; } diff --git a/src/modest-platform.h b/src/modest-platform.h index 6af81c4..a4cb411 100644 --- a/src/modest-platform.h +++ b/src/modest-platform.h @@ -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: diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 3e278c4..7a925af 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -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); diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 3c66833..0616909 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -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); } } diff --git a/src/widgets/modest-global-settings-dialog.c b/src/widgets/modest-global-settings-dialog.c index 49acb1d..c3845fe 100644 --- a/src/widgets/modest-global-settings-dialog.c +++ b/src/widgets/modest-global-settings-dialog.c @@ -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 { -- 1.7.9.5