X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-account.c;h=640094bac011e1aa4c10522ae4303a0c7368374d;hp=a2f4b654bddffda9cb64a0ccfb05481cd0c561c2;hb=bb515e94c04fe931befaebe40d91fa3e9217b7d6;hpb=20966143c0493a9a13453c8c6b5250bc9c5c136c diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index a2f4b65..640094b 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -42,7 +42,7 @@ #include #include #include -#ifdef MODEST_HILDON_VERSION_0 +#ifdef MODEST_HAVE_HILDON0_WIDGETS #include #else #include @@ -324,10 +324,12 @@ modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr, /* FIXME: for debugging. * Let's keep this because it is very useful for debugging. */ url = tny_account_get_url_string (TNY_ACCOUNT(tny_account)); - printf ("DEBUG %s:\n account-url: %s\n", __FUNCTION__, url); + + printf ("DEBUG %s:\n account-url: %s\n", __FUNCTION__, url); + g_free (url); /***********************/ - + return tny_account; } @@ -343,7 +345,7 @@ modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr, TnyAccount *result = modest_tny_account_new_from_server_account ( account_mgr, account_data); - + modest_account_mgr_free_server_account_data (account_mgr, account_data); return result; @@ -408,14 +410,28 @@ modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar tny_account_set_pass_func (tny_account, get_pass_func ? get_pass_func: get_pass_dummy); - /* 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); + /* 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); + + TnyAccountStore *astore = (TnyAccountStore *) modest_runtime_get_account_store (); + if (astore) { + TnyDevice *device = tny_account_store_get_device (astore); + GError *err = NULL; + g_object_set_data (G_OBJECT(tny_account), "account_store", (gpointer)astore); + tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (tny_account), + tny_device_is_online (device), &err); + if (err) + g_print ("Error connecting: %s\n", err->message); + g_object_unref (device); + } return tny_account; } @@ -635,16 +651,17 @@ recurse_folders (TnyFolderStore *store, folder = TNY_FOLDER (tny_iterator_get_current (iter)); stats = tny_folder_get_stats (folder); - /* initially, we sometimes get -1 from tinymail; ignore that */ - if (helper->function && helper->function (stats) > 0) - helper->sum += helper->function (stats); + if (stats) { + /* initially, we sometimes get -1 from tinymail; ignore that */ + if (helper->function && helper->function (stats) > 0) + helper->sum += helper->function (stats); - if (TNY_IS_FOLDER_STORE (folder)) { - recurse_folders (TNY_FOLDER_STORE (folder), query, helper); - } - + if (TNY_IS_FOLDER_STORE (folder)) { + recurse_folders (TNY_FOLDER_STORE (folder), query, helper); + } + g_object_unref (stats); + } g_object_unref (folder); - g_object_unref (stats); tny_iterator_next (iter); } g_object_unref (G_OBJECT (iter)); @@ -726,7 +743,7 @@ const gchar* modest_tny_account_get_parent_modest_account_name_for_server_accoun void modest_tny_account_set_parent_modest_account_name_for_server_account (TnyAccount *self, const gchar* parent_modest_acount_name) { g_object_set_data_full (G_OBJECT(self), "modest_account", - (gpointer*) g_strdup (parent_modest_acount_name), g_free); + (gpointer) g_strdup (parent_modest_acount_name), g_free); }