[evolution-data-server/account-mgmt: 26/28] Adapt ENameSelectorEntry to the new ESource API.



commit 9519bb298c3c2995d139735a005c0686061ab2c5
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Nov 30 20:25:58 2010 -0600

    Adapt ENameSelectorEntry to the new ESource API.

 libedataserverui/e-name-selector-entry.c |   61 ++++++++++++++---------------
 1 files changed, 29 insertions(+), 32 deletions(-)
---
diff --git a/libedataserverui/e-name-selector-entry.c b/libedataserverui/e-name-selector-entry.c
index 3a6740d..f1fb337 100644
--- a/libedataserverui/e-name-selector-entry.c
+++ b/libedataserverui/e-name-selector-entry.c
@@ -24,12 +24,16 @@
 #include <config.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
+#include <gconf/gconf-client.h>
 
 #include <camel/camel.h>
 #include <libebook/e-book.h>
 #include <libebook/e-contact.h>
 #include <libebook/e-destination.h>
+#include <libebook/e-source-address-book.h>
 #include <libedataserverui/e-book-auth-util.h>
+#include <libedataserver/e-source-autocomplete.h>
+#include <libedataserver/e-source-registry.h>
 #include <libedataserver/e-sexp.h>
 
 #include "e-name-selector-entry.h"
@@ -41,7 +45,6 @@
 struct _ENameSelectorEntryPrivate {
 
 	PangoAttrList *attr_list;
-	ESourceList *source_list;
 	EContactStore *contact_store;
 	ETreeModelGenerator *email_generator;
 	EDestinationStore *destination_store;
@@ -2009,8 +2012,9 @@ static void
 setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
 {
 	EContactStore *contact_store;
-	GSList *groups;
-	GSList *l;
+	ESourceRegistry *registry;
+	GList *list, *iter;
+	const gchar *extension_name;
 
 	g_return_if_fail (name_selector_entry->priv->contact_store == NULL);
 
@@ -2018,34 +2022,34 @@ setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
 
 	contact_store = e_contact_store_new ();
 	name_selector_entry->priv->contact_store = contact_store;
-	groups = e_source_list_peek_groups (name_selector_entry->priv->source_list);
 
-	for (l = groups; l; l = g_slist_next (l)) {
-		ESourceGroup *group   = l->data;
-		GSList       *sources = e_source_group_peek_sources (group);
-		GSList       *m;
+	registry = e_source_registry_get_default ();
+	extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-		for (m = sources; m; m = g_slist_next (m)) {
-			ESource *source = m->data;
-			GCancellable *cancellable;
-			const gchar *completion;
+	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+		ESource *source = E_SOURCE (iter->data);
+		ESourceAutocomplete *extension;
+		GCancellable *cancellable;
+		const gchar *extension_name;
 
-			/* Skip non-completion sources */
-			completion = e_source_get_property (source, "completion");
-			if (!completion || g_ascii_strcasecmp (completion, "true"))
-				continue;
+		extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
+		extension = e_source_get_extension (source, extension_name);
 
-			cancellable = g_cancellable_new ();
+		/* Skip non-completion sources. */
+		if (!e_source_autocomplete_get_include_me (extension))
+			continue;
 
-			g_queue_push_tail (
-				&name_selector_entry->priv->cancellables,
-				cancellable);
+		cancellable = g_cancellable_new ();
 
-			e_load_book_source_async (
-				source, NULL, cancellable,
-				(GAsyncReadyCallback) book_loaded_cb,
-				g_object_ref (contact_store));
-		}
+		g_queue_push_tail (
+			&name_selector_entry->priv->cancellables,
+			cancellable);
+
+		e_load_book_source_async (
+			source, NULL, cancellable,
+			(GAsyncReadyCallback) book_loaded_cb,
+			g_object_ref (name_selector_entry));
 	}
 
 	setup_contact_store (name_selector_entry);
@@ -2831,13 +2835,6 @@ e_name_selector_entry_init (ENameSelectorEntry *name_selector_entry)
 
 	g_queue_init (&name_selector_entry->priv->cancellables);
 
-	/* Source list */
-
-	if (!e_book_get_addressbooks (&name_selector_entry->priv->source_list, NULL)) {
-	  g_warning ("ENameSelectorEntry can't find any addressbooks!");
-	  return;
-	}
-
 	/* read minimum_query_length from gconf*/
 	gconf = gconf_client_get_default ();
 	if (COMPLETION_CUE_MIN_LEN == 0) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]