X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=f6f789259414b6dd761158d1f2f11390dabc4948;hp=110a26f6533ea1b8e33d3d7842e83c808e507311;hb=518e2f866b4ddaa35443cef48c874a358be0851f;hpb=a9c347489d676ecf1cb0a4ba30059432aeccee80 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 110a26f..f6f7892 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; } @@ -598,8 +598,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) { @@ -814,25 +812,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, @@ -1021,13 +1000,21 @@ modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op, { const GError *error; GObject *win = NULL; - const gchar *err_msg = (const gchar *) user_data; win = modest_mail_operation_get_source (mail_op); error = modest_mail_operation_get_error (mail_op); /* 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); @@ -1327,19 +1314,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: @@ -2285,7 +2276,7 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op, g_object_unref(edit_window); } -void +gboolean modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edit_window) { TnyTransportAccount *transport_account; @@ -2293,12 +2284,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) @@ -2308,7 +2318,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)) { @@ -2324,7 +2334,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); @@ -2347,18 +2357,18 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi data->priority_flags, on_save_to_drafts_cb, 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, info_text); + +/* 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 @@ -2377,7 +2387,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) { @@ -2396,24 +2406,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) @@ -2426,7 +2457,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; } } @@ -2441,7 +2472,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); @@ -2467,6 +2498,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); @@ -2475,10 +2515,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 @@ -4425,6 +4470,7 @@ open_msg_for_purge_cb (ModestMailOperation *mail_op, tny_iterator_next (iter); } + g_object_unref (iter); tny_msg_rewrite_cache (msg); } @@ -4432,7 +4478,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); @@ -4445,7 +4490,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; @@ -4463,7 +4507,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 @@ -5390,3 +5434,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; +}