void
modest_mail_operation_send_new_mail (ModestMailOperation *self,
TnyTransportAccount *transport_account,
+ TnyMsg *draft_msg,
const gchar *from, const gchar *to,
const gchar *cc, const gchar *bcc,
const gchar *subject, const gchar *plain_body,
TnyHeaderFlags priority_flags)
{
TnyMsg *new_msg = NULL;
+ TnyFolder *folder = NULL;
ModestMailOperationPrivate *priv = NULL;
g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
/* Call mail operation */
modest_mail_operation_send_mail (self, transport_account, new_msg);
+ folder = modest_tny_account_get_special_folder (TNY_ACCOUNT (transport_account), TNY_FOLDER_TYPE_DRAFTS);
+ if (folder) {
+ if (draft_msg != NULL) {
+ TnyHeader *header = tny_msg_get_header (draft_msg);
+ tny_folder_remove_msg (folder, header, NULL);
+ g_object_unref (header);
+ }
+ }
+
/* Free */
g_object_unref (G_OBJECT (new_msg));
}
void
modest_mail_operation_save_to_drafts (ModestMailOperation *self,
TnyTransportAccount *transport_account,
+ TnyMsg *draft_msg,
const gchar *from, const gchar *to,
const gchar *cc, const gchar *bcc,
const gchar *subject, const gchar *plain_body,
"modest: failed to create a new msg\n");
goto end;
}
+
+ if (draft_msg != NULL) {
+ TnyHeader *header = tny_msg_get_header (draft_msg);
+ tny_folder_remove_msg (folder, header, NULL);
+ g_object_unref (header);
+ }
tny_folder_add_msg (folder, msg, &(priv->error));
if (priv->error)
/* Get message from folder */
if (folder) {
/* Get account and set it into mail_operation */
- priv->account = tny_folder_get_account (TNY_FOLDER(folder));
+ priv->account = tny_folder_get_account (TNY_FOLDER(folder));
helper = g_slice_new0 (GetMsgAsyncHelper);
helper->mail_op = self;
priv->total = tny_list_get_length(header_list);
/* Get account and set it into mail_operation */
- if (tny_list_get_length (header_list) > 1) {
- iter = tny_list_create_iterator (header_list);
+ if (tny_list_get_length (header_list) >= 1) {
+ iter = tny_list_create_iterator (header_list);
header = TNY_HEADER (tny_iterator_get_current (iter));
folder = tny_header_get_folder (header);
priv->account = tny_folder_get_account (TNY_FOLDER(folder));
g_object_unref (header);
g_object_unref (folder);
+
+ if (tny_list_get_length (header_list) == 1) {
+ g_object_unref (iter);
+ iter = NULL;
+ }
}
/* Get msg size limit */
state = modest_mail_operation_clone_state (self);
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
g_slice_free (ModestMailOperationState, state);
-
- /* Notify the queue */
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), self);
}