X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-mail-operation.c;h=07e85cd11ab0277f503fd045d76385edba4b968c;hb=174c8c52a5f4e99469c2b83cc41443cc126e8bc0;hp=d9c203a9c6c12f218fecaf3eae4ad57a69235f38;hpb=2f51f213469dc0679fd33c205a6f6aa0c20481a9;p=modest diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index d9c203a..07e85cd 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -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 */ @@ -585,6 +588,7 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self, * because this function requires it to have a UID. */ tny_folder_remove_msg (folder, header, NULL); tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED); + tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN); g_object_unref (header); } } @@ -593,7 +597,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 +613,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 +637,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); @@ -649,6 +655,7 @@ modest_mail_operation_save_to_drafts (ModestMailOperation *self, /* Remove the old draft expunging it */ tny_folder_remove_msg (folder, header, NULL); tny_header_set_flags (header, TNY_HEADER_FLAG_DELETED); + tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN); tny_folder_sync (folder, FALSE, &(priv->error)); /* FALSE --> don't expunge */ g_object_unref (header); } @@ -662,12 +669,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 @@ -707,9 +713,6 @@ G_DEFINE_TYPE_WITH_CODE (InternalFolderObserver, static void foreach_add_item (gpointer header, gpointer user_data) { - /* printf("DEBUG: %s: header subject=%s\n", - * __FUNCTION__, tny_header_get_subject(TNY_HEADER(header))); - */ tny_list_prepend (TNY_LIST (user_data), g_object_ref (G_OBJECT (header))); } @@ -731,10 +734,6 @@ internal_folder_observer_update (TnyFolderObserver *self, TnyFolderChange *chang list = tny_simple_list_new (); tny_folder_change_get_added_headers (change, list); - /* printf ("DEBUG: %s: Calling foreach with a list of size=%d\n", - * __FUNCTION__, tny_list_get_length(list)); - */ - /* Add them to the folder observer */ tny_list_foreach (list, foreach_add_item, derived->new_headers); @@ -1090,8 +1089,9 @@ update_account_thread (gpointer thr_user_data) g_ptr_array_free (new_headers, FALSE); } - /* Perform send */ - priv->op_type = MODEST_MAIL_OPERATION_TYPE_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 (priv->account != NULL) @@ -1100,9 +1100,9 @@ update_account_thread (gpointer thr_user_data) send_queue = modest_runtime_get_send_queue (info->transport_account); if (send_queue) { - timeout = g_timeout_add (250, idle_notify_progress, info->mail_op); +/* timeout = g_timeout_add (250, idle_notify_progress, info->mail_op); */ modest_tny_send_queue_try_to_send (send_queue); - g_source_remove (timeout); +/* g_source_remove (timeout); */ } else { g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR, MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED, @@ -1375,7 +1375,7 @@ transfer_folder_status_cb (GObject *obj, g_return_if_fail (status->code == TNY_FOLDER_STATUS_CODE_COPY_FOLDER); helper = (XFerMsgAsyncHelper *) user_data; - g_return_if_fail (helper != NULL); + g_return_if_fail (helper != NULL); self = helper->mail_op; priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self); @@ -1643,42 +1643,33 @@ get_msg_cb (TnyFolder *folder, 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 @@ -1966,6 +1957,7 @@ modest_mail_operation_remove_msg (ModestMailOperation *self, TnyHeader *header, 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 */ @@ -2099,7 +2091,7 @@ modest_mail_operation_xfer_msgs (ModestMailOperation *self, priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED; g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR, MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES, - _("ckct_ib_unable_to_paste_here")); + _CS("ckct_ib_unable_to_paste_here")); /* Notify the queue */ modest_mail_operation_notify_end (self); return; @@ -2183,12 +2175,11 @@ on_refresh_folder (TnyFolder *folder, } priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS; - out: /* 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 (); } @@ -2281,11 +2272,6 @@ modest_mail_operation_notify_end (ModestMailOperation *self) priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self); - if (!priv) { - g_warning ("BUG: %s: priv == NULL", __FUNCTION__); - return; - } - /* Set the account back to not busy */ if (priv->account_name) { modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr(),