Merge lp:~renatofilho/address-book-service/fix-1207773 into lp:address-book-service

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 74
Merged at revision: 74
Proposed branch: lp:~renatofilho/address-book-service/fix-1207773
Merge into: lp:address-book-service
Diff against target: 182 lines (+51/-27)
2 files modified
src/qindividual.cpp (+5/-1)
src/update-contact-request.cpp (+46/-26)
To merge this branch: bzr merge lp:~renatofilho/address-book-service/fix-1207773
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+185961@code.launchpad.net

Commit message

Fixed contact organization information parse.
Fixed memory leak with QByteArray.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qindividual.cpp'
2--- src/qindividual.cpp 2013-07-26 13:39:56 +0000
3+++ src/qindividual.cpp 2013-09-17 01:54:28 +0000
4@@ -394,13 +394,17 @@
5 QString field;
6
7 field = QString::fromUtf8(folks_role_get_organisation_name(role));
8- if (field.isEmpty()) {
9+ if (!field.isEmpty()) {
10 org.setName(field);
11 }
12 field = QString::fromUtf8(folks_role_get_title(role));
13 if (!field.isEmpty()) {
14 org.setTitle(field);
15 }
16+ field = QString::fromUtf8(folks_role_get_role(role));
17+ if (!field.isEmpty()) {
18+ org.setRole(field);
19+ }
20 bool isPref = false;
21 DetailContextParser::parseParameters(org, fd, &isPref);
22 org.setDetailUri(QString("%1.%2").arg(index).arg(fieldIndex++));
23
24=== modified file 'src/update-contact-request.cpp'
25--- src/update-contact-request.cpp 2013-07-24 19:09:06 +0000
26+++ src/update-contact-request.cpp 2013-09-17 01:54:28 +0000
27@@ -164,13 +164,20 @@
28 QContactAddress addr = static_cast<QContactAddress>(newDetail);
29
30 FolksPostalAddress *pa;
31- pa = folks_postal_address_new(addr.postOfficeBox().toUtf8().data(),
32+ QByteArray postOfficeBox = addr.postOfficeBox().toUtf8();
33+ QByteArray street = addr.street().toUtf8();
34+ QByteArray locality = addr.locality().toUtf8();
35+ QByteArray region = addr.region().toUtf8();
36+ QByteArray postcode = addr.postcode().toUtf8();
37+ QByteArray country = addr.country().toUtf8();
38+
39+ pa = folks_postal_address_new(postOfficeBox.constData(),
40 NULL,
41- addr.street().toUtf8().data(),
42- addr.locality().toUtf8().data(),
43- addr.region().toUtf8().data(),
44- addr.postcode().toUtf8().data(),
45- addr.country().toUtf8().data(),
46+ street.constData(),
47+ locality.constData(),
48+ region.constData(),
49+ postcode.constData(),
50+ country.constData(),
51 NULL,
52 NULL);
53
54@@ -211,7 +218,8 @@
55 QString formattedUri = avatarUri.toString(QUrl::RemoveUserInfo);
56
57 if(!formattedUri.isEmpty()) {
58- GFile *avatarFile = g_file_new_for_uri(formattedUri.toUtf8().data());
59+ QByteArray uriUtf8 = formattedUri.toUtf8();
60+ GFile *avatarFile = g_file_new_for_uri(uriUtf8.constData());
61 avatarFileIcon = G_FILE_ICON(g_file_icon_new(avatarFile));
62 g_object_unref(avatarFile);
63 }
64@@ -277,8 +285,9 @@
65 fullName = label.label();
66 }
67
68+ QByteArray fullNameUtf8 = fullName.toUtf8();
69 folks_name_details_change_full_name(FOLKS_NAME_DETAILS(persona),
70- fullName.toUtf8().data(),
71+ fullNameUtf8.constData(),
72 (GAsyncReadyCallback) updateDetailsDone,
73 this);
74 } else {
75@@ -309,7 +318,8 @@
76 QContactEmailAddress email = static_cast<QContactEmailAddress>(newDetail);
77 FolksEmailFieldDetails *field;
78
79- field = folks_email_field_details_new(email.emailAddress().toUtf8().data(), NULL);
80+ QByteArray emailAddress = email.emailAddress().toUtf8();
81+ field = folks_email_field_details_new(emailAddress.constData(), NULL);
82 DetailContextParser::parseContext(FOLKS_ABSTRACT_FIELD_DETAILS(field), newDetail, newDetail == prefDetail);
83 gee_collection_add(GEE_COLLECTION(newSet), field);
84 g_object_unref(field);
85@@ -338,11 +348,16 @@
86 if (newDetails.count()) {
87 QContactName name = static_cast<QContactName>(newDetails[0]);
88
89- sn = folks_structured_name_new(name.lastName().toUtf8().data(),
90- name.firstName().toUtf8().data(),
91- name.middleName().toUtf8().data(),
92- name.prefix().toUtf8().data(),
93- name.suffix().toUtf8().data());
94+ QByteArray lastName = name.lastName().toUtf8();
95+ QByteArray firstName = name.firstName().toUtf8();
96+ QByteArray middleName = name.middleName().toUtf8();
97+ QByteArray prefix = name.prefix().toUtf8();
98+ QByteArray suffix = name.suffix().toUtf8();
99+ sn = folks_structured_name_new(lastName.constData(),
100+ firstName.constData(),
101+ middleName.constData(),
102+ prefix.constData(),
103+ suffix.constData());
104 }
105
106 folks_name_details_change_structured_name(FOLKS_NAME_DETAILS(persona),
107@@ -372,8 +387,9 @@
108 nicknameValue = nickname.nickname();
109 }
110
111+ QByteArray nicknameValueUtf8 = nicknameValue.toUtf8();
112 folks_name_details_change_nickname(FOLKS_NAME_DETAILS(persona),
113- nicknameValue.toUtf8().data(),
114+ nicknameValueUtf8.constData(),
115 (GAsyncReadyCallback) updateDetailsDone,
116 this);
117 } else {
118@@ -399,7 +415,8 @@
119 QContactNote note = static_cast<QContactNote>(newDetail);
120 FolksNoteFieldDetails *field;
121
122- field = folks_note_field_details_new(note.note().toUtf8().data(), 0, 0);
123+ QByteArray noteUtf8 = note.note().toUtf8();
124+ field = folks_note_field_details_new(noteUtf8.constData(), 0, 0);
125 DetailContextParser::parseContext(FOLKS_ABSTRACT_FIELD_DETAILS(field), newDetail, newDetail == prefDetail);
126 gee_collection_add(GEE_COLLECTION(newSet), field);
127 g_object_unref(field);
128@@ -438,12 +455,13 @@
129 FolksImFieldDetails *field;
130
131 if (account.protocol() != QContactOnlineAccount::ProtocolUnknown) {
132- field = folks_im_field_details_new(account.accountUri().toUtf8().data(), NULL);
133+ QByteArray accountUri = account.accountUri().toUtf8();
134+ field = folks_im_field_details_new(accountUri.constData(), NULL);
135 DetailContextParser::parseContext(FOLKS_ABSTRACT_FIELD_DETAILS(field), account, account == prefDetail);
136
137 QString protocolName(DetailContextParser::accountProtocolName(account.protocol()));
138- qDebug() << "Append protocol" << protocolName << account.accountUri();
139- gee_multi_map_set(imMap, protocolName.toUtf8().data(), field);
140+ QByteArray protocolNameUtf8 = protocolName.toUtf8();
141+ gee_multi_map_set(imMap, protocolNameUtf8.constData(), field);
142
143 g_object_unref(field);
144 }
145@@ -483,12 +501,12 @@
146 FolksRoleFieldDetails *field;
147 FolksRole *roleValue;
148
149- const gchar* title = org.title().isEmpty() ? "" : org.title().toUtf8().data();
150- const gchar* name = org.name().isEmpty() ? "" : org.name().toUtf8().data();
151- const gchar* roleName = org.role().isEmpty() ? "" : org.role().toUtf8().data();
152+ QByteArray title = org.title().isEmpty() ? "" : org.title().toUtf8();
153+ QByteArray name = org.name().isEmpty() ? "" : org.name().toUtf8();
154+ QByteArray roleName = org.role().isEmpty() ? "" : org.role().toUtf8();
155
156- roleValue = folks_role_new(title, name, "");
157- folks_role_set_role(roleValue, roleName);
158+ roleValue = folks_role_new(title.constData(), name.constData(), "");
159+ folks_role_set_role(roleValue, roleName.constData());
160 field = folks_role_field_details_new(roleValue, NULL);
161
162 DetailContextParser::parseContext(FOLKS_ABSTRACT_FIELD_DETAILS(field), newDetail, newDetail == prefDetail);
163@@ -530,7 +548,8 @@
164 QContactPhoneNumber phone = static_cast<QContactPhoneNumber>(newDetail);
165 FolksPhoneFieldDetails *field;
166
167- field = folks_phone_field_details_new(phone.number().toUtf8().data(), NULL);
168+ QByteArray phoneNumber = phone.number().toUtf8();
169+ field = folks_phone_field_details_new(phoneNumber.constData(), NULL);
170 DetailContextParser::parseContext(FOLKS_ABSTRACT_FIELD_DETAILS(field), newDetail, newDetail == prefDetail);
171 gee_collection_add(GEE_COLLECTION(newSet), field);
172 g_object_unref(field);
173@@ -569,7 +588,8 @@
174 QContactUrl url = static_cast<QContactUrl>(newDetail);
175 FolksUrlFieldDetails *field;
176
177- field = folks_url_field_details_new(url.url().toUtf8().data(), NULL);
178+ QByteArray urlValue = url.url().toUtf8();
179+ field = folks_url_field_details_new(urlValue.constData(), NULL);
180 DetailContextParser::parseContext(FOLKS_ABSTRACT_FIELD_DETAILS(field), newDetail, prefDetail == newDetail);
181 gee_collection_add(GEE_COLLECTION(newSet), field);
182 g_object_unref(field);

Subscribers

People subscribed via source and target branches