}
static void
+update_account_notify_user_and_free (UpdateAccountInfo *info,
+ TnyList *new_headers)
+{
+ /* Set the account back to not busy */
+ modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr (),
+ info->account_name, FALSE);
+
+ /* User callback */
+ if (info->callback)
+ info->callback (info->mail_op, new_headers, info->user_data);
+
+ /* Mail operation end */
+ modest_mail_operation_notify_end (info->mail_op);
+
+ /* Frees */
+ if (new_headers)
+ g_object_unref (new_headers);
+ destroy_update_account_info (info);
+}
+
+static void
inbox_refreshed_cb (TnyFolder *inbox,
gboolean canceled,
GError *err,
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (info->mail_op);
mgr = modest_runtime_get_account_mgr ();
- if (canceled || err || !inbox) {
+ if (canceled || err) {
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ if (err)
+ priv->error = g_error_copy (err);
+ else
+ g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
+ MODEST_MAIL_OPERATION_ERROR_OPERATION_CANCELED,
+ "canceled");
+ /* Notify the user about the error and then exit */
+ update_account_notify_user_and_free (info, NULL);
+ return;
+ }
+
+ if (!inbox) {
/* Try to send anyway */
goto send_mail;
}
if (!priv->error)
priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
- /* Set the account back to not busy */
- modest_account_mgr_set_account_busy (mgr, info->account_name, FALSE);
-
- /* Call the user callback */
- if (info->callback)
- info->callback (info->mail_op, new_headers, info->user_data);
-
- /* Notify about operation end */
- modest_mail_operation_notify_end (info->mail_op);
-
- /* Frees */
- if (new_headers)
- g_object_unref (new_headers);
- destroy_update_account_info (info);
+ /* Call the user callback and free */
+ update_account_notify_user_and_free (info, new_headers);
}
static void
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (info->mail_op);
if (err || canceled) {
- /* Try to continue anyway */
+ /* If the error was previosly set by another callback
+ don't set it again */
+ if (!priv->error) {
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ if (err)
+ priv->error = g_error_copy (err);
+ else
+ g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
+ MODEST_MAIL_OPERATION_ERROR_OPERATION_CANCELED,
+ "canceled");
+ }
} else if (info->poke_all) {
/* We're not getting INBOX children if we don't want to poke all */
TnyIterator *iter = tny_list_create_iterator (list);
TnyIterator *iter_all_folders;
TnyFolder *inbox = NULL;
+ /* If there was any error do not continue */
+ if (priv->error) {
+ update_account_notify_user_and_free (info, NULL);
+ return;
+ }
+
iter_all_folders = tny_list_create_iterator (info->folders);
/* Do a poke status over all folders */
g_object_unref (folder);
}
+static gboolean
+is_memory_full_error (GError *error)
+{
+ if (error->code == TNY_SYSTEM_ERROR_MEMORY ||
+ error->code == TNY_IO_ERROR_WRITE ||
+ error->code == TNY_IO_ERROR_READ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
void
modest_ui_actions_disk_operations_error_handler (ModestMailOperation *mail_op,
- gpointer user_data)
+ gpointer user_data)
{
const GError *error;
GObject *win = NULL;
/* If the mail op has been cancelled then it's not an error:
don't show any message */
if (status != MODEST_MAIL_OPERATION_STATUS_CANCELED) {
- /* Show error */
- if (error->code == TNY_SYSTEM_ERROR_MEMORY ||
- error->code == TNY_IO_ERROR_WRITE ||
- error->code == TNY_IO_ERROR_READ) {
+ if (is_memory_full_error ((GError *) error)) {
modest_platform_information_banner ((GtkWidget *) win,
NULL, dgettext("ke-recv",
"cerm_device_memory_full"));
modest_runtime_get_window_mgr ());
/* Free the helper */
open_msgs_helper_destroyer (helper);
+
+ /* In memory full conditions we could get this error here */
+ if (err && is_memory_full_error (err)) {
+ modest_platform_information_banner ((GtkWidget *) parent_window,
+ NULL, dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ }
goto clean;
}
info = (SendReceiveInfo *) user_data;
if (err || canceled) {
+ /* In memory full conditions we could get this error here */
+ if (err && is_memory_full_error (err)) {
+ modest_platform_information_banner ((GtkWidget *) parent_window,
+ NULL, dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ }
goto clean;
}
}
mail_op = modest_mail_operation_new_with_error_handling ((info->win) ? G_OBJECT (info->win) : NULL,
- modest_ui_actions_send_receive_error_handler,
+ modest_ui_actions_disk_operations_error_handler,
NULL, NULL);
if (info->win && MODEST_IS_MAIN_WINDOW (info->win))
TnyFolderStore *parent_folder = TNY_FOLDER_STORE (user_data);
if (canceled || err) {
+ /* In memory full conditions we could get this error here */
+ if (err && is_memory_full_error (err)) {
+ modest_platform_information_banner ((GtkWidget *) parent_window,
+ NULL, dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ }
goto frees;
}
GtkWidget *folder_view = NULL;
RenameFolderInfo *data = (RenameFolderInfo*)user_data;
- if (!canceled && (err == NULL) && MODEST_IS_MAIN_WINDOW(parent_window)) {
+ if (canceled || err) {
+ /* In memory full conditions we could get this error here */
+ if (err && is_memory_full_error (err)) {
+ modest_platform_information_banner ((GtkWidget *) parent_window,
+ NULL, dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ }
+ } else if (MODEST_IS_MAIN_WINDOW(parent_window)) {
folder_view = modest_main_window_get_child_widget (
MODEST_MAIN_WINDOW (parent_window),
(const gchar *) (data->new_name),
on_rename_folder_cb,
folder_view);
+ g_object_unref (mail_op);
}
- g_object_unref (mail_op);
g_free (data->new_name);
g_free (data);
}
g_object_unref (win);
}
-void
-modest_ui_actions_send_receive_error_handler (ModestMailOperation *mail_op,
- gpointer user_data)
-{
- GObject *win = modest_mail_operation_get_source (mail_op);
- const GError *error = modest_mail_operation_get_error (mail_op);
-
- g_return_if_fail (error != NULL);
- if (error->message != NULL)
- g_printerr ("modest: %s\n", error->message);
- else
- g_printerr ("modest: unkonw error on send&receive operation");
-
- /* Show error message */
-/* if (modest_mail_operation_get_id (mail_op) == MODEST_MAIL_OPERATION_TYPE_RECEIVE) */
-/* modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL, */
-/* _CS("sfil_ib_unable_to_receive")); */
-/* else */
-/* modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL, */
-/* _CS("sfil_ib_unable_to_send")); */
- g_object_unref (win);
-}
-
static void
open_msg_for_purge_cb (ModestMailOperation *mail_op,
TnyHeader *header,
gboolean dst_is_pop = FALSE;
if (canceled || err) {
- /* Show the proper error message */
- modest_ui_actions_on_account_connection_error (parent_window, account);
+ if (err && is_memory_full_error (err)) {
+ modest_platform_information_banner ((GtkWidget *) parent_window,
+ NULL, dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ } else {
+ /* Show the proper error message */
+ modest_ui_actions_on_account_connection_error (parent_window, account);
+ }
g_object_unref (dst_folder);
return;
}
TnyList *headers = TNY_LIST (user_data);
if (err || canceled) {
+ if (err && is_memory_full_error (err)) {
+ modest_platform_information_banner ((GtkWidget *) parent_window,
+ NULL, dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ }
goto out;
}