From e75aa2712e5ae4df8c42c28df7238bd13e0510e9 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 6 Feb 2004 18:19:04 +0000 Subject: implement (load_file_fn): use g_file_get_contents to get a string we can 2004-02-06 JP Rosevear * importers/evolution-vcard-importer.c (importer_destroy_cb): implement (load_file_fn): use g_file_get_contents to get a string we can convert to a contact list with eab_contact_list_from_string svn path=/trunk/; revision=24654 --- addressbook/importers/evolution-vcard-importer.c | 32 ++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'addressbook/importers') diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c index c794d7854a..45dbacf537 100644 --- a/addressbook/importers/evolution-vcard-importer.c +++ b/addressbook/importers/evolution-vcard-importer.c @@ -42,13 +42,11 @@ #include -//#include #include #include #include - -#include +#include #define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory" #define COMPONENT_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_Importer" @@ -211,7 +209,18 @@ static void importer_destroy_cb (gpointer data, GObject *where_object_was) { - /* FIXME Implement */ + VCardImporter *gci = data; + + if (gci->primary) + g_object_unref (gci->primary); + + if (gci->book) + g_object_unref (gci->book); + + g_list_foreach (gci->contactlist, (GFunc) g_object_unref, NULL); + g_list_free (gci->contactlist); + + g_free (gci); } static gboolean @@ -220,7 +229,8 @@ load_file_fn (EvolutionImporter *importer, void *closure) { VCardImporter *gci; - + char *contents; + if (check_file_is_vcard (filename) == FALSE) { return FALSE; } @@ -230,14 +240,22 @@ load_file_fn (EvolutionImporter *importer, gci->iterator = NULL; gci->ready = FALSE; - /* Load the book and the cards */ + /* Load the book */ gci->book = e_book_new (); if (!gci->book) { g_message (G_STRLOC ":Couldn't create EBook."); return FALSE; } e_book_load_source (gci->book, gci->primary, TRUE, NULL); -// gci->cardlist = e_card_load_cards_from_file_with_default_charset(filename, "ISO-8859-1"); + + /* Load the file and the contacts */ + if (!g_file_get_contents (filename, &contents, NULL, NULL)) { + g_message (G_STRLOC ":Couldn't read file."); + return FALSE; + } + gci->contactlist = eab_contact_list_from_string (contents); + g_free (contents); + gci->ready = TRUE; return TRUE; -- cgit v1.2.3