Bugfix when setting the account to online
authorPhilip Van Hoof <philip@codeminded.be>
Tue, 26 Jun 2007 15:51:46 +0000 (15:51 +0000)
committerPhilip Van Hoof <philip@codeminded.be>
Tue, 26 Jun 2007 15:51:46 +0000 (15:51 +0000)
pmo-trunk-r2432

src/modest-tny-account.c

index d601170..975caf3 100644 (file)
@@ -411,8 +411,27 @@ modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar
                                   get_pass_func ? get_pass_func: get_pass_dummy);
        
 
                                   get_pass_func ? get_pass_func: get_pass_dummy);
        
 
-       TnyAccountStore *astore = (TnyAccountStore *) modest_runtime_get_account_store ();
-       if (astore) {
+        /* This name is what shows up in the folder view -- so for some POP/IMAP/... server
+       *  account, we set its name to the account of which it is part. */
+
+        if (account_data->display_name)
+                tny_account_set_name (tny_account, account_data->display_name);
+
+        modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, account_name);
+
+        modest_account_mgr_free_account_data (account_mgr, account_data);
+
+
+       static gboolean first_time = TRUE;
+
+       /* The first time we are creating the initial accounts. They will be set online by other
+        * code that comes later. After the first time, this only happens when a new account is
+        * created in the wizard. That account needs to be set online if the device is online. */
+
+       if (!first_time)
+       {
+         TnyAccountStore *astore = (TnyAccountStore *) modest_runtime_get_account_store ();
+         if (astore) {
                TnyDevice *device = tny_account_store_get_device (astore);
                GError *err = NULL;
                tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (tny_account),
                TnyDevice *device = tny_account_store_get_device (astore);
                GError *err = NULL;
                tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (tny_account),
@@ -420,16 +439,9 @@ modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar
                if (err)
                        g_print ("Error connecting: %s\n", err->message);
                g_object_unref (device);
                if (err)
                        g_print ("Error connecting: %s\n", err->message);
                g_object_unref (device);
+         }
        }
        }
-       
-       /* This name is what shows up in the folder view -- so for some POP/IMAP/... server
-        * account, we set its name to the account of which it is part. */
-       if (account_data->display_name)
-               tny_account_set_name (tny_account, account_data->display_name); 
-
-       modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, account_name);
-       
-       modest_account_mgr_free_account_data (account_mgr, account_data);
+       first_time = FALSE;
 
        return tny_account;
 }
 
        return tny_account;
 }