aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/importers
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2004-05-21 08:17:44 +0800
committerHans Petter <hansp@src.gnome.org>2004-05-21 08:17:44 +0800
commitd4329193ff062d1925d856d80d177f068f964cfb (patch)
tree5fe6bf2eac5032e17022c3877b1e68ab824c91d0 /addressbook/importers
parent6ca92599a2316f55eae5930674718756f34eb772 (diff)
downloadgsoc2013-evolution-d4329193ff062d1925d856d80d177f068f964cfb.tar
gsoc2013-evolution-d4329193ff062d1925d856d80d177f068f964cfb.tar.gz
gsoc2013-evolution-d4329193ff062d1925d856d80d177f068f964cfb.tar.bz2
gsoc2013-evolution-d4329193ff062d1925d856d80d177f068f964cfb.tar.lz
gsoc2013-evolution-d4329193ff062d1925d856d80d177f068f964cfb.tar.xz
gsoc2013-evolution-d4329193ff062d1925d856d80d177f068f964cfb.tar.zst
gsoc2013-evolution-d4329193ff062d1925d856d80d177f068f964cfb.zip
Add helper func. (process_item_fn): Add undisplayed fields to notes.
2004-05-20 Hans Petter Jansson <hpj@ximian.com> * 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
Diffstat (limited to 'addressbook/importers')
-rw-r--r--addressbook/importers/evolution-ldif-importer.c31
-rw-r--r--addressbook/importers/evolution-vcard-importer.c29
2 files changed, 60 insertions, 0 deletions
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);