- /* FIXME. Make the header view sensitive again. This is a
- * temporary hack. See modest_ui_actions_on_save_to_drafts()
- * for details */
- win = MODEST_MAIN_WINDOW(modest_window_mgr_get_main_window(
- modest_runtime_get_window_mgr(), FALSE));
- if (win != NULL) {
- GtkWidget *hdrview = modest_main_window_get_child_widget(
- win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
- if (hdrview) gtk_widget_set_sensitive(hdrview, TRUE);
+ /* FIXME. Make the header view sensitive again. This is a
+ * temporary hack. See modest_ui_actions_on_save_to_drafts()
+ * for details */
+ win = MODEST_MAIN_WINDOW(modest_window_mgr_get_main_window(
+ modest_runtime_get_window_mgr(), FALSE));
+ if (win != NULL) {
+ GtkWidget *hdrview = modest_main_window_get_child_widget(
+ win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
+ if (hdrview) gtk_widget_set_sensitive(hdrview, TRUE);
+ }
+
+ edit_window = MODEST_MSG_EDIT_WINDOW (user_data);
+
+ /* 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);
+}
+
+static gboolean
+enough_space_for_message (ModestMsgEditWindow *edit_window,
+ MsgData *data)
+{
+ TnyAccountStore *acc_store;
+ guint64 available_disk, expected_size;
+ gint parts_count;
+ guint64 parts_size;
+
+ /* Check size */
+ acc_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store());
+ available_disk = modest_utils_get_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);
+
+ /* Double check: memory full condition or message too big */
+ if (available_disk < MIN_FREE_SPACE ||
+ expected_size > available_disk) {
+
+ modest_platform_information_banner (NULL, NULL,
+ dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ return FALSE;