2007-08-28 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Tue, 28 Aug 2007 12:50:44 +0000 (12:50 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 28 Aug 2007 12:50:44 +0000 (12:50 +0000)
* src/modest-search.c: (on_timeout_check_account_is_online),
(check_and_wait_for_account_is_online):
It is OK for local-folder and mmc accounts to be used when they
are in the _INIT folder, instead of waiting for them to change
(they never do).
For POP and IMAP, wait from them to stop being _INIT, rather than
waiting from them to be _CONNECTED, because that seems to be
the status that causes the problems.

pmo-trunk-r3109

ChangeLog2
src/modest-search.c

index b47982f..6f95f35 100644 (file)
@@ -1,5 +1,16 @@
 2007-08-28  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/modest-search.c: (on_timeout_check_account_is_online),
+       (check_and_wait_for_account_is_online):
+       It is OK for local-folder and mmc accounts to be used when they 
+       are in the _INIT folder, instead of waiting for them to change 
+       (they never do).
+       For POP and IMAP, wait from them to stop being _INIT, rather than 
+       waiting from them to be _CONNECTED, because that seems to be 
+       the status that causes the problems.
+
+2007-08-28  Murray Cumming  <murrayc@murrayc.com>
+
        * src/modest-search.c: (check_and_wait_for_account_is_online):
        Actually pass the account to the timeout callback.
 
index c30b300..5f3cb45 100644 (file)
@@ -43,6 +43,8 @@
 #include <tny-list.h>
 #include <tny-iterator.h>
 #include <tny-simple-list.h>
+#include <tny-camel-imap-store-account.h>
+#include <tny-camel-pop-store-account.h>
 
 #include <libmodest-dbus-client/libmodest-dbus-client.h>
 
@@ -95,7 +97,9 @@ on_timeout_check_account_is_online(gpointer user_data)
        
        gboolean stop_trying = FALSE;
        if (data && data->account && 
-               (tny_account_get_connection_status (data->account) == TNY_CONNECTION_STATUS_CONNECTED) )
+               /* We want to wait until TNY_CONNECTION_STATUS_INIT has changed to something else,
+                * after which the account is likely to be usable, or never likely to be usable soon: */
+               (tny_account_get_connection_status (data->account) != TNY_CONNECTION_STATUS_INIT) )
        {
                data->is_online = TRUE;
                
@@ -147,13 +151,20 @@ check_and_wait_for_account_is_online(TnyAccount *account)
                printf ("DEBUG: %s: device is offline.\n", __FUNCTION__);
                return FALSE;
        }
+       
+       /* The local_folders account never seems to leave TNY_CONNECTION_STATUS_INIT,
+        * so we avoid wait unnecessarily: */
+       if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) && 
+               !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account) ) {
+               return TRUE;            
+       }
                
        printf ("DEBUG: %s: tny_account_get_connection_status()==%d\n", __FUNCTION__, tny_account_get_connection_status (account));
        
-       /* TODO: The local_folders account never seems to leave TNY_CONNECTION_STATUS_INIT,
-        * so we wait unnecessarily,
-        * but that enum value isn't enough to get a message list from POP and IMAP. */
-       if (tny_account_get_connection_status (account) == TNY_CONNECTION_STATUS_CONNECTED)
+       /* The POP & IMAP store accounts seem to be TNY_CONNECTION_STATUS_DISCONNECTED, 
+        * and that seems to be an OK time to use them. Maybe it's just TNY_CONNECTION_STATUS_INIT that 
+        * we want to avoid. */
+       if (tny_account_get_connection_status (account) != TNY_CONNECTION_STATUS_INIT)
                return TRUE;
                
        /* This blocks on the result: */