typedef struct _GetMsgAsyncHelper {
ModestMailOperation *mail_op;
GetMsgAsyncUserCallback user_callback;
- guint pending_ops;
gpointer user_data;
} GetMsgAsyncHelper;
ModestMailOperationState *state;
ModestMailOperationPrivate *priv;
+ /* FIXME: this should be fixed properly
+ *
+ * in some cases, priv was NULL, so checking here to
+ * make sure.
+ */
+ g_return_val_if_fail (self, NULL);
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+ g_return_val_if_fail (priv, NULL);
+
+ if (!priv)
+ return NULL;
state = g_slice_new (ModestMailOperationState);
/* Set priority flags in message */
header = tny_msg_get_header (new_msg);
- tny_header_set_flags (header, priority_flags);
+ if (priority_flags != 0)
+ tny_header_set_flags (header, priority_flags);
/* Call mail operation */
modest_mail_operation_send_mail (self, transport_account, new_msg);
if (draft_msg != NULL) {
header = tny_msg_get_header (draft_msg);
+ /* Remove the old draft expunging it */
tny_folder_remove_msg (folder, header, NULL);
+ tny_folder_sync (folder, TRUE, NULL);
g_object_unref (header);
}
ModestMailOperationPrivate *priv;
ModestTnySendQueue *send_queue;
-
info = (UpdateAccountInfo *) thr_user_data;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(info->mail_op);
/* Notify about operation end. Note that the info could be
freed before this idle happens, but the mail operation will
be still alive */
- g_idle_add (notify_update_account_queue, info->mail_op);
+ g_idle_add (notify_update_account_queue, g_object_ref (info->mail_op));
/* Frees */
g_object_unref (query);
helper = g_slice_new0 (GetMsgAsyncHelper);
helper->mail_op = self;
helper->user_callback = user_callback;
- helper->pending_ops = 1;
helper->user_data = user_data;
tny_folder_get_msg_async (folder, header, get_msg_cb, get_msg_status_cb, helper);
self = helper->mail_op;
g_return_if_fail (MODEST_IS_MAIL_OPERATION(self));
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
-
- helper->pending_ops--;
/* Check errors and cancel */
if (*error) {
helper->user_callback (self, NULL, msg, helper->user_data);
}
- /* Free */
out:
- if (helper->pending_ops == 0) {
- g_slice_free (GetMsgAsyncHelper, helper);
+ /* Free */
+ g_slice_free (GetMsgAsyncHelper, helper);
- /* Notify about operation end */
- modest_mail_operation_notify_end (self);
- }
+ /* Notify about operation end */
+ modest_mail_operation_notify_end (self);
}
static void
priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
/* Notify about operation end */
- g_idle_add (notify_update_account_queue, info->mail_op);
+ g_idle_add (notify_update_account_queue, g_object_ref (info->mail_op));
/* Free thread resources. Will be called after all previous idles */
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE + 1, get_msgs_full_destroyer, info, NULL);