static TnyAccount *get_account_from_folder_store (TnyFolderStore *folder_store);
-static void transfer_messages_helper (GtkWindow *win,
- TnyFolder *src_folder,
- TnyList *headers,
- TnyFolder *dst_folder);
-
/*
* This function checks whether a TnyFolderStore is a pop account
*/
ModestWindow *msg_win = NULL;
ModestAccountMgr *mgr = modest_runtime_get_account_mgr();
ModestTnyAccountStore *store = modest_runtime_get_account_store();
+ GnomeVFSFileSize total_size, allowed_size;
+
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * composing a message with attachments
+ */
+ if (attachments && modest_platform_check_memory_low (win))
+ goto cleanup;
account_name = modest_account_mgr_get_default_account(mgr);
if (!account_name) {
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;
/* Create and register edit window */
/* This is destroyed by TODO. */
+ total_size = 0;
+ allowed_size = MODEST_MAX_ATTACHMENT_SIZE;
msg_win = modest_msg_edit_window_new (msg, account_name, FALSE);
while (attachments) {
- modest_msg_edit_window_attach_file_one((ModestMsgEditWindow *)msg_win,
- attachments->data);
+ total_size +=
+ modest_msg_edit_window_attach_file_one(
+ (ModestMsgEditWindow *)msg_win,
+ attachments->data, allowed_size);
+
+ if (total_size > allowed_size) {
+ g_warning ("%s: total size: %u",
+ __FUNCTION__, (unsigned int)total_size);
+ break;
+ }
+ allowed_size -= total_size;
+
attachments = g_slist_next(attachments);
}
modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win);
g_free (signature);
g_free (body);
g_free (account_name);
- if (account) g_object_unref (G_OBJECT(account));
- if (folder) g_object_unref (G_OBJECT(folder));
- if (msg_win) g_object_unref (G_OBJECT(msg_win));
- if (msg) g_object_unref (G_OBJECT(msg));
+ if (account)
+ g_object_unref (G_OBJECT(account));
+ if (folder)
+ g_object_unref (G_OBJECT(folder));
+ if (msg_win)
+ g_object_unref (G_OBJECT(msg_win));
+ if (msg)
+ g_object_unref (G_OBJECT(msg));
}
void
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);
modest_ui_actions_on_open (GtkAction *action, ModestWindow *win)
{
TnyList *headers;
+
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * opening
+ */
+ if (modest_platform_check_memory_low (MODEST_WINDOW(win)))
+ return;
/* Get headers */
headers = get_selected_headers (win);
g_return_if_fail (MODEST_IS_WINDOW(win));
+
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * reply/forward (because it could potentially require a lot of memory */
+ if (modest_platform_check_memory_low (MODEST_WINDOW(win)))
+ return;
+
+
/* we need an account when editing */
if (!modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE)) {
if (!modest_ui_actions_run_account_setup_wizard (win))
return;
}
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * activating headers
+ */
+ if (modest_platform_check_memory_low (MODEST_WINDOW(main_window)))
+ return;
+
/* headers = tny_simple_list_new (); */
/* tny_list_prepend (headers, G_OBJECT (header)); */
G_OBJECT(header_view),
MODEST_CONF_HEADER_VIEW_KEY);
} else {
- /* Update the active account */
- //modest_window_set_active_account (MODEST_WINDOW (main_window), NULL);
- /* Save only if we're seeing headers */
+ /* No need to save the header view
+ configuration for Maemo because it only
+ saves the sorting stuff and that it's
+ already being done by the sort
+ dialog. Remove it when the GNOME version
+ has the same behaviour */
+#ifdef MODEST_PLATFORM_GNOME
if (modest_main_window_get_contents_style (main_window) ==
MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS)
modest_widget_memory_save (conf, G_OBJECT (header_view),
MODEST_CONF_HEADER_VIEW_KEY);
+#endif
modest_header_view_clear (MODEST_HEADER_VIEW(header_view));
}
}
void
modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, TnyMimePart *mime_part,
ModestWindow *win)
-{
+{
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * viewing attachments
+ */
+ if (modest_platform_check_memory_low (MODEST_WINDOW(win)))
+ return;
+
modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (win), mime_part);
}
return FALSE;
}
+ /*
+ * djcb: if we're in low-memory state, we only allow for
+ * saving messages smaller than
+ * MODEST_MAX_LOW_MEMORY_MESSAGE_SIZE (see modest-defs.h) this
+ * should still allow for sending anything critical...
+ */
+ if (expected_size > MODEST_MAX_LOW_MEMORY_MESSAGE_SIZE) {
+
+ if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window))) {
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+ return FALSE;
+ }
+ }
+
+ /*
+ * 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)
return FALSE;
}
+
+ /*
+ * djcb: if we're in low-memory state, we only allow for sending messages
+ * smaller than MODEST_MAX_LOW_MEMORY_MESSAGE_SIZE (see modest-defs.h)
+ * this should still allow for sending anything critical...
+ */
+ if (expected_size > MODEST_MAX_LOW_MEMORY_MESSAGE_SIZE) {
+ if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window))) {
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+ return FALSE;
+ }
+ }
+
+ /*
+ * 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);
if (!account_name)
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,
g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
g_return_if_fail (GTK_IS_ACTION (action));
+
+ if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+ return;
+
if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
return;
g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
g_return_if_fail (GTK_IS_ACTION (action));
+ if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+ return;
+
modest_msg_edit_window_offer_attach_file (window);
}
folder_view =
get_folder_view_from_move_to_dialog (GTK_WIDGET(source_win));
- /* Select the newly created folder */
- modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view),
- new_folder, FALSE);
+ /* Select the newly created folder. It could happen
+ that the widget is no longer there (i.e. the window
+ has been destroyed, so we need to check this */
+ if (folder_view)
+ modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view),
+ new_folder, FALSE);
g_object_unref (new_folder);
}
/* Free. Note that the first time it'll be NULL so noop */
if (result == GTK_RESPONSE_ACCEPT) {
ModestMailOperation *mail_op;
- mail_op = modest_mail_operation_new (NULL);
+ mail_op = modest_mail_operation_new ((GObject *) parent_window);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
modest_mail_operation_create_folder (mail_op,
{
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) {
return dialog;
}
-/*
- * Returns TRUE if at least one of the headers of the list belongs to
- * a message that has been fully retrieved.
- */
-#if 0 /* no longer in use. delete in 2007.10 */
-static gboolean
-has_retrieved_msgs (TnyList *list)
-{
- TnyIterator *iter;
- gboolean found = FALSE;
-
- iter = tny_list_create_iterator (list);
- while (!tny_iterator_is_done (iter) && !found) {
- TnyHeader *header;
- TnyHeaderFlags flags = 0;
-
- header = TNY_HEADER (tny_iterator_get_current (iter));
- if (header) {
- flags = tny_header_get_flags (header);
- if (flags & TNY_HEADER_FLAG_CACHED)
-/* if (!(flags & TNY_HEADER_FLAG_PARTIAL)) */
- found = TRUE;
-
- g_object_unref (header);
- }
-
- if (!found)
- tny_iterator_next (iter);
- }
- g_object_unref (iter);
-
- return found;
-}
-#endif /* 0 */
/*
MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view));
path = gtk_tree_row_reference_get_path (helper->reference);
+ /* We need to unselect the previous one
+ because we could be copying instead of
+ moving */
+ gtk_tree_selection_unselect_all (sel);
gtk_tree_selection_select_path (sel, path);
gtk_tree_path_free (path);
}
/* Close the "Pasting" information banner */
gtk_widget_destroy (GTK_WIDGET(helper->banner));
+ g_object_unref (helper->banner);
if (helper->reference != NULL)
gtk_tree_row_reference_free (helper->reference);
g_free (helper);
gpointer user_data)
{
ModestWindow *main_window = NULL;
- GObject *win = NULL;
/* Disable next automatic folder selection */
main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
FALSE); /* don't create */
if (main_window) {
+ GObject *win = NULL;
GtkWidget *folder_view = NULL;
folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (main_window),
modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view),
TNY_FOLDER (user_data), FALSE);
}
- }
- /* Show notification dialog */
- win = modest_mail_operation_get_source (mail_op);
- modest_platform_run_information_dialog ((GtkWindow *) win, _("mail_in_ui_folder_move_target_error"), FALSE);
- if (win)
- g_object_unref (win);
+ /* Show notification dialog only if the main window exists */
+ win = modest_mail_operation_get_source (mail_op);
+ modest_platform_run_information_dialog ((GtkWindow *) win,
+ _("mail_in_ui_folder_move_target_error"),
+ FALSE);
+ if (win)
+ g_object_unref (win);
+ }
}
static void
g_object_unref (src_account);
}
+static void
+xfer_messages_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ ModestWindow *main_window = NULL;
+
+ /* Disable next automatic folder selection */
+ main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ FALSE); /* don't create */
+ if (main_window) {
+ GObject *win = modest_mail_operation_get_source (mail_op);
+ modest_platform_run_information_dialog ((GtkWindow *) win,
+ _("mail_in_ui_folder_move_target_error"),
+ FALSE);
+ if (win)
+ g_object_unref (win);
+ }
+}
/**
* Utility function that transfer messages from both the main window
const gchar *proto_str = NULL;
gboolean dst_is_pop = FALSE;
- if (canceled || err) {
- if (err && is_memory_full_error (err)) {
+ if (canceled)
+ goto end;
+
+ if (err) {
+ if (is_memory_full_error (err)) {
modest_platform_information_banner ((GtkWidget *) parent_window,
NULL, dgettext("ke-recv",
"cerm_device_memory_full"));
/* Show the proper error message */
modest_ui_actions_on_account_connection_error (parent_window, account);
}
- g_object_unref (dst_folder);
- return;
+ goto end;
}
dst_account = tny_folder_get_account (TNY_FOLDER (dst_folder));
headers = get_selected_headers (MODEST_WINDOW (win));
if (!headers) {
g_warning ("%s: no headers selected", __FUNCTION__);
- return;
+ goto end;
}
-
if (dst_is_pop) {
modest_platform_information_banner (GTK_WIDGET (win),
NULL,
"mail_in_ui_folder_move_targets_error",
tny_list_get_length (headers)));
g_object_unref (headers);
- return;
+ goto end;
}
MoveToHelper *helper = g_new0 (MoveToHelper, 1);
helper->banner = modest_platform_animation_banner (GTK_WIDGET (win), NULL,
_CS("ckct_nw_pasting"));
if (helper->banner != NULL) {
+ g_object_ref (helper->banner);
gtk_window_set_modal (GTK_WINDOW(helper->banner), FALSE);
gtk_widget_show (GTK_WIDGET(helper->banner));
}
ModestMailOperation *mail_op =
modest_mail_operation_new_with_error_handling (G_OBJECT(win),
- modest_ui_actions_move_folder_error_handler,
+ xfer_messages_error_handler,
NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
g_object_unref (G_OBJECT (mail_op));
g_object_unref (headers);
+ end:
g_object_unref (dst_folder);
}
helper->banner = modest_platform_animation_banner (GTK_WIDGET (parent_window), NULL,
_CS("ckct_nw_pasting"));
if (helper->banner != NULL) {
+ g_object_ref (helper->banner);
gtk_window_set_modal (GTK_WINDOW(helper->banner), FALSE);
gtk_widget_show (GTK_WIDGET(helper->banner));
}
headers = modest_header_view_get_selected_headers(header_view);
/* Transfer the messages */
- transfer_messages_helper (GTK_WINDOW (win), TNY_FOLDER (src_folder),
- headers, TNY_FOLDER (dst_folder));
+ modest_ui_actions_transfer_messages_helper (GTK_WINDOW (win), TNY_FOLDER (src_folder),
+ headers, TNY_FOLDER (dst_folder));
g_object_unref (headers);
}
}
-static void
-transfer_messages_helper (GtkWindow *win,
- TnyFolder *src_folder,
- TnyList *headers,
- TnyFolder *dst_folder)
+void
+modest_ui_actions_transfer_messages_helper (GtkWindow *win,
+ TnyFolder *src_folder,
+ TnyList *headers,
+ TnyFolder *dst_folder)
{
gboolean need_connection = TRUE;
gboolean do_xfer = TRUE;
} else {
TnyAccount *src_account = get_account_from_folder_store (TNY_FOLDER_STORE (src_folder));
xfer_messages_performer (FALSE, NULL, GTK_WINDOW (win),
- src_account,
- g_object_ref (dst_folder));
+ src_account, g_object_ref (dst_folder));
g_object_unref (src_account);
}
}
tny_list_append (headers, G_OBJECT (header));
/* Transfer the messages */
- transfer_messages_helper (GTK_WINDOW (win), src_folder, headers,
- TNY_FOLDER (dst_folder));
+ modest_ui_actions_transfer_messages_helper (GTK_WINDOW (win), src_folder, headers,
+ TNY_FOLDER (dst_folder));
/* Frees */
g_object_unref (header);
ModestWindow *window)
{
if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+
+ if (modest_platform_check_memory_low (MODEST_WINDOW(window)))
+ return;
+
modest_msg_view_window_save_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
} else {
/* not supported window for this action */
{
g_return_if_fail (MODEST_IS_WINDOW (window));
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * searching
+ */
+ if (modest_platform_check_memory_low (window))
+ return;
+
modest_platform_show_search_messages (GTK_WINDOW (window));
}
modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win)
{
g_return_if_fail (MODEST_IS_WINDOW (win));
+
+
+ /* we check for low-mem; in that case, show a warning, and don't allow
+ * for the addressbook
+ */
+ if (modest_platform_check_memory_low (win))
+ return;
+
+
modest_platform_show_addressbook (GTK_WINDOW (win));
}