X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=6b08023d3bcef5b4a4bb606ff9313adc2d8ef3e5;hp=0a1e0ea315af2256358b939a7a8d94e886806954;hb=9e57e2cf29636dad01d035358e2795340e7a89d0;hpb=30f857c62697eb8f26018c40aa98a23593501914 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 0a1e0ea..6b08023 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -702,7 +702,7 @@ modest_ui_actions_compose_msg(ModestWindow *win, /* 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)) + if (attachments && modest_platform_check_memory_low (win, TRUE)) goto cleanup; account_name = modest_account_mgr_get_default_account(mgr); @@ -733,7 +733,7 @@ modest_ui_actions_compose_msg(ModestWindow *win, 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, NULL); + msg = modest_tny_msg_new (to_str, from_str, cc_str, bcc_str, subject_str, body, NULL, NULL, NULL); if (!msg) { g_printerr ("modest: failed to create new msg\n"); goto cleanup; @@ -801,6 +801,18 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op, /* If there is no message or the operation was not successful */ status = modest_mail_operation_get_status (mail_op); if (!msg || status != MODEST_MAIL_OPERATION_STATUS_SUCCESS) { + const GError *error; + + /* If it's a memory low issue, then show a banner */ + error = modest_mail_operation_get_error (mail_op); + if (error && error->domain == MODEST_MAIL_OPERATION_ERROR && + error->code == MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY) { + GObject *source = modest_mail_operation_get_source (mail_op); + modest_platform_run_information_dialog (GTK_IS_WINDOW (source) ? GTK_WINDOW (source) : NULL, + dgettext("ke-recv","memr_ib_operation_disabled"), + TRUE); + g_object_unref (source); + } /* Remove the header from the preregistered uids */ modest_window_mgr_unregister_header (modest_runtime_get_window_mgr (), @@ -890,13 +902,15 @@ open_msg_cb (ModestMailOperation *mail_op, account = g_strdup(modest_tny_account_get_parent_modest_account_name_for_server_account( TNY_ACCOUNT(traccount))); send_queue = modest_runtime_get_send_queue(traccount, TRUE); - msg_id = modest_tny_send_queue_get_msg_id (header); - status = modest_tny_send_queue_get_msg_status(send_queue, msg_id); - /* Only open messages in outbox with the editor if they are in Failed state */ - if (status == MODEST_TNY_SEND_QUEUE_FAILED) { - open_in_editor = TRUE; + if (TNY_IS_SEND_QUEUE (send_queue)) { + msg_id = modest_tny_send_queue_get_msg_id (header); + status = modest_tny_send_queue_get_msg_status(send_queue, msg_id); + /* Only open messages in outbox with the editor if they are in Failed state */ + if (status == MODEST_TNY_SEND_QUEUE_FAILED) { + open_in_editor = TRUE; + } + g_free(msg_id); } - g_free(msg_id); g_object_unref(traccount); } else { g_warning("Cannot get transport account for message in outbox!!"); @@ -930,28 +944,19 @@ open_msg_cb (ModestMailOperation *mail_op, if (from_header) { GSList *accounts = modest_account_mgr_account_names (mgr, TRUE); GSList *node = NULL; - gchar *from_header_email; - - from_header_email = modest_text_utils_get_email_address ((const gchar *) from_header); for (node = accounts; node != NULL; node = g_slist_next (node)) { - gchar *from, *from_email; - - from = modest_account_mgr_get_from_string (mgr, node->data); - if (from) { - from_email = modest_text_utils_get_email_address ((const gchar *) from); - if (strcmp (from_header_email, from_email) == 0) { - g_free (account); - account = g_strdup (node->data); - g_free (from_email); - g_free (from); - break; - } - g_free (from_email); + gchar *from = modest_account_mgr_get_from_string (mgr, node->data); + + if (from && (strcmp (from_header, from) == 0)) { + g_free (account); + account = g_strdup (node->data); g_free (from); - } - } - g_free (from_header_email); + break; + } + g_free (from); + } + g_free (from_header); g_slist_foreach (accounts, (GFunc) g_free, NULL); g_slist_free (accounts); @@ -1402,7 +1407,7 @@ modest_ui_actions_on_open (GtkAction *action, ModestWindow *win) /* 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))) + if (modest_platform_check_memory_low (MODEST_WINDOW(win), TRUE)) return; /* Get headers */ @@ -1643,7 +1648,7 @@ reply_forward (ReplyForwardAction action, ModestWindow *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))) + if (modest_platform_check_memory_low (MODEST_WINDOW(win), TRUE)) return; @@ -2245,7 +2250,7 @@ modest_ui_actions_on_header_activated (ModestHeaderView *header_view, /* 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))) + if (modest_platform_check_memory_low (MODEST_WINDOW(main_window), TRUE)) return; modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window)); @@ -2300,10 +2305,22 @@ folder_refreshed_cb (ModestMailOperation *mail_op, { ModestMainWindow *win = NULL; GtkWidget *header_view; + const GError *error; g_return_if_fail (TNY_IS_FOLDER (folder)); win = MODEST_MAIN_WINDOW (user_data); + + /* Check if the operation failed due to memory low conditions */ + error = modest_mail_operation_get_error (mail_op); + if (error && error->domain == MODEST_MAIL_OPERATION_ERROR && + error->code == MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY) { + modest_platform_run_information_dialog (GTK_WINDOW (win), + dgettext("ke-recv","memr_ib_operation_disabled"), + TRUE); + return; + } + header_view = modest_main_window_get_child_widget(win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW); @@ -2482,7 +2499,7 @@ modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, TnyMimePart /* 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))) + if (modest_platform_check_memory_low (MODEST_WINDOW(win), TRUE)) return; modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (win), mime_part); @@ -2566,7 +2583,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi */ if (expected_size > MODEST_MAX_LOW_MEMORY_MESSAGE_SIZE) { - if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window))) { + if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window), TRUE)) { modest_msg_edit_window_free_msg_data (edit_window, data); return FALSE; } @@ -2736,7 +2753,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) * 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))) { + if (modest_platform_check_memory_low (MODEST_WINDOW(edit_window), TRUE)) { modest_msg_edit_window_free_msg_data (edit_window, data); return FALSE; } @@ -2958,7 +2975,7 @@ modest_ui_actions_on_insert_image (GtkAction *action, g_return_if_fail (GTK_IS_ACTION (action)); - if (modest_platform_check_memory_low (MODEST_WINDOW(window))) + if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE)) return; if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT) @@ -2974,7 +2991,7 @@ modest_ui_actions_on_attach_file (GtkAction *action, 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))) + if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE)) return; modest_msg_edit_window_offer_attach_file (window); @@ -3144,6 +3161,11 @@ modest_ui_actions_rename_folder_error_handler (ModestMailOperation *mail_op, case MODEST_MAIL_OPERATION_ERROR_FOLDER_EXISTS: message = _CS("ckdg_ib_folder_already_exists"); break; + case TNY_SERVICE_ERROR_STATE: + /* This means that the folder is already in use (a + message is opened for example */ + message = _("emev_ni_internal_error"); + break; default: message = _("emev_ib_ui_imap_unable_to_rename"); } @@ -4672,6 +4694,21 @@ modest_ui_actions_msgs_move_to_confirmation (ModestWindow *win, } static void +move_to_helper_destroyer (gpointer user_data) +{ + MoveToHelper *helper = (MoveToHelper *) user_data; + + /* Close the "Pasting" information banner */ + if (helper->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); +} + +static void move_to_cb (ModestMailOperation *mail_op, gpointer user_data) { @@ -4709,15 +4746,8 @@ move_to_cb (ModestMailOperation *mail_op, } g_object_unref (object); } - - /* Close the "Pasting" information banner */ - if (helper->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); + /* Destroy the helper */ + move_to_helper_destroyer (helper); } static void @@ -5004,7 +5034,7 @@ 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 */ @@ -5016,6 +5046,7 @@ xfer_messages_error_handler (ModestMailOperation *mail_op, if (win) g_object_unref (win); } + move_to_helper_destroyer (user_data); } /** @@ -5096,7 +5127,7 @@ xfer_messages_performer (gboolean canceled, ModestMailOperation *mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(win), xfer_messages_error_handler, - NULL, NULL); + helper, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); @@ -5447,7 +5478,7 @@ modest_ui_actions_save_attachments (GtkAction *action, { if (MODEST_IS_MSG_VIEW_WINDOW (window)) { - if (modest_platform_check_memory_low (MODEST_WINDOW(window))) + if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE)) return; modest_msg_view_window_save_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL); @@ -5493,15 +5524,53 @@ modest_ui_actions_on_help (GtkAction *action, { const gchar *help_id; - g_return_if_fail (action); g_return_if_fail (win && GTK_IS_WINDOW(win)); help_id = modest_window_mgr_get_help_id (modest_runtime_get_window_mgr(), win); - - if (help_id) - modest_platform_show_help (GTK_WINDOW (win), help_id); + + if (help_id) + modest_platform_show_help (GTK_WINDOW (win), help_id); +} + +void +modest_ui_actions_on_csm_help (GtkAction *action, + GtkWindow *win) +{ + const gchar* help_id = NULL; + GtkWidget *folder_view; + TnyFolderStore *folder_store; + + g_return_if_fail (win && MODEST_IS_MAIN_WINDOW (win)); + + /* Get selected folder */ + folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win), + MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW); + folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)); + + /* Switch help_id */ + if (folder_store && TNY_IS_FOLDER (folder_store)) + help_id = modest_tny_folder_get_help_id (TNY_FOLDER (folder_store)); + + if (folder_store) + g_object_unref (folder_store); + + if (help_id) + modest_platform_show_help (GTK_WINDOW (win), help_id); else - g_warning ("%s: no help for window %p", __FUNCTION__, win); + modest_ui_actions_on_help (action, win); +} + +static void +retrieve_contents_cb (ModestMailOperation *mail_op, + TnyHeader *header, + gboolean canceled, + TnyMsg *msg, + GError *err, + gpointer user_data) +{ + /* We only need this callback to show an error in case of + memory low condition */ + modest_ui_actions_msg_retrieval_check (mail_op, header, msg); } static void @@ -5528,7 +5597,7 @@ retrieve_msg_contents_performer (gboolean canceled, modest_ui_actions_disk_operations_error_handler, NULL, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); - modest_mail_operation_get_msgs_full (mail_op, headers, NULL, NULL, NULL); + modest_mail_operation_get_msgs_full (mail_op, headers, retrieve_contents_cb, NULL, NULL); /* Frees */ g_object_unref (mail_op); @@ -5688,7 +5757,7 @@ modest_ui_actions_on_search_messages (GtkAction *action, ModestWindow *window) /* we check for low-mem; in that case, show a warning, and don't allow * searching */ - if (modest_platform_check_memory_low (window)) + if (modest_platform_check_memory_low (window, TRUE)) return; modest_platform_show_search_messages (GTK_WINDOW (window)); @@ -5703,7 +5772,7 @@ modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *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)) + if (modest_platform_check_memory_low (win, TRUE)) return;