[evolution-couchdb] Deal correctly with composed names and use correct EContact field for job_title
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-couchdb] Deal correctly with composed names and use correct EContact field for job_title
- Date: Thu, 8 Apr 2010 16:16:10 +0000 (UTC)
commit 571b80ae88da235433d75b6100c6df14c8b5923b
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Thu Apr 8 18:16:01 2010 +0200
Deal correctly with composed names and use correct EContact field for job_title
addressbook/e-book-backend-couchdb.c | 41 ++++++++++++++++++++++++---------
1 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index a330b3e..e2cc184 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -54,6 +54,7 @@ vcard_from_couch_document (CouchdbDocument *document)
GSList *list, *sl;
GList *attr_list;
CouchdbStructField *app_annotations;
+ EContactName contact_name;
if (!desktopcouch_document_is_contact (document))
return NULL;
@@ -85,10 +86,18 @@ vcard_from_couch_document (CouchdbDocument *document)
couchdb_document_get_revision (document));
e_contact_set (contact, E_CONTACT_UID, (const gpointer) couchdb_document_get_id (document));
- e_contact_set (contact, E_CONTACT_GIVEN_NAME,
- (const gpointer) desktopcouch_document_contact_get_first_name (document));
- e_contact_set (contact, E_CONTACT_FAMILY_NAME,
- (const gpointer) desktopcouch_document_contact_get_last_name (document));
+
+ contact_name.family = desktopcouch_document_contact_get_last_name (document);
+ contact_name.given = desktopcouch_document_contact_get_first_name (document);
+ contact_name.additional = desktopcouch_document_contact_get_middle_name (document);
+ contact_name.prefixes = desktopcouch_document_contact_get_title (document);
+ contact_name.suffixes = desktopcouch_document_contact_get_suffix (document);
+ e_contact_set (contact, E_CONTACT_NAME, (const gpointer) &contact_name);
+
+ str = e_contact_name_to_string (&contact_name);
+ e_contact_set (contact, E_CONTACT_FULL_NAME, (const gpointer) str);
+ g_free (str);
+
e_contact_set (contact, E_CONTACT_NICKNAME,
(const gpointer) desktopcouch_document_contact_get_nick_name (document));
e_contact_set (contact, E_CONTACT_SPOUSE,
@@ -99,8 +108,6 @@ vcard_from_couch_document (CouchdbDocument *document)
e_contact_set (contact, E_CONTACT_ORG_UNIT,
(const gpointer) desktopcouch_document_contact_get_department (document));
e_contact_set (contact, E_CONTACT_TITLE,
- (const gpointer) desktopcouch_document_contact_get_title (document));
- e_contact_set (contact, E_CONTACT_ROLE,
(const gpointer) desktopcouch_document_contact_get_job_title (document));
e_contact_set (contact, E_CONTACT_MANAGER,
(const gpointer) desktopcouch_document_contact_get_manager_name (document));
@@ -724,6 +731,7 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
CouchdbDocument *document;
gint i;
CouchdbStructField *postal_address, *app_annotations;
+ EContactName *contact_name;
/* create the CouchDBDocument to put on the database */
document = desktopcouch_document_contact_new (couchdb_backend->couchdb);
@@ -736,15 +744,26 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
if (str)
couchdb_document_set_revision (document, str);
- desktopcouch_document_contact_set_first_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
- desktopcouch_document_contact_set_last_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));
+ contact_name = (EContactName *) e_contact_get (contact, E_CONTACT_NAME);
+ if (contact_name != NULL) {
+ if (contact_name->prefixes != NULL)
+ desktopcouch_document_contact_set_title (document, (const char *) contact_name->prefixes);
+ if (contact_name->given != NULL)
+ desktopcouch_document_contact_set_first_name (document, (const char *) contact_name->given);
+ if (contact_name->additional != NULL)
+ desktopcouch_document_contact_set_middle_name (document, (const gchar *) contact_name->additional);
+ if (contact_name->family != NULL)
+ desktopcouch_document_contact_set_last_name (document, (const char *) contact_name->family);
+ if (contact_name->suffixes != NULL)
+ desktopcouch_document_contact_set_suffix (document, (const char *) contact_name->suffixes);
+ }
+
desktopcouch_document_contact_set_nick_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_NICKNAME));
desktopcouch_document_contact_set_spouse_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_SPOUSE));
desktopcouch_document_contact_set_company (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG));
desktopcouch_document_contact_set_department (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG_UNIT));
- desktopcouch_document_contact_set_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_TITLE));
- desktopcouch_document_contact_set_job_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_ROLE));
+ desktopcouch_document_contact_set_job_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_TITLE));
desktopcouch_document_contact_set_manager_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_MANAGER));
desktopcouch_document_contact_set_assistant_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_ASSISTANT));
desktopcouch_document_contact_set_office (document, (const char *) e_contact_get_const (contact, E_CONTACT_OFFICE));
@@ -1421,6 +1440,7 @@ e_book_backend_couchdb_get_supported_fields (EBookBackend *backend,
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_GIVEN_NAME)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FAMILY_NAME)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FULL_NAME)));
+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NAME)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NICKNAME)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_SPOUSE)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
@@ -1437,7 +1457,6 @@ e_book_backend_couchdb_get_supported_fields (EBookBackend *backend,
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG_UNIT)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_TITLE)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ROLE)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_MANAGER)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ASSISTANT)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_OFFICE)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]