[evolution-couchdb] Set descriptions for mail addresses correctly
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-couchdb] Set descriptions for mail addresses correctly
- Date: Sat, 25 Jul 2009 21:46:49 +0000 (UTC)
commit 9cf1a80ab78492ad6d13315f5630588519eb2b40
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Sat Jul 25 23:39:45 2009 +0200
Set descriptions for mail addresses correctly
addressbook/e-book-backend-couchdb.c | 40 +++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index ce87944..f24e8e0 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -161,7 +161,7 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
{
EContactDate *dt;
GSList *list;
- gint i;
+ GList *attr_list, *al;
const char *str;
CouchDBDocument *document;
EContactAddress *contact_address;
@@ -178,14 +178,44 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
/* email addresses */
list = NULL;
- for (i = E_CONTACT_FIRST_EMAIL_ID; i <= E_CONTACT_LAST_EMAIL_ID; i++) {
+ attr_list = e_contact_get_attributes (contact, E_CONTACT_EMAIL);
+ for (al = attr_list; al != NULL; al = al->next) {
const gchar *email;
+ EVCardAttribute *attr = (EVCardAttribute *) al->data;
- email = e_contact_get_const (contact, i);
+ email = e_vcard_attribute_get_value (attr);
if (email) {
CouchDBStructField *sf;
-
- sf = couchdb_document_contact_email_new (email, /* FIXME */ NULL);
+ GList *params;
+ const gchar *description = NULL;
+
+ params = e_vcard_attribute_get_params (attr);
+ if (params) {
+ GList *pl;
+
+ for (pl = params; pl != NULL; pl = pl->next) {
+ GList *v;
+ EVCardAttributeParam *p = pl->data;
+
+ if (g_strcmp0 (EVC_TYPE, e_vcard_attribute_param_get_name (p)) != 0)
+ continue;
+
+ v = e_vcard_attribute_param_get_values (p);
+ while (v && v->data) {
+ if (g_ascii_strcasecmp ((const gchar *) v->data, "HOME") == 0) {
+ description = "home";
+ break;
+ } else if (g_ascii_strcasecmp ((const gchar *) v->data, "WORK") == 0) {
+ description = "work";
+ break;
+ }
+
+ v = v->next;
+ }
+ }
+ }
+
+ sf = couchdb_document_contact_email_new (email, description);
list = g_slist_append (list, sf);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]