X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=9c88b5d5b7963142b92cb8c067eeb11c86ea78bb;hp=3451b38734347a6e2241b028896844cc84033027;hb=93540692199f400bd03936d3ac1d7340a2710d14;hpb=2290a841d02ff9980feb86a96c2ac341b4dd0511 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 3451b38..9c88b5d 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -70,7 +70,7 @@ #include "modest-text-utils.h" #ifdef MODEST_HAVE_EASYSETUP -#include "easysetup/modest-easysetup-wizard.h" +#include "easysetup/modest-easysetup-wizard-dialog.h" #endif /* MODEST_HAVE_EASYSETUP */ #include @@ -1002,8 +1002,8 @@ banner_cleanup: } void -modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op, - gpointer user_data) +modest_ui_actions_disk_operations_error_handler (ModestMailOperation *mail_op, + gpointer user_data) { const GError *error; GObject *win = NULL; @@ -1044,9 +1044,29 @@ get_account_from_header_list (TnyList *headers) TnyIterator *iter = tny_list_create_iterator (headers); TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter)); TnyFolder *folder = tny_header_get_folder (header); - account = tny_folder_get_account (folder); - g_object_unref (folder); - g_object_unref (header); + + if (!folder) { + g_object_unref (header); + + while (!tny_iterator_is_done (iter)) { + header = TNY_HEADER (tny_iterator_get_current (iter)); + folder = tny_header_get_folder (header); + if (folder) + break; + g_object_unref (header); + header = NULL; + tny_iterator_next (iter); + } + } + + if (folder) { + account = tny_folder_get_account (folder); + g_object_unref (folder); + } + + if (header) + g_object_unref (header); + g_object_unref (iter); } return account; @@ -1130,7 +1150,7 @@ open_msgs_performer(gboolean canceled, /* Create the mail operation */ mail_op = modest_mail_operation_new_with_error_handling ((GObject *) parent_window, - modest_ui_actions_get_msgs_full_error_handler, + modest_ui_actions_disk_operations_error_handler, error_msg, g_free); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); @@ -1175,8 +1195,8 @@ open_msgs_from_headers (TnyList *headers, ModestWindow *win) /* Check that only one message is selected for opening */ if (tny_list_get_length (headers) != 1) { - modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL, - _("mcen_ib_select_one_message")); + modest_platform_information_banner ((win) ? GTK_WIDGET (win) : NULL, + NULL, _("mcen_ib_select_one_message")); return; } @@ -1185,7 +1205,10 @@ open_msgs_from_headers (TnyList *headers, ModestWindow *win) /* Get the account */ account = get_account_from_header_list (headers); - + + if (!account) + return; + /* Look if we already have a message view for each header. If true, then remove the header from the list of headers to open */ @@ -1508,8 +1531,10 @@ reply_forward (ReplyForwardAction action, ModestWindow *win) * whether he/she wants to download them. */ if (num_of_unc_msgs) { TnyAccount *account = get_account_from_header_list (header_list); - continue_download = connect_to_get_msg (win, num_of_unc_msgs, account); - g_object_unref (account); + if (account) { + continue_download = connect_to_get_msg (win, num_of_unc_msgs, account); + g_object_unref (account); + } } } @@ -1566,7 +1591,7 @@ reply_forward (ReplyForwardAction action, ModestWindow *win) if (do_retrieve) { mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(win), - modest_ui_actions_get_msgs_full_error_handler, + modest_ui_actions_disk_operations_error_handler, NULL, NULL); modest_mail_operation_queue_add ( modest_runtime_get_mail_operation_queue (), mail_op); @@ -1732,6 +1757,7 @@ typedef struct { TnyAccount *account; ModestWindow *win; gchar *account_name; + gboolean poke_status; } SendReceiveInfo; static void @@ -1766,7 +1792,7 @@ do_send_receive_performer (gboolean canceled, /* 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->win) ? FALSE : TRUE, + modest_mail_operation_update_account (mail_op, info->account_name, info->poke_status, (info->win) ? retrieve_all_messages_cb : NULL, new_messages_arrived, info->win); g_object_unref (G_OBJECT (mail_op)); @@ -1791,6 +1817,7 @@ do_send_receive_performer (gboolean canceled, void modest_ui_actions_do_send_receive (const gchar *account_name, gboolean force_connection, + gboolean poke_status, ModestWindow *win) { gchar *acc_name = NULL; @@ -1818,6 +1845,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name, info = g_slice_new (SendReceiveInfo); info->account_name = acc_name; info->win = (win) ? g_object_ref (win) : NULL; + info->poke_status = poke_status; info->account = modest_tny_account_store_get_server_account (acc_store, acc_name, TNY_ACCOUNT_TYPE_STORE); @@ -1906,7 +1934,8 @@ modest_ui_actions_cancel_send (GtkAction *action, ModestWindow *win) */ void modest_ui_actions_do_send_receive_all (ModestWindow *win, - gboolean force_connection) + gboolean force_connection, + gboolean poke_status) { GSList *account_names, *iter; @@ -1915,7 +1944,9 @@ modest_ui_actions_do_send_receive_all (ModestWindow *win, iter = account_names; while (iter) { - modest_ui_actions_do_send_receive ((const char*) iter->data, force_connection, win); + modest_ui_actions_do_send_receive ((const char*) iter->data, + force_connection, + poke_status, win); iter = g_slist_next (iter); } @@ -1956,8 +1987,9 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win) g_object_unref (folder_store); } - /* Refresh the active account. Force the connection if needed */ - modest_ui_actions_do_send_receive (NULL, TRUE, 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); } @@ -2025,6 +2057,7 @@ modest_ui_actions_on_header_selected (ModestHeaderView *header_view, gtk_widget_grab_focus (GTK_WIDGET(header_view)); /* Update toolbar dimming state */ + modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window)); modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window)); } @@ -2297,15 +2330,10 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op, edit_window = MODEST_MSG_EDIT_WINDOW (user_data); - /* It might not be a good idea to do nothing if there was an error, - * so let's at least show a generic error banner. */ - /* TODO error while saving attachment, show "Saving draft failed" banner */ - if (modest_mail_operation_get_error (mail_op) != NULL) { - g_warning ("%s failed: %s\n", __FUNCTION__, (modest_mail_operation_get_error (mail_op))->message); - modest_platform_information_banner (NULL, NULL, _("mail_ib_file_operation_failed")); - } else { + /* Set draft is there was no error */ + if (!modest_mail_operation_get_error (mail_op)) modest_msg_edit_window_set_draft (edit_window, saved_draft); - } + g_object_unref(edit_window); } @@ -2373,7 +2401,8 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi from = modest_account_mgr_get_from_string (account_mgr, account_name); /* Create the mail operation */ - mail_operation = modest_mail_operation_new (NULL); + mail_operation = modest_mail_operation_new_with_error_handling (NULL, modest_ui_actions_disk_operations_error_handler, + NULL, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation); modest_mail_operation_save_to_drafts (mail_operation, @@ -2467,9 +2496,6 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) if (!modest_msg_edit_window_check_names (edit_window, TRUE)) return TRUE; - /* FIXME: Code added just for testing. The final version will - use the send queue provided by tinymail and some - classifier */ MsgData *data = modest_msg_edit_window_get_msg_data (edit_window); /* Check size */ @@ -2723,11 +2749,20 @@ do_create_folder_cb (ModestMailOperation *mail_op, GtkWindow *source_win = (GtkWindow *) modest_mail_operation_get_source (mail_op); if (modest_mail_operation_get_error (mail_op)) { - /* Show an error */ - modest_platform_information_banner (GTK_WIDGET (source_win), NULL, - _("mail_in_ui_folder_create_error")); - /* Try again */ + /* Show an error. If there was some problem writing to + disk, show it, otherwise show the generic folder + create error. We do it here and not in an error + handler because the call to do_create_folder will + stop the main loop in a gtk_dialog_run and then, + the message won't be shown until that dialog is + closed */ + modest_ui_actions_disk_operations_error_handler (mail_op, + _("mail_in_ui_folder_create_error")); + + /* Try again. Do *NOT* show any error because the mail + operations system will do it for us because we + created the mail_op with new_with_error_handler */ do_create_folder (source_win, parent_folder, (const gchar *) suggested_name); } else { /* the 'source_win' is either the ModestMainWindow, or the 'Move to folder'-dialog @@ -2768,8 +2803,7 @@ do_create_folder (GtkWindow *parent_window, if (result == GTK_RESPONSE_ACCEPT) { ModestMailOperation *mail_op; - mail_op = modest_mail_operation_new (G_OBJECT(parent_window)); - + mail_op = modest_mail_operation_new (NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); modest_mail_operation_create_folder (mail_op, @@ -3322,8 +3356,10 @@ modest_ui_actions_on_cut (GtkAction *action, if (num_of_unc_msgs) { TnyAccount *account = get_account_from_header_list (header_list); - continue_download = connect_to_get_msg (window, num_of_unc_msgs, account); - g_object_unref (account); + if (account) { + continue_download = connect_to_get_msg (window, num_of_unc_msgs, account); + g_object_unref (account); + } } if (num_of_unc_msgs == 0 || continue_download) { @@ -3383,8 +3419,10 @@ modest_ui_actions_on_copy (GtkAction *action, if (num_of_unc_msgs) { TnyAccount *account = get_account_from_header_list (header_list); - continue_download = connect_to_get_msg (window, num_of_unc_msgs, account); - g_object_unref (account); + if (account) { + continue_download = connect_to_get_msg (window, num_of_unc_msgs, account); + g_object_unref (account); + } } if (num_of_unc_msgs == 0 || continue_download) { @@ -4595,7 +4633,7 @@ modest_ui_actions_on_main_window_remove_attachments (GtkAction *action, ModestMailOperation *mail_op = NULL; modest_window_mgr_register_header (modest_runtime_get_window_mgr (), header, NULL); mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win), - modest_ui_actions_get_msgs_full_error_handler, + modest_ui_actions_disk_operations_error_handler, NULL, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); modest_mail_operation_get_msg (mail_op, header, open_msg_for_purge_cb, win); @@ -5180,7 +5218,7 @@ retrieve_msg_contents_performer (gboolean canceled, /* Create mail operation */ mail_op = modest_mail_operation_new_with_error_handling ((GObject *) parent_window, - modest_ui_actions_get_msgs_full_error_handler, + modest_ui_actions_disk_operations_error_handler, NULL, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); modest_mail_operation_get_msgs_full (mail_op, headers, NULL, NULL, NULL);