Merge lp:~rodrigo-moya/evolution-couchdb/add-new-fields into lp:evolution-couchdb

Proposed by Rodrigo Moya
Status: Merged
Approved by: Rodrigo Moya
Approved revision: 59
Merge reported by: Rodrigo Moya
Merged at revision: not available
Proposed branch: lp:~rodrigo-moya/evolution-couchdb/add-new-fields
Merge into: lp:evolution-couchdb
Diff against target: None lines
To merge this branch: bzr merge lp:~rodrigo-moya/evolution-couchdb/add-new-fields
Reviewer Review Type Date Requested Status
Joshua Blount (community) Approve
Review via email: mp+10525@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

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

Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

BTW, this branch depends on this one (https://code.edge.launchpad.net/~rodrigo-moya/couchdb-glib/more-contact-fields) from couchdb-glib

Revision history for this message
Joshua Blount (jblount) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addressbook/e-book-backend-couchdb.c'
--- addressbook/e-book-backend-couchdb.c 2009-08-19 17:03:34 +0000
+++ addressbook/e-book-backend-couchdb.c 2009-08-21 12:27:37 +0000
@@ -43,15 +43,36 @@
43 return NULL;43 return NULL;
4444
45 contact = e_contact_new ();45 contact = e_contact_new ();
46 e_vcard_add_attribute_with_value (E_VCARD (contact),
47 e_vcard_attribute_new (NULL, COUCHDB_REVISION_PROP),
48 couchdb_document_get_revision (document));
49
46 e_contact_set (contact, E_CONTACT_UID, (const gpointer) couchdb_document_get_id (document));50 e_contact_set (contact, E_CONTACT_UID, (const gpointer) couchdb_document_get_id (document));
47 e_contact_set (contact, E_CONTACT_GIVEN_NAME,51 e_contact_set (contact, E_CONTACT_GIVEN_NAME,
48 (const gpointer) couchdb_document_contact_get_first_name (document));52 (const gpointer) couchdb_document_contact_get_first_name (document));
49 e_contact_set (contact, E_CONTACT_FAMILY_NAME,53 e_contact_set (contact, E_CONTACT_FAMILY_NAME,
50 (const gpointer) couchdb_document_contact_get_last_name (document));54 (const gpointer) couchdb_document_contact_get_last_name (document));
55 e_contact_set (contact, E_CONTACT_NICKNAME,
56 (const gpointer) couchdb_document_contact_get_nick_name (document));
57 e_contact_set (contact, E_CONTACT_SPOUSE,
58 (const gpointer) couchdb_document_contact_get_spouse_name (document));
5159
52 e_vcard_add_attribute_with_value (E_VCARD (contact),60 e_contact_set (contact, E_CONTACT_ORG,
53 e_vcard_attribute_new (NULL, COUCHDB_REVISION_PROP),61 (const gpointer) couchdb_document_contact_get_company (document));
54 couchdb_document_get_revision (document));62 e_contact_set (contact, E_CONTACT_ORG_UNIT,
63 (const gpointer) couchdb_document_contact_get_department (document));
64 e_contact_set (contact, E_CONTACT_TITLE,
65 (const gpointer) couchdb_document_contact_get_title (document));
66 e_contact_set (contact, E_CONTACT_ROLE,
67 (const gpointer) couchdb_document_contact_get_job_title (document));
68 e_contact_set (contact, E_CONTACT_MANAGER,
69 (const gpointer) couchdb_document_contact_get_manager_name (document));
70 e_contact_set (contact, E_CONTACT_ASSISTANT,
71 (const gpointer) couchdb_document_contact_get_assistant_name (document));
72 e_contact_set (contact, E_CONTACT_OFFICE,
73 (const gpointer) couchdb_document_contact_get_office (document));
74 e_contact_set (contact, E_CONTACT_NOTE,
75 (const gpointer) couchdb_document_contact_get_notes (document));
5576
56 /* parse email addresses */77 /* parse email addresses */
57 attr_list = NULL;78 attr_list = NULL;
@@ -259,6 +280,18 @@
259 }280 }
260 }281 }
261282
283 /* wedding date */
284 str = (char *) couchdb_document_contact_get_wedding_date (document);
285 if (str) {
286 EContactDate *dt;
287
288 dt = e_contact_date_from_string (str);
289 if (dt) {
290 e_contact_set (contact, E_CONTACT_ANNIVERSARY, (const gpointer) dt);
291 e_contact_date_free (dt);
292 }
293 }
294
262 /* application annotations */295 /* application annotations */
263 if (couchdb_document_has_field (document, "application_annotations")) {296 if (couchdb_document_has_field (document, "application_annotations")) {
264 CouchDBStructField *annotations = couchdb_document_get_application_annotations (document);297 CouchDBStructField *annotations = couchdb_document_get_application_annotations (document);
@@ -415,6 +448,17 @@
415448
416 couchdb_document_contact_set_first_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));449 couchdb_document_contact_set_first_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
417 couchdb_document_contact_set_last_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));450 couchdb_document_contact_set_last_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));
451 couchdb_document_contact_set_nick_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_NICKNAME));
452 couchdb_document_contact_set_spouse_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_SPOUSE));
453
454 couchdb_document_contact_set_company (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG));
455 couchdb_document_contact_set_department (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG_UNIT));
456 couchdb_document_contact_set_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_TITLE));
457 couchdb_document_contact_set_job_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_ROLE));
458 couchdb_document_contact_set_manager_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_MANAGER));
459 couchdb_document_contact_set_assistant_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_ASSISTANT));
460 couchdb_document_contact_set_office (document, (const char *) e_contact_get_const (contact, E_CONTACT_OFFICE));
461 couchdb_document_contact_set_notes (document, (const char *) e_contact_get_const (contact, E_CONTACT_NOTE));
418462
419 /* email addresses */463 /* email addresses */
420 list = NULL;464 list = NULL;
@@ -519,6 +563,15 @@
519 g_free (dt_str);563 g_free (dt_str);
520 }564 }
521565
566 /* wedding date */
567 dt = (EContactDate *) e_contact_get_const (contact, E_CONTACT_ANNIVERSARY);
568 if (dt) {
569 char *dt_str = e_contact_date_to_string (dt);
570 couchdb_document_contact_set_wedding_date (document, (const char *) dt_str);
571
572 g_free (dt_str);
573 }
574
522 /* application annotations */575 /* application annotations */
523 str = e_vcard_attribute_get_value (e_vcard_get_attribute (E_VCARD (contact), COUCHDB_APPLICATION_ANNOTATIONS_PROP));576 str = e_vcard_attribute_get_value (e_vcard_get_attribute (E_VCARD (contact), COUCHDB_APPLICATION_ANNOTATIONS_PROP));
524 if (str) {577 if (str) {
@@ -615,8 +668,6 @@
615 if (error) {668 if (error) {
616 g_warning ("Could not get CouchDB database info: %s", error->message);669 g_warning ("Could not get CouchDB database info: %s", error->message);
617 g_error_free (error);670 g_error_free (error);
618
619 return GNOME_Evolution_Addressbook_NoSuchBook;
620 }671 }
621672
622 if (only_if_exists)673 if (only_if_exists)
@@ -626,8 +677,12 @@
626 error = NULL;677 error = NULL;
627 if (!couchdb_create_database (couchdb_backend->couchdb,678 if (!couchdb_create_database (couchdb_backend->couchdb,
628 couchdb_backend->dbname,679 couchdb_backend->dbname,
629 &error))680 &error)) {
681 g_warning ("Could not create 'contacts' database: %s", error->message);
682 g_error_free (error);
683
630 return GNOME_Evolution_Addressbook_PermissionDenied;684 return GNOME_Evolution_Addressbook_PermissionDenied;
685 }
631 } else686 } else
632 couchdb_database_info_unref (db_info);687 couchdb_database_info_unref (db_info);
633688
@@ -929,6 +984,20 @@
929 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_GIVEN_NAME)));984 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_GIVEN_NAME)));
930 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FAMILY_NAME)));985 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FAMILY_NAME)));
931 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FULL_NAME)));986 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FULL_NAME)));
987 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NICKNAME)));
988 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_SPOUSE)));
989 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
990 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ANNIVERSARY)));
991 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NOTE)));
992
993 /* Company fields */
994 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG)));
995 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG_UNIT)));
996 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_TITLE)));
997 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ROLE)));
998 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_MANAGER)));
999 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ASSISTANT)));
1000 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_OFFICE)));
9321001
933 /* Email addresses */1002 /* Email addresses */
934 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_1)));1003 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_1)));
@@ -957,7 +1026,6 @@
957 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_HOME)));1026 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_HOME)));
958 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_WORK)));1027 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_WORK)));
959 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_OTHER)));1028 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_OTHER)));
960 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
9611029
962 e_data_book_respond_get_supported_fields (book, opid,1030 e_data_book_respond_get_supported_fields (book, opid,
963 GNOME_Evolution_Addressbook_Success, fields);1031 GNOME_Evolution_Addressbook_Success, fields);

Subscribers

People subscribed via source and target branches