/* 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
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)
{
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
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
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 */