diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-07-12 23:26:47 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-07-12 23:26:47 +0800 |
commit | 78bf9d9d708dd255cc0966d64112aba56a4b2544 (patch) | |
tree | 99005ed153514c35d47a86482cad28b024c7ee50 /e-util | |
parent | eb29179da623f9cf4abd663577395a085452ca18 (diff) | |
download | gsoc2013-evolution-78bf9d9d708dd255cc0966d64112aba56a4b2544.tar.gz gsoc2013-evolution-78bf9d9d708dd255cc0966d64112aba56a4b2544.tar.zst gsoc2013-evolution-78bf9d9d708dd255cc0966d64112aba56a4b2544.zip |
Bug 624128 - Folder -> Subscriptions is always enabled
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-account-utils.c | 42 | ||||
-rw-r--r-- | e-util/e-account-utils.h | 1 |
2 files changed, 43 insertions, 0 deletions
diff --git a/e-util/e-account-utils.c b/e-util/e-account-utils.c index 4395542f7c..66242408ac 100644 --- a/e-util/e-account-utils.c +++ b/e-util/e-account-utils.c @@ -137,3 +137,45 @@ e_get_account_by_uid (const gchar *uid) /* XXX EAccountList misuses const. */ return (EAccount *) account; } + +/** + * e_get_any_enabled_account: + * + * Returns the default mail account if it's enabled, otherwise the first + * enabled mail account in the global #EAccountList, or finally %NULL if + * all mail accounts are disabled or none exist. + * + * Returns: an enabled #EAccount, or %NULL if there are none + **/ +EAccount * +e_get_any_enabled_account (void) +{ + EAccount *account; + EAccountList *account_list; + EIterator *iter; + + account = e_get_default_account (); + if (account != NULL && account->enabled) + return account; + + account = NULL; + + account_list = e_get_account_list (); + iter = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iter) && account == NULL) { + EAccount *candidate; + + /* XXX EIterator misuses const. */ + candidate = (EAccount *) e_iterator_get (iter); + + if (candidate->enabled) + account = candidate; + else + e_iterator_next (iter); + } + + g_object_unref (iter); + + return account; +} diff --git a/e-util/e-account-utils.h b/e-util/e-account-utils.h index f2ae8fc5dc..f8c5c968a4 100644 --- a/e-util/e-account-utils.h +++ b/e-util/e-account-utils.h @@ -29,6 +29,7 @@ EAccount * e_get_default_account (void); void e_set_default_account (EAccount *account); EAccount * e_get_account_by_name (const gchar *name); EAccount * e_get_account_by_uid (const gchar *uid); +EAccount * e_get_any_enabled_account (void); G_END_DECLS |