* Uncomment flush call to tny_send_queue.
[modest] / src / modest-mail-operation.c
index 1674414..8f4cb07 100644 (file)
@@ -572,6 +572,9 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self,
        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 */
@@ -593,7 +596,7 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self,
        g_object_unref (G_OBJECT (new_msg));
 }
 
-void
+TnyMsg*
 modest_mail_operation_save_to_drafts (ModestMailOperation *self,
                                      TnyTransportAccount *transport_account,
                                      TnyMsg *draft_msg,
@@ -609,8 +612,8 @@ modest_mail_operation_save_to_drafts (ModestMailOperation *self,
        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);
 
@@ -633,6 +636,8 @@ modest_mail_operation_save_to_drafts (ModestMailOperation *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);
@@ -662,12 +667,11 @@ modest_mail_operation_save_to_drafts (ModestMailOperation *self,
                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 
@@ -1090,7 +1094,8 @@ update_account_thread (gpointer thr_user_data)
                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;