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 | |
parent | d05d0b0338eebc3ca68f69b69c9932f884effed0 (diff) | |
download | gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.gz gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.zst gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.zip |
Use e_load_book_source_async() for all EBook loading.
Diffstat (limited to 'addressbook/importers')
-rw-r--r-- | addressbook/importers/evolution-csv-importer.c | 37 | ||||
-rw-r--r-- | addressbook/importers/evolution-ldif-importer.c | 36 | ||||
-rw-r--r-- | addressbook/importers/evolution-vcard-importer.c | 31 |
3 files changed, 44 insertions, 60 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 diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c index f5fe14bd6b..d78f29e0d7 100644 --- a/addressbook/importers/evolution-ldif-importer.c +++ b/addressbook/importers/evolution-ldif-importer.c @@ -42,12 +42,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" @@ -622,35 +622,29 @@ ldif_import_done (LDIFImporter *gci) } static void -book_loaded_cb (EBook *book, const GError *error, gpointer closure) +book_loaded_cb (ESource *source, + GAsyncResult *result, + LDIFImporter *gci) { - LDIFImporter *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) { ldif_import_done (gci); - else - gci->idle_id = g_idle_add (ldif_import_contacts, gci); + return; + } + + gci->idle_id = g_idle_add (ldif_import_contacts, gci); } static void ldif_import (EImport *ei, EImportTarget *target, EImportImporter *im) { LDIFImporter *gci; - EBook *book; + ESource *source; FILE *file = NULL; EImportTargetURI *s = (EImportTargetURI *)target; gchar *filename; - book = e_book_new(g_datalist_get_data(&target->data, "ldif-source"), NULL); - if (book == NULL) { - g_message(G_STRLOC ":Couldn't create EBook."); - e_import_complete (ei, target); - return; - } - filename = g_filename_from_uri (s->uri_src, NULL, NULL); if (filename != NULL) { file = g_fopen(filename, "r"); @@ -659,7 +653,6 @@ ldif_import (EImport *ei, EImportTarget *target, EImportImporter *im) if (file == NULL) { g_message(G_STRLOC ":Can't open .ldif file"); e_import_complete (ei, target); - g_object_unref (book); return; } @@ -667,7 +660,6 @@ ldif_import (EImport *ei, EImportTarget *target, EImportImporter *im) g_datalist_set_data(&target->data, "ldif-data", gci); gci->import = g_object_ref (ei); gci->target = target; - gci->book = book; gci->file = file; fseek (file, 0, SEEK_END); gci->size = ftell (file); @@ -677,7 +669,11 @@ ldif_import (EImport *ei, EImportTarget *target, EImportImporter *im) (GDestroyNotify) g_free, (GDestroyNotify) NULL); - addressbook_load (gci->book, book_loaded_cb, gci); + source = g_datalist_get_data (&target->data, "ldif-source"); + + e_load_book_source_async ( + source, NULL, NULL, (GAsyncReadyCallback) + book_loaded_cb, gci); } static void diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c index 1610337036..c9cc489f2b 100644 --- a/addressbook/importers/evolution-vcard-importer.c +++ b/addressbook/importers/evolution-vcard-importer.c @@ -36,6 +36,7 @@ #include <glib/gstdio.h> #include <libebook/e-book.h> +#include <libedataserverui/e-book-auth-util.h> #include <libedataserverui/e-source-selector.h> #include <util/eab-book-util.h> @@ -44,7 +45,6 @@ #include "e-util/e-import.h" #include "e-util/e-datetime-format.h" #include "misc/e-web-view-preview.h" -#include "util/addressbook.h" #include "evolution-addressbook-importers.h" @@ -475,14 +475,13 @@ vcard_import_done (VCardImporter *gci) } static void -book_loaded_cb (EBook *book, const GError *error, gpointer closure) +book_loaded_cb (ESource *source, + GAsyncResult *result, + VCardImporter *gci) { - VCardImporter *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) { vcard_import_done (gci); return; } @@ -517,7 +516,7 @@ static void vcard_import (EImport *ei, EImportTarget *target, EImportImporter *im) { VCardImporter *gci; - EBook *book; + ESource *source; EImportTargetURI *s = (EImportTargetURI *)target; gchar *filename; gchar *contents; @@ -538,19 +537,10 @@ vcard_import (EImport *ei, EImportTarget *target, EImportImporter *im) return; } - book = e_book_new(g_datalist_get_data(&target->data, "vcard-source"), NULL); - if (book == NULL) { - g_message(G_STRLOC ":Couldn't create EBook."); - g_free (filename); - e_import_complete (ei, target); - return; - } - if (!g_file_get_contents (filename, &contents, NULL, NULL)) { g_message (G_STRLOC ":Couldn't read file."); g_free (filename); e_import_complete (ei, target); - g_object_unref (book); return; } @@ -559,11 +549,14 @@ vcard_import (EImport *ei, EImportTarget *target, EImportImporter *im) g_datalist_set_data(&target->data, "vcard-data", gci); gci->import = g_object_ref (ei); gci->target = target; - gci->book = book; gci->encoding = encoding; gci->contents = contents; - addressbook_load (book, book_loaded_cb, gci); + source = g_datalist_get_data (&target->data, "vcard-source"); + + e_load_book_source_async ( + source, NULL, NULL, (GAsyncReadyCallback) + book_loaded_cb, gci); } static void |