[evolution-data-server/account-mgmt: 22/33] Adapt ENameSelector to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/account-mgmt: 22/33] Adapt ENameSelector to the new ESource API.
- Date: Wed, 7 Sep 2011 16:08:56 +0000 (UTC)
commit 9188b4a82d627aa43caf07d06cd97b00643f01aa
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Nov 24 10:09:58 2010 -0500
Adapt ENameSelector to the new ESource API.
libedataserverui/e-name-selector.c | 88 ++++++++++++-----------------------
libedataserverui/e-name-selector.h | 1 -
2 files changed, 30 insertions(+), 59 deletions(-)
---
diff --git a/libedataserverui/e-name-selector.c b/libedataserverui/e-name-selector.c
index 84b1156..f451fcf 100644
--- a/libedataserverui/e-name-selector.c
+++ b/libedataserverui/e-name-selector.c
@@ -29,10 +29,13 @@
#include <glib/gi18n-lib.h>
#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
-
-#include "e-contact-store.h"
-#include "e-destination-store.h"
-#include "e-client-utils.h"
+#include <libebook/e-source-address-book.h>
+#include <libedataserver/e-source-autocomplete.h>
+#include <libedataserver/e-source-registry.h>
+#include <libedataserverui/e-client-utils.h>
+#include <libedataserverui/e-contact-store.h>
+#include <libedataserverui/e-destination-store.h>
+#include <libedataserverui/e-book-auth-util.h>
#include "e-name-selector.h"
typedef struct {
@@ -50,7 +53,6 @@ struct _ENameSelectorPrivate {
ENameSelectorDialog *dialog;
GArray *sections;
- ESourceList *source_list;
gboolean books_loaded;
GCancellable *cancellable;
@@ -103,7 +105,7 @@ name_selector_book_loaded_cb (GObject *source_object,
&& !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning (
"ENameSelector: Could not load \"%s\": %s",
- e_source_peek_name (source), error->message);
+ e_source_get_display_name (source), error->message);
g_error_free (error);
goto exit;
}
@@ -149,59 +151,34 @@ name_selector_book_loaded_cb (GObject *source_object,
void
e_name_selector_load_books (ENameSelector *name_selector)
{
- ESourceList *source_list;
- GSList *groups;
- GSList *iter1;
-
- g_return_if_fail (name_selector != NULL);
- g_return_if_fail (E_IS_NAME_SELECTOR (name_selector));
- g_return_if_fail (name_selector->priv != NULL);
- g_return_if_fail (!name_selector->priv->books_loaded);
-
- name_selector->priv->books_loaded = TRUE;
-
- if (!e_book_client_get_sources (&source_list, NULL)) {
- g_warning ("ENameSelector can't find any addressbooks!");
- return;
- }
+ ESourceRegistry *registry;
+ GList *list, *iter;
+ const gchar *extension_name;
- /* This keeps the source groups alive while the async operation
- * is running, without which e_book_new() can't obtain an absolute
- * URI for the ESource. We drop the reference in dispose(). */
- name_selector->priv->source_list = source_list;
+ registry = e_source_registry_get_default ();
- groups = e_source_list_peek_groups (source_list);
+ extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ list = e_source_registry_list_sources (registry, extension_name);
- for (iter1 = groups; iter1 != NULL; iter1 = iter1->next) {
- ESourceGroup *source_group;
- GSList *sources;
- GSList *iter2;
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESource *source = E_SOURCE (iter->data);
+ ESourceAutocomplete *extension;
+ const gchar *extension_name;
- source_group = E_SOURCE_GROUP (iter1->data);
- sources = e_source_group_peek_sources (source_group);
+ extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
+ extension = e_source_get_extension (source, extension_name);
- for (iter2 = sources; iter2 != NULL; iter2 = iter2->next) {
- ESource *source;
- const gchar *property;
-
- source = E_SOURCE (iter2->data);
-
- /* We're only loading completion books for now,
- * as we don't want unnecessary authentication
- * prompts. */
- property = e_source_get_property (source, "completion");
-
- if (property == NULL)
- continue;
-
- if (g_ascii_strcasecmp (property, "true") != 0)
- continue;
+ /* Only load address books with autocomplete enabled,
+ * so as to avoid unnecessary authentication prompts. */
+ if (!e_source_autocomplete_get_include_me (extension))
+ continue;
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, name_selector->priv->cancellable,
- e_client_utils_authenticate_handler, NULL,
- name_selector_book_loaded_cb, g_object_ref (name_selector));
- }
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_CONTACTS,
+ TRUE, name_selector->priv->cancellable,
+ e_client_utils_authenticate_handler, NULL,
+ name_selector_book_loaded_cb,
+ g_object_ref (name_selector));
}
}
@@ -239,11 +216,6 @@ name_selector_dispose (GObject *object)
priv->cancellable = NULL;
}
- if (priv->source_list != NULL) {
- g_object_unref (priv->source_list);
- priv->source_list = NULL;
- }
-
for (ii = 0; ii < priv->source_books->len; ii++) {
SourceBook *source_book;
diff --git a/libedataserverui/e-name-selector.h b/libedataserverui/e-name-selector.h
index 90952fa..e904213 100644
--- a/libedataserverui/e-name-selector.h
+++ b/libedataserverui/e-name-selector.h
@@ -23,7 +23,6 @@
#ifndef E_NAME_SELECTOR_H
#define E_NAME_SELECTOR_H
-#include <libedataserver/e-source-list.h>
#include <libedataserverui/e-name-selector-model.h>
#include <libedataserverui/e-name-selector-dialog.h>
#include <libedataserverui/e-name-selector-entry.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]