+ switch (type) {
+ case TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS:
+ modest_type = MODEST_PROTOCOL_TYPE_TRANSPORT;
+ break;
+ case TNY_ACCOUNT_STORE_STORE_ACCOUNTS:
+ modest_type = MODEST_PROTOCOL_TYPE_STORE;
+ break;
+ case TNY_ACCOUNT_STORE_BOTH:
+ modest_type = MODEST_PROTOCOL_TYPE_ANY;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ cursor = accounts = modest_account_mgr_account_names (priv->account_mgr, NULL);
+
+ while (cursor) {
+ gchar *account_name;
+ gchar *server_account;
+ TnyAccount *account;
+ gboolean is_server_account;
+
+ account_name = (gchar*)cursor->data;
+ account = NULL;
+ is_server_account = FALSE;
+
+ if (!modest_account_mgr_account_get_enabled (priv->account_mgr, account_name)) {
+ g_free (account_name);
+ cursor = cursor->next;
+ continue;
+ }
+
+ if (modest_type == MODEST_PROTOCOL_TYPE_TRANSPORT || modest_type == MODEST_PROTOCOL_TYPE_ANY) {
+ server_account = get_server_account_for_account (self, account_name,
+ MODEST_PROTOCOL_TYPE_TRANSPORT);
+ if (server_account) {
+ account = tny_account_from_name (self, account_name,
+ server_account,
+ MODEST_PROTOCOL_TYPE_TRANSPORT);
+ is_server_account = TRUE;
+ }
+
+ if (!account)
+ g_printerr ("modest: no transport account for '%s'\n",
+ account_name);
+ else
+ tny_list_prepend (list, G_OBJECT(account));
+
+ g_free (server_account);
+ }
+
+ if (modest_type == MODEST_PROTOCOL_TYPE_STORE || modest_type == MODEST_PROTOCOL_TYPE_ANY) {
+ server_account = get_server_account_for_account (self, account_name,
+ MODEST_PROTOCOL_TYPE_STORE);
+ if (server_account) {
+ account = tny_account_from_name (self, account_name,
+ server_account,
+ MODEST_PROTOCOL_TYPE_STORE);
+ is_server_account = TRUE;
+ }
+
+ if (!account)
+ g_printerr ("modest: no store account for '%s'\n",
+ account_name);
+ else
+ tny_list_prepend (list, G_OBJECT(account));
+ g_free (server_account);
+ }
+
+ g_free (account_name);
+ cursor = cursor->next;
+ }
+
+ g_slist_free (accounts);
+
+ tny_session_camel_set_account_store (priv->tny_session_camel, iface);
+}
+
+
+/*
+ * the cache dir will be ~/.modest/cache
+ * might want to change this in a simple #define...