Work to fix bug NB#80656.
[modest] / src / modest-ui-actions.c
index f567e03..765dc88 100644 (file)
@@ -749,7 +749,7 @@ modest_ui_actions_compose_msg(ModestWindow *win,
                body = use_signature ? g_strconcat("\n", signature, NULL) : g_strdup("");
        }
 
                body = use_signature ? g_strconcat("\n", signature, NULL) : g_strdup("");
        }
 
-       msg = modest_tny_msg_new (to_str, from_str, cc_str, bcc_str, subject_str, body, NULL);
+       msg = modest_tny_msg_new (to_str, from_str, cc_str, bcc_str, subject_str, body, NULL, NULL);
        if (!msg) {
                g_printerr ("modest: failed to create new msg\n");
                goto cleanup;
        if (!msg) {
                g_printerr ("modest: failed to create new msg\n");
                goto cleanup;
@@ -767,7 +767,7 @@ modest_ui_actions_compose_msg(ModestWindow *win,
                                attachments->data, allowed_size);
 
                if (total_size > allowed_size) {
                                attachments->data, allowed_size);
 
                if (total_size > allowed_size) {
-                       g_warning ("%s: total size: %u", 
+                       g_warning ("%s: total size: %u",
                                   __FUNCTION__, (unsigned int)total_size);
                        break;
                }
                                   __FUNCTION__, (unsigned int)total_size);
                        break;
                }
@@ -1032,6 +1032,9 @@ modest_ui_actions_disk_operations_error_handler (ModestMailOperation *mail_op,
                        modest_platform_information_banner ((GtkWidget *) win,
                                                            NULL, dgettext("ke-recv",
                                                                           "cerm_device_memory_full"));
                        modest_platform_information_banner ((GtkWidget *) win,
                                                            NULL, dgettext("ke-recv",
                                                                           "cerm_device_memory_full"));
+               } else if (error->code == MODEST_MAIL_OPERATION_ERROR_FILE_IO) {
+                       modest_platform_information_banner ((GtkWidget *) win,
+                                                           NULL, dgettext ("hildon-common-strings", "sfil_ni_unable_to_open_file_not_found"));
                } 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);
@@ -2509,7 +2512,6 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
                return FALSE;
        }
 
                return FALSE;
        }
 
-               
        /*
         * djcb: if we're in low-memory state, we only allow for
         * saving messages smaller than
        /*
         * djcb: if we're in low-memory state, we only allow for
         * saving messages smaller than
@@ -2524,6 +2526,21 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
                }
        }
 
                }
        }
 
+       /*
+        * djcb: we also make sure that the attachments are smaller than the max size
+        * this is for the case where we'd try to forward a message with attachments 
+        * bigger than our max allowed size, or sending an message from drafts which
+        * somehow got past our checks when attaching.
+        */
+       if (expected_size > MODEST_MAX_ATTACHMENT_SIZE) {
+               modest_platform_run_information_dialog (
+                       GTK_WINDOW(edit_window),
+                       dgettext("ke-recv","memr_ib_operation_disabled"),
+                       TRUE);
+               modest_msg_edit_window_free_msg_data (edit_window, data);
+               return FALSE;
+       }
+
        account_name = g_strdup (data->account_name);
        account_mgr = modest_runtime_get_account_mgr();
        if (!account_name)
        account_name = g_strdup (data->account_name);
        account_mgr = modest_runtime_get_account_mgr();
        if (!account_name)
@@ -2679,6 +2696,20 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
                }
        }
 
                }
        }
 
+       /*
+        * djcb: we also make sure that the attachments are smaller than the max size
+        * this is for the case where we'd try to forward a message with attachments 
+        * bigger than our max allowed size, or sending an message from drafts which
+        * somehow got past our checks when attaching.
+        */
+       if (expected_size > MODEST_MAX_ATTACHMENT_SIZE) {
+               modest_platform_run_information_dialog (
+                       GTK_WINDOW(edit_window),
+                       dgettext("ke-recv","memr_ib_operation_disabled"),
+                       TRUE);
+               modest_msg_edit_window_free_msg_data (edit_window, data);
+               return FALSE;
+       }
 
        ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
        gchar *account_name = g_strdup (data->account_name);
 
        ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
        gchar *account_name = g_strdup (data->account_name);
@@ -2713,7 +2744,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
        gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
 
        /* Create the mail operation */
        gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
 
        /* Create the mail operation */
-       ModestMailOperation *mail_operation = modest_mail_operation_new (NULL);
+       ModestMailOperation *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_send_new_mail (mail_operation,
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
 
        modest_mail_operation_send_new_mail (mail_operation,
@@ -3088,6 +3119,11 @@ on_rename_folder_cb (ModestMailOperation *mail_op,
 {
        ModestFolderView *folder_view;
 
 {
        ModestFolderView *folder_view;
 
+       /* If the window was closed when renaming a folder this could
+          happen */
+       if (MODEST_IS_FOLDER_VIEW (user_data))
+               return;
+
        folder_view = MODEST_FOLDER_VIEW (user_data);
        /* Note that if the rename fails new_folder will be NULL */
        if (new_folder) {
        folder_view = MODEST_FOLDER_VIEW (user_data);
        /* Note that if the rename fails new_folder will be NULL */
        if (new_folder) {