- /* Check errors and cancel */
- if (error) {
- priv->error = g_error_copy (error);
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
- } 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"),
- tny_folder_get_name (folder));
- } else {
- priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
- }
-
- /* If user defined callback function was defined, call it even
- if the operation failed*/
- if (helper->user_callback) {
- /* This is not a GDK lock because we are a Tinymail callback
- * which is already GDK locked by Tinymail */
-
- /* no gdk_threads_enter (), CHECKED */
- helper->user_callback (self, helper->header, msg, helper->user_data);
- /* no gdk_threads_leave (), CHECKED */
- }
-
- /* Notify about operation end */
- modest_mail_operation_notify_end (self);
- /* Free */
- g_object_unref (helper->mail_op);
- g_object_unref (helper->header);
- g_slice_free (GetMsgAsyncHelper, helper);
-
-}
-
-static void
-get_msg_status_cb (GObject *obj,
- TnyStatus *status,
- gpointer user_data)
-{
- GetMsgAsyncHelper *helper = NULL;
- ModestMailOperation *self;
- ModestMailOperationPrivate *priv;
- ModestMailOperationState *state;
-
- g_return_if_fail (status != NULL);
- g_return_if_fail (status->code == TNY_FOLDER_STATUS_CODE_GET_MSG);
-
- helper = (GetMsgAsyncHelper *) user_data;
- g_return_if_fail (helper != NULL);
-
- self = helper->mail_op;
- priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
-
- priv->done = 1;
- priv->total = 1;
-
- state = modest_mail_operation_clone_state (self);
- state->bytes_done = status->position;
- state->bytes_total = status->of_total;
-
- /* This is not a GDK lock because we are a Tinymail callback
- * which is already GDK locked by Tinymail */
-
- /* no gdk_threads_enter (), CHECKED */
- g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
- /* no gdk_threads_leave (), CHECKED */
-
- g_slice_free (ModestMailOperationState, state);
-}
-
-/****************************************************/
-typedef struct {
- ModestMailOperation *mail_op;
- TnyList *headers;
- GetMsgAsyncUserCallback user_callback;
- gpointer user_data;
- GDestroyNotify notify;
-} GetFullMsgsInfo;
-
-typedef struct {
- GetMsgAsyncUserCallback user_callback;
- TnyHeader *header;
- TnyMsg *msg;
- gpointer user_data;
- ModestMailOperation *mail_op;
-} NotifyGetMsgsInfo;
-
-
-/*
- * Used by get_msgs_full_thread to call the user_callback for each
- * message that has been read
- */
-static gboolean
-notify_get_msgs_full (gpointer data)
-{
- NotifyGetMsgsInfo *info;
-
- info = (NotifyGetMsgsInfo *) data;
-
- /* This is a GDK lock because we are an idle callback and
- * because info->user_callback can contain Gtk+ code */
-
- gdk_threads_enter (); /* CHECKED */
- info->user_callback (info->mail_op, info->header, info->msg, info->user_data);
- gdk_threads_leave (); /* CHECKED */
-
- g_slice_free (NotifyGetMsgsInfo, info);
-
- return FALSE;
-}
-
-/*
- * Used by get_msgs_full_thread to free al the thread resources and to
- * call the destroy function for the passed user_data
- */
-static gboolean
-get_msgs_full_destroyer (gpointer data)
-{
- GetFullMsgsInfo *info;
-
- info = (GetFullMsgsInfo *) data;
-
- if (info->notify) {
-
- /* This is a GDK lock because we are an idle callback and
- * because info->notify can contain Gtk+ code */
-
- gdk_threads_enter (); /* CHECKED */
- info->notify (info->user_data);
- gdk_threads_leave (); /* CHECKED */
- }
-
- /* free */
- g_object_unref (info->headers);
- g_slice_free (GetFullMsgsInfo, info);
-
- return FALSE;
-}
-
-static gpointer
-get_msgs_full_thread (gpointer thr_user_data)
-{
- GetFullMsgsInfo *info;
- ModestMailOperationPrivate *priv = NULL;
- TnyIterator *iter = NULL;
-
- info = (GetFullMsgsInfo *) thr_user_data;