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

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 68
Merged at revision: 72
Proposed branch: lp:~renatofilho/address-book-service/fix-1222994
Merge into: lp:address-book-service
Diff against target: 206 lines (+42/-19)
3 files modified
qcontacts/contacts-service.cpp (+33/-19)
src/addressbook-adaptor.cpp (+5/-0)
src/addressbook-adaptor.h (+4/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-service/fix-1222994
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+184709@code.launchpad.net

Commit message

Fixed service respaw on QContact plugin.

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
Bill Filler (bfiller) wrote :

this doesn't fix the bug but does change the behavior. if I stop address-book-service the contacts view still shows the existing contacts which is different (the list used to be cleared). But then if I click on a contact to see it's details nothing happens. I would have expected an error or expected the service to be auto started by dbus activation when I'm requesting a detail.

Also, if service is stopped and you try to add a new contact the UI just spins an animation forever when you press the save button. It should either display an error or auto start the service via dbus activation

review: Needs Fixing
68. By Renato Araujo Oliveira Filho

Clear contact list if the service disappear;
Re-start the service if the service disappear;

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

tested, works

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qcontacts/contacts-service.cpp'
2--- qcontacts/contacts-service.cpp 2013-09-10 18:44:50 +0000
3+++ qcontacts/contacts-service.cpp 2013-09-11 22:08:54 +0000
4@@ -82,13 +82,11 @@
5 {
6 while(!m_pendingRequests.isEmpty()) {
7 QPointer<QContactAbstractRequest> request = m_pendingRequests.takeFirst();
8- if (request) {
9- QContactManagerEngine::updateRequestState(request,
10- QContactAbstractRequest::CanceledState);
11- }
12+ request->cancel();
13+ request->waitForFinished();
14 }
15+ m_runningRequests.clear();
16
17- Q_ASSERT(m_runningRequests.size() == 0);
18 delete m_serviceWatcher;
19 }
20
21@@ -98,10 +96,10 @@
22 if (name == CPIM_SERVICE_NAME) {
23 if (!newOwner.isEmpty()) {
24 // service appear
25- QMetaObject::invokeMethod(this, "initialize", Qt::QueuedConnection);
26+ initialize();
27 } else if (!m_iface.isNull()) {
28 // lost service
29- QMetaObject::invokeMethod(this, "deinitialize", Qt::QueuedConnection);
30+ deinitialize();
31 }
32 }
33 }
34@@ -138,15 +136,32 @@
35
36 void GaleraContactsService::deinitialize()
37 {
38+ Q_FOREACH(RequestData* rData, m_runningRequests) {
39+ rData->cancel();
40+ rData->request()->waitForFinished();
41+ rData->setError(QContactManager::UnspecifiedError);
42+ }
43+
44+ //clear contacts
45+ Q_EMIT contactsRemoved(m_contactIds);
46+
47 if (!m_iface.isNull()) {
48 m_id.clear();
49 m_contacts.clear();
50 m_contactIds.clear();
51 m_relationships.clear();
52 m_orderedRelationships.clear();
53- m_iface.clear();
54 Q_EMIT serviceChanged();
55 }
56+
57+ // this will make the service re-initialize
58+ QDBusMessage result = m_iface->call("ping");
59+ if (result.type() == QDBusMessage::ErrorMessage) {
60+ qWarning() << result.errorName() << result.errorMessage();
61+ m_serviceIsReady = false;
62+ } else {
63+ m_serviceIsReady = m_iface.data()->property("isReady").toBool();
64+ }
65 }
66
67 bool GaleraContactsService::isOnline() const
68@@ -156,9 +171,8 @@
69
70 void GaleraContactsService::fetchContactsById(QtContacts::QContactFetchByIdRequest *request)
71 {
72- qDebug() << Q_FUNC_INFO;
73-
74 if (!isOnline()) {
75+ qWarning() << "Server is not online";
76 RequestData::setError(request);
77 return;
78 }
79@@ -184,9 +198,8 @@
80
81 void GaleraContactsService::fetchContacts(QtContacts::QContactFetchRequest *request)
82 {
83- qDebug() << Q_FUNC_INFO;
84-
85 if (!isOnline()) {
86+ qWarning() << "Server is not online";
87 RequestData::setError(request);
88 return;
89 }
90@@ -238,8 +251,8 @@
91
92 void GaleraContactsService::fetchContactsPage(RequestData *request)
93 {
94- qDebug() << Q_FUNC_INFO;
95 if (!isOnline() || !request->isLive()) {
96+ qWarning() << "Server is not online";
97 destroyRequest(request);
98 return;
99 }
100@@ -264,8 +277,6 @@
101
102 void GaleraContactsService::fetchContactsDone(RequestData *request, QDBusPendingCallWatcher *call)
103 {
104- qDebug() << Q_FUNC_INFO;
105-
106 if (!request->isLive()) {
107 destroyRequest(request);
108 return;
109@@ -319,7 +330,6 @@
110
111 void GaleraContactsService::saveContact(QtContacts::QContactSaveRequest *request)
112 {
113- qDebug() << Q_FUNC_INFO;
114 QList<QContact> contacts = request->contacts();
115 QStringList vcards = VCardParser::contactToVcard(contacts);
116
117@@ -349,8 +359,8 @@
118 }
119 void GaleraContactsService::createContacts(QtContacts::QContactSaveRequest *request, QStringList &contacts)
120 {
121- qDebug() << Q_FUNC_INFO;
122 if (!isOnline()) {
123+ qWarning() << "Server is not online";
124 RequestData::setError(request);
125 return;
126 }
127@@ -375,8 +385,6 @@
128
129 void GaleraContactsService::createContactsDone(RequestData *request, QDBusPendingCallWatcher *call)
130 {
131- qDebug() << Q_FUNC_INFO;
132-
133 if (!request->isLive()) {
134 destroyRequest(request);
135 return;
136@@ -408,6 +416,7 @@
137 void GaleraContactsService::removeContact(QContactRemoveRequest *request)
138 {
139 if (!isOnline()) {
140+ qWarning() << "Server is not online";
141 RequestData::setError(request);
142 return;
143 }
144@@ -460,6 +469,7 @@
145 {
146 qDebug() << Q_FUNC_INFO;
147 if (!isOnline()) {
148+ qWarning() << "Server is not online";
149 RequestData::setError(request);
150 return;
151 }
152@@ -536,14 +546,18 @@
153 void GaleraContactsService::addRequest(QtContacts::QContactAbstractRequest *request)
154 {
155 qDebug() << Q_FUNC_INFO << request->state();
156+
157 if (!m_serviceIsReady) {
158 m_pendingRequests << QPointer<QtContacts::QContactAbstractRequest>(request);
159 return;
160 }
161+
162 if (!isOnline()) {
163+ qWarning() << "Server is not online";
164 QContactManagerEngine::updateRequestState(request, QContactAbstractRequest::FinishedState);
165 return;
166 }
167+
168 Q_ASSERT(request->state() == QContactAbstractRequest::ActiveState);
169 switch (request->type()) {
170 case QContactAbstractRequest::ContactFetchRequest:
171
172=== modified file 'src/addressbook-adaptor.cpp'
173--- src/addressbook-adaptor.cpp 2013-06-20 13:18:10 +0000
174+++ src/addressbook-adaptor.cpp 2013-09-11 22:08:54 +0000
175@@ -103,4 +103,9 @@
176 return m_addressBook->isReady();
177 }
178
179+bool AddressBookAdaptor::ping()
180+{
181+ return true;
182+}
183+
184 } //namespace
185
186=== modified file 'src/addressbook-adaptor.h'
187--- src/addressbook-adaptor.h 2013-06-20 13:18:10 +0000
188+++ src/addressbook-adaptor.h 2013-09-11 22:08:54 +0000
189@@ -51,6 +51,9 @@
190 " <arg direction=\"out\" type=\"a(ss)\" name=\"errorMap\"/>\n"
191 " </signal>\n"
192 " <signal name=\"ready\"/>\n"
193+" <method name=\"ping\">\n"
194+" <arg direction=\"out\" type=\"b\"/>\n"
195+" </method>\n"
196 " <method name=\"availableSources\">\n"
197 " <arg direction=\"out\" type=\"a(sb)\"/>\n"
198 " <annotation value=\"SourceList\" name=\"com.trolltech.QtDBus.QtTypeName.Out0\"/>\n"
199@@ -107,6 +110,7 @@
200 QString linkContacts(const QStringList &contacts);
201 bool unlinkContacts(const QString &parentId, const QStringList &contactsIds);
202 bool isReady();
203+ bool ping();
204
205 Q_SIGNALS:
206 void contactsAdded(const QStringList &ids);

Subscribers

People subscribed via source and target branches