/* New mail operation */
mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(window),
modest_ui_actions_get_msgs_full_error_handler,
- NULL);
+ NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msg (mail_op, header, view_msg_cb, row_reference);
GError *error;
ErrorCheckingUserCallback error_checking;
gpointer error_checking_user_data;
+ ErrorCheckingUserDataDestroyer error_checking_user_data_destroyer;
ModestMailOperationStatus status;
ModestMailOperationTypeOperation op_type;
};
ModestMailOperation*
modest_mail_operation_new_with_error_handling (GObject *source,
ErrorCheckingUserCallback error_handler,
- gpointer user_data)
+ gpointer user_data,
+ ErrorCheckingUserDataDestroyer error_handler_destroyer)
{
ModestMailOperation *obj;
ModestMailOperationPrivate *priv;
g_return_val_if_fail (error_handler != NULL, obj);
priv->error_checking = error_handler;
priv->error_checking_user_data = user_data;
+ priv->error_checking_user_data_destroyer = error_handler_destroyer;
return obj;
}
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
g_return_if_fail(priv->status != MODEST_MAIL_OPERATION_STATUS_SUCCESS);
+ /* Call the user callback */
if (priv->error_checking != NULL)
priv->error_checking (self, priv->error_checking_user_data);
}
priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
- /* Get message from folder */
- if (folder) {
- /* Get account and set it into mail_operation */
- priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
+ /* Get account and set it into mail_operation */
+ priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
+
+ /* Check for cached messages */
+ if (tny_header_get_flags (header) & TNY_HEADER_FLAG_CACHED)
+ priv->op_type = MODEST_MAIL_OPERATION_TYPE_OPEN;
+ else
+ priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
+
+ helper = g_slice_new0 (GetMsgAsyncHelper);
+ helper->mail_op = self;
+ helper->user_callback = user_callback;
+ helper->user_data = user_data;
+ helper->header = g_object_ref (header);
- /* Check for cached messages */
- if (tny_header_get_flags (header) & TNY_HEADER_FLAG_CACHED)
- priv->op_type = MODEST_MAIL_OPERATION_TYPE_OPEN;
- else
- priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
-
- helper = g_slice_new0 (GetMsgAsyncHelper);
- helper->mail_op = self;
- helper->user_callback = user_callback;
- helper->user_data = user_data;
- helper->header = g_object_ref (header);
-
- // The callback's reference so that the mail op is not
- // finalized until the async operation is completed even if
- // the user canceled the request meanwhile.
- g_object_ref (G_OBJECT (helper->mail_op));
-
- modest_mail_operation_notify_start (self);
- tny_folder_get_msg_async (folder, header, get_msg_cb, get_msg_status_cb, helper);
+ /* The callback's reference so that the mail op is not
+ * finalized until the async operation is completed even if
+ * the user canceled the request meanwhile.
+ */
+ g_object_ref (G_OBJECT (helper->mail_op));
- g_object_unref (G_OBJECT (folder));
- } else {
- /* Set status failed and set an error */
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
- g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
- MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
- _("Error trying to get a message. No folder found for header"));
+ modest_mail_operation_notify_start (self);
+ tny_folder_get_msg_async (folder, header, get_msg_cb, get_msg_status_cb, helper);
- /* Notify the queue */
- modest_mail_operation_notify_end (self);
- }
+ g_object_unref (G_OBJECT (folder));
}
static void
not wrapp this emission because we assume that this
function is always called from within the main lock */
g_signal_emit (G_OBJECT (self), signals[OPERATION_FINISHED_SIGNAL], 0, NULL);
+
+ /* Remove the error user data */
+ if (priv->error_checking_user_data && priv->error_checking_user_data_destroyer)
+ priv->error_checking_user_data_destroyer (priv->error_checking_user_data);
}
TnyAccount *
} ModestMailOperationTypeOperation;
/**
- * ErrorCheckingAsyncUserCallback:
+ * ErrorCheckingUserCallback:
*
* @mail_op: the current mail operation.
* @user_data: generic data passed to user defined function.
typedef void (*ErrorCheckingUserCallback) (ModestMailOperation *mail_op, gpointer user_data);
/**
+ * ErrorCheckingUserDataDestroyer:
+ *
+ * @user_data: generic data passed to user defined function.
+ *
+ * This function is used to destroy the user_data passed to the error
+ * checking user callback function
+ */
+typedef void (*ErrorCheckingUserDataDestroyer) (gpointer user_data);
+
+
+/**
* GetMsgAsyncUserCallback:
*
* @mail_op: the current #ModestMailOperation.
**/
ModestMailOperation* modest_mail_operation_new_with_error_handling (GObject *source,
ErrorCheckingUserCallback error_handler,
- gpointer user_data);
+ gpointer user_data,
+ ErrorCheckingUserDataDestroyer error_handler_destroyer);
/**
* modest_mail_operation_execute_error_handler
* @self: a #ModestMailOperation
g_object_unref (folder);
}
+
+static void
+open_msg_error_handler (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ /* Show the message error */
+ GObject *win = modest_mail_operation_get_source (mail_op);
+
+ modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
+ (gchar *) user_data);
+ if (win)
+ g_object_unref (win);
+}
+
void
modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op,
gpointer user_data)
iter_not_opened = NULL;
/* Create the mail operation */
- mail_op = modest_mail_operation_new_with_error_handling (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);
if (tny_list_get_length (not_opened_headers) > 1) {
+ mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win),
+ modest_ui_actions_get_msgs_full_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,
not_opened_headers,
open_msg_cb,
} else {
TnyIterator *iter = tny_list_create_iterator (not_opened_headers);
TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
+ const gchar *proto_name;
+ gchar *error_msg;
+ ModestTransportStoreProtocol proto;
+
+ /* Get the error message depending on the protocol */
+ proto_name = tny_account_get_proto (account);
+ proto = modest_protocol_info_get_transport_store_protocol (proto_name);
+
+ if (proto == MODEST_PROTOCOL_STORE_POP) {
+ error_msg = g_strdup (_("emev_ni_ui_pop3_msg_recv_error"));
+ } else if (proto == MODEST_PROTOCOL_STORE_IMAP) {
+ error_msg = g_strdup_printf (_("emev_ni_ui_imap_message_not_available_in_server"),
+ tny_header_get_subject (header));
+ } else {
+ error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error"));
+ }
+
+ /* Create and call the mail operation */
+ mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win),
+ open_msg_error_handler,
+ error_msg,
+ g_free);
+ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
+
modest_mail_operation_get_msg (mail_op, header, open_msg_cb, NULL);
+
g_object_unref (header);
g_object_unref (iter);
}
if (header) {
/* Retrieve messages */
if (do_retrieve) {
- mail_op = modest_mail_operation_new_with_error_handling (
- G_OBJECT(win),
- modest_ui_actions_get_msgs_full_error_handler,
- NULL);
+ mail_op =
+ modest_mail_operation_new_with_error_handling (G_OBJECT(win),
+ modest_ui_actions_get_msgs_full_error_handler,
+ NULL, NULL);
modest_mail_operation_queue_add (
modest_runtime_get_mail_operation_queue (), mail_op);
mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win),
modest_ui_actions_send_receive_error_handler,
- NULL);
+ NULL, NULL);
g_signal_connect (G_OBJECT(mail_op), "operation-finished",
G_CALLBACK (on_send_receive_finished),
mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(parent_window),
modest_ui_actions_new_folder_error_handler,
- parent_window);
+ parent_window, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
mail_op =
modest_mail_operation_new_with_error_handling (G_OBJECT(main_window),
modest_ui_actions_rename_folder_error_handler,
- main_window);
+ main_window, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
mail_op =
modest_mail_operation_new_with_error_handling (G_OBJECT(main_window),
modest_ui_actions_delete_folder_error_handler,
- NULL);
+ NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
modest_window_mgr_register_header (modest_runtime_get_window_mgr (), header);
mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win),
modest_ui_actions_get_msgs_full_error_handler,
- NULL);
+ NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msg (mail_op, header, open_msg_for_purge_cb, win);
ModestMailOperation *mail_op =
modest_mail_operation_new_with_error_handling (G_OBJECT(win),
modest_ui_actions_move_folder_error_handler,
- NULL);
+ NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
mail_op =
modest_mail_operation_new_with_error_handling (G_OBJECT(win),
modest_ui_actions_move_folder_error_handler,
- src_folder);
+ src_folder, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
/* Create mail operation */
mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (window),
modest_ui_actions_get_msgs_full_error_handler,
- NULL);
+ 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);
/* Transfer messages */
mail_op = modest_mail_operation_new_with_error_handling (NULL,
modest_ui_actions_move_folder_error_handler,
- NULL);
+ NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
mail_op =
modest_mail_operation_new_with_error_handling (G_OBJECT (modest_window_mgr_get_main_window (mgr)),
modest_ui_actions_move_folder_error_handler,
- folder);
+ folder, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);