aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog10
-rw-r--r--addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in (renamed from addressbook/backend/ebook/GNOME_Evolution_Addressbook_GnomeCard_Importer.oaf.in)14
-rw-r--r--addressbook/backend/ebook/Makefile.am10
-rw-r--r--addressbook/backend/ebook/evolution-vcard-importer.c (renamed from addressbook/backend/ebook/evolution-gnomecard-importer.c)65
4 files changed, 69 insertions, 30 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index f32fbeca29..10e0616c9c 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,13 @@
+2001-05-08 Iain Holmes <iain@ximian.com>
+
+ * backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in:
+ Renamed the GnomeCard_Importer.oaf.in to this, and change the IID.
+
+ * Makefile.am: Rename all the GnomeCard to VCard.
+
+ * evolution-vcard-importer.c: Make the GnomeCard a generic
+ vcard importer.
+
2001-05-08 Christopher James Lahey <clahey@ximian.com>
* backend/ebook/Makefile.am (libebookinclude_HEADERS): Removed
diff --git a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_GnomeCard_Importer.oaf.in b/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in
index 69dfa90871..9cd4699633 100644
--- a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_GnomeCard_Importer.oaf.in
+++ b/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in
@@ -1,29 +1,29 @@
<oaf_info>
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_GnomeCard_ImporterFactory"
+<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory"
type="exe"
- location="evolution-gnomecard-importer">
+ location="evolution-vcard-importer">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/ObjectFactory:1.0"/>
</oaf_attribute>
<oaf_attribute name="description" type="string"
- _value="Factory to import GnomeCard files into Evolution."/>
+ _value="Factory to import VCard files into Evolution."/>
</oaf_server>
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_GnomeCard_Importer"
+<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_Importer"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_GnomeCard_ImporterFactory">
+ location="OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Evolution/Importer:1.0"/>
</oaf_attribute>
<oaf_attribute name="evolution:menu-name" type="string"
- value="GnomeCard (.vcf, .gcrd)"/>
+ value="VCard (.vcf, .gcrd)"/>
<oaf_attribute name="description" type="string"
- _value="Imports GnomeCard files into Evolution."/>
+ _value="Imports VCard files into Evolution."/>
</oaf_server>
</oaf_info>
diff --git a/addressbook/backend/ebook/Makefile.am b/addressbook/backend/ebook/Makefile.am
index da7307c1a5..624d1b072b 100644
--- a/addressbook/backend/ebook/Makefile.am
+++ b/addressbook/backend/ebook/Makefile.am
@@ -1,6 +1,6 @@
noinst_PROGRAMS = test-card test-client test-client-list
-bin_PROGRAMS = evolution-gnomecard-importer \
+bin_PROGRAMS = evolution-vcard-importer \
load-pine-addressbook load-gnomecard-addressbook
CORBA_SOURCE = \
@@ -106,9 +106,9 @@ test_card_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/e-util/libeutil.la
-evolution_gnomecard_importer_SOURCES = \
- evolution-gnomecard-importer.c
-evolution_gnomecard_importer_LDADD = \
+evolution_vcard_importer_SOURCES = \
+ evolution-vcard-importer.c
+evolution_vcard_importer_LDADD = \
libebook.la \
$(BONOBO_GNOME_LIBS) \
$(EXTRA_GNOME_LIBS) \
@@ -148,7 +148,7 @@ dist-hook:
cd $(distdir); rm -f $(BUILT_SOURCES)
oafdir = $(datadir)/oaf
-oaf_in_files = GNOME_Evolution_Addressbook_GnomeCard_Importer.oaf.in
+oaf_in_files = GNOME_Evolution_Addressbook_VCard_Importer.oaf.in
oaf_DATA = $(oaf_in_files:.oaf.in=.oaf)
@XML_I18N_MERGE_OAF_RULE@
diff --git a/addressbook/backend/ebook/evolution-gnomecard-importer.c b/addressbook/backend/ebook/evolution-vcard-importer.c
index bb5e45cdd6..2864627a39 100644
--- a/addressbook/backend/ebook/evolution-gnomecard-importer.c
+++ b/addressbook/backend/ebook/evolution-vcard-importer.c
@@ -12,7 +12,7 @@
#include <importer/evolution-importer.h>
#include <importer/GNOME_Evolution_Importer.h>
-#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_GnomeCard_ImporterFactory"
+#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory"
static BonoboGenericFactory *factory = NULL;
@@ -22,14 +22,14 @@ typedef struct {
GList *iterator;
EBook *book;
gboolean ready;
-} GnomeCardImporter;
+} VCardImporter;
static void
add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
{
ECard *card = E_CARD(closure);
char *vcard = e_card_get_vcard(card);
- g_print ("Saved card: %s\n", vcard);
+
g_free(vcard);
gtk_object_unref(GTK_OBJECT(card));
}
@@ -37,14 +37,14 @@ add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
static void
book_open_cb (EBook *book, EBookStatus status, gpointer closure)
{
- GnomeCardImporter *gci = (GnomeCardImporter *) closure;
+ VCardImporter *gci = (VCardImporter *) closure;
gci->cardlist = e_card_load_cards_from_file(gci->filename);
gci->ready = TRUE;
}
static void
-ebook_create (GnomeCardImporter *gci)
+ebook_create (VCardImporter *gci)
{
gchar *path, *uri;
@@ -75,12 +75,12 @@ process_item_fn (EvolutionImporter *importer,
void *closure,
CORBA_Environment *ev)
{
- GnomeCardImporter *gci = (GnomeCardImporter *) closure;
+ VCardImporter *gci = (VCardImporter *) closure;
ECard *card;
if (gci->iterator == NULL)
gci->iterator = gci->cardlist;
-
+
if (gci->ready == FALSE) {
GNOME_Evolution_ImporterListener_notifyResult (listener,
GNOME_Evolution_ImporterListener_NOT_READY,
@@ -95,12 +95,12 @@ process_item_fn (EvolutionImporter *importer,
FALSE, ev);
return;
}
-
+
card = gci->iterator->data;
e_book_add_card (gci->book, card, add_card_cb, card);
-
+
gci->iterator = gci->iterator->next;
-
+
GNOME_Evolution_ImporterListener_notifyResult (listener,
GNOME_Evolution_ImporterListener_OK,
gci->iterator ? TRUE : FALSE,
@@ -116,6 +116,35 @@ static char *supported_extensions[3] = {
".vcf", ".gcrd", NULL
};
+/* Actually check the contents of this file */
+static gboolean
+check_file_is_vcard (const char *filename)
+{
+ FILE *handle;
+ char line[4096];
+ gboolean result;
+
+ handle = fopen (filename, "r");
+ if (handle == NULL) {
+ return FALSE;
+ }
+
+ fgets (line, 4096, handle);
+ if (line == NULL) {
+ fclose (handle);
+ return FALSE;
+ }
+
+ if (strcmp (line, "BEGIN:VCARD") == 0) {
+ result = TRUE;
+ } else {
+ result = FALSE;
+ }
+
+ fclose (handle);
+ return result;
+}
+
static gboolean
support_format_fn (EvolutionImporter *importer,
const char *filename,
@@ -127,7 +156,7 @@ support_format_fn (EvolutionImporter *importer,
ext = strrchr (filename, '.');
for (i = 0; supported_extensions[i] != NULL; i++) {
if (strcmp (supported_extensions[i], ext) == 0)
- return TRUE;
+ return check_file_is_vcard (filename);
}
return FALSE;
@@ -135,7 +164,7 @@ support_format_fn (EvolutionImporter *importer,
static void
importer_destroy_cb (GtkObject *object,
- GnomeCardImporter *gci)
+ VCardImporter *gci)
{
gtk_main_quit ();
}
@@ -146,9 +175,9 @@ load_file_fn (EvolutionImporter *importer,
const char *folderpath,
void *closure)
{
- GnomeCardImporter *gci;
+ VCardImporter *gci;
- gci = (GnomeCardImporter *) closure;
+ gci = (VCardImporter *) closure;
gci->filename = g_strdup (filename);
gci->cardlist = NULL;
gci->iterator = NULL;
@@ -163,9 +192,9 @@ factory_fn (BonoboGenericFactory *_factory,
void *closure)
{
EvolutionImporter *importer;
- GnomeCardImporter *gci;
+ VCardImporter *gci;
- gci = g_new (GnomeCardImporter, 1);
+ gci = g_new (VCardImporter, 1);
importer = evolution_importer_new (support_format_fn, load_file_fn,
process_item_fn, NULL, gci);
@@ -197,8 +226,8 @@ main (int argc,
{
CORBA_ORB orb;
- gnome_init_with_popt_table ("Evolution-GnomeCard-Importer",
- "0.0", argc, argv, oaf_popt_options, 0,
+ gnome_init_with_popt_table ("Evolution-VCard-Importer",
+ PACKAGE, argc, argv, oaf_popt_options, 0,
NULL);
orb = oaf_init (argc, argv);
if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {