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

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Merged at revision: 99
Proposed branch: lp:~renatofilho/address-book-service/fix-1233785
Merge into: lp:address-book-service
Prerequisite: lp:~renatofilho/address-book-service/fix-1269561
Diff against target: 247 lines (+141/-9)
7 files modified
common/vcard-parser.cpp (+35/-0)
common/vcard-parser.h (+2/-0)
lib/qindividual.cpp (+15/-3)
qcontacts/contacts-service.cpp (+1/-1)
tests/unittest/CMakeLists.txt (+1/-1)
tests/unittest/dummy-backend.cpp (+8/-4)
tests/unittest/readonly-prop-test.cpp (+79/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-service/fix-1233785
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+206191@code.launchpad.net

This proposal supersedes a proposal from 2014-02-06.

Commit message

Skip IM field if it was marked as folks automatic field.

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list. NO

* Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes) YES

* Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator? YES

* Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/address-book-service) on device or emulator? YES

* If you changed the UI, was the change specified/approved by design? N/A

* If you changed the packaging (debian), did you subscribe a core-dev to this MP? N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote : Posted in a previous version of this proposal

doesn't work right
Steps to reproduce:
1) Add a contact with an email <email address hidden>
2) save the contact
3) edit the contct, add jabber <email address hidden>
4) save the contact
5) this all works, now try to delete the contact and you can't delete it

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
103. By Renato Araujo Oliveira Filho

