Merge lp:~rodrigo-moya/evolution-couchdb/fix-title-confusion into lp:evolution-couchdb

Proposed by Rodrigo Moya
Status: Merged
Approved by: Elliot Murphy
Approved revision: 134
Merge reported by: Rodrigo Moya
Merged at revision: not available
Proposed branch: lp:~rodrigo-moya/evolution-couchdb/fix-title-confusion
Merge into: lp:evolution-couchdb
Diff against target: 98 lines (+30/-11)
1 file modified
addressbook/e-book-backend-couchdb.c (+30/-11)
To merge this branch: bzr merge lp:~rodrigo-moya/evolution-couchdb/fix-title-confusion
Reviewer Review Type Date Requested Status
Elliot Murphy (community) Approve
Review via email: mp+22959@code.launchpad.net

Description of the change

Deal correctly with composed names and use correct EContact field for job_title

To post a comment you must log in.
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

To compile this branch, btw, you'd need to have this other branch: https://launchpad.net/~rodrigo-moya/couchdb-glib/add-missing-name-fields/+merge/22955

Revision history for this message
Elliot Murphy (statik) wrote :

Excellent! Glad to get rid of another data loss in contacts.

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 2010-04-06 18:07:58 +0000
3+++ addressbook/e-book-backend-couchdb.c 2010-04-07 15:54:21 +0000
4@@ -54,6 +54,7 @@
5 GSList *list, *sl;
6 GList *attr_list;
7 CouchdbStructField *app_annotations;
8+ EContactName contact_name;
9
10 if (!desktopcouch_document_is_contact (document))
11 return NULL;
12@@ -85,10 +86,18 @@
13 couchdb_document_get_revision (document));
14
15 e_contact_set (contact, E_CONTACT_UID, (const gpointer) couchdb_document_get_id (document));
16- e_contact_set (contact, E_CONTACT_GIVEN_NAME,
17- (const gpointer) desktopcouch_document_contact_get_first_name (document));
18- e_contact_set (contact, E_CONTACT_FAMILY_NAME,
19- (const gpointer) desktopcouch_document_contact_get_last_name (document));
20+
21+ contact_name.family = desktopcouch_document_contact_get_last_name (document);
22+ contact_name.given = desktopcouch_document_contact_get_first_name (document);
23+ contact_name.additional = desktopcouch_document_contact_get_middle_name (document);
24+ contact_name.prefixes = desktopcouch_document_contact_get_title (document);
25+ contact_name.suffixes = desktopcouch_document_contact_get_suffix (document);
26+ e_contact_set (contact, E_CONTACT_NAME, (const gpointer) &contact_name);
27+
28+ str = e_contact_name_to_string (&contact_name);
29+ e_contact_set (contact, E_CONTACT_FULL_NAME, (const gpointer) str);
30+ g_free (str);
31+
32 e_contact_set (contact, E_CONTACT_NICKNAME,
33 (const gpointer) desktopcouch_document_contact_get_nick_name (document));
34 e_contact_set (contact, E_CONTACT_SPOUSE,
35@@ -99,8 +108,6 @@
36 e_contact_set (contact, E_CONTACT_ORG_UNIT,
37 (const gpointer) desktopcouch_document_contact_get_department (document));
38 e_contact_set (contact, E_CONTACT_TITLE,
39- (const gpointer) desktopcouch_document_contact_get_title (document));
40- e_contact_set (contact, E_CONTACT_ROLE,
41 (const gpointer) desktopcouch_document_contact_get_job_title (document));
42 e_contact_set (contact, E_CONTACT_MANAGER,
43 (const gpointer) desktopcouch_document_contact_get_manager_name (document));
44@@ -724,6 +731,7 @@
45 CouchdbDocument *document;
46 gint i;
47 CouchdbStructField *postal_address, *app_annotations;
48+ EContactName *contact_name;
49
50 /* create the CouchDBDocument to put on the database */
51 document = desktopcouch_document_contact_new (couchdb_backend->couchdb);
52@@ -736,15 +744,26 @@
53 if (str)
54 couchdb_document_set_revision (document, str);
55
56- desktopcouch_document_contact_set_first_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
57- desktopcouch_document_contact_set_last_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));
58+ contact_name = (EContactName *) e_contact_get (contact, E_CONTACT_NAME);
59+ if (contact_name != NULL) {
60+ if (contact_name->prefixes != NULL)
61+ desktopcouch_document_contact_set_title (document, (const char *) contact_name->prefixes);
62+ if (contact_name->given != NULL)
63+ desktopcouch_document_contact_set_first_name (document, (const char *) contact_name->given);
64+ if (contact_name->additional != NULL)
65+ desktopcouch_document_contact_set_middle_name (document, (const gchar *) contact_name->additional);
66+ if (contact_name->family != NULL)
67+ desktopcouch_document_contact_set_last_name (document, (const char *) contact_name->family);
68+ if (contact_name->suffixes != NULL)
69+ desktopcouch_document_contact_set_suffix (document, (const char *) contact_name->suffixes);
70+ }
71+
72 desktopcouch_document_contact_set_nick_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_NICKNAME));
73 desktopcouch_document_contact_set_spouse_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_SPOUSE));
74
75 desktopcouch_document_contact_set_company (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG));
76 desktopcouch_document_contact_set_department (document, (const char *) e_contact_get_const (contact, E_CONTACT_ORG_UNIT));
77- desktopcouch_document_contact_set_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_TITLE));
78- desktopcouch_document_contact_set_job_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_ROLE));
79+ desktopcouch_document_contact_set_job_title (document, (const char *) e_contact_get_const (contact, E_CONTACT_TITLE));
80 desktopcouch_document_contact_set_manager_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_MANAGER));
81 desktopcouch_document_contact_set_assistant_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_ASSISTANT));
82 desktopcouch_document_contact_set_office (document, (const char *) e_contact_get_const (contact, E_CONTACT_OFFICE));
83@@ -1421,6 +1440,7 @@
84 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_GIVEN_NAME)));
85 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FAMILY_NAME)));
86 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FULL_NAME)));
87+ fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NAME)));
88 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NICKNAME)));
89 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_SPOUSE)));
90 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
91@@ -1437,7 +1457,6 @@
92 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG)));
93 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG_UNIT)));
94 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_TITLE)));
95- fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ROLE)));
96 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_MANAGER)));
97 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ASSISTANT)));
98 fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_OFFICE)));

Subscribers

People subscribed via source and target branches