aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-30 07:54:45 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-30 07:54:45 +0800
commit43814fe77518e97c6b9c9ecb1d499dc3eb323296 (patch)
treea3353a6405accaa23473ce3893359d180c7a6880 /e-util
parent83627486d54d307e7bf80885757247880eab1d26 (diff)
downloadgsoc2013-evolution-43814fe77518e97c6b9c9ecb1d499dc3eb323296.tar
gsoc2013-evolution-43814fe77518e97c6b9c9ecb1d499dc3eb323296.tar.gz
gsoc2013-evolution-43814fe77518e97c6b9c9ecb1d499dc3eb323296.tar.bz2
gsoc2013-evolution-43814fe77518e97c6b9c9ecb1d499dc3eb323296.tar.lz
gsoc2013-evolution-43814fe77518e97c6b9c9ecb1d499dc3eb323296.tar.xz
gsoc2013-evolution-43814fe77518e97c6b9c9ecb1d499dc3eb323296.tar.zst
gsoc2013-evolution-43814fe77518e97c6b9c9ecb1d499dc3eb323296.zip
Bug 633172 - Folder->Subscriptions is always enabled
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-account-utils.c55
-rw-r--r--e-util/e-account-utils.h2
2 files changed, 56 insertions, 1 deletions
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 <camel/camel.h>
#include <gconf/gconf-client.h>
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);
+}
diff --git a/e-util/e-account-utils.h b/e-util/e-account-utils.h
index 0f3fbcbe21..57ca8400be 100644
--- a/e-util/e-account-utils.h
+++ b/e-util/e-account-utils.h
@@ -18,6 +18,7 @@
#ifndef E_ACCOUNT_UTILS_H
#define E_ACCOUNT_UTILS_H
+#include <camel/camel.h>
#include <libedataserver/e-account.h>
#include <libedataserver/e-account-list.h>
@@ -33,6 +34,7 @@ EAccount * e_get_account_by_transport_url (const gchar *transport_url);
EAccount * e_get_any_enabled_account (void);
EAccountService *
e_get_default_transport (void);
+GList * e_get_subscribable_accounts (CamelSession *session);
G_END_DECLS