X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=ff2d5a3956241f6f65e13c4c1fe56a46df5af2a5;hp=410748ca421e9773282d3f8a2df6e2a6434876f0;hb=bf0f833e064072ecd32174a30ff0f87e2cc072a2;hpb=a13d5091c8e0feecf34e28e25bd67cdf7dac118f diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 410748c..ff2d5a3 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -184,7 +184,7 @@ remote_folder_is_pop (const TnyFolderStore *folder) account = tny_folder_get_account(TNY_FOLDER(folder)); } - if (!account && !TNY_IS_ACCOUNT(account)) { + if (!TNY_IS_ACCOUNT(account)) { g_warning ("%s: could not get account", __FUNCTION__); return FALSE; } @@ -395,10 +395,8 @@ void modest_ui_actions_refresh_message_window_after_delete (ModestMsgViewWindow* win) { /* Close msg view window or select next */ - if (modest_msg_view_window_last_message_selected (win) && - modest_msg_view_window_first_message_selected (win)) { - modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (win)); - } else if (!modest_msg_view_window_select_next_message (win)) { + if (!modest_msg_view_window_select_next_message (win) && + !modest_msg_view_window_select_previous_message (win)) { gboolean ret_value; g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value); } @@ -597,8 +595,6 @@ modest_ui_actions_on_delete_message_or_folder (GtkAction *action, ModestWindow * modest_ui_actions_on_delete_message (action, win); } - - void modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win) { @@ -813,25 +809,6 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) modest_ui_actions_compose_msg(win, NULL, NULL, NULL, NULL, NULL, NULL); } -void -modest_ui_actions_on_new_msg_or_folder (GtkAction *action, ModestWindow *win) -{ - g_return_if_fail (MODEST_IS_WINDOW (win)); - - /* Check first if the folder view has the focus */ - if (MODEST_IS_MAIN_WINDOW (win)) { - GtkWidget *w; - w = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win), - MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW); - if (gtk_widget_is_focus (w)) { - modest_ui_actions_on_new_folder (action, MODEST_MAIN_WINDOW(win)); - return; - } - } - - modest_ui_actions_on_new_msg (action, win); -} - gboolean modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op, @@ -1020,19 +997,21 @@ modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op, { const GError *error; GObject *win = NULL; - const gchar *err_msg; win = modest_mail_operation_get_source (mail_op); error = modest_mail_operation_get_error (mail_op); - - /* Select error message */ - if (error->code == MODEST_MAIL_OPERATION_ERROR_MESSAGE_SIZE_LIMIT) - err_msg = _("emev_ni_ui_imap_msg_size_exceed_error"); - else - err_msg = (const gchar *) user_data; /* Show error */ - modest_platform_run_information_dialog ((GtkWindow *) win, err_msg); + if (error->code == TNY_SYSTEM_ERROR_MEMORY || + error->code == TNY_IO_ERROR_WRITE || + error->code == TNY_IO_ERROR_READ) { + 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); + } if (win) g_object_unref (win); @@ -1059,6 +1038,16 @@ get_account_from_header_list (TnyList *headers) return account; } +static void +foreach_unregister_headers (gpointer data, + gpointer user_data) +{ + ModestWindowMgr *mgr = (ModestWindowMgr *) user_data; + TnyHeader *header = TNY_HEADER (data); + + modest_window_mgr_unregister_header (mgr, header); +} + static void open_msgs_performer(gboolean canceled, GError *err, @@ -1077,6 +1066,9 @@ open_msgs_performer(gboolean canceled, status = tny_account_get_connection_status (account); if (err || canceled) { + /* Unregister the already registered headers */ + tny_list_foreach (not_opened_headers, foreach_unregister_headers, + modest_runtime_get_window_mgr ()); goto clean; } @@ -1319,19 +1311,23 @@ reply_forward_cb (ModestMailOperation *mail_op, switch (rf_helper->action) { case ACTION_REPLY: new_msg = - modest_tny_msg_create_reply_msg (msg, header, from, signature, + modest_tny_msg_create_reply_msg (msg, header, from, + (use_signature) ? signature : NULL, rf_helper->reply_forward_type, MODEST_TNY_MSG_REPLY_MODE_SENDER); break; case ACTION_REPLY_TO_ALL: new_msg = - modest_tny_msg_create_reply_msg (msg, header, from, signature, rf_helper->reply_forward_type, + modest_tny_msg_create_reply_msg (msg, header, from, + (use_signature) ? signature : NULL, + rf_helper->reply_forward_type, MODEST_TNY_MSG_REPLY_MODE_ALL); edit_type = MODEST_EDIT_TYPE_REPLY; break; case ACTION_FORWARD: new_msg = - modest_tny_msg_create_forward_msg (msg, from, signature, rf_helper->reply_forward_type); + modest_tny_msg_create_forward_msg (msg, from, (use_signature) ? signature : NULL, + rf_helper->reply_forward_type); edit_type = MODEST_EDIT_TYPE_FORWARD; break; default: @@ -1667,7 +1663,7 @@ new_messages_arrived (ModestMailOperation *self, send&receive was invoked by the user then do not show any visual notification, only play a sound and activate the LED (for the Maemo version) */ - if ((new_headers != NULL) && (tny_list_get_length (new_headers) > 0)) + if (TNY_IS_LIST(new_headers) && (tny_list_get_length (new_headers)) > 0) modest_platform_on_new_headers_received (new_headers, show_visual_notifications); @@ -1822,9 +1818,12 @@ modest_ui_actions_do_cancel_send (const gchar *account_name, MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND, "modest: could not find send queue for account\n"); } else { - /* Keeep messages in outbox folder */ - tny_send_queue_cancel (send_queue, FALSE, &error); - } + /* Cancel the current send */ + tny_account_cancel (TNY_ACCOUNT (transport_account)); + + /* Suspend all pending messages */ + tny_send_queue_cancel (send_queue, TNY_SEND_QUEUE_CANCEL_ACTION_SUSPEND, &error); + } frees: if (transport_account != NULL) @@ -2268,13 +2267,13 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op, 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")); - return; + } else { + modest_msg_edit_window_set_draft (edit_window, saved_draft); } - - modest_msg_edit_window_set_draft (edit_window, saved_draft); + g_object_unref(edit_window); } -void +gboolean modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edit_window) { TnyTransportAccount *transport_account; @@ -2282,12 +2281,31 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi MsgData *data; gchar *account_name, *from; ModestAccountMgr *account_mgr; - char *info_text; +/* char *info_text; */ + gboolean had_error = FALSE; + guint64 available_disk, expected_size; + gint parts_count; + guint64 parts_size; - g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window)); + g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), FALSE); data = modest_msg_edit_window_get_msg_data (edit_window); + /* Check size */ + available_disk = modest_folder_available_space (NULL); + modest_msg_edit_window_get_parts_size (edit_window, &parts_count, &parts_size); + expected_size = modest_tny_msg_estimate_size (data->plain_body, + data->html_body, + parts_count, + parts_size); + + if ((available_disk != -1) && expected_size > available_disk) { + modest_msg_edit_window_free_msg_data (edit_window, data); + + modest_platform_information_banner (NULL, NULL, dgettext("ke-recv", "cerm_device_memory_full")); + return FALSE; + } + account_name = g_strdup (data->account_name); account_mgr = modest_runtime_get_account_mgr(); if (!account_name) @@ -2297,7 +2315,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi if (!account_name) { g_printerr ("modest: no account found\n"); modest_msg_edit_window_free_msg_data (edit_window, data); - return; + return FALSE; } if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) { @@ -2313,7 +2331,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi g_printerr ("modest: no transport account found for '%s'\n", account_name); g_free (account_name); modest_msg_edit_window_free_msg_data (edit_window, data); - return; + return FALSE; } from = modest_account_mgr_get_from_string (account_mgr, account_name); @@ -2335,19 +2353,19 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi data->images, data->priority_flags, on_save_to_drafts_cb, - edit_window); - info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts")); - modest_platform_information_banner (NULL, NULL, info_text); + g_object_ref(edit_window)); + +/* info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts")); */ + modest_platform_information_banner (NULL, NULL, _CS("sfil_ib_saving")); + modest_msg_edit_window_reset_modified (edit_window); /* Frees */ - g_free (info_text); g_free (from); g_free (account_name); g_object_unref (G_OBJECT (transport_account)); g_object_unref (G_OBJECT (mail_operation)); modest_msg_edit_window_free_msg_data (edit_window, data); - modest_msg_edit_window_reset_modified (edit_window); /* ** FIXME ** * If the drafts folder is selected then make the header view @@ -2366,7 +2384,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi */ ModestMainWindow *win = MODEST_MAIN_WINDOW(modest_window_mgr_get_main_window( modest_runtime_get_window_mgr(), FALSE)); - if (win != NULL) { + if (!had_error && win != NULL) { ModestFolderView *view = MODEST_FOLDER_VIEW(modest_main_window_get_child_widget( win, MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW)); if (view != NULL) { @@ -2385,24 +2403,45 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi if (folder != NULL) g_object_unref(folder); } } + + return !had_error; } /* For instance, when clicking the Send toolbar button when editing a message: */ -void +gboolean modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) { TnyTransportAccount *transport_account = NULL; + gboolean had_error = FALSE; + guint64 available_disk, expected_size; + gint parts_count; + guint64 parts_size; - g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window)); + g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), TRUE); if (!modest_msg_edit_window_check_names (edit_window, TRUE)) - return; + 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 */ + available_disk = modest_folder_available_space (NULL); + modest_msg_edit_window_get_parts_size (edit_window, &parts_count, &parts_size); + expected_size = modest_tny_msg_estimate_size (data->plain_body, + data->html_body, + parts_count, + parts_size); + + if ((available_disk != -1) && expected_size > available_disk) { + modest_msg_edit_window_free_msg_data (edit_window, data); + + modest_platform_information_banner (NULL, NULL, dgettext("ke-recv", "cerm_device_memory_full")); + return FALSE; + } + ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr(); gchar *account_name = g_strdup (data->account_name); if (!account_name) @@ -2415,7 +2454,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) modest_msg_edit_window_free_msg_data (edit_window, data); /* Run account setup wizard */ if (!modest_ui_actions_run_account_setup_wizard (MODEST_WINDOW(edit_window))) { - return; + return TRUE; } } @@ -2430,7 +2469,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) modest_msg_edit_window_free_msg_data (edit_window, data); /* Run account setup wizard */ if (!modest_ui_actions_run_account_setup_wizard(MODEST_WINDOW(edit_window))) - return; + return TRUE; } gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name); @@ -2456,6 +2495,15 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) if (modest_mail_operation_get_status (mail_operation) == MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS) modest_platform_information_banner (NULL, NULL, _("mcen_ib_outbox_waiting_to_be_sent")); + + if (modest_mail_operation_get_error (mail_operation) != NULL) { + const GError *error = modest_mail_operation_get_error (mail_operation); + if (error->code == MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED) { + g_warning ("%s failed: %s\n", __FUNCTION__, (modest_mail_operation_get_error (mail_operation))->message); + modest_platform_information_banner (NULL, NULL, _CS("sfil_ni_not_enough_memory")); + had_error = TRUE; + } + } /* Free data: */ g_free (from); @@ -2464,10 +2512,15 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) g_object_unref (G_OBJECT (mail_operation)); modest_msg_edit_window_free_msg_data (edit_window, data); - modest_msg_edit_window_set_sent (edit_window, TRUE); - /* Save settings and close the window: */ - modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (edit_window)); + if (!had_error) { + modest_msg_edit_window_set_sent (edit_window, TRUE); + + /* Save settings and close the window: */ + modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (edit_window)); + } + + return !had_error; } void @@ -3260,7 +3313,10 @@ modest_ui_actions_on_copy (GtkAction *action, focused_widget = gtk_window_get_focus (GTK_WINDOW (window)); if (GTK_IS_LABEL (focused_widget)) { - gtk_clipboard_set_text (clipboard, gtk_label_get_text (GTK_LABEL (focused_widget)), -1); + gchar *selection; + selection = modest_text_utils_label_get_selection (GTK_LABEL (focused_widget)); + gtk_clipboard_set_text (clipboard, selection, -1); + g_free (selection); gtk_clipboard_set_can_store (clipboard, NULL, 0); gtk_clipboard_store (clipboard); } else if (GTK_IS_EDITABLE (focused_widget)) { @@ -3932,10 +3988,15 @@ on_move_to_dialog_folder_selection_changed (ModestFolderView* self, if ((gpointer) local_account != (gpointer) folder_store && (gpointer) mmc_account != (gpointer) folder_store) { + const char *proto_name = tny_account_get_proto (TNY_ACCOUNT (folder_store)); + ModestTransportStoreProtocol proto = MODEST_PROTOCOL_STORE_MAILDIR; + if (proto_name != NULL) { + proto = modest_protocol_info_get_transport_store_protocol (proto_name); + } is_local_account = FALSE; /* New button should be dimmed on remote - account root */ - new_sensitive = FALSE; + POP account root */ + new_sensitive = (proto != MODEST_PROTOCOL_STORE_POP); } g_object_unref (local_account); } @@ -4246,10 +4307,11 @@ move_to_cb (ModestMailOperation *mail_op, if (MODEST_IS_MSG_VIEW_WINDOW (object)) { ModestMsgViewWindow *self = MODEST_MSG_VIEW_WINDOW (object); - if (!modest_msg_view_window_select_next_message (self)) - if (!modest_msg_view_window_select_previous_message (self)) - /* No more messages to view, so close this window */ - modest_ui_actions_on_close_window (NULL, MODEST_WINDOW(self)); + if (!modest_msg_view_window_select_next_message (self) && + !modest_msg_view_window_select_previous_message (self)) { + /* No more messages to view, so close this window */ + modest_ui_actions_on_close_window (NULL, MODEST_WINDOW(self)); + } } else if (MODEST_IS_MAIN_WINDOW (object) && helper->reference != NULL) { GtkWidget *header_view; GtkTreePath *path; @@ -4277,7 +4339,17 @@ folder_move_to_cb (ModestMailOperation *mail_op, TnyFolder *new_folder, gpointer user_data) { + GtkWidget *folder_view; + GObject *object; + + object = modest_mail_operation_get_source (mail_op); + folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(object), + MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW); + g_object_ref (folder_view); + g_object_unref (object); move_to_cb (mail_op, user_data); + modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view), new_folder, FALSE); + g_object_unref (folder_view); } static void @@ -4405,6 +4477,7 @@ open_msg_for_purge_cb (ModestMailOperation *mail_op, tny_iterator_next (iter); } + g_object_unref (iter); tny_msg_rewrite_cache (msg); } @@ -4412,7 +4485,6 @@ open_msg_for_purge_cb (ModestMailOperation *mail_op, /* This string no longer exists, refer to NB#75415 for more info */ /* modest_platform_information_banner (NULL, NULL, _("mail_ib_attachment_already_purged")); */ } - g_object_unref (iter); modest_window_mgr_unregister_header (mgr, header); @@ -4425,7 +4497,6 @@ modest_ui_actions_on_main_window_remove_attachments (GtkAction *action, { GtkWidget *header_view; TnyList *header_list; - TnyIterator *iter; TnyHeader *header; TnyHeaderFlags flags; ModestWindow *msg_view_window = NULL; @@ -4443,7 +4514,7 @@ modest_ui_actions_on_main_window_remove_attachments (GtkAction *action, } if (tny_list_get_length (header_list) == 1) { - iter = tny_list_create_iterator (header_list); + TnyIterator *iter = tny_list_create_iterator (header_list); header = TNY_HEADER (tny_iterator_get_current (iter)); g_object_unref (iter); } else @@ -4489,8 +4560,8 @@ modest_ui_actions_on_main_window_remove_attachments (GtkAction *action, */ static void xfer_messages_from_move_to_cb (gboolean canceled, GError *err, - GtkWindow *parent_window, - TnyAccount *account, gpointer user_data) + GtkWindow *parent_window, + TnyAccount *account, gpointer user_data) { TnyFolderStore *dst_folder = TNY_FOLDER_STORE (user_data); ModestWindow *win = MODEST_WINDOW (parent_window); @@ -4503,13 +4574,6 @@ xfer_messages_from_move_to_cb (gboolean canceled, GError *err, g_object_unref (dst_folder); return; } - - if (!TNY_IS_FOLDER (dst_folder)) { - modest_platform_information_banner (GTK_WIDGET (win), - NULL, - _CS("ckdg_ib_unable_to_move_to_current_location")); - return; - } dst_account = tny_folder_get_account (TNY_FOLDER (dst_folder)); proto_str = tny_account_get_proto (dst_account); @@ -4574,6 +4638,36 @@ xfer_messages_from_move_to_cb (gboolean canceled, GError *err, } typedef struct { + TnyAccount *dst_account; + ModestConnectedPerformer callback; + gpointer data; +} DoubleConnectionInfo; + +static void +src_account_connect_performer (gboolean canceled, + GError *err, + GtkWindow *parent_window, + TnyAccount *src_account, + gpointer user_data) +{ + DoubleConnectionInfo *info = (DoubleConnectionInfo *) user_data; + + if (canceled || err) { + /* If there was any error call the user callback */ + info->callback (canceled, err, parent_window, src_account, info->data); + } else { + /* Connect the destination account */ + modest_platform_connect_if_remote_and_perform (parent_window, TRUE, + TNY_FOLDER_STORE (info->dst_account), + info->callback, info->data); + } + + /* Free the info object */ + g_object_unref (info->dst_account); + g_slice_free (DoubleConnectionInfo, info); +} + +typedef struct { TnyFolder *src_folder; TnyFolderStore *dst_folder; gboolean delete_original; @@ -4674,8 +4768,8 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action, /* Allow only to transfer folders to the local root folder */ if (TNY_IS_ACCOUNT (dst_folder) && - !MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (dst_folder)) { - do_xfer = FALSE; + !MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (dst_folder)) { + do_xfer = FALSE; } else if (!TNY_IS_FOLDER (src_folder)) { g_warning ("%s: src_folder is not a TnyFolder.\n", __FUNCTION__); do_xfer = FALSE; @@ -4700,25 +4794,48 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action, } } else if (gtk_widget_is_focus (GTK_WIDGET(header_view))) { gboolean do_xfer = TRUE; + + /* Show an error when trying to move msgs to an account */ + if (!TNY_IS_FOLDER (dst_folder)) { + modest_platform_information_banner (GTK_WIDGET (win), + NULL, + _CS("ckdg_ib_unable_to_move_to_current_location")); + goto free; + } + /* Ask for confirmation if the source folder is remote and we're not connected */ if (!online && modest_tny_folder_store_is_remote(src_folder)) { TnyList *headers = modest_header_view_get_selected_headers(header_view); if (!msgs_already_deleted_from_server(headers, src_folder)) { guint num_headers = tny_list_get_length(headers); TnyAccount *account = get_account_from_header_list (headers); - if (!connect_to_get_msg(MODEST_WINDOW (win), num_headers, account)) + GtkResponseType response; + + response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win), + ngettext("mcen_nc_get_msg", + "mcen_nc_get_msgs", + num_headers)); + if (response == GTK_RESPONSE_CANCEL) do_xfer = FALSE; + g_object_unref (account); } g_object_unref(headers); } if (do_xfer) /* Transfer messages */ { - g_object_ref (dst_folder); + DoubleConnectionInfo *info = g_slice_new (DoubleConnectionInfo); + info->callback = xfer_messages_from_move_to_cb; + info->dst_account = tny_folder_get_account (TNY_FOLDER (dst_folder)); + info->data = g_object_ref (dst_folder); + modest_platform_connect_if_remote_and_perform(GTK_WINDOW (win), TRUE, - TNY_FOLDER_STORE (dst_folder), xfer_messages_from_move_to_cb, dst_folder); + TNY_FOLDER_STORE (src_folder), + src_account_connect_performer, + info); } } + free: if (src_folder) g_object_unref (src_folder); } @@ -5198,7 +5315,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, gchar *message = NULL; /* Don't show anything if the user cancelled something */ - if (err->code == TNY_TRANSPORT_ACCOUNT_ERROR_SEND_USER_CANCEL) + if (err->code == TNY_SYSTEM_ERROR_CANCEL) return; /* Get the server name: */ @@ -5215,20 +5332,17 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, /* Show the appropriate message text for the GError: */ switch (err->code) { - case TNY_TRANSPORT_ACCOUNT_ERROR_SEND_HOST_LOOKUP_FAILED: + case TNY_SERVICE_ERROR_CONNECT: message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"), server_name); break; - case TNY_TRANSPORT_ACCOUNT_ERROR_SEND_SERVICE_UNAVAILABLE: - message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"), server_name); - break; - case TNY_TRANSPORT_ACCOUNT_ERROR_SEND_AUTHENTICATION_NOT_SUPPORTED: + case TNY_SERVICE_ERROR_AUTHENTICATE: message = g_strdup_printf (_("emev_ni_ui_smtp_authentication_fail_error"), server_name); break; - case TNY_TRANSPORT_ACCOUNT_ERROR_SEND: + case TNY_SERVICE_ERROR_SEND: message = g_strdup (_("emev_ib_ui_smtp_send_error")); break; default: - g_warning ("%s: unexpected TNY_TRANSPORT_ACCOUNT_ERROR %d", + g_warning ("%s: unexpected ERROR %d", __FUNCTION__, err->code); message = g_strdup (_("emev_ib_ui_smtp_send_error")); break; @@ -5283,6 +5397,10 @@ modest_ui_actions_on_send_queue_status_changed (ModestTnySendQueue *send_queue, #else gtk_widget_queue_draw (header_view); #endif + + /* Rerun dimming rules, because the message could become deletable for example */ + modest_window_check_dimming_rules_group (MODEST_WINDOW (main_window), + MODEST_DIMMING_RULES_TOOLBAR); /* Free */ frees: @@ -5323,3 +5441,54 @@ modest_ui_actions_on_account_connection_error (GtkWindow *parent_window, g_free (error_note); } } + +gchar * +modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win) +{ + gchar *msg = NULL; + TnyFolderStore *folder = NULL; + TnyAccount *account = NULL; + ModestTransportStoreProtocol proto; + TnyHeader *header = NULL; + + if (MODEST_IS_MAIN_WINDOW (win)) { + GtkWidget *header_view; + TnyList* headers = NULL; + TnyIterator *iter; + header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win), + MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW); + headers = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view)); + if (!headers || tny_list_get_length (headers) == 0) { + if (headers) + g_object_unref (headers); + return NULL; + } + iter = tny_list_create_iterator (headers); + header = TNY_HEADER (tny_iterator_get_current (iter)); + folder = TNY_FOLDER_STORE (tny_header_get_folder (header)); + g_object_unref (iter); + g_object_unref (headers); + } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) { + header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win)); + folder = TNY_FOLDER_STORE (tny_header_get_folder (header)); + } + + /* Get the account type */ + account = tny_folder_get_account (TNY_FOLDER (folder)); + proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account)); + if (proto == MODEST_PROTOCOL_STORE_POP) { + msg = g_strdup (_("emev_ni_ui_pop3_msg_recv_error")); + } else if (proto == MODEST_PROTOCOL_STORE_IMAP) { + msg = g_strdup_printf (_("emev_ni_ui_imap_message_not_available_in_server"), + tny_header_get_subject (header)); + } else { + msg = g_strdup_printf (_("mail_ni_ui_folder_get_msg_folder_error")); + } + + /* Frees */ + g_object_unref (account); + g_object_unref (folder); + g_object_unref (header); + + return msg; +}