If we didn't manage to disconnect all accounts, then begin another
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 26 Aug 2009 13:49:30 +0000 (15:49 +0200)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 31 Aug 2009 08:06:25 +0000 (10:06 +0200)
shutdown cycle again (fixes NB#131351).

src/modest-main.c
src/modest-tny-account-store.c
src/modest-tny-account-store.h

index 721b0bb..31469d7 100644 (file)
@@ -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;
index 444f069..5c101de 100644 (file)
@@ -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;
index c08f134..68cf7bf 100644 (file)
@@ -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: