}
break;
case MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED:
- /* If mail_op is mine, check errors */
-/* status = modest_mail_operation_get_status (mail_op); */
-/* if (status != MODEST_MAIL_OPERATION_STATUS_SUCCESS) */
-/* modest_mail_operation_execute_error_handler (mail_op); */
-
/* Change toolbar mode */
if (mode == TOOLBAR_MODE_TRANSFER) {
while (tmp) {
ModestMailOperation *mail_op)
{
ModestMailOperationQueuePrivate *priv;
+ ModestMailOperationStatus status;
g_return_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self));
g_return_if_fail (MODEST_IS_MAIL_OPERATION (mail_op));
g_queue_remove (priv->op_queue, mail_op);
g_mutex_unlock (priv->queue_lock);
- /* Debug code */
- {
- const GError *err;
- err = modest_mail_operation_get_error (mail_op);
- if (err)
- g_printerr ("Error in %s: %s\n", __FUNCTION__, err->message);
- }
-
/* Notify observers */
g_signal_emit (self, signals[QUEUE_CHANGED_SIGNAL], 0,
mail_op, MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED);
+ /* Check errors */
+ status = modest_mail_operation_get_status (mail_op);
+ if (status != MODEST_MAIL_OPERATION_STATUS_SUCCESS)
+ modest_mail_operation_execute_error_handler (mail_op);
+
/* Free object */
modest_runtime_verify_object_last_ref (mail_op, "");
g_object_unref (G_OBJECT (mail_op));
GObject *source;
GError *error;
ErrorCheckingUserCallback error_checking;
+ gpointer error_checking_user_data;
ModestMailOperationStatus status;
ModestMailOperationTypeOperation op_type;
};
priv->status = MODEST_MAIL_OPERATION_STATUS_INVALID;
priv->op_type = MODEST_MAIL_OPERATION_TYPE_UNKNOWN;
priv->error = NULL;
- priv->error_checking = NULL;
priv->done = 0;
priv->total = 0;
priv->source = NULL;
+ priv->error_checking = NULL;
+ priv->error_checking_user_data = NULL;
}
static void
ModestMailOperation*
modest_mail_operation_new_with_error_handling (ModestMailOperationTypeOperation op_type,
GObject *source,
- ErrorCheckingUserCallback error_handler)
+ ErrorCheckingUserCallback error_handler,
+ gpointer user_data)
{
ModestMailOperation *obj;
ModestMailOperationPrivate *priv;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
g_return_if_fail(priv->status != MODEST_MAIL_OPERATION_STATUS_SUCCESS);
- if (priv->error_checking == NULL)
- return;
- priv->error_checking (priv->source, self);
+ if (priv->error_checking != NULL)
+ priv->error_checking (self, priv->error_checking_user_data);
}
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
/* FIXME: the error msg is different for pop */
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
- MODEST_MAIL_OPERATION_ERROR_BAD_PARAMETER,
- _("emev_ni_ui_imap_msg_sizelimit_error"));
+ MODEST_MAIL_OPERATION_ERROR_SIZE_LIMIT,
+ _("emev_ni_ui_imap_msg_size_exceed_error"));
/* Remove from queue and free resources */
modest_mail_operation_notify_end (self);
if (notify)
} ModestMailOperationTypeOperation;
/**
- * ErroCheckingAsyncUserCallback:
+ * ErrorCheckingAsyncUserCallback:
*
- * @obj: a #GObject generic object which has created current mail operation.
+ * @mail_op: the current mail operation.
* @user_data: generic data passed to user defined function.
*
* This function implements required actions to performs under error
* states.
*/
-typedef void (*ErrorCheckingUserCallback) (const GObject *obj, gpointer user_data);
+typedef void (*ErrorCheckingUserCallback) (ModestMailOperation *mail_op, gpointer user_data);
/**
* GetMsgAsyncUserCallback:
**/
ModestMailOperation* modest_mail_operation_new_with_error_handling (ModestMailOperationTypeOperation op_type,
GObject *source,
- ErrorCheckingUserCallback error_handler);
+ ErrorCheckingUserCallback error_handler,
+ gpointer user_data);
/**
* modest_mail_operation_execute_error_handler
* @self: a #ModestMailOperation
*
- * Executes error handler, if it exists, passing @self objsect as
- * user_data argument of error handling function.
+ * Executes error handler if exists. The error handler is the one that
+ * MUST free the user data passed to the
+ * modest_mail_operation_new_with_error_handling constructor
**/
void
modest_mail_operation_execute_error_handler (ModestMailOperation *self);
#include <modest-tny-msg.h>
#include <modest-tny-account.h>
#include <modest-address-book.h>
-
+#include "modest-error.h"
#include "modest-ui-actions.h"
#include "modest-tny-platform-factory.h"
}
/*
+ * This function is the error handler of the
+ * modest_mail_operation_get_msgs_full operation
+ */
+static void
+modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ const GError *error;
+
+ error = modest_mail_operation_get_error (mail_op);
+ if (error->code == MODEST_MAIL_OPERATION_ERROR_SIZE_LIMIT) {
+ modest_platform_run_information_dialog (GTK_WINDOW (modest_mail_operation_get_source (mail_op)),
+ error->message);
+ }
+}
+
+/*
* This function is used by both modest_ui_actions_on_open and
* modest_ui_actions_on_header_activated. This way we always do the
* same when trying to open messages.
}
/* Open each message */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT (win));
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT (win),
+ modest_ui_actions_get_msgs_full_error_handler,
+ NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msgs_full (mail_op,
headers,
reply_forward_cb (NULL, header, msg, rf_helper);
} else {
/* Retrieve messages */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT(win),
+ modest_ui_actions_get_msgs_full_error_handler,
+ NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msgs_full (mail_op,
header_list,
return;
/* Create mail operation */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT (window));
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT (window),
+ modest_ui_actions_get_msgs_full_error_handler,
+ 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);