diff options
author | Chris Toshok <toshok@ximian.com> | 2004-01-23 03:39:53 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2004-01-23 03:39:53 +0800 |
commit | 63bf7e21910188ffdaf7d83a39d18c477d7d9d85 (patch) | |
tree | 2d9f220731328dfddc20441f78b97f467e627edb /addressbook/gui | |
parent | f75a1e4af4a65540efc295160cc884f762ed31a3 (diff) | |
download | gsoc2013-evolution-63bf7e21910188ffdaf7d83a39d18c477d7d9d85.tar gsoc2013-evolution-63bf7e21910188ffdaf7d83a39d18c477d7d9d85.tar.gz gsoc2013-evolution-63bf7e21910188ffdaf7d83a39d18c477d7d9d85.tar.bz2 gsoc2013-evolution-63bf7e21910188ffdaf7d83a39d18c477d7d9d85.tar.lz gsoc2013-evolution-63bf7e21910188ffdaf7d83a39d18c477d7d9d85.tar.xz gsoc2013-evolution-63bf7e21910188ffdaf7d83a39d18c477d7d9d85.tar.zst gsoc2013-evolution-63bf7e21910188ffdaf7d83a39d18c477d7d9d85.zip |
[ fixes bug #52944 ] do some massaging of contacts as we import them, to
2004-01-22 Chris Toshok <toshok@ximian.com>
[ fixes bug #52944 ]
* gui/component/addressbook-migrate.c (migrate_contacts): do some
massaging of contacts as we import them, to fix up the differences
between 1.4 and 1.5 vcards.
svn path=/trunk/; revision=24369
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/addressbook-migrate.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/addressbook/gui/component/addressbook-migrate.c b/addressbook/gui/component/addressbook-migrate.c index 79e21f4ed6..60b87d4dd6 100644 --- a/addressbook/gui/component/addressbook-migrate.c +++ b/addressbook/gui/component/addressbook-migrate.c @@ -232,6 +232,62 @@ migrate_contacts (EBook *old_book, EBook *new_book) for (l = contacts; l; l = l->next) { EContact *contact = l->data; GError *e = NULL; + GList *attrs, *attr; + + /* do some last minute massaging of the contact's attributes */ + + attrs = e_vcard_get_attributes (E_VCARD (contact)); + for (attr = attrs; attr;) { + EVCardAttribute *a = attr->data; + + /* evo 1.4 used the non-standard X-EVOLUTION-OFFICE attribute, + evo 1.5 uses the third element in the ORG list attribute. */ + if (!strcmp ("X-EVOLUTION-OFFICE", e_vcard_attribute_get_name (a))) { + GList *v = e_vcard_attribute_get_values (a); + GList *next_attr; + + if (v && v->data) + e_contact_set (contact, E_CONTACT_OFFICE, v->data); + + next_attr = attr->next; + e_vcard_remove_attribute (E_VCARD (contact), a); + attr = next_attr; + } + /* evo 1.4 didn't put TYPE=VOICE in for phone numbers. + evo 1.5 does. + + so we search through the attribute params for + either TYPE=VOICE or TYPE=FAX. If we find + either we do nothing. If we find neither, we + add TYPE=VOICE. + */ + else if (!strcmp ("TEL", e_vcard_attribute_get_name (a))) { + GList *params, *param; + gboolean found = FALSE; + + params = e_vcard_attribute_get_params (a); + for (param = params; param; param = param->next) { + EVCardAttributeParam *p = param->data; + if (!strcmp (EVC_TYPE, e_vcard_attribute_param_get_name (p))) { + GList *v = e_vcard_attribute_param_get_values (p); + if (v && v->data) + if (!strcmp ("VOICE", v->data) + || !strcmp ("FAX", v->data)) + found = TRUE; + } + } + + if (!found) + e_vcard_attribute_add_param_with_value (a, + e_vcard_attribute_param_new (EVC_TYPE), + "VOICE"); + attr = attr->next; + } + else { + attr = attr->next; + } + } + if (!e_book_add_contact (new_book, contact, &e)) |