X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=0616909fd7f346df9681bbdfcee27e787a99f883;hp=e361b678e664ec8f1b2deee9024f1a169e2bb3fc;hb=38d749525e49d48344543d54c7f60c044c347c3f;hpb=f61c492d279c559b9f8b9b3fcea3d7a66f45578a diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index e361b67..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); @@ -975,30 +975,41 @@ cleanup: g_object_unref (folder); } +static gboolean +is_memory_full_error (GError *error) +{ + if (error->code == TNY_SYSTEM_ERROR_MEMORY || + error->code == TNY_IO_ERROR_WRITE || + error->code == TNY_IO_ERROR_READ) { + return TRUE; + } else { + return FALSE; + } +} + void modest_ui_actions_disk_operations_error_handler (ModestMailOperation *mail_op, - gpointer user_data) + gpointer user_data) { const GError *error; GObject *win = NULL; + ModestMailOperationStatus status; win = modest_mail_operation_get_source (mail_op); error = modest_mail_operation_get_error (mail_op); + status = modest_mail_operation_get_status (mail_op); - /* Show error */ - if (error->code == TNY_SYSTEM_ERROR_MEMORY || - error->code == TNY_IO_ERROR_WRITE || - error->code == TNY_IO_ERROR_READ) { - ModestMailOperationStatus st = modest_mail_operation_get_status (mail_op); - /* If the mail op has been cancelled then it's not an error: don't show any message */ - if (st != MODEST_MAIL_OPERATION_STATUS_CANCELED) { + /* If the mail op has been cancelled then it's not an error: + don't show any message */ + if (status != MODEST_MAIL_OPERATION_STATUS_CANCELED) { + if (is_memory_full_error ((GError *) error)) { modest_platform_information_banner ((GtkWidget *) win, NULL, dgettext("ke-recv", "cerm_device_memory_full")); + } else if (user_data) { + modest_platform_information_banner ((GtkWidget *) win, + NULL, user_data); } - } else if (user_data) { - modest_platform_information_banner ((GtkWidget *) win, - NULL, user_data); } if (win) @@ -1107,6 +1118,13 @@ open_msgs_performer(gboolean canceled, modest_runtime_get_window_mgr ()); /* Free the helper */ open_msgs_helper_destroyer (helper); + + /* In memory full conditions we could get this error here */ + if (err && is_memory_full_error (err)) { + modest_platform_information_banner ((GtkWidget *) parent_window, + NULL, dgettext("ke-recv", + "cerm_device_memory_full")); + } goto clean; } @@ -1801,6 +1819,8 @@ typedef struct { ModestWindow *win; gchar *account_name; gboolean poke_status; + gboolean interactive; + ModestMailOperation *mail_op; } SendReceiveInfo; static void @@ -1810,12 +1830,21 @@ do_send_receive_performer (gboolean canceled, TnyAccount *account, gpointer user_data) { - ModestMailOperation *mail_op; SendReceiveInfo *info; info = (SendReceiveInfo *) user_data; if (err || canceled) { + /* In memory full conditions we could get this error here */ + if (err && is_memory_full_error (err)) { + modest_platform_information_banner ((GtkWidget *) parent_window, + NULL, dgettext("ke-recv", + "cerm_device_memory_full")); + } + if (info->mail_op) { + modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), + info->mail_op); + } goto clean; } @@ -1823,25 +1852,21 @@ do_send_receive_performer (gboolean canceled, if (info->win && MODEST_IS_MAIN_WINDOW (info->win)) { modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW (info->win)); } - - mail_op = modest_mail_operation_new_with_error_handling ((info->win) ? G_OBJECT (info->win) : NULL, - modest_ui_actions_send_receive_error_handler, - NULL, NULL); if (info->win && MODEST_IS_MAIN_WINDOW (info->win)) - g_signal_connect (G_OBJECT(mail_op), "operation-finished", + g_signal_connect (G_OBJECT (info->mail_op), "operation-finished", G_CALLBACK (on_send_receive_finished), info->win); /* Send & receive. */ - modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); - modest_mail_operation_update_account (mail_op, info->account_name, info->poke_status, + modest_mail_operation_update_account (info->mail_op, info->account_name, info->poke_status, info->interactive, (info->win) ? retrieve_all_messages_cb : NULL, new_messages_arrived, info->win); - g_object_unref (G_OBJECT (mail_op)); clean: /* Frees */ + if (info->mail_op) + g_object_unref (G_OBJECT (info->mail_op)); if (info->account_name) g_free (info->account_name); if (info->win) @@ -1861,6 +1886,7 @@ void modest_ui_actions_do_send_receive (const gchar *account_name, gboolean force_connection, gboolean poke_status, + gboolean interactive, ModestWindow *win) { gchar *acc_name = NULL; @@ -1889,8 +1915,16 @@ modest_ui_actions_do_send_receive (const gchar *account_name, info->account_name = acc_name; info->win = (win) ? g_object_ref (win) : NULL; info->poke_status = poke_status; + info->interactive = interactive; info->account = modest_tny_account_store_get_server_account (acc_store, acc_name, TNY_ACCOUNT_TYPE_STORE); + /* We need to create the operation here, because otherwise it + could happen that the queue emits the queue-empty signal + while we're trying to connect the account */ + info->mail_op = modest_mail_operation_new_with_error_handling ((info->win) ? G_OBJECT (info->win) : NULL, + modest_ui_actions_disk_operations_error_handler, + NULL, NULL); + modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), info->mail_op); /* Invoke the connect and perform */ modest_platform_connect_and_perform ((win) ? GTK_WINDOW (win) : NULL, @@ -1978,7 +2012,8 @@ modest_ui_actions_cancel_send (GtkAction *action, ModestWindow *win) void modest_ui_actions_do_send_receive_all (ModestWindow *win, gboolean force_connection, - gboolean poke_status) + gboolean poke_status, + gboolean interactive) { GSList *account_names, *iter; @@ -1989,7 +2024,7 @@ modest_ui_actions_do_send_receive_all (ModestWindow *win, while (iter) { modest_ui_actions_do_send_receive ((const char*) iter->data, force_connection, - poke_status, win); + poke_status, interactive, win); iter = g_slist_next (iter); } @@ -2032,7 +2067,7 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win) /* Refresh the active account. Force the connection if needed and poke the status of all folders */ - modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, win); + modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, TRUE, win); } @@ -2868,6 +2903,12 @@ create_folder_performer (gboolean canceled, TnyFolderStore *parent_folder = TNY_FOLDER_STORE (user_data); if (canceled || err) { + /* In memory full conditions we could get this error here */ + if (err && is_memory_full_error (err)) { + modest_platform_information_banner ((GtkWidget *) parent_window, + NULL, dgettext("ke-recv", + "cerm_device_memory_full")); + } goto frees; } @@ -2969,7 +3010,14 @@ on_rename_folder_performer (gboolean canceled, GtkWidget *folder_view = NULL; RenameFolderInfo *data = (RenameFolderInfo*)user_data; - if (!canceled && (err == NULL) && MODEST_IS_MAIN_WINDOW(parent_window)) { + if (canceled || err) { + /* In memory full conditions we could get this error here */ + if (err && is_memory_full_error (err)) { + modest_platform_information_banner ((GtkWidget *) parent_window, + NULL, dgettext("ke-recv", + "cerm_device_memory_full")); + } + } else if (MODEST_IS_MAIN_WINDOW(parent_window)) { folder_view = modest_main_window_get_child_widget ( MODEST_MAIN_WINDOW (parent_window), @@ -2993,9 +3041,9 @@ on_rename_folder_performer (gboolean canceled, (const gchar *) (data->new_name), on_rename_folder_cb, folder_view); + g_object_unref (mail_op); } - g_object_unref (mail_op); g_free (data->new_name); g_free (data); } @@ -3060,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); } @@ -3132,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; } @@ -4524,34 +4574,11 @@ 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); } -void -modest_ui_actions_send_receive_error_handler (ModestMailOperation *mail_op, - gpointer user_data) -{ - GObject *win = modest_mail_operation_get_source (mail_op); - const GError *error = modest_mail_operation_get_error (mail_op); - - g_return_if_fail (error != NULL); - if (error->message != NULL) - g_printerr ("modest: %s\n", error->message); - else - g_printerr ("modest: unkonw error on send&receive operation"); - - /* Show error message */ -/* if (modest_mail_operation_get_id (mail_op) == MODEST_MAIL_OPERATION_TYPE_RECEIVE) */ -/* modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL, */ -/* _CS("sfil_ib_unable_to_receive")); */ -/* else */ -/* modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL, */ -/* _CS("sfil_ib_unable_to_send")); */ - g_object_unref (win); -} - static void open_msg_for_purge_cb (ModestMailOperation *mail_op, TnyHeader *header, @@ -4794,8 +4821,14 @@ xfer_messages_performer (gboolean canceled, gboolean dst_is_pop = FALSE; if (canceled || err) { - /* Show the proper error message */ - modest_ui_actions_on_account_connection_error (parent_window, account); + if (err && is_memory_full_error (err)) { + modest_platform_information_banner ((GtkWidget *) parent_window, + NULL, dgettext("ke-recv", + "cerm_device_memory_full")); + } else { + /* Show the proper error message */ + modest_ui_actions_on_account_connection_error (parent_window, account); + } g_object_unref (dst_folder); return; } @@ -5261,6 +5294,11 @@ retrieve_msg_contents_performer (gboolean canceled, TnyList *headers = TNY_LIST (user_data); if (err || canceled) { + if (err && is_memory_full_error (err)) { + modest_platform_information_banner ((GtkWidget *) parent_window, + NULL, dgettext("ke-recv", + "cerm_device_memory_full")); + } goto out; } @@ -5511,10 +5549,13 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, TnyTransportAccount *server_account; gchar *message = NULL; - /* Don't show anything if the user cancelled something */ - if (err->code == TNY_SYSTEM_ERROR_CANCEL) + /* Don't show anything if the user cancelled something or the send receive request is not + * interactive */ + if (err->code == TNY_SYSTEM_ERROR_CANCEL || + !modest_tny_send_queue_get_requested_send_receive (MODEST_TNY_SEND_QUEUE (self))) return; + /* Get the server name: */ server_account = TNY_TRANSPORT_ACCOUNT (tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self))); @@ -5532,7 +5573,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, message = g_strdup_printf (_("emev_ni_ui_smtp_authentication_fail_error"), server_name); break; case TNY_SERVICE_ERROR_SEND: - message = g_strdup (_("emev_ib_ui_smtp_send_error")); + message = g_strdup (dgettext("hildon-common-strings", "sfil_ib_unable_to_send")); break; case TNY_SERVICE_ERROR_UNAVAILABLE: message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"), server_name); @@ -5540,7 +5581,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, default: g_warning ("%s: unexpected ERROR %d", __FUNCTION__, err->code); - message = g_strdup (_("emev_ib_ui_smtp_send_error")); + message = g_strdup (dgettext("hildon-common-strings", "sfil_ib_unable_to_send")); break; } @@ -5548,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); } @@ -5634,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); } }