From d4329193ff062d1925d856d80d177f068f964cfb Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Fri, 21 May 2004 00:17:44 +0000 Subject: Add helper func. (process_item_fn): Add undisplayed fields to notes. 2004-05-20 Hans Petter Jansson * importers/evolution-ldif-importer.c (add_to_notes): Add helper func. (process_item_fn): Add undisplayed fields to notes. * importers/evolution-vcard-importer.c (add_to_notes): Add helper func. (process_item_fn): Add undisplayed fields to notes. svn path=/trunk/; revision=26025 --- addressbook/importers/evolution-ldif-importer.c | 31 ++++++++++++++++++++++++ addressbook/importers/evolution-vcard-importer.c | 29 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'addressbook/importers') diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c index e756f6adff..a19c229ae5 100644 --- a/addressbook/importers/evolution-ldif-importer.c +++ b/addressbook/importers/evolution-ldif-importer.c @@ -428,6 +428,30 @@ create_contacts_from_ldif (const char *filename) return list; } +static void +add_to_notes (EContact *contact, EContactField field) +{ + const gchar *old_text; + const gchar *field_text; + gchar *new_text; + + old_text = e_contact_get_const (contact, E_CONTACT_NOTE); + if (old_text && strstr (old_text, e_contact_pretty_name (field))) + return; + + field_text = e_contact_get_const (contact, field); + if (!field_text || !*field_text) + return; + + new_text = g_strdup_printf ("%s%s%s: %s", + old_text ? old_text : "", + old_text && *old_text && + *(old_text + strlen (old_text) - 1) != '\n' ? "\n" : "", + e_contact_pretty_name (field), field_text); + e_contact_set (contact, E_CONTACT_NOTE, new_text); + g_free (new_text); +} + /* EvolutionImporter methods */ static void process_item_fn (EvolutionImporter *importer, @@ -459,6 +483,13 @@ process_item_fn (EvolutionImporter *importer, contact = gci->iterator->data; if (e_contact_get (contact, E_CONTACT_IS_LIST)) resolve_list_card (gci, contact); + else { + /* Work around the fact that these fields no longer show up in the UI */ + add_to_notes (contact, E_CONTACT_OFFICE); + add_to_notes (contact, E_CONTACT_SPOUSE); + add_to_notes (contact, E_CONTACT_BLOG_URL); + } + /* FIXME Error checking */ e_book_add_contact (gci->book, contact, NULL); diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c index 5719dce51c..eedacef874 100644 --- a/addressbook/importers/evolution-vcard-importer.c +++ b/addressbook/importers/evolution-vcard-importer.c @@ -60,6 +60,30 @@ typedef struct { gboolean ready; } VCardImporter; +static void +add_to_notes (EContact *contact, EContactField field) +{ + const gchar *old_text; + const gchar *field_text; + gchar *new_text; + + old_text = e_contact_get_const (contact, E_CONTACT_NOTE); + if (old_text && strstr (old_text, e_contact_pretty_name (field))) + return; + + field_text = e_contact_get_const (contact, field); + if (!field_text || !*field_text) + return; + + new_text = g_strdup_printf ("%s%s%s: %s", + old_text ? old_text : "", + old_text && *old_text && + *(old_text + strlen (old_text) - 1) != '\n' ? "\n" : "", + e_contact_pretty_name (field), field_text); + e_contact_set (contact, E_CONTACT_NOTE, new_text); + g_free (new_text); +} + /* EvolutionImporter methods */ static void process_item_fn (EvolutionImporter *importer, @@ -125,6 +149,11 @@ process_item_fn (EvolutionImporter *importer, } e_contact_set_attributes (contact, E_CONTACT_EMAIL, attrs); + /* Work around the fact that these fields no longer show up in the UI */ + add_to_notes (contact, E_CONTACT_OFFICE); + add_to_notes (contact, E_CONTACT_SPOUSE); + add_to_notes (contact, E_CONTACT_BLOG_URL); + /* FIXME Error checking */ e_book_add_contact (gci->book, contact, NULL); -- cgit v1.2.3