/* 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);
/* 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 (),
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!!");
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);
/* 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 */
/* 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;
/* 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));
{
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);
/* 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);
*/
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;
}
* 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;
}
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)
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);
}
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)
{
}
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
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 (win)
g_object_unref (win);
}
+ move_to_helper_destroyer (user_data);
}
/**
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);
{
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);
{
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
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);
/* 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));
/* 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;