ModestToolBarModes mode;
GSList *tmp;
gboolean mode_changed = FALSE;
+ ModestMailOperationStatus status;
g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
}
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) {
modest_progress_object_remove_operation (MODEST_PROGRESS_OBJECT (tmp->data),
}
}
+
break;
}
+
}
static void
#include <tny-status.h>
#include <camel/camel-stream-mem.h>
#include <glib/gi18n.h>
+#include "modest-platform.h"
#include <modest-tny-account.h>
#include <modest-tny-send-queue.h>
#include <modest-runtime.h>
ModestMailOperationStatus status;
ModestMailOperationId id;
GObject *source;
+ ErrorCheckingUserCallback error_checking;
GError *error;
};
return obj;
}
+ModestMailOperation*
+modest_mail_operation_new_with_error_handling (ModestMailOperationId id,
+ GObject *source,
+ ErrorCheckingUserCallback error_handler)
+{
+ ModestMailOperation *obj;
+ ModestMailOperationPrivate *priv;
+
+ obj = modest_mail_operation_new (id, source);
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE(obj);
+
+ g_return_val_if_fail (error_handler != NULL, obj);
+ priv->error_checking = error_handler;
+
+ return obj;
+}
+
+void
+modest_mail_operation_execute_error_handler (ModestMailOperation *self)
+{
+ 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);
+}
+
ModestMailOperationId
modest_mail_operation_get_id (ModestMailOperation *self)
_("FIXME: unable to rename"));
} else {
/* Rename. Camel handles folder subscription/unsubscription */
-
TnyFolderStore *into;
TnyFolder *nfol;
g_object_unref (nfol);
CHECK_EXCEPTION (priv, MODEST_MAIL_OPERATION_STATUS_FAILED);
+
}
/* Notify the queue */
} else if (cancelled) {
priv->status = MODEST_MAIL_OPERATION_STATUS_CANCELED;
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
- MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
- _("Error trying to refresh the contents of %s"),
+ MODEST_MAIL_OPERATION_ERROR_OPERATION_CANCELED,
+ _("Transference of %s was cancelled."),
tny_folder_get_name (folder));
} else {
priv->done = 1;
priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
}
-
+
/* Free */
g_slice_free (XFerFolderAsyncHelper, helper);
g_object_unref (folder);
g_object_unref (into);
- g_object_unref (new_folder);
+ if (new_folder != NULL)
+ g_object_unref (new_folder);
/* Notify the queue */
modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
};
/**
+ * ErroCheckingAsyncUserCallback:
+ *
+ * @obj: a #GObject generic object which has created 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);
+
+/**
* GetMsgAsynUserCallback:
*
* @obj: a #GObject generic object which has created current mail operation.
GObject *source);
/**
+ * modest_mail_operation_new_with_error_handling:
+ * @id: a #ModestMailOperationId identification of operation type.
+ * @source: a #GObject which creates this new operation.
+ * @error_handler: a #ErrorCheckingUserCallback function to performs operations when
+ * an error occurs.
+ *
+ * Creates a new instance of class #ModestMailOperation, using parameters
+ * to initialize its private structure. @source parameter may be NULL.
+ * @error_handler can not be NULL, but it will be returned an mail operation
+ * object without error handling capability.
+ **/
+ModestMailOperation* modest_mail_operation_new_with_error_handling (ModestMailOperationId id,
+ GObject *source,
+ ErrorCheckingUserCallback error_handler);
+/**
+ * modest_mail_operation_get_id
+ * @self: a #ModestMailOperation
+ *
+ * Executes error handler, if it exists, passing @self objsect as
+ * user_data argument of error handling function.
+ **/
+void
+modest_mail_operation_execute_error_handler (ModestMailOperation *self);
+
+/**
* modest_mail_operation_get_id
* @self: a #ModestMailOperation
*
+/**
+ * modest_mail_operation_xfer_folder:
+ * @self: a #ModestMailOperation
+ * @folder: a #TnyFolder
+ * @parent: the new parent of the folder as #TnyFolderStore
+ * @delete_original: wheter or not delete the original folder
+ *
+ * Sets the given @folder as child of a provided #TnyFolderStore. This
+ * operation also transfers all the messages contained in the folder
+ * and all of his children folders with their messages as well. This
+ * operation is synchronous, so the #ModestMailOperation should not be
+ * added to any #ModestMailOperationQueue.
+ *
+ * If @delete_original is TRUE this function moves the original
+ * folder, if it is FALSE the it just copies it
+ *
+ **/
void modest_mail_operation_xfer_folder_async (ModestMailOperation *self,
TnyFolder *folder,
TnyFolderStore *parent,
} else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
/* for MsgViewWindows, we simply return a list with one element */
- TnyMsg *msg;
TnyHeader *header;
TnyList *list = NULL;
- msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW(win));
- if (msg) {
- header = tny_msg_get_header (msg);
+ header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
+ if (header != NULL) {
list = tny_simple_list_new ();
tny_list_prepend (list, G_OBJECT(header));
g_object_unref (G_OBJECT(header));
}
+
return list;
} else
g_return_if_fail (found);
}
+static void
+move_to_error_checking (const GObject *obj, gpointer user_data)
+{
+ ModestWindow *win = NULL;
+
+ g_return_if_fail (MODEST_IS_WINDOW (obj));
+ win = MODEST_WINDOW (obj);
+
+ /* TODO: show error message */
+/* modest_platform_run_information_dialog (GTK_WINDOW (win), */
+/* _("mail_in_ui_folder_move_target_error")); */
+}
+
/*
* UI handler for the "Move to" action when invoked from the
* ModestMainWindow
modest_ui_actions_on_main_window_move_to (GtkAction *action,
ModestMainWindow *win)
{
- GtkWidget *dialog, *folder_view, *tree_view = NULL;
+ GtkWidget *dialog = NULL, *folder_view = NULL, *tree_view = NULL;
+ GtkWidget *header_view = NULL;
gint result;
- TnyFolderStore *folder_store;
+ TnyFolderStore *folder_store = NULL;
ModestMailOperation *mail_op = NULL;
g_return_if_fail (MODEST_IS_MAIN_WINDOW (win));
folder_view = modest_main_window_get_child_widget (win,
MODEST_WIDGET_TYPE_FOLDER_VIEW);
+ /* Get header view */
+ header_view = modest_main_window_get_child_widget (win,
+ MODEST_WIDGET_TYPE_HEADER_VIEW);
+
/* Create and run the dialog */
dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
result = gtk_dialog_run (GTK_DIALOG(dialog));
TnyFolderStore *src_folder;
src_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+ /* Clean folder on header view before moving it */
+ modest_header_view_set_folder (MODEST_HEADER_VIEW (header_view), NULL);
+
if (TNY_IS_FOLDER (src_folder)) {
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE, G_OBJECT(win));
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_ID_RECEIVE,
+ G_OBJECT(win),
+ move_to_error_checking);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
/* Frees */
g_object_unref (G_OBJECT (src_folder));
} else {
- GtkWidget *header_view;
- header_view = modest_main_window_get_child_widget (win,
- MODEST_WIDGET_TYPE_HEADER_VIEW);
if (gtk_widget_is_focus (header_view)) {
TnyList *headers;
gint response;
g_signal_connect (G_OBJECT (mail_op), "progress-changed",
G_CALLBACK (on_progress_changed), helper);
- modest_mail_operation_xfer_folder (mail_op,
- folder,
- parent_folder,
- helper->delete_source);
-
+ modest_mail_operation_xfer_folder_async (mail_op,
+ folder,
+ parent_folder,
+ helper->delete_source);
+
/* Frees */
g_object_unref (G_OBJECT (parent_folder));
g_object_unref (G_OBJECT (folder));
/* Do not allow further process */
g_signal_stop_emission_by_name (widget, "drag-data-received");
- /* Get the action */
- if (context->action == GDK_ACTION_MOVE)
- delete_source = TRUE;
+ /* Get the action (FIXME: only copy is currently implemented */
+/* if (context->action == GDK_ACTION_MOVE) */
+/* delete_source = TRUE; */
/* Check if the get_data failed */
if (selection_data == NULL || selection_data->length < 0)