From 4b88140cb6e3d7a82d2da878d3d3345c460be60a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 29 Oct 2010 19:54:45 -0400 Subject: Bug 633172 - Folder->Subscriptions is always enabled --- e-util/e-account-utils.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'e-util/e-account-utils.c') diff --git a/e-util/e-account-utils.c b/e-util/e-account-utils.c index 1590c98bfb..df93fa2202 100644 --- a/e-util/e-account-utils.c +++ b/e-util/e-account-utils.c @@ -22,7 +22,6 @@ #include "e-account-utils.h" -#include #include static EAccountList *global_account_list; @@ -355,3 +354,57 @@ e_get_default_transport (void) return NULL; } + +/** + * e_get_subscribable_accounts: + * @session: a #CamelSession + * + * Returns a list of enabled accounts that support folder subscriptions. + * The #EAccount objects are not referenced, but the list itself should + * be should be freed with g_list_free(). + * + * Returns: a list of #EAccount objects + **/ +GList * +e_get_subscribable_accounts (CamelSession *session) +{ + EAccountList *account_list; + EAccount *account; + EIterator *iterator; + GList *subscribable = NULL; + + g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL); + + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + CamelStore *store = NULL; + + /* XXX EIterator misuses const. */ + account = (EAccount *) e_iterator_get (iterator); + + if (account->enabled) { + const gchar *url; + + url = e_account_get_string ( + account, E_ACCOUNT_SOURCE_URL); + store = (CamelStore *) camel_session_get_service ( + session, url, CAMEL_PROVIDER_STORE, NULL); + } + + e_iterator_next (iterator); + + if (store == NULL) + continue; + + if (!camel_store_supports_subscriptions (store)) + continue; + + subscribable = g_list_prepend (subscribable, account); + } + + g_object_unref (iterator); + + return g_list_reverse (subscribable); +} -- cgit v1.2.3