From d5c19bade4f957618138985dcba1280b5a7f40ed Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Tue, 11 Sep 2007 16:40:20 +0000 Subject: [PATCH] * Removed a connect_and_wait from the mail_operations because UI code is not allowed in that part of the code. Moved it to the UI actions * Fixed an infinite loop in on_cert_dialog_response caused by a recursive gtk_dialog_response in the handler * Fixed a logical id * Removed some unused debug code * Fixes NB#62237, new notification for invalid certificates (using some previous code from djcb) * Fixes NB#60517, the Send&Receive option in the main menu no longer freezes the progress bar pmo-trunk-r3278 --- src/gnome/modest-platform.c | 8 ++++++ src/maemo/modest-main-window.c | 1 - src/maemo/modest-platform.c | 20 ++++++++------- src/modest-mail-operation.c | 17 +++---------- src/modest-tny-account-store.c | 53 +++++++++++++--------------------------- src/modest-ui-actions.c | 13 ++++++++++ 6 files changed, 52 insertions(+), 60 deletions(-) diff --git a/src/gnome/modest-platform.c b/src/gnome/modest-platform.c index 6d2d200..fd191dc 100644 --- a/src/gnome/modest-platform.c +++ b/src/gnome/modest-platform.c @@ -248,3 +248,11 @@ modest_platform_create_folder_view (TnyFolderStoreQuery *query) return widget; } + +gboolean +modest_platform_run_alert_dialog (const gchar* prompt, + gboolean is_question) +{ + /* TODO */ + return TRUE; +} diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 587daa7..4f37f52 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -633,7 +633,6 @@ update_menus (ModestMainWindow* self) refresh_action_name = g_strconcat ("SendReceive", account_data->account_name, NULL); refresh_account_action = gtk_action_new ((const gchar*) refresh_action_name, display_name, NULL, NULL); - printf("DEBUG: %s: menu display_name=%s\n", __FUNCTION__, display_name); gtk_action_group_add_action (priv->view_additions_group, refresh_account_action); merge_id = (guint8) gtk_ui_manager_new_merge_id (parent_priv->ui_manager); diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index b88226f..c781dba 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -1525,14 +1525,14 @@ modest_platform_check_and_wait_for_account_is_online(TnyAccount *account) static void on_cert_dialog_response (GtkDialog *dialog, gint response_id, const gchar* cert) { - // handle ok/cancel in the normal way - if (response_id != GTK_RESPONSE_HELP) - gtk_dialog_response (dialog, response_id); - else { - // GTK_RESPONSE_HELP means we need to show the certificate + /* GTK_RESPONSE_HELP means we need to show the certificate */ + if (response_id == GTK_RESPONSE_HELP) { GtkWidget *note; gchar *msg; + /* Do not close the dialog */ + g_signal_stop_emission_by_name (dialog, "response"); + msg = g_strdup_printf (_("mcen_ni_view_unknown_certificate"), cert); note = hildon_note_new_information (GTK_WINDOW(dialog), msg); gtk_dialog_run (GTK_DIALOG(note)); @@ -1550,7 +1550,7 @@ modest_platform_run_certificate_conformation_dialog (const gchar* server_name, GtkWindow *main_win = (GtkWindow*)modest_window_mgr_get_main_window (modest_runtime_get_window_mgr()); - gchar *question = g_strdup_printf (_("mcen_mc_unknown_certificate"), + gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"), server_name); note = hildon_note_new_confirmation_add_buttons ( @@ -1561,8 +1561,9 @@ modest_platform_run_certificate_conformation_dialog (const gchar* server_name, _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL, NULL, NULL); - g_signal_connect (G_OBJECT(note), "response", G_CALLBACK(on_cert_dialog_response), - (gpointer)certificate); + g_signal_connect (G_OBJECT(note), "response", + G_CALLBACK(on_cert_dialog_response), + (gpointer) certificate); response = gtk_dialog_run(GTK_DIALOG(note)); gtk_widget_destroy(GTK_WIDGET(note)); @@ -1574,7 +1575,8 @@ modest_platform_run_certificate_conformation_dialog (const gchar* server_name, gboolean -modest_platform_run_alert_dialog (const gchar* prompt, gboolean is_question) +modest_platform_run_alert_dialog (const gchar* prompt, + gboolean is_question) { ModestWindow *main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()); diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index d120b2d..5b38f54 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -1468,19 +1468,12 @@ modest_mail_operation_update_account (ModestMailOperation *self, priv->done = 0; priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS; - /* Get the Modest account */ + /* Get the store account */ store_account = (TnyStoreAccount *) modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), account_name, TNY_ACCOUNT_TYPE_STORE); - /* Make sure that we have a connection, and request one - * if necessary: - * TODO: Is there some way to trigger this for every attempt to - * use the network? */ - if (!modest_platform_connect_and_wait (NULL, TNY_ACCOUNT (store_account))) - goto error; - if (!store_account) { g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR, MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND, @@ -2484,16 +2477,12 @@ modest_mail_operation_remove_msgs (ModestMailOperation *self, /* remove message from folder */ tny_folder_remove_msgs (folder, headers, &(priv->error)); if (!priv->error) { - if (TNY_IS_CAMEL_IMAP_FOLDER (folder)) + if (TNY_IS_CAMEL_IMAP_FOLDER (folder) || + TNY_IS_CAMEL_POP_FOLDER (folder)) tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /* FALSE --> don't expunge */ -/* tny_folder_sync (folder, FALSE, &(priv->error)); /\* FALSE --> don't expunge */ - else if (TNY_IS_CAMEL_POP_FOLDER (folder)) - tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /* TRUE --> dont expunge */ -/* tny_folder_sync (folder, TRUE, &(priv->error)); /\* TRUE --> expunge */ else /* local folders */ tny_folder_sync_async(folder, TRUE, NULL, NULL, NULL); /* TRUE --> expunge */ -/* tny_folder_sync (folder, TRUE, &(priv->error)); /\* TRUE --> expunge */ } diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 74f077a..177b1ba 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -1049,37 +1049,27 @@ modest_tny_account_store_find_account_by_url (TnyAccountStore *self, const gchar -static void -log_alert_error (const GError *err) -{ - if (err) - g_warning ("%s: %d, message=%s", __FUNCTION__, err->domain, err->message); -} - - static gboolean -modest_tny_account_store_alert (TnyAccountStore *self, TnyAccount *account, TnyAlertType type, - gboolean question, const GError *error) +modest_tny_account_store_alert (TnyAccountStore *self, + TnyAccount *account, + TnyAlertType type, + gboolean question, + const GError *error) { ModestTransportStoreProtocol proto = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN; const gchar* server_name = NULL; gchar *prompt = NULL; gboolean retval; - + + g_return_val_if_fail (account, FALSE); g_return_val_if_fail (error, FALSE); - log_alert_error (error); if ((error->domain != TNY_ACCOUNT_ERROR) && (error->domain != TNY_ACCOUNT_STORE_ERROR)) return FALSE; /* Get the server name: */ - if (account && TNY_IS_ACCOUNT (account)) - server_name = tny_account_get_hostname (account); - if (!server_name) { - g_warning ("%s: cannot get server name", __FUNCTION__); - return FALSE; - } + server_name = tny_account_get_hostname (account); if (account) { const gchar *proto_name = tny_account_get_proto (account); @@ -1116,8 +1106,7 @@ modest_tny_account_store_alert (TnyAccountStore *self, TnyAccount *account, TnyA server_name); break; default: - g_warning ("%s: should not be reached (%d)", __FUNCTION__, proto); - return FALSE; + g_return_val_if_reached (FALSE); } break; @@ -1128,11 +1117,7 @@ modest_tny_account_store_alert (TnyAccountStore *self, TnyAccount *account, TnyA break; case TNY_ACCOUNT_ERROR_TRY_CONNECT_CERTIFICATE: - /* TODO: This needs a logical ID and/or some specified way to ask the - * different certificate questions: */ - prompt = g_strdup_printf( - _("Certificate Problem:\n%s"), - error->message); + /* We'll show the proper dialog later */ break; case TNY_ACCOUNT_ERROR_TRY_CONNECT: @@ -1144,10 +1129,6 @@ modest_tny_account_store_alert (TnyAccountStore *self, TnyAccount *account, TnyA * specific dialog messages from Chapter 12 of the UI spec. */ case TNY_ACCOUNT_STORE_ERROR_UNKNOWN_ALERT: - /* This debug output is useful. Please keep it uncommented until - * we have fixed the problems in this function: */ - g_debug ("%s: %d, message=%s",__FUNCTION__, - error->domain, error->message); /* TODO: Remove the internal error message for the real release. * This is just so the testers can give us more information: */ @@ -1164,18 +1145,18 @@ modest_tny_account_store_alert (TnyAccountStore *self, TnyAccount *account, TnyA break; default: - g_warning ("%s: Unhandled GError code: %d, message=%s", - __FUNCTION__, error->code, error->message); - prompt = NULL; - break; + g_return_val_if_reached (FALSE); } - if (!prompt) - return FALSE; + + if (error->code == TNY_ACCOUNT_ERROR_TRY_CONNECT_CERTIFICATE) + retval = modest_platform_run_certificate_conformation_dialog (server_name, + error->message); else retval = modest_platform_run_alert_dialog (prompt, question); - g_free (prompt); + if (prompt) + g_free (prompt); return retval; } diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index bbe1fc5..ef85141 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -1571,6 +1571,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win) { gchar *acc_name = NULL; ModestMailOperation *mail_op; + TnyAccount *store_account = NULL; /* If no account name was provided then get the current account, and if there is no current account then pick the default one: */ @@ -1586,6 +1587,18 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win) acc_name = g_strdup (account_name); } + + /* Ensure that we have a connection available */ + store_account = + modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), + account_name, + TNY_ACCOUNT_TYPE_STORE); + if (!modest_platform_connect_and_wait (NULL, TNY_ACCOUNT (store_account))) { + g_object_unref (store_account); + return; + } + g_object_unref (store_account); + /* Set send/receive operation in progress */ modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win)); -- 1.7.9.5