}
-
-TnyAccount*
-modest_account_mgr_get_tny_account (ModestAccountMgr *self, const gchar* account_name,
- TnyAccountType type)
-{
- TnyAccount *account = NULL;
- TnyList *accounts;
- TnyIterator *iter;
- gchar *server_account;
- const gchar *conf_key;
- TnyGetAccountsRequestType request_type; /* really confusing.... */
-
- g_return_val_if_fail (self, NULL);
- g_return_val_if_fail (account_name, NULL);
-
- switch (type) {
- case TNY_ACCOUNT_TYPE_STORE:
- conf_key = MODEST_ACCOUNT_STORE_ACCOUNT;
- request_type = TNY_ACCOUNT_STORE_STORE_ACCOUNTS;
- break;
- case TNY_ACCOUNT_TYPE_TRANSPORT:
- conf_key = MODEST_ACCOUNT_TRANSPORT_ACCOUNT;
- request_type = TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS;
- break;
- default:
- g_return_val_if_reached (NULL);
- }
-
- server_account = modest_account_mgr_get_string (self, account_name, conf_key, FALSE, NULL);
- if (!server_account) {
- g_printerr ("modest: no %s account specified for %s\n",
- type == TNY_ACCOUNT_TYPE_TRANSPORT ? "transport" : "store", account_name);
- return NULL;
- }
-
- accounts = tny_simple_list_new ();
- tny_account_store_get_accounts (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()),
- accounts, request_type);
- iter = tny_list_create_iterator (accounts);
- while (tny_iterator_is_done (iter)) {
- account = TNY_ACCOUNT(tny_iterator_get_current(iter));
- if (strcmp (tny_account_get_id (account), server_account) == 0)
- break;
- g_object_unref (G_OBJECT(account));
- }
-
- g_object_unref (G_OBJECT(iter));
- g_object_unref (G_OBJECT(accounts));
-
- if (!account)
- g_printerr ("modest: no tny %s account found for %s\n",
- type == TNY_ACCOUNT_TYPE_TRANSPORT ? "transport" : "store", account_name);
- else {
- /* sanity check */
- if ((type == TNY_ACCOUNT_TYPE_TRANSPORT && !TNY_IS_TRANSPORT_ACCOUNT(account)) ||
- (type == TNY_ACCOUNT_TYPE_STORE && !TNY_IS_STORE_ACCOUNT(account))) {
- g_printerr ("modest: tny %s acccount found for %s, but was expecting %s account\n",
- type == TNY_ACCOUNT_TYPE_TRANSPORT ? "transport" : "store", account_name,
- type == TNY_ACCOUNT_TYPE_TRANSPORT ? "store" : "transport");
- g_object_unref (G_OBJECT(account));
- account = NULL;
- }
- }
- return account;
-}
-
-
gchar*
modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name)
{