From bb2db35bafed990fa0e9212422a59a39439ffa4b Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Fri, 18 Apr 2008 10:09:38 +0000 Subject: [PATCH] * Fixes NB#84492, remove the messages in the outbox that belongs to a removed account * Added a new method to remove send_queues * Fixed and invalid error report when a mail operation is never executed pmo-trunk-r4429 --- src/modest-mail-operation-queue.c | 3 ++- src/modest-runtime.c | 18 ++++++++++++++++++ src/modest-runtime.h | 8 ++++++++ src/modest-tny-account-store.c | 14 +++++++++++++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/modest-mail-operation-queue.c b/src/modest-mail-operation-queue.c index eacb4c3..aadb3b8 100644 --- a/src/modest-mail-operation-queue.c +++ b/src/modest-mail-operation-queue.c @@ -328,7 +328,8 @@ modest_mail_operation_queue_remove (ModestMailOperationQueue *self, /* Check errors */ status = modest_mail_operation_get_status (mail_op); - if (status != MODEST_MAIL_OPERATION_STATUS_SUCCESS) { + if (status != MODEST_MAIL_OPERATION_STATUS_SUCCESS && + status != MODEST_MAIL_OPERATION_STATUS_INVALID) { /* This is a sanity check. Shouldn't be needed, but prevent possible application crashes. It's useful also for detecting mail operations with invalid diff --git a/src/modest-runtime.c b/src/modest-runtime.c index 9d8a368..26ed013 100644 --- a/src/modest-runtime.c +++ b/src/modest-runtime.c @@ -241,6 +241,24 @@ void modest_runtime_remove_all_send_queues () modest_cache_mgr_flush (cache_mgr, MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE); } +void +modest_runtime_remove_send_queue (TnyTransportAccount *account) +{ + + ModestCacheMgr *cache_mgr; + GHashTable *send_queue_cache; + + g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT (account)); + g_return_if_fail (_singletons); + + cache_mgr = modest_singletons_get_cache_mgr (_singletons); + send_queue_cache = modest_cache_mgr_get_cache (cache_mgr, + MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE); + + if (g_hash_table_lookup (send_queue_cache, account)) + g_hash_table_remove (send_queue_cache, account); +} + ModestWindowMgr * modest_runtime_get_window_mgr (void) { diff --git a/src/modest-runtime.h b/src/modest-runtime.h index 98b92e0..53bccbd 100644 --- a/src/modest-runtime.h +++ b/src/modest-runtime.h @@ -195,6 +195,14 @@ ModestMailOperationQueue* modest_runtime_get_mail_operation_queue (void); ModestTnySendQueue* modest_runtime_get_send_queue (TnyTransportAccount *account); /** + * modest_runtime_remove_send_queue: + * @account: a #TnyTransportAccount + * + * Removes the send queue associated with the given transport account + **/ +void modest_runtime_remove_send_queue (TnyTransportAccount *account); + +/** * modest_runtime_remove_all_send_queues: * * Removes all send queues, ready for them to be recreated, for instance diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 23aff8b..088f941 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -1744,8 +1744,17 @@ on_account_disconnect_when_removing (TnyCamelAccount *account, g_object_unref (account); /* Clear the cache if it's an store account */ - if (TNY_IS_STORE_ACCOUNT (account)) + if (TNY_IS_STORE_ACCOUNT (account)) { tny_store_account_delete_cache (TNY_STORE_ACCOUNT (account)); + } else if (TNY_IS_TRANSPORT_ACCOUNT (account)) { + ModestTnySendQueue* send_queue; + send_queue = modest_runtime_get_send_queue (TNY_TRANSPORT_ACCOUNT (account)); + if (modest_tny_send_queue_sending_in_progress (send_queue)) + tny_send_queue_cancel (TNY_SEND_QUEUE (send_queue), + TNY_SEND_QUEUE_CANCEL_ACTION_REMOVE, + NULL); + modest_runtime_remove_send_queue (TNY_TRANSPORT_ACCOUNT (account)); + } } static void @@ -1816,12 +1825,15 @@ on_account_removed (ModestAccountMgr *acc_mgr, if (outbox_account) { tny_list_remove (priv->store_accounts_outboxes, G_OBJECT (outbox_account)); + /* Remove existing emails to send */ + tny_store_account_delete_cache (TNY_STORE_ACCOUNT (outbox_account)); g_object_unref (outbox_account); } local_account = modest_tny_account_store_get_local_folders_account (self); modest_tny_local_folders_account_remove_folder_from_outbox (MODEST_TNY_LOCAL_FOLDERS_ACCOUNT (local_account), outbox); + g_hash_table_remove (priv->outbox_of_transport, transport_account); /* Notify the change in the local account */ -- 1.7.9.5