-
- tny_session_camel_set_ui_locker (priv->session, tny_gtk_lockable_new ());
- /* FIXME: unref this in the end? */
- tny_session_camel_set_async_connecting (priv->session, TRUE);
-
- /* force a cache fill... ugly */
- list = TNY_LIST(tny_simple_list_new());
- tny_account_store_get_accounts (TNY_ACCOUNT_STORE(obj), list,
- TNY_ACCOUNT_STORE_BOTH);
- g_object_unref(list);
-
- /* Connect signals */
- g_signal_connect (G_OBJECT(account_mgr), "account_changed",
- G_CALLBACK (on_account_changed), obj);
- g_signal_connect (G_OBJECT(account_mgr), "account_removed",
- G_CALLBACK (on_account_removed), obj);
-
- return MODEST_TNY_ACCOUNT_STORE(obj);
-}
-
-/** Fill the TnyList from the appropriate cached GSList of accounts. */
-static void
-get_cached_accounts (TnyAccountStore *self, TnyList *list, TnyAccountType type)
-{
- ModestTnyAccountStorePrivate *priv;
- GSList *accounts, *cursor;
-
- priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- accounts = (type == TNY_ACCOUNT_TYPE_STORE ? priv->store_accounts : priv->transport_accounts);
-
- cursor = accounts;
- while (cursor) {
- if (cursor->data) {
- GObject *object = G_OBJECT(cursor->data);
- tny_list_prepend (list, object);
- }
-
- cursor = cursor->next;
- }
-}
-
-static void
-create_per_account_local_outbox_folders (TnyAccountStore *self)
-{
- g_return_if_fail (self);
-
- ModestTnyAccountStorePrivate *priv =
- MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
-
- /* printf("DEBUG: %s: priv->store_accounts_outboxes = %p\n", __FUNCTION__, priv->store_accounts_outboxes); */
-
- GSList *accounts = NULL;
-
- GSList *account_names = modest_account_mgr_account_names (priv->account_mgr,
- TRUE /* including disabled accounts */);
-
- GSList *iter = NULL;
- for (iter = account_names; iter; iter = g_slist_next (iter)) {
-
- const gchar* account_name = (const gchar*)iter->data;
-
- /* Create a per-account local outbox folder (a _store_ account)
- * for each _transport_ account: */
- TnyAccount *tny_account_outbox =
- modest_tny_account_new_for_per_account_local_outbox_folder (
- priv->account_mgr, account_name, priv->session);
-
- accounts = g_slist_append (accounts, tny_account_outbox); /* cache it */
- };
-
- g_slist_free (account_names);
-
- priv->store_accounts_outboxes = accounts;
-}
-
-/* This function fills the TnyList, and also stores a GSList of the accounts,
- * for caching purposes. It creates the TnyAccount objects if necessary.
- * The @list parameter may be NULL, if you just want to fill the cache.
- */
-static void
-get_server_accounts (TnyAccountStore *self, TnyList *list, TnyAccountType type)
-{
- g_return_if_fail (self);
-
- /* printf ("DEBUG: %s: list=%p, type=%d\n", __FUNCTION__, list, type); */
-
- ModestTnyAccountStorePrivate *priv =
- MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
-
- /* Do nothing if the accounts are already cached: */
- if (type == TNY_ACCOUNT_TYPE_STORE) {
- if (priv->store_accounts)
- return;
- } else if (type == TNY_ACCOUNT_TYPE_TRANSPORT) {
- if (priv->transport_accounts)
- return;