TnyList *headers;
TnyFolder *dest_folder;
XferMsgsAsynUserCallback user_callback;
+ gboolean delete;
gpointer user_data;
} XFerMsgAsyncHelper;
{
CreateMsgIdleInfo *info = (CreateMsgIdleInfo *) idle_data;
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* callback could be 'send mail' or 'save to draft'; i dont knonw */
+ /* why these tow operations must serialized, i think it could be */
+ /* removed */
gdk_threads_enter ();
info->callback (info->mail_op, info->msg, info->userdata);
gdk_threads_leave ();
+
g_object_unref (info->mail_op);
if (info->msg)
g_object_unref (info->msg);
state = modest_mail_operation_clone_state (mail_op);
#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* However, refresh_account operations call async operations on */
+ /* on tinymail, which also emmit 'progress-changed' signal. This */
+ /* may be is required to serialize executions of progress-changed'*/
+ /* signal handlers. */
gdk_threads_enter ();
#endif
g_signal_emit (G_OBJECT (mail_op), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
pair = (ModestPair *) data;
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* However, refresh_account operations call async operations on */
+ /* on tinymail, which also emmit 'progress-changed' signal. This */
+ /* may be is required to serialize executions of progress-changed'*/
+ /* signal handlers */
#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
gdk_threads_enter ();
#endif
static gboolean
set_last_updated_idle (gpointer data)
{
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* and executed with g_idle_add_full during process of method */
+ /* update_account_thread, to serialize access to LAST_UPDATED */
+ /* property of each account */
gdk_threads_enter ();
/* It does not matter if the time is not exactly the same than
idle_info = (UpdateAccountInfo *) data;
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* and executed with g_idle_add during update_account_thread, to */
+ /* serialize the execution of refresh user callback (mainloop) */
+ /* received as parameter in modest_mail_operation_update_account */
gdk_threads_enter ();
idle_info->callback (idle_info->mail_op,
idle_info->new_headers,
state = modest_mail_operation_clone_state (self);
#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* However, refresh_account operations call async operations on */
+ /* on tinymail, which also emmit 'progress-changed' signal. This */
+ /* may be is required to serialize executions of progress-changed'*/
+ /* signal handlers. */
gdk_threads_enter ();
#endif
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
/* If user defined callback function was defined, call it */
if (helper->user_callback) {
+ /* GDK LOCK: I think this one can be removed if Tinymail */
+ /* wraps the lock itself. */
+ /* This function is called as idle in tinymail. */
gdk_threads_enter ();
helper->user_callback (priv->source, helper->user_data);
gdk_threads_leave ();
state->bytes_done = status->position;
state->bytes_total = status->of_total;
#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* However, refresh_account operations call async operations on */
+ /* on tinymail, which also emmit 'progress-changed' signal. This */
+ /* may be is required to serialize executions of progress-changed'*/
+ /* signal handlers. */
gdk_threads_enter ();
#endif
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
info = (GetFullMsgsInfo *) data;
if (info->notify) {
+ /* GDK LOCK: this one is here because we call this from */
+ /* a thread. */
+ /* It's used to free user_data, like pasted attachments */
gdk_threads_enter ();
info->notify (info->user_data);
gdk_threads_leave ();
priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
-
+ /* remove message from folder */
tny_folder_remove_msg (folder, header, &(priv->error));
- if (!priv->error) {
- tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED);
- tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
-
- if (TNY_IS_CAMEL_IMAP_FOLDER (folder))
- tny_folder_sync(folder, FALSE, &(priv->error)); /* FALSE --> don't expunge */
- else if (TNY_IS_CAMEL_POP_FOLDER (folder))
- tny_folder_sync(folder, TRUE, &(priv->error)); /* TRUE --> expunge */
- else
- /* lcoal folders */
- tny_folder_sync(folder, TRUE, &(priv->error)); /* TRUE --> expunge */
- }
+/* if (!priv->error) { */
+/* tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED); */
+/* tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN); */
+
+/* if (TNY_IS_CAMEL_IMAP_FOLDER (folder)) */
+/* tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /\* FALSE --> don't expunge *\/ */
+/* /\* tny_folder_sync (folder, FALSE, &(priv->error)); /\\* FALSE --> don't expunge *\\/ *\/ */
+/* else if (TNY_IS_CAMEL_POP_FOLDER (folder)) */
+/* tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /\* TRUE --> dont expunge *\/ */
+/* /\* tny_folder_sync (folder, TRUE, &(priv->error)); /\\* TRUE --> expunge *\\/ *\/ */
+/* else */
+/* /\* local folders *\/ */
+/* tny_folder_sync_async(folder, TRUE, NULL, NULL, NULL); /\* TRUE --> expunge *\/ */
+/* /\* tny_folder_sync (folder, TRUE, &(priv->error)); /\\* TRUE --> expunge *\\/ *\/ */
+/* } */
/* Set status */
state = modest_mail_operation_clone_state (self);
#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* However, refresh_account operations call async operations on */
+ /* on tinymail, which also emmit 'progress-changed' signal. This */
+ /* may be is required to serialize executions of progress-changed'*/
+ /* signal handlers. */
gdk_threads_enter ();
#endif
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
XFerMsgAsyncHelper *helper;
ModestMailOperation *self;
ModestMailOperationPrivate *priv;
+ TnyIterator *iter = NULL;
+ TnyHeader *header = NULL;
helper = (XFerMsgAsyncHelper *) user_data;
self = helper->mail_op;
priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
}
+
+ /* Mark headers as deleted and seen */
+ if ((helper->delete) &&
+ (priv->status == MODEST_MAIL_OPERATION_STATUS_SUCCESS)) {
+ iter = tny_list_create_iterator (helper->headers);
+ while (!tny_iterator_is_done (iter)) {
+ header = TNY_HEADER (tny_iterator_get_current (iter));
+ tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED);
+ tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
+ g_object_unref (header);
+
+ tny_iterator_next (iter);
+ }
+
+ }
+
+
/* Notify about operation end */
modest_mail_operation_notify_end (self);
/* If user defined callback function was defined, call it */
if (helper->user_callback) {
+ /* GDK LOCK: I think this one can be removed if Tinymail */
+ /* wraps the lock itself. */
+ /* This function is called as idle in tinymail. */
gdk_threads_enter ();
helper->user_callback (priv->source, helper->user_data);
gdk_threads_leave ();
}
/* Free */
- g_object_unref (helper->headers);
- g_object_unref (helper->dest_folder);
- g_object_unref (helper->mail_op);
+ if (helper->headers)
+ g_object_unref (helper->headers);
+ if (helper->dest_folder)
+ g_object_unref (helper->dest_folder);
+ if (helper->mail_op)
+ g_object_unref (helper->mail_op);
+ if (folder)
+ g_object_unref (folder);
+ if (iter)
+ g_object_unref (iter);
g_slice_free (XFerMsgAsyncHelper, helper);
- g_object_unref (folder);
}
helper->headers = g_object_ref(headers);
helper->user_callback = user_callback;
helper->user_data = user_data;
+ helper->delete = delete_original;
/* Get account and set it into mail_operation */
priv->account = modest_tny_folder_get_account (src_folder);
self = helper->mail_op;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+ g_return_if_fail(priv!=NULL);
+
if (*error) {
priv->error = g_error_copy (*error);
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
out:
/* Call user defined callback, if it exists */
if (helper->user_callback) {
+ /* GDK LOCK: I think this one can be removed if Tinymail */
+ /* wraps the lock itself. */
+ /* This function is called as idle in tinymail. */
gdk_threads_enter ();
helper->user_callback (self, folder, helper->user_data);
gdk_threads_leave ();
/* Notify about operation end */
modest_mail_operation_notify_end (self);
+ g_object_unref(self);
}
static void
state = modest_mail_operation_clone_state (self);
#ifdef TINYMAIL_IDLES_NOT_LOCKED_YET
+ /* GDK LOCK: this one is here because we call this from a thread */
+ /* However, refresh_account operations call async operations on */
+ /* on tinymail, which also emmit 'progress-changed' signal. This */
+ /* may be is required to serialize executions of progress-changed'*/
+ /* signal handlers. */
gdk_threads_enter ();
#endif
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
/* Create the helper */
helper = g_slice_new0 (RefreshAsyncHelper);
- helper->mail_op = self;
+ helper->mail_op = g_object_ref(self);
helper->user_callback = user_callback;
helper->user_data = user_data;