aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/importers/evolution-csv-importer.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/importers/evolution-csv-importer.c')
-rw-r--r--addressbook/importers/evolution-csv-importer.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/addressbook/importers/evolution-csv-importer.c b/addressbook/importers/evolution-csv-importer.c
index 358b8198ab..76607f342e 100644
--- a/addressbook/importers/evolution-csv-importer.c
+++ b/addressbook/importers/evolution-csv-importer.c
@@ -34,8 +34,8 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libebook/e-book.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libebook/e-book-client.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
#include <libebook/e-destination.h>
@@ -66,7 +66,7 @@ typedef struct {
* file to an index in the known fields array. */
GHashTable *fields_map;
- EBook *book;
+ EBookClient *book_client;
GSList *contacts;
} CSVImporter;
@@ -721,7 +721,11 @@ csv_import_contacts (gpointer d) {
EContact *contact = NULL;
while ((contact = getNextCSVEntry (gci, gci->file))) {
- e_book_add_contact (gci->book, contact, NULL);
+ gchar *uid = NULL;
+ if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) {
+ e_contact_set (contact, E_CONTACT_UID, uid);
+ g_free (uid);
+ }
gci->contacts = g_slist_prepend (gci->contacts, contact);
}
if (contact == NULL) {
@@ -755,7 +759,7 @@ csv_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im)
ESourceList *source_list;
/* FIXME Better error handling */
- if (!e_book_get_addressbooks (&source_list, NULL))
+ if (!e_book_client_get_sources (&source_list, NULL))
return NULL;
vbox = gtk_vbox_new (FALSE, FALSE);
@@ -829,7 +833,7 @@ csv_import_done (CSVImporter *gci)
g_source_remove (gci->idle_id);
fclose (gci->file);
- g_object_unref (gci->book);
+ g_object_unref (gci->book_client);
g_slist_foreach (gci->contacts, (GFunc) g_object_unref, NULL);
g_slist_free (gci->contacts);
@@ -843,13 +847,20 @@ csv_import_done (CSVImporter *gci)
}
static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- CSVImporter *gci)
+ gpointer user_data)
{
- gci->book = e_load_book_source_finish (source, result, NULL);
+ ESource *source = E_SOURCE (source_object);
+ CSVImporter *gci = user_data;
+ EClient *client = NULL;
+
+ if (!e_client_utils_open_new_finish (source, result, &client, NULL))
+ client = NULL;
+
+ gci->book_client = client ? E_BOOK_CLIENT (client) : NULL;
- if (gci->book == NULL) {
+ if (gci->book_client == NULL) {
csv_import_done (gci);
return;
}
@@ -893,8 +904,8 @@ csv_import (EImport *ei, EImportTarget *target, EImportImporter *im)
source = g_datalist_get_data (&target->data, "csv-source");
- e_load_book_source_async (
- source, NULL, NULL, (GAsyncReadyCallback)
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
book_loaded_cb, gci);
}
@@ -931,7 +942,7 @@ static GtkWidget *
csv_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
{
GtkWidget *preview;
- GList *contacts = NULL;
+ GSList *contacts = NULL;
EContact *contact;
EImportTargetURI *s = (EImportTargetURI *) target;
gchar *filename;
@@ -960,14 +971,13 @@ csv_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
fseek (file, 0, SEEK_SET);
while (contact = getNextCSVEntry (gci, gci->file), contact != NULL) {
- contacts = g_list_prepend (contacts, contact);
+ contacts = g_slist_prepend (contacts, contact);
}
- contacts = g_list_reverse (contacts);
+ contacts = g_slist_reverse (contacts);
preview = evolution_contact_importer_get_preview_widget (contacts);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ e_client_util_free_object_slist (contacts);
fclose (file);
g_free (gci);