header = tny_msg_get_header (new_msg);
if (priority_flags != 0)
tny_header_set_flags (header, priority_flags);
+ if (attachments_list != NULL) {
+ tny_header_set_flags (header, TNY_HEADER_FLAG_ATTACHMENTS);
+ }
g_object_unref (G_OBJECT(header));
/* Call mail operation */
g_object_unref (G_OBJECT (new_msg));
}
-void
+TnyMsg*
modest_mail_operation_save_to_drafts (ModestMailOperation *self,
TnyTransportAccount *transport_account,
TnyMsg *draft_msg,
TnyHeader *header = NULL;
ModestMailOperationPrivate *priv = NULL;
- g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
- g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT (transport_account));
+ g_return_val_if_fail (MODEST_IS_MAIL_OPERATION (self), NULL);
+ g_return_val_if_fail (TNY_IS_TRANSPORT_ACCOUNT (transport_account), NULL);
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
/* add priority flags */
header = tny_msg_get_header (msg);
tny_header_set_flags (header, priority_flags);
+ if (attachments_list != NULL)
+ tny_header_set_flags (header, TNY_HEADER_FLAG_ATTACHMENTS);
g_object_unref (G_OBJECT(header));
folder = modest_tny_account_get_special_folder (TNY_ACCOUNT (transport_account), TNY_FOLDER_TYPE_DRAFTS);
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
end:
- if (msg)
- g_object_unref (G_OBJECT(msg));
if (folder)
g_object_unref (G_OBJECT(folder));
modest_mail_operation_notify_end (self);
+ return msg;
}
typedef struct
g_ptr_array_free (new_headers, FALSE);
}
- /* Perform send */
+ /* Perform send (if operation was not cancelled) */
+ if (did_a_cancel) goto out;
priv->op_type = MODEST_MAIL_OPERATION_TYPE_SEND;
priv->done = 0;
priv->total = 0;
if (*error) {
priv->error = g_error_copy (*error);
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
- goto out;
- }
- if (cancelled) {
+ } 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));
- goto out;
- }
-
- /* The mail operation might have been canceled in which case we do not
- want to notify anyone anymore. */
- if(priv->status != MODEST_MAIL_OPERATION_STATUS_CANCELED) {
+ } else {
priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
+ }
- /* If user defined callback function was defined, call it */
- 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 ();
- }
+ /* 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 ();
}
- out:
/* Free */
+ g_object_unref (helper->mail_op);
g_object_unref (helper->header);
g_slice_free (GetMsgAsyncHelper, helper);
/* Notify about operation end */
- if(priv->status != MODEST_MAIL_OPERATION_STATUS_CANCELED)
- modest_mail_operation_notify_end (self);
-
- g_object_unref (G_OBJECT (self));
+ modest_mail_operation_notify_end (self);
}
static void
/* Call user defined callback, if it exists */
if (helper->user_callback) {
gdk_threads_enter ();
- helper->user_callback (priv->source, folder, helper->user_data);
+ helper->user_callback (self, folder, helper->user_data);
gdk_threads_leave ();
}