Merged parent branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve
Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/vcard-parser.cpp'
2--- common/vcard-parser.cpp 2013-11-05 19:26:25 +0000
3+++ common/vcard-parser.cpp 2014-02-24 17:08:01 +0000
4@@ -80,6 +80,22 @@
5 prop.setParameters(params);
6 }
7
8+ // export read-only info
9+ if (detail.accessConstraints().testFlag(QContactDetail::ReadOnly)) {
10+ QVersitProperty &prop = toBeAdded->last();
11+ QMultiHash<QString, QString> params = prop.parameters();
12+ params.insert(galera::VCardParser::ReadOnlyFieldName, "YES");
13+ prop.setParameters(params);
14+ }
15+
16+ // export Irremovable info
17+ if (detail.accessConstraints().testFlag(QContactDetail::Irremovable)) {
18+ QVersitProperty &prop = toBeAdded->last();
19+ QMultiHash<QString, QString> params = prop.parameters();
20+ params.insert(galera::VCardParser::IrremovableFieldName, "YES");
21+ prop.setParameters(params);
22+ }
23+
24 switch (detail.type()) {
25 case QContactDetail::TypeAvatar:
26 {
27@@ -151,6 +167,23 @@
28 det.setDetailUri(pid);
29 }
30
31+ bool ro = (property.parameters().value(galera::VCardParser::ReadOnlyFieldName, "NO") == "YES");
32+ bool irremovable = (property.parameters().value(galera::VCardParser::IrremovableFieldName, "NO") == "YES");
33+ if (ro && irremovable) {
34+ QContactDetail &det = updatedDetails->last();
35+ QContactManagerEngine::setDetailAccessConstraints(&det,
36+ QContactDetail::ReadOnly |
37+ QContactDetail::Irremovable);
38+ } else if (ro) {
39+ QContactDetail &det = updatedDetails->last();
40+ QContactManagerEngine::setDetailAccessConstraints(&det,
41+ QContactDetail::ReadOnly);
42+ } else if (irremovable) {
43+ QContactDetail &det = updatedDetails->last();
44+ QContactManagerEngine::setDetailAccessConstraints(&det,
45+ QContactDetail::Irremovable);
46+ }
47+
48 if (updatedDetails->size() == 0) {
49 return;
50 }
51@@ -204,6 +237,8 @@
52 const QString VCardParser::PidMapFieldName = QStringLiteral("CLIENTPIDMAP");
53 const QString VCardParser::PidFieldName = QStringLiteral("PID");
54 const QString VCardParser::PrefParamName = QStringLiteral("PREF");
55+const QString VCardParser::IrremovableFieldName = QStringLiteral("IRREMOVABLE");
56+const QString VCardParser::ReadOnlyFieldName = QStringLiteral("READ-ONLY");
57
58 static QMap<QtContacts::QContactDetail::DetailType, QString> prefferedActions()
59 {
60
61=== modified file 'common/vcard-parser.h'
62--- common/vcard-parser.h 2013-07-21 01:09:23 +0000
63+++ common/vcard-parser.h 2014-02-24 17:08:01 +0000
64@@ -32,6 +32,8 @@
65 static const QString PidMapFieldName;
66 static const QString PidFieldName;
67 static const QString PrefParamName;
68+ static const QString IrremovableFieldName;
69+ static const QString ReadOnlyFieldName;
70 static const QMap<QtContacts::QContactDetail::DetailType, QString> PreferredActionNames;
71
72 static QStringList contactToVcard(QList<QtContacts::QContact> contacts);
73
74=== modified file 'lib/qindividual.cpp'
75--- lib/qindividual.cpp 2014-02-24 17:08:01 +0000
76+++ lib/qindividual.cpp 2014-02-24 17:08:01 +0000
77@@ -187,9 +187,17 @@
78 {
79 if (!detail.isEmpty()) {
80 QtContacts::QContactDetail cpy(detail);
81- if (readOnly) {
82- QContactManagerEngine::setDetailAccessConstraints(&cpy, QContactDetail::ReadOnly);
83- }
84+ QtContacts::QContactDetail::AccessConstraints access;
85+ if (readOnly ||
86+ detail.accessConstraints().testFlag(QContactDetail::ReadOnly)) {
87+ access |= QContactDetail::ReadOnly;
88+ }
89+
90+ if (detail.accessConstraints().testFlag(QContactDetail::Irremovable)) {
91+ access |= QContactDetail::Irremovable;
92+ }
93+
94+ QContactManagerEngine::setDetailAccessConstraints(&cpy, access);
95 contact->appendDetail(cpy);
96 }
97 }
98@@ -589,6 +597,10 @@
99 while(gee_iterator_next(iterValues)) {
100 FolksAbstractFieldDetails *fd = FOLKS_ABSTRACT_FIELD_DETAILS(gee_iterator_get(iterValues));
101 const char *uri = (const char*) folks_abstract_field_details_get_value(fd);
102+ GeeCollection *parameters = folks_abstract_field_details_get_parameter_values(fd, "X-FOLKS-FIELD");
103+ if (parameters) {
104+ continue;
105+ }
106
107 QContactOnlineAccount account;
108 account.setAccountUri(QString::fromUtf8(uri));
109
110=== modified file 'qcontacts/contacts-service.cpp'
111--- qcontacts/contacts-service.cpp 2013-10-23 13:31:03 +0000
112+++ qcontacts/contacts-service.cpp 2014-02-24 17:08:01 +0000
113@@ -59,7 +59,7 @@
114 m_iface(0)
115 {
116 RequestData::registerMetaType();
117-
118+
119 m_serviceWatcher = new QDBusServiceWatcher(CPIM_SERVICE_NAME,
120 QDBusConnection::sessionBus(),
121 QDBusServiceWatcher::WatchForOwnerChange,
122
123=== modified file 'tests/unittest/CMakeLists.txt'
124--- tests/unittest/CMakeLists.txt 2014-02-24 17:08:01 +0000
125+++ tests/unittest/CMakeLists.txt 2014-02-24 17:08:01 +0000
126@@ -70,8 +70,8 @@
127
128 declare_test(addressbook-test True ${BASE_CLIENT_TEST_SRC})
129 declare_test(service-life-cycle-test True ${BASE_CLIENT_TEST_SRC})
130+ declare_test(readonly-prop-test True ${BASE_CLIENT_TEST_SRC})
131 declare_test(contact-link-test True ${BASE_CLIENT_TEST_SRC})
132-
133 elseif()
134 message(STATUS "DBus test runner not found. Some tests will be disabled")
135 endif()
136
137=== modified file 'tests/unittest/dummy-backend.cpp'
138--- tests/unittest/dummy-backend.cpp 2014-02-24 17:08:01 +0000
139+++ tests/unittest/dummy-backend.cpp 2014-02-24 17:08:01 +0000
140@@ -213,15 +213,19 @@
141 void DummyBackendProxy::configurePrimaryStore()
142 {
143 static const char* writableProperties[] = {
144- folks_persona_store_detail_key(FolksPersonaDetail::FOLKS_PERSONA_DETAIL_FULL_NAME),
145- folks_persona_store_detail_key(FolksPersonaDetail::FOLKS_PERSONA_DETAIL_EMAIL_ADDRESSES),
146- folks_persona_store_detail_key(FolksPersonaDetail::FOLKS_PERSONA_DETAIL_PHONE_NUMBERS),
147+ folks_persona_store_detail_key(FOLKS_PERSONA_DETAIL_FULL_NAME),
148+ folks_persona_store_detail_key(FOLKS_PERSONA_DETAIL_ALIAS),
149+ folks_persona_store_detail_key(FOLKS_PERSONA_DETAIL_NICKNAME),
150+ folks_persona_store_detail_key(FOLKS_PERSONA_DETAIL_STRUCTURED_NAME),
151+ folks_persona_store_detail_key(FOLKS_PERSONA_DETAIL_IS_FAVOURITE),
152+ folks_persona_store_detail_key(FOLKS_PERSONA_DETAIL_EMAIL_ADDRESSES),
153+ folks_persona_store_detail_key(FOLKS_PERSONA_DETAIL_PHONE_NUMBERS),
154 0
155 };
156
157 m_primaryPersonaStore = folks_dummy_persona_store_new("dummy-store",
158 "Dummy personas",
159- const_cast<char**>(writableProperties), 4);
160+ const_cast<char**>(writableProperties), 7);
161 folks_dummy_persona_store_set_persona_type(m_primaryPersonaStore, FOLKS_DUMMY_TYPE_FULL_PERSONA);
162 folks_dummy_persona_store_update_trust_level(m_primaryPersonaStore, FOLKS_PERSONA_STORE_TRUST_FULL);
163
164
165=== added file 'tests/unittest/readonly-prop-test.cpp'
166--- tests/unittest/readonly-prop-test.cpp 1970-01-01 00:00:00 +0000
167+++ tests/unittest/readonly-prop-test.cpp 2014-02-24 17:08:01 +0000
168@@ -0,0 +1,79 @@
169+/*
170+ * Copyright 2013 Canonical Ltd.
171+ *
172+ * This file is part of contact-service-app.
173+ *
174+ * contact-service-app is free software; you can redistribute it and/or modify
175+ * it under the terms of the GNU General Public License as published by
176+ * the Free Software Foundation; version 3.
177+ *
178+ * contact-service-app is distributed in the hope that it will be useful,
179+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
180+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181+ * GNU General Public License for more details.
182+ *
183+ * You should have received a copy of the GNU General Public License
184+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
185+ */
186+
187+#include "base-client-test.h"
188+#include "lib/source.h"
189+#include "common/dbus-service-defs.h"
190+#include "common/vcard-parser.h"
191+
192+#include <QObject>
193+#include <QtDBus>
194+#include <QtTest>
195+#include <QDebug>
196+#include <QtVersit>
197+
198+class ReadOnlyPropTest : public BaseClientTest
199+{
200+ Q_OBJECT
201+private:
202+ QString m_basicVcard;
203+ QString m_resultBasicVcard;
204+
205+private Q_SLOTS:
206+ void initTestCase()
207+ {
208+ BaseClientTest::initTestCase();
209+ m_basicVcard = QStringLiteral("BEGIN:VCARD\n"
210+ "VERSION:3.0\n"
211+ "N:Tal;Fulano_;de;;\n"
212+ "EMAIL:fulano_@ubuntu.com\n"
213+ "TEL;PID=1.1;TYPE=ISDN:33331410\n"
214+ "TEL;PID=1.2;TYPE=CELL:8888888\n"
215+ "URL:www.canonical.com\n"
216+ "END:VCARD");
217+ }
218+
219+ void testCreateContactAndReturnReadOlyFileds()
220+ {
221+ // call create contact
222+ QDBusReply<QString> reply = m_serverIface->call("createContact", m_basicVcard, "dummy-store");
223+
224+ // check if the returned id is valid
225+ QString newContactId = reply.value();
226+ QVERIFY(!newContactId.isEmpty());
227+
228+ // check if the cotact was created with URL as read-only field
229+ // URL is not a writable property on our dummy backend
230+ QDBusReply<QStringList> reply2 = m_dummyIface->call("listContacts");
231+ QCOMPARE(reply2.value().count(), 1);
232+
233+ QList<QtContacts::QContact> contactsCreated = galera::VCardParser::vcardToContact(reply2.value());
234+ QCOMPARE(contactsCreated.count(), 1);
235+ Q_FOREACH(QContactDetail det, contactsCreated[0].details()) {
236+ if (det.type() == QContactDetail::TypeUrl) {
237+ QVERIFY(det.accessConstraints().testFlag(QContactDetail::ReadOnly));
238+ } else {
239+ QVERIFY(!det.accessConstraints().testFlag(QContactDetail::ReadOnly));
240+ }
241+ }
242+ }
243+};
244+
245+QTEST_MAIN(ReadOnlyPropTest)
246+
247+#include "readonly-prop-test.moc"

Subscribers

People subscribed via source and target branches