diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-01-22 05:31:09 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-01-22 05:34:39 +0800 |
commit | b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4 (patch) | |
tree | 9af4d94e34145cf56984cf313dd237470c3f15ce /addressbook/importers/evolution-csv-importer.c | |
parent | d05d0b0338eebc3ca68f69b69c9932f884effed0 (diff) | |
download | gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.gz gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.bz2 gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.lz gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.xz gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.zst gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.zip |
Use e_load_book_source_async() for all EBook loading.
Diffstat (limited to 'addressbook/importers/evolution-csv-importer.c')
-rw-r--r-- | addressbook/importers/evolution-csv-importer.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/addressbook/importers/evolution-csv-importer.c b/addressbook/importers/evolution-csv-importer.c index 9e15a58dee..69e82957d6 100644 --- a/addressbook/importers/evolution-csv-importer.c +++ b/addressbook/importers/evolution-csv-importer.c @@ -32,12 +32,12 @@ #include <glib/gstdio.h> #include <libebook/e-book.h> +#include <libedataserverui/e-book-auth-util.h> #include <libedataserverui/e-source-selector.h> #include <libebook/e-destination.h> #include "e-util/e-import.h" -#include "util/addressbook.h" #include "evolution-addressbook-importers.h" @@ -828,24 +828,25 @@ csv_import_done (CSVImporter *gci) } static void -book_loaded_cb (EBook *book, const GError *error, gpointer closure) +book_loaded_cb (ESource *source, + GAsyncResult *result, + CSVImporter *gci) { - CSVImporter *gci = closure; + gci->book = e_load_book_source_finish (source, result, NULL); - g_return_if_fail (gci != NULL); - g_return_if_fail (gci->book == book); - - if (error) + if (gci->book == NULL) { csv_import_done (gci); - else - gci->idle_id = g_idle_add (csv_import_contacts, gci); + return; + } + + gci->idle_id = g_idle_add (csv_import_contacts, gci); } static void csv_import (EImport *ei, EImportTarget *target, EImportImporter *im) { CSVImporter *gci; - EBook *book; + ESource *source; gchar *filename; FILE *file; EImportTargetURI *s = (EImportTargetURI *) target; @@ -856,20 +857,11 @@ csv_import (EImport *ei, EImportTarget *target, EImportImporter *im) return; } - book = e_book_new(g_datalist_get_data(&target->data, "csv-source"), NULL); - if (book == NULL) { - g_message("Couldn't Create EBook"); - e_import_complete (ei, target); - g_free (filename); - return; - } - file = g_fopen (filename, "r"); g_free (filename); if (file == NULL) { g_message("Can't open .csv file"); e_import_complete (ei, target); - g_object_unref (book); return; } @@ -877,7 +869,6 @@ csv_import (EImport *ei, EImportTarget *target, EImportImporter *im) g_datalist_set_data(&target->data, "csv-data", gci); gci->import = g_object_ref (ei); gci->target = target; - gci->book = book; gci->file = file; gci->fields_map = NULL; gci->count = 0; @@ -885,7 +876,11 @@ csv_import (EImport *ei, EImportTarget *target, EImportImporter *im) gci->size = ftell (file); fseek (file, 0, SEEK_SET); - addressbook_load (gci->book, book_loaded_cb, gci); + source = g_datalist_get_data (&target->data, "csv-source"); + + e_load_book_source_async ( + source, NULL, NULL, (GAsyncReadyCallback) + book_loaded_cb, gci); } static void |