Merge lp:~rodrigo-moya/evolution-couchdb/set-descriptions into lp:evolution-couchdb

Proposed by Rodrigo Moya
Status: Superseded
Proposed branch: lp:~rodrigo-moya/evolution-couchdb/set-descriptions
Merge into: lp:evolution-couchdb
Diff against target: None lines
To merge this branch: bzr merge lp:~rodrigo-moya/evolution-couchdb/set-descriptions
Reviewer Review Type Date Requested Status
dobey (community) Needs Fixing
Chad Miller (community) Approve
Review via email: mp+9092@code.launchpad.net

This proposal has been superseded by a proposal from 2009-07-21.

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

Set the description for email addresses correctly

Revision history for this message
Chad Miller (cmiller) wrote :

Looks good.

My only complaint is that I hate integers mapped to true/false, as in the three strcmp()s. "String compare", on equality, returns zero -- which is false in C. I really want a comparison to zero, or at least a comment there explaining what it means.

review: Approve
Revision history for this message
dobey (dobey) wrote :

As already suggested, please use comparison against 0 for the strcmp/g_strcasecmp calls. Also, I think you might need to check that the return of e_vcard_attribute_param_get_name is not NULL, if it could ever return NULL, otherwise strcmp() will crash.

review: Needs Fixing
43. By Rodrigo Moya

Handle NULL values with g_strcmp0 rather than plain strcmp

Unmerged revisions

43. By Rodrigo Moya

Handle NULL values with g_strcmp0 rather than plain strcmp

42. By Rodrigo Moya

Set the description for email addresses correctly

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-07-01 16:03:33 +0000
3+++ addressbook/e-book-backend-couchdb.c 2009-07-21 12:05:53 +0000
4@@ -161,7 +161,7 @@
5 {
6 EContactDate *dt;
7 GSList *list;
8- gint i;
9+ GList *attr_list, *al;
10 const char *str;
11 CouchDBDocument *document;
12 EContactAddress *contact_address;
13@@ -178,14 +178,44 @@
14
15 /* email addresses */
16 list = NULL;
17- for (i = E_CONTACT_FIRST_EMAIL_ID; i <= E_CONTACT_LAST_EMAIL_ID; i++) {
18+ attr_list = e_contact_get_attributes (contact, E_CONTACT_EMAIL);
19+ for (al = attr_list; al != NULL; al = al->next) {
20 const gchar *email;
21+ EVCardAttribute *attr = (EVCardAttribute *) al->data;
22
23- email = e_contact_get_const (contact, i);
24+ email = e_vcard_attribute_get_value (attr);
25 if (email) {
26 CouchDBStructField *sf;
27-
28- sf = couchdb_document_contact_email_new (email, /* FIXME */ NULL);
29+ GList *params;
30+ const gchar *description = NULL;
31+
32+ params = e_vcard_attribute_get_params (attr);
33+ if (params) {
34+ GList *pl;
35+
36+ for (pl = params; pl != NULL; pl = pl->next) {
37+ GList *v;
38+ EVCardAttributeParam *p = pl->data;
39+
40+ if (strcmp (EVC_TYPE, e_vcard_attribute_param_get_name (p)))
41+ continue;
42+
43+ v = e_vcard_attribute_param_get_values (p);
44+ while (v && v->data) {
45+ if (!g_ascii_strcasecmp ((const gchar *) v->data, "HOME")) {
46+ description = "home";
47+ break;
48+ } else if (!g_ascii_strcasecmp ((const gchar *) v->data, "WORK")) {
49+ description = "work";
50+ break;
51+ }
52+
53+ v = v->next;
54+ }
55+ }
56+ }
57+
58+ sf = couchdb_document_contact_email_new (email, description);
59 list = g_slist_append (list, sf);
60 }
61 }

Subscribers

People subscribed via source and target branches