[evolution/account-mgmt: 16/50] Adapt mail/importers to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/account-mgmt: 16/50] Adapt mail/importers to the new ESource API.
- Date: Wed, 7 Sep 2011 16:09:06 +0000 (UTC)
commit 0ae12b617a1c3ae55359caa585c73062871c4605
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Dec 8 09:40:51 2010 -0500
Adapt mail/importers to the new ESource API.
mail/importers/pine-importer.c | 48 ++++++++++++++++-----------------------
1 files changed, 20 insertions(+), 28 deletions(-)
---
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index 710e02b..56b5e25 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -40,6 +40,8 @@
#include <libebook/e-book-client.h>
#include <libebook/e-destination.h>
+#include <libebook/e-source-address-book.h>
+#include <libedataserver/e-source-registry.h>
#include "mail-importer.h"
@@ -176,26 +178,21 @@ import_contact (EBookClient *book_client,
static void
import_contacts (void)
{
- ESource *primary;
- ESourceList *source_list;
- EBookClient *book_client;
+ ESourceRegistry *registry;
+ EBookClient *book_client = NULL;
+ GList *list;
gchar *name;
GString *line;
FILE *fp;
gsize offset;
+ const gchar *extension_name;
GError *error = NULL;
printf("importing pine addressbook\n");
- e_book_client_get_sources (&source_list, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to get book sources: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
+ registry = e_source_registry_get_default ();
+ extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ list = e_source_registry_list_sources (registry, extension_name);
name = g_build_filename(g_get_home_dir(), ".addressbook", NULL);
fp = fopen(name, "r");
@@ -203,30 +200,25 @@ import_contacts (void)
if (fp == NULL)
return;
- primary = e_source_list_peek_source_any (source_list);
- /* FIXME Better error handling */
- if ((book_client = e_book_client_new (primary, &error)) == NULL) {
- fclose (fp);
- g_warning ("Could not create EBook: %s", error->message);
- if (error)
- g_error_free (error);
- return;
+ if (list != NULL) {
+ ESource *source;
+
+ source = E_SOURCE (list->data);
+ book_client = e_book_client_new (source, &error);
+ g_list_free (list);
}
- if (!e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error)) {
- g_object_unref (primary);
- g_object_unref (source_list);
- fclose (fp);
+ if (book_client != NULL)
+ e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error);
+ if (error != NULL) {
g_warning (
"%s: Failed to open book client: %s",
G_STRFUNC, error->message);
- if (error)
- g_error_free (error);
+ g_error_free (error);
+ fclose (fp);
return;
}
- g_object_unref (primary);
- g_object_unref (source_list);
line = g_string_new("");
g_string_set_size (line, 256);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]