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
1=== modified file 'addressbook/e-book-backend-couchdb.c'
2--- addressbook/e-book-backend-couchdb.c 2009-08-19 17:03:34 +0000
3+++ addressbook/e-book-backend-couchdb.c 2009-08-21 12:27:37 +0000
4@@ -43,15 +43,36 @@
5 return NULL;
6
7 contact = e_contact_new ();
8+ e_vcard_add_attribute_with_value (E_VCARD (contact),
9+ e_vcard_attribute_new (NULL, COUCHDB_REVISION_PROP),
10+ couchdb_document_get_revision (document));
11+
12 e_contact_set (contact, E_CONTACT_UID, (const gpointer) couchdb_document_get_id (document));
13 e_contact_set (contact, E_CONTACT_GIVEN_NAME,
14 (const gpointer) couchdb_document_contact_get_first_name (document));
15 e_contact_set (contact, E_CONTACT_FAMILY_NAME,
16 (const gpointer) couchdb_document_contact_get_last_name (document));
17+ e_contact_set (contact, E_CONTACT_NICKNAME,
18+ (const gpointer) couchdb_document_contact_get_nick_name (document));
19+ e_contact_set (contact, E_CONTACT_SPOUSE,
20+ (const gpointer) couchdb_document_contact_get_spouse_name (document));
21
22- e_vcard_add_attribute_with_value (E_VCARD (contact),
23- e_vcard_attribute_new (NULL, COUCHDB_REVISION_PROP),
24- couchdb_document_get_revision (document));
25+ e_contact_set (contact, E_CONTACT_ORG,
26+ (const gpointer) couchdb_document_contact_get_company (document));
27+ e_contact_set (contact, E_CONTACT_ORG_UNIT,
28+ (const gpointer) couchdb_document_contact_get_department (document));
29+ e_contact_set (contact, E_CONTACT_TITLE,
30+ (const gpointer) couchdb_document_contact_get_title (document));
31+ e_contact_set (contact, E_CONTACT_ROLE,
32+ (const gpointer) couchdb_document_contact_get_job_title (document));
33+ e_contact_set (contact, E_CONTACT_MANAGER,
34+ (const gpointer) couchdb_document_contact_get_manager_name (document));
35+ e_contact_set (contact, E_CONTACT_ASSISTANT,
36+ (const gpointer) couchdb_document_contact_get_assistant_name (document));
37+ e_contact_set (contact, E_CONTACT_OFFICE,
38+ (const gpointer) couchdb_document_contact_get_office (document));
39+ e_contact_set (contact, E_CONTACT_NOTE,
40+ (const gpointer) couchdb_document_contact_get_notes (document));
41
42 /* parse email addresses */
43 attr_list = NULL;
44@@ -259,6 +280,18 @@
45 }
46 }
47
48+ /* wedding date */
49+ str = (char *) couchdb_document_contact_get_wedding_date (document);
50+ if (str) {
51+ EContactDate *dt;
52+
53+ dt = e_contact_date_from_string (str);
54+ if (dt) {
55+ e_contact_set (contact, E_CONTACT_ANNIVERSARY, (const gpointer) dt);
56+ e_contact_date_free (dt);
57+ }
58+ }
59+
60 /* application annotations */
61 if (couchdb_document_has_field (document, "application_annotations")) {
62 CouchDBStructField *annotations = couchdb_document_get_application_annotations (document);
63@@ -415,6 +448,17 @@
64
65 couchdb_document_contact_set_first_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
66 couchdb_document_contact_set_last_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));
67+ couchdb_document_contact_set_nick_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_NICKNAME));
68+ couchdb_document_contact_set_spouse_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_SPOUSE));
69+
70+ couchdb_document_contact_set_company (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG));
71+ couchdb_document_contact_set_department (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG_UNIT));
72+ couchdb_document_contact_set_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_TITLE));
73+ couchdb_document_contact_set_job_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_ROLE));
74+ couchdb_document_contact_set_manager_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_MANAGER));
75+ couchdb_document_contact_set_assistant_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_ASSISTANT));
76+ couchdb_document_contact_set_office (document, (const char *) e_contact_get_const (contact, E_CONTACT_OFFICE));
77+ couchdb_document_contact_set_notes (document, (const char *) e_contact_get_const (contact, E_CONTACT_NOTE));
78
79 /* email addresses */
80 list = NULL;
81@@ -519,6 +563,15 @@
82 g_free (dt_str);
83 }
84
85+ /* wedding date */
86+ dt = (EContactDate *) e_contact_get_const (contact, E_CONTACT_ANNIVERSARY);
87+ if (dt) {
88+ char *dt_str = e_contact_date_to_string (dt);
89+ couchdb_document_contact_set_wedding_date (document, (const char *) dt_str);
90+
91+ g_free (dt_str);
92+ }
93+
94 /* application annotations */
95 str = e_vcard_attribute_get_value (e_vcard_get_attribute (E_VCARD (contact), COUCHDB_APPLICATION_ANNOTATIONS_PROP));
96 if (str) {
97@@ -615,8 +668,6 @@
98 if (error) {
99 g_warning ("Could not get CouchDB database info: %s", error->message);
100 g_error_free (error);
101-
102- return GNOME_Evolution_Addressbook_NoSuchBook;
103 }
104
105 if (only_if_exists)
106@@ -626,8 +677,12 @@
107 error = NULL;
108 if (!couchdb_create_database (couchdb_backend->couchdb,
109 couchdb_backend->dbname,
110- &error))
111+ &error)) {
112+ g_warning ("Could not create 'contacts' database: %s", error->message);
113+ g_error_free (error);
114+
115 return GNOME_Evolution_Addressbook_PermissionDenied;
116+ }
117 } else
118 couchdb_database_info_unref (db_info);
119
120@@ -929,6 +984,20 @@
121 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_GIVEN_NAME)));
122 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FAMILY_NAME)));
123 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FULL_NAME)));
124+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NICKNAME)));
125+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_SPOUSE)));
126+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
127+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ANNIVERSARY)));
128+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NOTE)));
129+
130+ /* Company fields */
131+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG)));
132+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG_UNIT)));
133+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_TITLE)));
134+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ROLE)));
135+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_MANAGER)));
136+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ASSISTANT)));
137+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_OFFICE)));
138
139 /* Email addresses */
140 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_1)));
141@@ -957,7 +1026,6 @@
142 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_HOME)));
143 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_WORK)));
144 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_OTHER)));
145- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
146
147 e_data_book_respond_get_supported_fields (book, opid,
148 GNOME_Evolution_Addressbook_Success, fields);

Subscribers

People subscribed via source and target branches