From ee2b7fd70461e2892919bba6ac908b18e9008141 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Wed, 26 Aug 2009 15:49:30 +0200 Subject: [PATCH] If we didn't manage to disconnect all accounts, then begin another shutdown cycle again (fixes NB#131351). --- src/modest-main.c | 3 ++- src/modest-tny-account-store.c | 45 ++++++++++++++++++++++++++++++++++++++++ src/modest-tny-account-store.h | 11 +++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/modest-main.c b/src/modest-main.c index 721b0bb..31469d7 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -63,7 +63,8 @@ on_idle_exit_modest (gpointer data) gdk_threads_enter (); mail_op_queue = modest_runtime_get_mail_operation_queue (); - if (modest_mail_operation_queue_running_shutdown (mail_op_queue)) { + if (modest_tny_account_store_is_shutdown (modest_runtime_get_account_store ()) && + modest_mail_operation_queue_running_shutdown (mail_op_queue)) { /* Disconnect signals. Will be freed by the destroy notify */ handlers = (MainSignalHandlers *) data; diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 444f069..5c101de 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -2191,6 +2191,51 @@ modest_tny_account_store_shutdown (ModestTnyAccountStore *self, } gboolean +modest_tny_account_store_is_shutdown (ModestTnyAccountStore *self) +{ + ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self); + TnyIterator *iter; + gboolean found; + + found = FALSE; + + for (iter = tny_list_create_iterator (priv->store_accounts); + !found && !tny_iterator_is_done (iter); + tny_iterator_next (iter)) { + TnyAccount *account; + + account = (TnyAccount *) tny_iterator_get_current (iter); + if (TNY_IS_ACCOUNT (account)) { + found = (tny_account_get_connection_status (account) == TNY_CONNECTION_STATUS_CONNECTED) || + (tny_account_get_connection_status (account) == TNY_CONNECTION_STATUS_RECONNECTING); + } + g_object_unref (account); + } + g_object_unref (iter); + + if (found) + return !found; + + for (iter = tny_list_create_iterator (priv->transport_accounts); + !found && !tny_iterator_is_done (iter); + tny_iterator_next (iter)) { + TnyAccount *account; + + account = (TnyAccount *) tny_iterator_get_current (iter); + if (TNY_IS_ACCOUNT (account)) { + found = (tny_account_get_connection_status (account) == TNY_CONNECTION_STATUS_CONNECTED) || + (tny_account_get_connection_status (account) == TNY_CONNECTION_STATUS_RECONNECTING); + } + g_object_unref (account); + } + g_object_unref (iter); + + return !found; + +} + + +gboolean modest_tny_account_store_is_send_mail_blocked (ModestTnyAccountStore *self) { ModestTnyAccountStorePrivate *priv; diff --git a/src/modest-tny-account-store.h b/src/modest-tny-account-store.h index c08f134..68cf7bf 100644 --- a/src/modest-tny-account-store.h +++ b/src/modest-tny-account-store.h @@ -249,7 +249,16 @@ typedef void (*ModestTnyAccountStoreShutdownCallback) (ModestTnyAccountStore *ac void modest_tny_account_store_shutdown (ModestTnyAccountStore *self, ModestTnyAccountStoreShutdownCallback callback, gpointer userdata); - + +/** + * modest_tny_account_store_is_shutdown: + * @self: a #ModestTnyAccountStore + * + * Check if all accounts are disconnected + * + * Returns: %TRUE if all accounts are disconnected, %FALSE otherwise. + */ +gboolean modest_tny_account_store_is_shutdown (ModestTnyAccountStore *self); /** * modest_tny_account_store_is_send_mail_blocked: -- 1.7.9.5