[evolution-couchdb] Support a lot of new fields for contacts
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-couchdb] Support a lot of new fields for contacts
- Date: Sat, 22 Aug 2009 10:00:37 +0000 (UTC)
commit 8499f1b55d8d1448724fe3a2801643bef2aef112
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Sat Aug 22 12:00:21 2009 +0200
Support a lot of new fields for contacts
Don't return an error if the database is not found in CouchDB, since that
prevented the database creation to be attempted
addressbook/e-book-backend-couchdb.c | 84 ++++++++++++++++++++++++++++++---
1 files changed, 76 insertions(+), 8 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index 9b5a4b1..454d573 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -43,15 +43,36 @@ vcard_from_couch_document (CouchDBDocument *document)
return NULL;
contact = e_contact_new ();
+ e_vcard_add_attribute_with_value (E_VCARD (contact),
+ e_vcard_attribute_new (NULL, COUCHDB_REVISION_PROP),
+ 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) couchdb_document_contact_get_first_name (document));
e_contact_set (contact, E_CONTACT_FAMILY_NAME,
(const gpointer) couchdb_document_contact_get_last_name (document));
-
- e_vcard_add_attribute_with_value (E_VCARD (contact),
- e_vcard_attribute_new (NULL, COUCHDB_REVISION_PROP),
- couchdb_document_get_revision (document));
+ e_contact_set (contact, E_CONTACT_NICKNAME,
+ (const gpointer) couchdb_document_contact_get_nick_name (document));
+ e_contact_set (contact, E_CONTACT_SPOUSE,
+ (const gpointer) couchdb_document_contact_get_spouse_name (document));
+
+ e_contact_set (contact, E_CONTACT_ORG,
+ (const gpointer) couchdb_document_contact_get_company (document));
+ e_contact_set (contact, E_CONTACT_ORG_UNIT,
+ (const gpointer) couchdb_document_contact_get_department (document));
+ e_contact_set (contact, E_CONTACT_TITLE,
+ (const gpointer) couchdb_document_contact_get_title (document));
+ e_contact_set (contact, E_CONTACT_ROLE,
+ (const gpointer) couchdb_document_contact_get_job_title (document));
+ e_contact_set (contact, E_CONTACT_MANAGER,
+ (const gpointer) couchdb_document_contact_get_manager_name (document));
+ e_contact_set (contact, E_CONTACT_ASSISTANT,
+ (const gpointer) couchdb_document_contact_get_assistant_name (document));
+ e_contact_set (contact, E_CONTACT_OFFICE,
+ (const gpointer) couchdb_document_contact_get_office (document));
+ e_contact_set (contact, E_CONTACT_NOTE,
+ (const gpointer) couchdb_document_contact_get_notes (document));
/* parse email addresses */
attr_list = NULL;
@@ -259,6 +280,18 @@ vcard_from_couch_document (CouchDBDocument *document)
}
}
+ /* wedding date */
+ str = (char *) couchdb_document_contact_get_wedding_date (document);
+ if (str) {
+ EContactDate *dt;
+
+ dt = e_contact_date_from_string (str);
+ if (dt) {
+ e_contact_set (contact, E_CONTACT_ANNIVERSARY, (const gpointer) dt);
+ e_contact_date_free (dt);
+ }
+ }
+
/* application annotations */
if (couchdb_document_has_field (document, "application_annotations")) {
CouchDBStructField *annotations = couchdb_document_get_application_annotations (document);
@@ -415,6 +448,17 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
couchdb_document_contact_set_first_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
couchdb_document_contact_set_last_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));
+ couchdb_document_contact_set_nick_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_NICKNAME));
+ couchdb_document_contact_set_spouse_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_SPOUSE));
+
+ couchdb_document_contact_set_company (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG));
+ couchdb_document_contact_set_department (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG_UNIT));
+ couchdb_document_contact_set_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_TITLE));
+ couchdb_document_contact_set_job_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_ROLE));
+ couchdb_document_contact_set_manager_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_MANAGER));
+ couchdb_document_contact_set_assistant_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_ASSISTANT));
+ couchdb_document_contact_set_office (document, (const char *) e_contact_get_const (contact, E_CONTACT_OFFICE));
+ couchdb_document_contact_set_notes (document, (const char *) e_contact_get_const (contact, E_CONTACT_NOTE));
/* email addresses */
list = NULL;
@@ -519,6 +563,15 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
g_free (dt_str);
}
+ /* wedding date */
+ dt = (EContactDate *) e_contact_get_const (contact, E_CONTACT_ANNIVERSARY);
+ if (dt) {
+ char *dt_str = e_contact_date_to_string (dt);
+ couchdb_document_contact_set_wedding_date (document, (const char *) dt_str);
+
+ g_free (dt_str);
+ }
+
/* application annotations */
str = e_vcard_attribute_get_value (e_vcard_get_attribute (E_VCARD (contact), COUCHDB_APPLICATION_ANNOTATIONS_PROP));
if (str) {
@@ -615,8 +668,6 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
if (error) {
g_warning ("Could not get CouchDB database info: %s", error->message);
g_error_free (error);
-
- return GNOME_Evolution_Addressbook_NoSuchBook;
}
if (only_if_exists)
@@ -626,8 +677,12 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
error = NULL;
if (!couchdb_create_database (couchdb_backend->couchdb,
couchdb_backend->dbname,
- &error))
+ &error)) {
+ g_warning ("Could not create 'contacts' database: %s", error->message);
+ g_error_free (error);
+
return GNOME_Evolution_Addressbook_PermissionDenied;
+ }
} else
couchdb_database_info_unref (db_info);
@@ -929,6 +984,20 @@ 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_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)));
+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ANNIVERSARY)));
+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NOTE)));
+
+ /* Company fields */
+ 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)));
/* Email addresses */
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_1)));
@@ -957,7 +1026,6 @@ e_book_backend_couchdb_get_supported_fields (EBookBackend *backend,
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_HOME)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_WORK)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_OTHER)));
- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
e_data_book_respond_get_supported_fields (book, opid,
GNOME_Evolution_Addressbook_Success, fields);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]