- priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
-
- priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
- info = g_slice_new0 (GetMimePartSizeInfo);
- info->mail_op = g_object_ref (self);
- info->mime_part = g_object_ref (part);
- info->callback = user_callback;
- info->userdata = user_data;
-
- thread = g_thread_create (get_mime_part_size_thread, info, FALSE, NULL);
-
-}
-
-static void
-get_msg_cb (TnyFolder *folder,
- gboolean cancelled,
- TnyMsg *msg,
- GError **error,
- gpointer user_data)
-{
- GetMsgAsyncHelper *helper = NULL;
- ModestMailOperation *self = NULL;
- ModestMailOperationPrivate *priv = NULL;
-
- helper = (GetMsgAsyncHelper *) user_data;
- g_return_if_fail (helper != NULL);
- self = helper->mail_op;
- g_return_if_fail (MODEST_IS_MAIL_OPERATION(self));
- priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
-
- /* 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 callback is called into an iddle by tinymail,
- and idles are not in the main lock */
- gdk_threads_enter ();
- helper->user_callback (self, helper->header, msg, helper->user_data);
- gdk_threads_leave ();
- }
-
- /* 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;
-#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
- gdk_threads_enter ();
-#endif
- g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
-#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
- gdk_threads_leave ();
-#endif
- 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;
-
- /* Call the user callback. Idles are not in the main lock, so
- lock it */
- gdk_threads_enter ();
- info->user_callback (info->mail_op, info->header, info->msg, info->user_data);
- gdk_threads_leave ();