Merge lp:~renatofilho/address-book-service/remove-updater into lp:address-book-service
- remove-updater
- Merge into trunk
Proposed by
Renato Araujo Oliveira Filho
Status: | Rejected |
---|---|
Rejected by: | Renato Araujo Oliveira Filho |
Proposed branch: | lp:~renatofilho/address-book-service/remove-updater |
Merge into: | lp:address-book-service |
Diff against target: |
2743 lines (+32/-2113) 33 files modified
CMakeLists.txt (+0/-1) config.h.in (+0/-7) contacts/contacts-service.cpp (+0/-8) contacts/contacts-service.h (+0/-2) contacts/qcontact-backend.cpp (+0/-1) debian/address-book-updater.install (+0/-3) debian/control (+1/-14) lib/addressbook-adaptor.cpp (+2/-13) lib/addressbook-adaptor.h (+3/-12) lib/addressbook.cpp (+11/-198) lib/addressbook.h (+3/-13) lib/qindividual.cpp (+1/-12) lib/qindividual.h (+0/-3) lib/view.cpp (+5/-9) lib/view.h (+1/-1) tests/CMakeLists.txt (+0/-1) tests/address_book_service_testability/helpers.py (+2/-2) tests/unittest/contact-sort-test.cpp (+3/-3) updater/CMakeLists.txt (+0/-49) updater/ab-i18n.h (+0/-27) updater/ab-notify-message.cpp (+0/-136) updater/ab-notify-message.h (+0/-54) updater/ab-update-adaptor.cpp (+0/-50) updater/ab-update-adaptor.h (+0/-67) updater/ab-update-buteo-import.cpp (+0/-730) updater/ab-update-buteo-import.h (+0/-74) updater/ab-update-module.cpp (+0/-28) updater/ab-update-module.h (+0/-56) updater/ab-update.cpp (+0/-366) updater/ab-update.h (+0/-87) updater/main.cpp (+0/-77) upstart/CMakeLists.txt (+0/-2) upstart/address-book-updater.conf.in (+0/-7) |
To merge this branch: | bzr merge lp:~renatofilho/address-book-service/remove-updater |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Ubuntu Phablet Team | Pending | ||
Review via email: mp+273689@code.launchpad.net |
Commit message
Remove updater app.
Reverted changes for 'safeMode'.
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote : | # |
We decided to use address-
Unmerged revisions
- 165. By Renato Araujo Oliveira Filho
-
Reverted changes for 'safeMode'.
SafeMode is not necessary anymore. We do not run an account update.
- 164. By Renato Araujo Oliveira Filho
-
Remove updater app.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2015-09-23 12:36:13 +0000 |
3 | +++ CMakeLists.txt 2015-10-07 13:33:41 +0000 |
4 | @@ -96,7 +96,6 @@ |
5 | add_subdirectory(lib) |
6 | add_subdirectory(src) |
7 | add_subdirectory(contacts) |
8 | -add_subdirectory(updater) |
9 | add_subdirectory(upstart) |
10 | add_subdirectory(dbus) |
11 | add_subdirectory(po) |
12 | |
13 | === modified file 'config.h.in' |
14 | --- config.h.in 2015-09-21 13:56:06 +0000 |
15 | +++ config.h.in 2015-10-07 13:33:41 +0000 |
16 | @@ -3,13 +3,6 @@ |
17 | |
18 | #define SETTINGS_APPLICATION "AddressBookService" |
19 | #define SETTINGS_ORG "Canonical" |
20 | -#define SETTINGS_SAFE_MODE_KEY "safe-mode" |
21 | -#define SETTINGS_INVISIBLE_SOURCES "invisible-sources" |
22 | -#define ADDRESS_BOOK_SAFE_MODE "ADDRESS_BOOK_SAFE_MODE" |
23 | -#define ADDRESS_BOOK_SHOW_INVISIBLE_PROP "show-invisible" |
24 | - |
25 | -//updater |
26 | -#define SETTINGS_BUTEO_KEY "Buteo/migration_complete" |
27 | |
28 | #define QT_PLUGINS_BINARY_DIR "@CMAKE_BINARY_DIR@" |
29 | #define TEST_DATA_DIR "@TEST_DATA_DIR@" |
30 | |
31 | === modified file 'contacts/contacts-service.cpp' |
32 | --- contacts/contacts-service.cpp 2015-09-18 14:58:37 +0000 |
33 | +++ contacts/contacts-service.cpp 2015-10-07 13:33:41 +0000 |
34 | @@ -196,7 +196,6 @@ |
35 | if (!m_iface->lastError().isValid()) { |
36 | m_serviceIsReady = m_iface.data()->property("isReady").toBool(); |
37 | connect(m_iface.data(), SIGNAL(readyChanged()), this, SLOT(onServiceReady())); |
38 | - connect(m_iface.data(), SIGNAL(safeModeChanged()), this, SIGNAL(serviceChanged())); |
39 | connect(m_iface.data(), SIGNAL(contactsAdded(QStringList)), this, SLOT(onContactsAdded(QStringList))); |
40 | connect(m_iface.data(), SIGNAL(contactsRemoved(QStringList)), this, SLOT(onContactsRemoved(QStringList))); |
41 | connect(m_iface.data(), SIGNAL(contactsUpdated(QStringList)), this, SLOT(onContactsUpdated(QStringList))); |
42 | @@ -248,7 +247,6 @@ |
43 | QDBusMessage result = m_iface->call("query", |
44 | filterStr, "", |
45 | request->fetchHint().maxCountHint(), |
46 | - m_showInvisibleContacts, |
47 | QStringList()); |
48 | if (result.type() == QDBusMessage::ErrorMessage) { |
49 | qWarning() << result.errorName() << result.errorMessage(); |
50 | @@ -309,7 +307,6 @@ |
51 | filterStr, |
52 | sortStr, |
53 | request->fetchHint().maxCountHint(), |
54 | - m_showInvisibleContacts, |
55 | QStringList()); |
56 | if (pcall.isError()) { |
57 | qWarning() << pcall.error().name() << pcall.error().message(); |
58 | @@ -779,11 +776,6 @@ |
59 | } |
60 | } |
61 | |
62 | -void GaleraContactsService::setShowInvisibleContacts(bool show) |
63 | -{ |
64 | - m_showInvisibleContacts = show; |
65 | -} |
66 | - |
67 | void GaleraContactsService::addRequest(QtContacts::QContactAbstractRequest *request) |
68 | { |
69 | if (!isOnline()) { |
70 | |
71 | === modified file 'contacts/contacts-service.h' |
72 | --- contacts/contacts-service.h 2015-09-16 13:28:23 +0000 |
73 | +++ contacts/contacts-service.h 2015-10-07 13:33:41 +0000 |
74 | @@ -66,7 +66,6 @@ |
75 | void cancelRequest(QtContacts::QContactAbstractRequest *request); |
76 | void waitRequest(QtContacts::QContactAbstractRequest *request); |
77 | void releaseRequest(QtContacts::QContactAbstractRequest *request); |
78 | - void setShowInvisibleContacts(bool show); |
79 | |
80 | Q_SIGNALS: |
81 | void contactsAdded(QList<QContactId> ids); |
82 | @@ -87,7 +86,6 @@ |
83 | QDBusServiceWatcher *m_serviceWatcher; |
84 | bool m_serviceIsReady; |
85 | int m_pageSize; |
86 | - bool m_showInvisibleContacts; |
87 | |
88 | QSharedPointer<QDBusInterface> m_iface; |
89 | QString m_serviceName; |
90 | |
91 | === modified file 'contacts/qcontact-backend.cpp' |
92 | --- contacts/qcontact-backend.cpp 2015-09-16 15:57:58 +0000 |
93 | +++ contacts/qcontact-backend.cpp 2015-10-07 13:33:41 +0000 |
94 | @@ -64,7 +64,6 @@ |
95 | GaleraManagerEngine* GaleraManagerEngine::createEngine(const QMap<QString, QString> ¶meters) |
96 | { |
97 | GaleraManagerEngine *engine = new GaleraManagerEngine(); |
98 | - engine->m_service->setShowInvisibleContacts(parameters.value(ADDRESS_BOOK_SHOW_INVISIBLE_PROP, "false").toLower() == "true"); |
99 | return engine; |
100 | } |
101 | |
102 | |
103 | === removed file 'debian/address-book-updater.install' |
104 | --- debian/address-book-updater.install 2015-09-03 20:09:42 +0000 |
105 | +++ debian/address-book-updater.install 1970-01-01 00:00:00 +0000 |
106 | @@ -1,3 +0,0 @@ |
107 | -usr/lib/*/address-book-service/address-book-updater |
108 | -usr/share/upstart/sessions/address-book-updater.conf |
109 | -usr/share/dbus-1/services/com.canonical.pim.updater.service |
110 | |
111 | === modified file 'debian/control' |
112 | --- debian/control 2015-10-01 14:48:00 +0000 |
113 | +++ debian/control 2015-10-07 13:33:41 +0000 |
114 | @@ -32,8 +32,7 @@ |
115 | Package: address-book-service |
116 | Architecture: any |
117 | Multi-Arch: same |
118 | -Depends: address-book-updater (= ${binary:Version}), |
119 | - evolution-data-server(>= 3.12.11), |
120 | +Depends: evolution-data-server(>= 3.12.11), |
121 | libfolks-eds25, |
122 | ${misc:Depends}, |
123 | ${shlibs:Depends}, |
124 | @@ -65,15 +64,3 @@ |
125 | ${shlibs:Depends}, |
126 | Description: QtContacts backend for galera contact service. |
127 | A QContactEngine implementation using address-book-service. |
128 | - |
129 | -Package: address-book-updater |
130 | -Architecture: any |
131 | -Multi-Arch: same |
132 | -Depends: buteo-sync-plugins-contacts-google, |
133 | - indicator-transfer-buteo, |
134 | - qtcontact5-galera (= ${binary:Version}), |
135 | - ${misc:Depends}, |
136 | - ${shlibs:Depends}, |
137 | -Description: Ubuntu contact service updater |
138 | - A helper program to update address book service and address book app configuration and sync files. |
139 | - |
140 | |
141 | === modified file 'lib/addressbook-adaptor.cpp' |
142 | --- lib/addressbook-adaptor.cpp 2015-09-29 14:37:03 +0000 |
143 | +++ lib/addressbook-adaptor.cpp 2015-10-07 13:33:41 +0000 |
144 | @@ -30,7 +30,6 @@ |
145 | { |
146 | setAutoRelaySignals(true); |
147 | connect(m_addressBook, SIGNAL(readyChanged()), SIGNAL(readyChanged())); |
148 | - connect(m_addressBook, SIGNAL(safeModeChanged()), SIGNAL(safeModeChanged())); |
149 | } |
150 | |
151 | AddressBookAdaptor::~AddressBookAdaptor() |
152 | @@ -106,9 +105,9 @@ |
153 | return QString(); |
154 | } |
155 | |
156 | -QDBusObjectPath AddressBookAdaptor::query(const QString &clause, const QString &sort, int maxCount, bool showInvisible, const QStringList &sources) |
157 | +QDBusObjectPath AddressBookAdaptor::query(const QString &clause, const QString &sort, int maxCount, const QStringList &sources) |
158 | { |
159 | - View *v = m_addressBook->query(clause, sort, maxCount, showInvisible, sources); |
160 | + View *v = m_addressBook->query(clause, sort, maxCount, sources); |
161 | v->registerObject(m_connection); |
162 | return QDBusObjectPath(v->dynamicObjectPath()); |
163 | } |
164 | @@ -174,14 +173,4 @@ |
165 | m_addressBook->shutdown(); |
166 | } |
167 | |
168 | -bool AddressBookAdaptor::safeMode() const |
169 | -{ |
170 | - return m_addressBook->isSafeMode(); |
171 | -} |
172 | - |
173 | -void AddressBookAdaptor::setSafeMode(bool flag) |
174 | -{ |
175 | - m_addressBook->setSafeMode(flag); |
176 | -} |
177 | - |
178 | } //namespace |
179 | |
180 | === modified file 'lib/addressbook-adaptor.h' |
181 | --- lib/addressbook-adaptor.h 2015-09-16 13:28:23 +0000 |
182 | +++ lib/addressbook-adaptor.h 2015-10-07 13:33:41 +0000 |
183 | @@ -38,7 +38,6 @@ |
184 | Q_CLASSINFO("D-Bus Introspection", "" |
185 | " <interface name=\"com.canonical.pim.AddressBook\">\n" |
186 | " <property name=\"isReady\" type=\"b\" access=\"read\"/>\n" |
187 | -" <property name=\"safeMode\" type=\"b\" access=\"readwrite\"/>\n" |
188 | " <signal name=\"contactsUpdated\">\n" |
189 | " <arg direction=\"out\" type=\"as\" name=\"ids\"/>\n" |
190 | " </signal>\n" |
191 | @@ -52,7 +51,6 @@ |
192 | " <arg direction=\"out\" type=\"a(ss)\" name=\"errorMap\"/>\n" |
193 | " </signal>\n" |
194 | " <signal name=\"readyChanged\"/>\n" |
195 | -" <signal name=\"safeModeChanged\"/>\n" |
196 | " <method name=\"ping\">\n" |
197 | " <arg direction=\"out\" type=\"b\"/>\n" |
198 | " </method>\n" |
199 | @@ -67,14 +65,14 @@ |
200 | " <method name=\"createSource\">\n" |
201 | " <arg direction=\"in\" type=\"s\"/>\n" |
202 | " <arg direction=\"in\" type=\"b\"/>\n" |
203 | -" <arg direction=\"out\" type=\"(sb)\"/>\n" |
204 | +" <arg direction=\"out\" type=\"(ssssubb)\"/>\n" |
205 | " <annotation value=\"Source\" name=\"com.trolltech.QtDBus.QtTypeName.Out0\"/>\n" |
206 | " </method>\n" |
207 | " <method name=\"createSourceForAccount\">\n" |
208 | " <arg direction=\"in\" type=\"s\"/>\n" |
209 | " <arg direction=\"in\" type=\"u\"/>\n" |
210 | " <arg direction=\"in\" type=\"b\"/>\n" |
211 | -" <arg direction=\"out\" type=\"(sb)\"/>\n" |
212 | +" <arg direction=\"out\" type=\"(ssssubb)\"/>\n" |
213 | " <annotation value=\"Source\" name=\"com.trolltech.QtDBus.QtTypeName.Out0\"/>\n" |
214 | " </method>\n" |
215 | " <method name=\"removeSource\">\n" |
216 | @@ -88,7 +86,6 @@ |
217 | " <arg direction=\"in\" type=\"s\" name=\"clause\"/>\n" |
218 | " <arg direction=\"in\" type=\"s\" name=\"sort\"/>\n" |
219 | " <arg direction=\"in\" type=\"i\" name=\"maxCount\"/>\n" |
220 | -" <arg direction=\"in\" type=\"b\" name=\"showDiabledContacts\"/>\n" |
221 | " <arg direction=\"in\" type=\"as\" name=\"sources\"/>\n" |
222 | " <arg direction=\"out\" type=\"o\"/>\n" |
223 | " </method>\n" |
224 | @@ -122,14 +119,11 @@ |
225 | " </interface>\n" |
226 | "") |
227 | Q_PROPERTY(bool isReady READ isReady NOTIFY readyChanged) |
228 | - Q_PROPERTY(bool safeMode READ safeMode WRITE setSafeMode NOTIFY safeModeChanged) |
229 | |
230 | public: |
231 | AddressBookAdaptor(const QDBusConnection &connection, AddressBook *parent); |
232 | virtual ~AddressBookAdaptor(); |
233 | |
234 | - void setSafeMode(bool flag); |
235 | - |
236 | public Q_SLOTS: |
237 | SourceList availableSources(const QDBusMessage &message); |
238 | Source source(const QDBusMessage &message); |
239 | @@ -140,19 +134,17 @@ |
240 | const QDBusMessage &message); |
241 | bool removeSource(const QString &sourceId, const QDBusMessage &message); |
242 | QStringList sortFields(); |
243 | - QDBusObjectPath query(const QString &clause, const QString &sort, int maxCount, bool showInvisible, const QStringList &sources); |
244 | + QDBusObjectPath query(const QString &clause, const QString &sort, int maxCount, const QStringList &sources); |
245 | int removeContacts(const QStringList &contactIds, const QDBusMessage &message); |
246 | QString createContact(const QString &contact, const QString &source, const QDBusMessage &message); |
247 | QStringList updateContacts(const QStringList &contacts, const QDBusMessage &message); |
248 | QString linkContacts(const QStringList &contacts); |
249 | bool unlinkContacts(const QString &parentId, const QStringList &contactsIds); |
250 | bool isReady(); |
251 | - bool safeMode() const; |
252 | bool ping(); |
253 | void purgeContacts(const QString &since, const QString &sourceId, const QDBusMessage &message); |
254 | void shutDown() const; |
255 | |
256 | - |
257 | Q_SIGNALS: |
258 | void contactsAdded(const QStringList &ids); |
259 | void contactsRemoved(const QStringList &ids); |
260 | @@ -160,7 +152,6 @@ |
261 | void asyncOperationResult(QMap<QString, QString> errors); |
262 | void readyChanged(); |
263 | void reloaded(); |
264 | - void safeModeChanged(); |
265 | |
266 | private: |
267 | AddressBook *m_addressBook; |
268 | |
269 | === modified file 'lib/addressbook.cpp' |
270 | --- lib/addressbook.cpp 2015-09-29 12:52:30 +0000 |
271 | +++ lib/addressbook.cpp 2015-10-07 13:33:41 +0000 |
272 | @@ -143,7 +143,6 @@ |
273 | namespace galera |
274 | { |
275 | int AddressBook::m_sigQuitFd[2] = {0, 0}; |
276 | -QSettings AddressBook::m_settings(SETTINGS_ORG, SETTINGS_APPLICATION); |
277 | |
278 | AddressBook::AddressBook(QObject *parent) |
279 | : QObject(parent), |
280 | @@ -157,9 +156,7 @@ |
281 | m_isAboutToReload(false), |
282 | m_individualsChangedDetailedId(0), |
283 | m_notifyIsQuiescentHandlerId(0), |
284 | - m_connection(QDBusConnection::sessionBus()), |
285 | - m_messagingMenu(0), |
286 | - m_messagingMenuMessage(0) |
287 | + m_connection(QDBusConnection::sessionBus()) |
288 | { |
289 | if (qEnvironmentVariableIsSet(ALTERNATIVE_CPIM_SERVICE_NAME)) { |
290 | m_serviceName = qgetenv(ALTERNATIVE_CPIM_SERVICE_NAME); |
291 | @@ -170,21 +167,10 @@ |
292 | prepareUnixSignals(); |
293 | connectWithEDS(); |
294 | connect(this, SIGNAL(readyChanged()), SLOT(checkCompatibility())); |
295 | - connect(this, SIGNAL(safeModeChanged()), SLOT(onSafeModeChanged())); |
296 | } |
297 | |
298 | AddressBook::~AddressBook() |
299 | { |
300 | - if (m_messagingMenuMessage) { |
301 | - g_object_unref(m_messagingMenuMessage); |
302 | - m_messagingMenuMessage = 0; |
303 | - } |
304 | - |
305 | - if (m_messagingMenu) { |
306 | - g_object_unref(m_messagingMenu); |
307 | - m_messagingMenu = 0; |
308 | - } |
309 | - |
310 | if (m_individualAggregator) { |
311 | qWarning() << "Addressbook destructor called while running, you should call shutdown first"; |
312 | shutdown(); |
313 | @@ -285,44 +271,6 @@ |
314 | } |
315 | } |
316 | |
317 | -void AddressBook::checkCompatibility() |
318 | -{ |
319 | - QByteArray envSafeMode = qgetenv(ADDRESS_BOOK_SAFE_MODE); |
320 | - if (!envSafeMode.isEmpty()) { |
321 | - return; |
322 | - } |
323 | - GError *gError = NULL; |
324 | - ESourceRegistry *r = e_source_registry_new_sync(NULL, &gError); |
325 | - if (gError) { |
326 | - qWarning() << "Fail to check compatibility" << gError->message; |
327 | - g_error_free(gError); |
328 | - return; |
329 | - } |
330 | - |
331 | - bool enableSafeMode = false; |
332 | - GList *sources = e_source_registry_list_sources(r, E_SOURCE_EXTENSION_ADDRESS_BOOK); |
333 | - for(GList *l = sources; l != NULL; l = l->next) { |
334 | - ESource *s = E_SOURCE(l->data); |
335 | - if ((strcmp(e_source_get_uid(s), "system-address-book") != 0) && |
336 | - !e_source_has_extension(s, E_SOURCE_EXTENSION_UBUNTU)) { |
337 | - qDebug() << "Source does not contains UBUNTU extension" << QString::fromUtf8(e_source_get_display_name(s)); |
338 | - enableSafeMode = true; |
339 | - break; |
340 | - } |
341 | - } |
342 | - |
343 | - g_list_free_full(sources, g_object_unref); |
344 | - g_object_unref(r); |
345 | - |
346 | - if (enableSafeMode) { |
347 | - qWarning() << "Enabling safe mode"; |
348 | - setSafeMode(true); |
349 | - Q_EMIT safeModeChanged(); |
350 | - } else { |
351 | - qDebug() << "Safe mode not necessary"; |
352 | - } |
353 | -} |
354 | - |
355 | void AddressBook::shutdown() |
356 | { |
357 | m_isAboutToQuit = true; |
358 | @@ -619,64 +567,6 @@ |
359 | self->prepareFolks(); |
360 | } |
361 | |
362 | -void AddressBook::onSafeModeMessageActivated(MessagingMenuMessage *message, |
363 | - const char *actionId, |
364 | - GVariant *param, |
365 | - AddressBook *self) |
366 | -{ |
367 | - if (self->m_messagingMenu) { |
368 | - if (self->m_messagingMenuMessage) { |
369 | - messaging_menu_app_remove_message(self->m_messagingMenu, self->m_messagingMenuMessage); |
370 | - g_object_unref(self->m_messagingMenuMessage); |
371 | - self->m_messagingMenuMessage = 0; |
372 | - } |
373 | - |
374 | - messaging_menu_app_unregister(self->m_messagingMenu); |
375 | - g_object_unref(self->m_messagingMenu); |
376 | - self->m_messagingMenu = 0; |
377 | - } |
378 | - |
379 | - url_dispatch_send("application:///address-book-app.desktop", NULL, NULL); |
380 | -} |
381 | - |
382 | -bool AddressBook::isSafeMode() |
383 | -{ |
384 | - QByteArray envSafeMode = qgetenv(ADDRESS_BOOK_SAFE_MODE); |
385 | - if (!envSafeMode.isEmpty()) { |
386 | - return (envSafeMode.toLower() == "on" ? true : false); |
387 | - } else { |
388 | - return m_settings.value(SETTINGS_SAFE_MODE_KEY, false).toBool(); |
389 | - } |
390 | -} |
391 | - |
392 | -void AddressBook::setSafeMode(bool flag) |
393 | -{ |
394 | - QByteArray envSafeMode = qgetenv(ADDRESS_BOOK_SAFE_MODE); |
395 | - if (!envSafeMode.isEmpty()) { |
396 | - return; |
397 | - } |
398 | - |
399 | - if (m_settings.value(SETTINGS_SAFE_MODE_KEY, false).toBool() != flag) { |
400 | - m_settings.setValue(SETTINGS_SAFE_MODE_KEY, flag); |
401 | - if (!flag) { |
402 | - // make all contacts visible |
403 | - Q_FOREACH(ContactEntry *entry, m_contacts->values()) { |
404 | - QIndividual *i = entry->individual(); |
405 | - if (!i->isVisible()) { |
406 | - i->setVisible(true); |
407 | - } |
408 | - } |
409 | - // clear invisible sources list |
410 | - m_settings.setValue(SETTINGS_INVISIBLE_SOURCES, QStringList()); |
411 | - } |
412 | - m_settings.sync(); |
413 | - // avoid send a ton of signals since the service will be reseted after the |
414 | - // 'safeModeChanged' signal |
415 | - m_notifyContactUpdate->clear(); |
416 | - Q_EMIT safeModeChanged(); |
417 | - } |
418 | -} |
419 | - |
420 | void AddressBook::createSourceDone(GObject *source, |
421 | GAsyncResult *res, |
422 | void *data) |
423 | @@ -700,14 +590,6 @@ |
424 | cData->m_accountId, |
425 | false, |
426 | cData->m_setAsPrimary); |
427 | - // if in safe mode source will be invisible, we use that to avoid invalid states |
428 | - if (isSafeMode()) { |
429 | - qDebug() << "Source will be invisible until safe mode is gone" << cData->m_sourceId << e_source_get_uid(cData->m_source); |
430 | - QStringList iSources = cData->m_addressbook->m_settings.value(SETTINGS_INVISIBLE_SOURCES).toStringList(); |
431 | - iSources << e_source_get_uid(cData->m_source); |
432 | - cData->m_addressbook->m_settings.setValue(SETTINGS_INVISIBLE_SOURCES, iSources); |
433 | - cData->m_addressbook->m_settings.sync(); |
434 | - } |
435 | } |
436 | g_object_unref(source); |
437 | QDBusMessage reply = cData->m_message.createReply(QVariant::fromValue<Source>(src)); |
438 | @@ -839,12 +721,6 @@ |
439 | } |
440 | } |
441 | |
442 | - // If running on safe mode only the system-address-book is writable |
443 | - if (isSafeMode() && (id != "system-address-book")) { |
444 | - qDebug() << "Running safe mode for source" << id << displayName; |
445 | - canWrite = false; |
446 | - } |
447 | - |
448 | result << Source(id, displayName, applicationId, providerName, accountId, !canWrite, isPrimary); |
449 | g_object_unref(store); |
450 | } |
451 | @@ -939,9 +815,9 @@ |
452 | return ""; |
453 | } |
454 | |
455 | -View *AddressBook::query(const QString &clause, const QString &sort, int maxCount, bool showInvisible, const QStringList &sources) |
456 | +View *AddressBook::query(const QString &clause, const QString &sort, int maxCount, const QStringList &sources) |
457 | { |
458 | - View *view = new View(clause, sort, maxCount, showInvisible, sources, m_ready ? m_contacts : 0, this); |
459 | + View *view = new View(clause, sort, maxCount, sources, m_ready ? m_contacts : 0, this); |
460 | m_views << view; |
461 | connect(view, SIGNAL(closed()), this, SLOT(viewClosed())); |
462 | return view; |
463 | @@ -954,9 +830,7 @@ |
464 | |
465 | void AddressBook::individualChanged(QIndividual *individual) |
466 | { |
467 | - if (individual->isVisible()) { |
468 | - m_notifyContactUpdate->insertChangedContacts(QSet<QString>() << individual->id()); |
469 | - } |
470 | + m_notifyContactUpdate->insertChangedContacts(QSet<QString>() << individual->id()); |
471 | } |
472 | |
473 | void AddressBook::onEdsServiceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) |
474 | @@ -971,44 +845,6 @@ |
475 | } |
476 | } |
477 | |
478 | -void AddressBook::onSafeModeChanged() |
479 | -{ |
480 | - GIcon *icon = g_themed_icon_new("address-book-app"); |
481 | - bool showUpdateComplete = false; |
482 | - |
483 | - if (m_messagingMenu == 0) { |
484 | - m_messagingMenu = messaging_menu_app_new("address-book-app.desktop"); |
485 | - messaging_menu_app_register(m_messagingMenu); |
486 | - messaging_menu_app_append_source(m_messagingMenu, MESSAGING_MENU_SOURCE_ID, icon, C::gettext("Address book service")); |
487 | - } |
488 | - |
489 | - if (m_messagingMenuMessage) { |
490 | - messaging_menu_app_remove_message(m_messagingMenu, m_messagingMenuMessage); |
491 | - g_object_unref (m_messagingMenuMessage); |
492 | - m_messagingMenuMessage = 0; |
493 | - } |
494 | - |
495 | - if (isSafeMode()) { |
496 | - m_messagingMenuMessage = messaging_menu_message_new("address-book-service-safe-mode", |
497 | - icon, |
498 | - C::gettext("Update required"), |
499 | - NULL, |
500 | - C::gettext("Your Contacts app needs to be upgraded. Only local contacts will be editable until upgrade is complete"), |
501 | - QDateTime::currentMSecsSinceEpoch() * 1000); // the value is expected to be in microseconds |
502 | - } else { |
503 | - m_messagingMenuMessage = messaging_menu_message_new("address-book-service-safe-mode", |
504 | - icon, |
505 | - C::gettext("Update complete"), |
506 | - NULL, |
507 | - C::gettext("Your Contacts app update is complete."), |
508 | - QDateTime::currentMSecsSinceEpoch() * 1000); // the value is expected to be in microseconds |
509 | - } |
510 | - |
511 | - g_signal_connect(m_messagingMenuMessage, "activate", G_CALLBACK(&AddressBook::onSafeModeMessageActivated), this); |
512 | - messaging_menu_app_append_message(m_messagingMenu, m_messagingMenuMessage, MESSAGING_MENU_SOURCE_ID, true); |
513 | - g_object_unref(icon); |
514 | -} |
515 | - |
516 | int AddressBook::removeContacts(const QStringList &contactIds, const QDBusMessage &message) |
517 | { |
518 | RemoveContactsData *data = new RemoveContactsData; |
519 | @@ -1175,32 +1011,28 @@ |
520 | } |
521 | } |
522 | |
523 | -QString AddressBook::removeContact(FolksIndividual *individual, bool *visible) |
524 | +QString AddressBook::removeContact(FolksIndividual *individual) |
525 | { |
526 | QString contactId = QString::fromUtf8(folks_individual_get_id(individual)); |
527 | ContactEntry *ci = m_contacts->take(contactId); |
528 | if (ci) { |
529 | - *visible = ci->individual()->isVisible(); |
530 | delete ci; |
531 | return contactId; |
532 | } |
533 | return QString(); |
534 | } |
535 | |
536 | -QString AddressBook::addContact(FolksIndividual *individual, bool visible) |
537 | +QString AddressBook::addContact(FolksIndividual *individual) |
538 | { |
539 | QString id = QString::fromUtf8(folks_individual_get_id(individual)); |
540 | ContactEntry *entry = m_contacts->value(id); |
541 | if (entry) { |
542 | entry->individual()->setIndividual(individual); |
543 | - entry->individual()->setVisible(visible); |
544 | - |
545 | // update contact position on map |
546 | m_contacts->updatePosition(entry); |
547 | } else { |
548 | QIndividual *i = new QIndividual(individual, m_individualAggregator); |
549 | i->addListener(this, SLOT(individualChanged(QIndividual*))); |
550 | - i->setVisible(visible); |
551 | m_contacts->insert(new ContactEntry(i)); |
552 | //TODO: Notify view |
553 | } |
554 | @@ -1217,11 +1049,6 @@ |
555 | QSet<QString> removedIds; |
556 | QSet<QString> addedIds; |
557 | QSet<QString> updatedIds; |
558 | - QStringList invisibleSources; |
559 | - |
560 | - if (isSafeMode()) { |
561 | - invisibleSources = self->m_settings.value(SETTINGS_INVISIBLE_SOURCES).toStringList(); |
562 | - } |
563 | |
564 | GeeSet *removed = gee_multi_map_get_keys(changes); |
565 | GeeIterator *iter = gee_iterable_iterator(GEE_ITERABLE(removed)); |
566 | @@ -1231,9 +1058,8 @@ |
567 | continue; |
568 | } |
569 | |
570 | - bool visible = true; |
571 | - QString cId = self->removeContact(individual, &visible); |
572 | - if (visible && !cId.isEmpty()) { |
573 | + QString cId = self->removeContact(individual); |
574 | + if (!cId.isEmpty()) { |
575 | removedIds << cId; |
576 | } |
577 | g_object_unref(individual); |
578 | @@ -1255,24 +1081,11 @@ |
579 | continue; |
580 | } |
581 | |
582 | - bool visible = true; |
583 | - if (!invisibleSources.isEmpty()) { |
584 | - GeeSet *personas = folks_individual_get_personas(individual); |
585 | - GeeIterator *iter = gee_iterable_iterator(GEE_ITERABLE(personas)); |
586 | - if (gee_iterator_next(iter)) { |
587 | - FolksPersona *persona = FOLKS_PERSONA(gee_iterator_get(iter)); |
588 | - FolksPersonaStore *ps = folks_persona_get_store(persona); |
589 | - g_object_unref(persona); |
590 | - visible = !invisibleSources.contains(folks_persona_store_get_id(ps)); |
591 | - } |
592 | - g_object_unref(iter); |
593 | - } |
594 | - |
595 | bool exists = self->m_contacts->contains(id); |
596 | - QString cId = self->addContact(individual, visible); |
597 | - if (visible && exists) { |
598 | + QString cId = self->addContact(individual); |
599 | + if (exists) { |
600 | updatedIds << cId; |
601 | - } else if (visible) { |
602 | + } else { |
603 | addedIds << cId; |
604 | } |
605 | |
606 | |
607 | === modified file 'lib/addressbook.h' |
608 | --- lib/addressbook.h 2015-09-17 15:07:41 +0000 |
609 | +++ lib/addressbook.h 2015-10-07 13:33:41 +0000 |
610 | @@ -58,19 +58,16 @@ |
611 | |
612 | // Adaptor |
613 | QString linkContacts(const QStringList &contacts); |
614 | - View *query(const QString &clause, const QString &sort, int maxCount, bool showInvisible, const QStringList &sources); |
615 | + View *query(const QString &clause, const QString &sort, int maxCount, const QStringList &sources); |
616 | QStringList sortFields(); |
617 | bool unlinkContacts(const QString &parent, const QStringList &contacts); |
618 | bool isReady() const; |
619 | - void setSafeMode(bool flag); |
620 | |
621 | - static bool isSafeMode(); |
622 | static int init(); |
623 | |
624 | Q_SIGNALS: |
625 | void stopped(); |
626 | void readyChanged(); |
627 | - void safeModeChanged(); |
628 | |
629 | public Q_SLOTS: |
630 | bool start(); |
631 | @@ -89,7 +86,6 @@ |
632 | void viewClosed(); |
633 | void individualChanged(QIndividual *individual); |
634 | void onEdsServiceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); |
635 | - void onSafeModeChanged(); |
636 | |
637 | // Unix signal handlers. |
638 | void handleSigQuit(); |
639 | @@ -98,9 +94,6 @@ |
640 | void checkForEds(); |
641 | void unprepareFolks(); |
642 | |
643 | - // check compatibility and if the safe mode should be enabled |
644 | - void checkCompatibility(); |
645 | - |
646 | private: |
647 | FolksIndividualAggregator *m_individualAggregator; |
648 | ContactsMap *m_contacts; |
649 | @@ -109,9 +102,6 @@ |
650 | // timer to avoid send several updates at the same time |
651 | DirtyContactsNotify *m_notifyContactUpdate; |
652 | QDBusServiceWatcher *m_edsWatcher; |
653 | - MessagingMenuApp *m_messagingMenu; |
654 | - MessagingMenuMessage *m_messagingMenuMessage; |
655 | - static QSettings m_settings; |
656 | |
657 | bool m_edsIsLive; |
658 | bool m_ready; |
659 | @@ -153,8 +143,8 @@ |
660 | void continueShutdown(); |
661 | void setIsReady(bool isReady); |
662 | bool registerObject(QDBusConnection &connection); |
663 | - QString removeContact(FolksIndividual *individual, bool *visible); |
664 | - QString addContact(FolksIndividual *individual, bool visible); |
665 | + QString removeContact(FolksIndividual *individual); |
666 | + QString addContact(FolksIndividual *individual); |
667 | FolksPersonaStore *getFolksStore(const QString &source); |
668 | |
669 | static void availableSourcesDoneListAllSources(FolksBackendStore *backendStore, |
670 | |
671 | === modified file 'lib/qindividual.cpp' |
672 | --- lib/qindividual.cpp 2015-09-04 18:41:06 +0000 |
673 | +++ lib/qindividual.cpp 2015-10-07 13:33:41 +0000 |
674 | @@ -155,8 +155,7 @@ |
675 | : m_individual(0), |
676 | m_aggregator(aggregator), |
677 | m_contact(0), |
678 | - m_currentUpdate(0), |
679 | - m_visible(true) |
680 | + m_currentUpdate(0) |
681 | { |
682 | if (m_supportedExtendedDetails.isEmpty()) { |
683 | m_supportedExtendedDetails << X_CREATED_AT |
684 | @@ -1214,16 +1213,6 @@ |
685 | return m_deletedAt; |
686 | } |
687 | |
688 | -bool QIndividual::setVisible(bool visible) |
689 | -{ |
690 | - m_visible = visible; |
691 | -} |
692 | - |
693 | -bool QIndividual::isVisible() const |
694 | -{ |
695 | - return m_visible; |
696 | -} |
697 | - |
698 | void QIndividual::setIndividual(FolksIndividual *individual) |
699 | { |
700 | static QList<QByteArray> individualProperties; |
701 | |
702 | === modified file 'lib/qindividual.h' |
703 | --- lib/qindividual.h 2015-09-04 15:01:52 +0000 |
704 | +++ lib/qindividual.h 2015-10-07 13:33:41 +0000 |
705 | @@ -57,8 +57,6 @@ |
706 | void flush(); |
707 | bool markAsDeleted(); |
708 | QDateTime deletedAt(); |
709 | - bool setVisible(bool visible); |
710 | - bool isVisible() const; |
711 | |
712 | static QtContacts::QContact copy(const QtContacts::QContact &c, QList<QtContacts::QContactDetail::DetailType> fields); |
713 | static GHashTable *parseDetails(const QtContacts::QContact &contact); |
714 | @@ -83,7 +81,6 @@ |
715 | QMetaObject::Connection m_updateConnection; |
716 | QMutex m_contactLock; |
717 | QDateTime m_deletedAt; |
718 | - bool m_visible; |
719 | static bool m_autoLink; |
720 | static QStringList m_supportedExtendedDetails; |
721 | |
722 | |
723 | === modified file 'lib/view.cpp' |
724 | --- lib/view.cpp 2015-09-16 13:28:23 +0000 |
725 | +++ lib/view.cpp 2015-10-07 13:33:41 +0000 |
726 | @@ -43,13 +43,12 @@ |
727 | class FilterThread: public QRunnable |
728 | { |
729 | public: |
730 | - FilterThread(QString filter, QString sort, int maxCount, bool showInvisible, ContactsMap *allContacts, QObject *parent) |
731 | + FilterThread(QString filter, QString sort, int maxCount, ContactsMap *allContacts, QObject *parent) |
732 | : m_parent(parent), |
733 | m_filter(filter), |
734 | m_sortClause(sort), |
735 | m_maxCount(maxCount), |
736 | m_allContacts(allContacts), |
737 | - m_showInvisible(showInvisible), |
738 | m_canceled(false), |
739 | m_running(false), |
740 | m_done(false) |
741 | @@ -140,8 +139,7 @@ |
742 | // filter contacts if necessary |
743 | if (m_filter.isValid() && m_filter.isEmpty()) { |
744 | Q_FOREACH(ContactEntry *entry, m_allContacts->values()) { |
745 | - if ((m_showInvisible || entry->individual()->isVisible()) && |
746 | - !entry->individual()->deletedAt().isValid()) { |
747 | + if (!entry->individual()->deletedAt().isValid()) { |
748 | |
749 | QContact contact = entry->individual()->contact(); |
750 | |
751 | @@ -188,8 +186,7 @@ |
752 | QDateTime deletedAt = entry->individual()->deletedAt(); |
753 | m_canceledLock.unlock(); |
754 | |
755 | - if ((m_showInvisible || entry->individual()->isVisible()) && |
756 | - checkContact(contact, deletedAt)) { |
757 | + if (checkContact(contact, deletedAt)) { |
758 | if (needSort) { |
759 | addSorted(&m_contacts, contact, m_sortClause); |
760 | } else { |
761 | @@ -217,7 +214,6 @@ |
762 | QList<QContact> m_contacts; |
763 | |
764 | int m_maxCount; |
765 | - bool m_showInvisible; |
766 | bool m_canceled; |
767 | QReadWriteLock m_canceledLock; |
768 | bool m_running; |
769 | @@ -229,12 +225,12 @@ |
770 | } |
771 | }; |
772 | |
773 | -View::View(const QString &clause, const QString &sort, int maxCount, bool showInvisible, |
774 | +View::View(const QString &clause, const QString &sort, int maxCount, |
775 | const QStringList &sources, ContactsMap *allContacts, |
776 | QObject *parent) |
777 | : QObject(parent), |
778 | m_sources(sources), |
779 | - m_filterThread(new FilterThread(clause, sort, maxCount, showInvisible, allContacts, this)), |
780 | + m_filterThread(new FilterThread(clause, sort, maxCount, allContacts, this)), |
781 | m_adaptor(0), |
782 | m_waiting(0) |
783 | { |
784 | |
785 | === modified file 'lib/view.h' |
786 | --- lib/view.h 2015-09-16 13:28:23 +0000 |
787 | +++ lib/view.h 2015-10-07 13:33:41 +0000 |
788 | @@ -42,7 +42,7 @@ |
789 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
790 | |
791 | public: |
792 | - View(const QString &clause, const QString &sort, int maxCount, bool showInvisible, const QStringList &sources, ContactsMap *allContacts, QObject *parent); |
793 | + View(const QString &clause, const QString &sort, int maxCount, const QStringList &sources, ContactsMap *allContacts, QObject *parent); |
794 | ~View(); |
795 | |
796 | static QString objectPath(); |
797 | |
798 | === modified file 'tests/CMakeLists.txt' |
799 | --- tests/CMakeLists.txt 2015-09-11 13:30:07 +0000 |
800 | +++ tests/CMakeLists.txt 2015-10-07 13:33:41 +0000 |
801 | @@ -4,4 +4,3 @@ |
802 | PATHS /usr/lib/evolution/) |
803 | add_subdirectory(data) |
804 | add_subdirectory(unittest) |
805 | -add_subdirectory(tst_tools) |
806 | |
807 | === modified file 'tests/address_book_service_testability/helpers.py' |
808 | --- tests/address_book_service_testability/helpers.py 2015-09-17 16:45:14 +0000 |
809 | +++ tests/address_book_service_testability/helpers.py 2015-10-07 13:33:41 +0000 |
810 | @@ -24,9 +24,9 @@ |
811 | bus = dbus.SessionBus() |
812 | |
813 | |
814 | -def query_contacts(fields='', query='', max_count=0, show_invisible=False, sources=[]): |
815 | +def query_contacts(fields='', query='', max_count=0, sources=[]): |
816 | iface = _get_contacts_dbus_service_iface() |
817 | - view_path = iface.query(fields, query, max_count, show_invisible, []) |
818 | + view_path = iface.query(fields, query, max_count, []) |
819 | view = bus.get_object( |
820 | 'com.canonical.pim', view_path) |
821 | view_iface = dbus.Interface( |
822 | |
823 | === modified file 'tests/unittest/contact-sort-test.cpp' |
824 | --- tests/unittest/contact-sort-test.cpp 2015-09-16 13:28:23 +0000 |
825 | +++ tests/unittest/contact-sort-test.cpp 2015-10-07 13:33:41 +0000 |
826 | @@ -100,7 +100,7 @@ |
827 | m_serverIface->call("createContact", copyVcard, "dummy-store"); |
828 | |
829 | // check if the cotact is listed in the correct order |
830 | - QDBusMessage result = m_serverIface->call("query", "", "", 0, false, QStringList()); |
831 | + QDBusMessage result = m_serverIface->call("query", "", "", 0, QStringList()); |
832 | QDBusObjectPath viewObjectPath = result.arguments()[0].value<QDBusObjectPath>(); |
833 | QDBusInterface *view = new QDBusInterface(m_serverIface->service(), |
834 | viewObjectPath.path(), |
835 | @@ -147,7 +147,7 @@ |
836 | m_serverIface->call("createContact", copyVcard, "dummy-store"); |
837 | |
838 | // check if the cotact is listed in the correct order |
839 | - QDBusMessage result = m_serverIface->call("query", "", "", 0, false, QStringList()); |
840 | + QDBusMessage result = m_serverIface->call("query", "", "", 0, QStringList()); |
841 | QDBusObjectPath viewObjectPath = result.arguments()[0].value<QDBusObjectPath>(); |
842 | QDBusInterface *view = new QDBusInterface(m_serverIface->service(), |
843 | viewObjectPath.path(), |
844 | @@ -179,7 +179,7 @@ |
845 | m_serverIface->call("updateContact", vcard, "dummy-store"); |
846 | |
847 | // check if the cotact still in the correct order |
848 | - result = m_serverIface->call("query", "", "", 0, false, QStringList()); |
849 | + result = m_serverIface->call("query", "", "", 0, QStringList()); |
850 | viewObjectPath = result.arguments()[0].value<QDBusObjectPath>(); |
851 | view = new QDBusInterface(m_serverIface->service(), |
852 | viewObjectPath.path(), |
853 | |
854 | === removed directory 'updater' |
855 | === removed file 'updater/CMakeLists.txt' |
856 | --- updater/CMakeLists.txt 2015-09-03 19:09:36 +0000 |
857 | +++ updater/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
858 | @@ -1,49 +0,0 @@ |
859 | -set(ADDRESS_BOOK_UPDATE_LIB address-book-updater-lib) |
860 | -set(ADDRESS_BOOK_UPDATE_BIN address-book-updater) |
861 | - |
862 | -include_directories( |
863 | - ${CMAKE_BINARY_DIR} |
864 | - ${CMAKE_SOURCE_DIR}/common |
865 | - ${AccountsQt5_INCLUDE_DIRS} |
866 | - ${LIBNOTIFY_INCLUDE_DIRS} |
867 | -) |
868 | - |
869 | -set(ADDRESS_BOOK_UPDATE_LIB_SRCS |
870 | - ab-i18n.h |
871 | - ab-notify-message.h |
872 | - ab-notify-message.cpp |
873 | - ab-update.h |
874 | - ab-update.cpp |
875 | - ab-update-adaptor.h |
876 | - ab-update-adaptor.cpp |
877 | - ab-update-buteo-import.h |
878 | - ab-update-buteo-import.cpp |
879 | - ab-update-module.h |
880 | - ab-update-module.cpp |
881 | -) |
882 | - |
883 | -add_library(${ADDRESS_BOOK_UPDATE_LIB} STATIC |
884 | - ${ADDRESS_BOOK_UPDATE_LIB_SRCS} |
885 | -) |
886 | - |
887 | -target_link_libraries(${ADDRESS_BOOK_UPDATE_LIB} |
888 | - Qt5::Core |
889 | - Qt5::DBus |
890 | - Qt5::Contacts |
891 | - Qt5::Xml |
892 | - Qt5::Network |
893 | - ${AccountsQt5_LIBRARIES} |
894 | - ${LIBNOTIFY_LIBRARIES} |
895 | -) |
896 | - |
897 | -add_executable(${ADDRESS_BOOK_UPDATE_BIN} |
898 | - main.cpp |
899 | -) |
900 | - |
901 | -target_link_libraries(${ADDRESS_BOOK_UPDATE_BIN} |
902 | - ${ADDRESS_BOOK_UPDATE_LIB} |
903 | -) |
904 | - |
905 | -install(TARGETS ${ADDRESS_BOOK_UPDATE_BIN} |
906 | - RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR} |
907 | -) |
908 | |
909 | === removed file 'updater/ab-i18n.h' |
910 | --- updater/ab-i18n.h 2015-09-03 20:09:42 +0000 |
911 | +++ updater/ab-i18n.h 1970-01-01 00:00:00 +0000 |
912 | @@ -1,27 +0,0 @@ |
913 | -/* |
914 | - * Copyright 2015 Canonical Ltd. |
915 | - * |
916 | - * This file is part of address-book-service. |
917 | - * |
918 | - * sync-monitor is free software; you can redistribute it and/or modify |
919 | - * it under the terms of the GNU General Public License as published by |
920 | - * the Free Software Foundation; version 3. |
921 | - * |
922 | - * contact-service-app is distributed in the hope that it will be useful, |
923 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
924 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
925 | - * GNU General Public License for more details. |
926 | - * |
927 | - * You should have received a copy of the GNU General Public License |
928 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
929 | - */ |
930 | - |
931 | -#pragma once |
932 | - |
933 | -#include "config.h" |
934 | - |
935 | -extern "C" { |
936 | -#include <libintl.h> |
937 | -#define _(String) dgettext (GETTEXT_PACKAGE, String) |
938 | -} |
939 | - |
940 | |
941 | === removed file 'updater/ab-notify-message.cpp' |
942 | --- updater/ab-notify-message.cpp 2015-09-16 20:57:19 +0000 |
943 | +++ updater/ab-notify-message.cpp 1970-01-01 00:00:00 +0000 |
944 | @@ -1,136 +0,0 @@ |
945 | -/* |
946 | - * Copyright 2015 Canonical Ltd. |
947 | - * |
948 | - * This file is part of address-book-service. |
949 | - * |
950 | - * sync-monitor is free software; you can redistribute it and/or modify |
951 | - * it under the terms of the GNU General Public License as published by |
952 | - * the Free Software Foundation; version 3. |
953 | - * |
954 | - * contact-service-app is distributed in the hope that it will be useful, |
955 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
956 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
957 | - * GNU General Public License for more details. |
958 | - * |
959 | - * You should have received a copy of the GNU General Public License |
960 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
961 | - */ |
962 | - |
963 | -#include "ab-notify-message.h" |
964 | -#include "ab-i18n.h" |
965 | - |
966 | -#include <QtCore/QCoreApplication> |
967 | -#include <QtCore/QDebug> |
968 | - |
969 | -int ABNotifyMessage::m_instanceCount = 0; |
970 | - |
971 | -ABNotifyMessage::ABNotifyMessage(bool singleMessage, QObject *parent) |
972 | - : QObject(parent), |
973 | - m_notification(0), |
974 | - m_singleMessage(singleMessage) |
975 | -{ |
976 | - if (m_instanceCount == 0) { |
977 | - m_instanceCount++; |
978 | - notify_init(QCoreApplication::instance()->applicationName().toUtf8()); |
979 | - } |
980 | -} |
981 | - |
982 | -ABNotifyMessage::~ABNotifyMessage() |
983 | -{ |
984 | - if (m_notification) { |
985 | - g_object_unref(m_notification); |
986 | - m_notification = 0; |
987 | - } |
988 | - |
989 | - m_instanceCount--; |
990 | - if (m_instanceCount == 0) { |
991 | - notify_uninit(); |
992 | - } |
993 | - |
994 | -} |
995 | - |
996 | -void ABNotifyMessage::show(const QString &title, const QString &msg, const QString &iconName) |
997 | -{ |
998 | - m_notification = notify_notification_new(title.toUtf8().data(), |
999 | - msg.toUtf8().data(), |
1000 | - iconName.isEmpty() ? (const char*) 0 : iconName.toUtf8().constData()); |
1001 | - |
1002 | - GError *error = 0; |
1003 | - notify_notification_set_timeout(m_notification, NOTIFY_EXPIRES_DEFAULT); |
1004 | - notify_notification_show(m_notification, &error); |
1005 | - if (error) { |
1006 | - qWarning() << "Fail to launch notification" << error->message; |
1007 | - g_error_free(error); |
1008 | - } |
1009 | - g_signal_connect_after(m_notification, |
1010 | - "closed", |
1011 | - (GCallback) ABNotifyMessage::onNotificationClosed, |
1012 | - this); |
1013 | -} |
1014 | - |
1015 | -void ABNotifyMessage::askYesOrNo(const QString &title, |
1016 | - const QString &msg, |
1017 | - const QString &iconName) |
1018 | -{ |
1019 | - m_notification = notify_notification_new(title.toUtf8().data(), |
1020 | - msg.toUtf8().data(), |
1021 | - iconName.isEmpty() ? (const char*) 0 : iconName.toUtf8().constData()); |
1022 | - notify_notification_set_hint_string(m_notification, |
1023 | - "x-canonical-snap-decisions", |
1024 | - "true"); |
1025 | - notify_notification_set_hint_string(m_notification, |
1026 | - "x-canonical-private-button-tint", |
1027 | - "true"); |
1028 | - notify_notification_set_hint_string(m_notification, |
1029 | - "x-canonical-non-shaped-icon", |
1030 | - "true"); |
1031 | - notify_notification_add_action(m_notification, |
1032 | - "action_accept", _("Yes"), |
1033 | - (NotifyActionCallback) ABNotifyMessage::onQuestionAccepted, |
1034 | - this, |
1035 | - NULL); |
1036 | - notify_notification_add_action(m_notification, |
1037 | - "action_reject", _("No"), |
1038 | - (NotifyActionCallback) ABNotifyMessage::onQuestionRejected, |
1039 | - this, |
1040 | - NULL); |
1041 | - notify_notification_show(m_notification, 0); |
1042 | - g_signal_connect_after(m_notification, |
1043 | - "closed", |
1044 | - (GCallback) ABNotifyMessage::onNotificationClosed, |
1045 | - this); |
1046 | -} |
1047 | - |
1048 | -int ABNotifyMessage::closedReason() const |
1049 | -{ |
1050 | - if (m_notification) { |
1051 | - return notify_notification_get_closed_reason(m_notification); |
1052 | - } else { |
1053 | - return 0; |
1054 | - } |
1055 | -} |
1056 | - |
1057 | -void ABNotifyMessage::onQuestionAccepted(NotifyNotification *notification, char *action, ABNotifyMessage *self) |
1058 | -{ |
1059 | - Q_UNUSED(notification) |
1060 | - Q_UNUSED(action) |
1061 | - |
1062 | - Q_EMIT self->questionAccepted(); |
1063 | -} |
1064 | - |
1065 | -void ABNotifyMessage::onQuestionRejected(NotifyNotification *notification, char *action, ABNotifyMessage *self) |
1066 | -{ |
1067 | - Q_UNUSED(notification) |
1068 | - Q_UNUSED(action) |
1069 | - |
1070 | - Q_EMIT self->questionRejected(); |
1071 | -} |
1072 | - |
1073 | -void ABNotifyMessage::onNotificationClosed(NotifyNotification *notification, ABNotifyMessage *self) |
1074 | -{ |
1075 | - Q_UNUSED(notification) |
1076 | - Q_EMIT self->messageClosed(); |
1077 | - if (self->m_singleMessage) { |
1078 | - self->deleteLater(); |
1079 | - } |
1080 | -} |
1081 | |
1082 | === removed file 'updater/ab-notify-message.h' |
1083 | --- updater/ab-notify-message.h 2015-09-16 20:57:19 +0000 |
1084 | +++ updater/ab-notify-message.h 1970-01-01 00:00:00 +0000 |
1085 | @@ -1,54 +0,0 @@ |
1086 | -/* |
1087 | - * Copyright 2015 Canonical Ltd. |
1088 | - * |
1089 | - * This file is part of address-book-service. |
1090 | - * |
1091 | - * sync-monitor is free software; you can redistribute it and/or modify |
1092 | - * it under the terms of the GNU General Public License as published by |
1093 | - * the Free Software Foundation; version 3. |
1094 | - * |
1095 | - * contact-service-app is distributed in the hope that it will be useful, |
1096 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1097 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1098 | - * GNU General Public License for more details. |
1099 | - * |
1100 | - * You should have received a copy of the GNU General Public License |
1101 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1102 | - */ |
1103 | - |
1104 | -#pragma once |
1105 | -#include <QtCore/QString> |
1106 | -#include <QtCore/QObject> |
1107 | - |
1108 | -#include <libnotify/notify.h> |
1109 | - |
1110 | -class ABNotifyMessage : public QObject |
1111 | -{ |
1112 | - Q_OBJECT |
1113 | -public: |
1114 | - ABNotifyMessage(bool singleMessage, QObject *parent = 0); |
1115 | - ~ABNotifyMessage(); |
1116 | - |
1117 | - void show(const QString &title, const QString &msg, const QString &iconName); |
1118 | - void askYesOrNo(const QString &title, const QString &msg, const QString &iconName); |
1119 | - int closedReason() const; |
1120 | - |
1121 | -Q_SIGNALS: |
1122 | - void questionAccepted(); |
1123 | - void questionRejected(); |
1124 | - void messageClosed(); |
1125 | - |
1126 | -private: |
1127 | - NotifyNotification *m_notification; |
1128 | - bool m_singleMessage; |
1129 | - static int m_instanceCount; |
1130 | - |
1131 | - static void onQuestionAccepted(NotifyNotification *notification, |
1132 | - char *action, |
1133 | - ABNotifyMessage *self); |
1134 | - static void onQuestionRejected(NotifyNotification *notification, |
1135 | - char *action, |
1136 | - ABNotifyMessage *self); |
1137 | - static void onNotificationClosed(NotifyNotification *notification, |
1138 | - ABNotifyMessage *self); |
1139 | -}; |
1140 | |
1141 | === removed file 'updater/ab-update-adaptor.cpp' |
1142 | --- updater/ab-update-adaptor.cpp 2015-09-16 00:33:43 +0000 |
1143 | +++ updater/ab-update-adaptor.cpp 1970-01-01 00:00:00 +0000 |
1144 | @@ -1,50 +0,0 @@ |
1145 | -/* |
1146 | - * Copyright 2015 Canonical Ltd. |
1147 | - * |
1148 | - * This file is part of address-book-service. |
1149 | - * |
1150 | - * sync-monitor is free software; you can redistribute it and/or modify |
1151 | - * it under the terms of the GNU General Public License as published by |
1152 | - * the Free Software Foundation; version 3. |
1153 | - * |
1154 | - * contact-service-app is distributed in the hope that it will be useful, |
1155 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1156 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1157 | - * GNU General Public License for more details. |
1158 | - * |
1159 | - * You should have received a copy of the GNU General Public License |
1160 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1161 | - */ |
1162 | - |
1163 | -#include "ab-update-adaptor.h" |
1164 | - |
1165 | -ABUpdateAdaptor::ABUpdateAdaptor(ABUpdate *parent) |
1166 | - : QDBusAbstractAdaptor(parent), |
1167 | - m_abUpdate(parent) |
1168 | -{ |
1169 | - setAutoRelaySignals(true); |
1170 | -} |
1171 | - |
1172 | -ABUpdateAdaptor::~ABUpdateAdaptor() |
1173 | -{ |
1174 | -} |
1175 | - |
1176 | -bool ABUpdateAdaptor::needsUpdate() const |
1177 | -{ |
1178 | - return !m_abUpdate->needsUpdate().isEmpty(); |
1179 | -} |
1180 | - |
1181 | -bool ABUpdateAdaptor::isRunning() const |
1182 | -{ |
1183 | - return m_abUpdate->isRunning(); |
1184 | -} |
1185 | - |
1186 | -void ABUpdateAdaptor::startUpdate() |
1187 | -{ |
1188 | - m_abUpdate->startUpdate(); |
1189 | -} |
1190 | - |
1191 | -void ABUpdateAdaptor::cancelUpdate() |
1192 | -{ |
1193 | - m_abUpdate->cancelUpdate(); |
1194 | -} |
1195 | |
1196 | === removed file 'updater/ab-update-adaptor.h' |
1197 | --- updater/ab-update-adaptor.h 2015-09-16 00:33:43 +0000 |
1198 | +++ updater/ab-update-adaptor.h 1970-01-01 00:00:00 +0000 |
1199 | @@ -1,67 +0,0 @@ |
1200 | -/* |
1201 | - * Copyright 2015 Canonical Ltd. |
1202 | - * |
1203 | - * This file is part of address-book-service. |
1204 | - * |
1205 | - * sync-monitor is free software; you can redistribute it and/or modify |
1206 | - * it under the terms of the GNU General Public License as published by |
1207 | - * the Free Software Foundation; version 3. |
1208 | - * |
1209 | - * contact-service-app is distributed in the hope that it will be useful, |
1210 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1211 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1212 | - * GNU General Public License for more details. |
1213 | - * |
1214 | - * You should have received a copy of the GNU General Public License |
1215 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1216 | - */ |
1217 | - |
1218 | -#pragma once |
1219 | -#include <QtCore/QObject> |
1220 | -#include <QtDBus/QDBusAbstractAdaptor> |
1221 | - |
1222 | -#include "ab-update.h" |
1223 | -#include "dbus-service-defs.h" |
1224 | -#include "config.h" |
1225 | - |
1226 | -class ABUpdateAdaptor : public QDBusAbstractAdaptor |
1227 | -{ |
1228 | - Q_OBJECT |
1229 | - Q_CLASSINFO("D-Bus Interface", CPIM_UPDATE_OBJECT_IFACE_NAME) |
1230 | - Q_CLASSINFO("D-Bus Introspection", "" |
1231 | -" <interface name=\"com.canonical.pim.Updater\">\n" |
1232 | -" <property name=\"needsUpdate\" type=\"b\" access=\"read\"/>\n" |
1233 | -" <property name=\"isRunning\" type=\"b\" access=\"read\"/>\n" |
1234 | -" <signal name=\"updateDone\"/>\n" |
1235 | -" <signal name=\"updateError\">\n" |
1236 | -" <arg direction=\"out\" type=\"s\" name=\"errorMessage\"/>\n" |
1237 | -" </signal>\n" |
1238 | -" <method name=\"startUpdate\"/>\n" |
1239 | -" <method name=\"cancelUpdate\"/>\n" |
1240 | -" </interface>\n" |
1241 | -"") |
1242 | - Q_PROPERTY(bool needsUpdate READ needsUpdate NOTIFY onNeedsUpdateChanged) |
1243 | - Q_PROPERTY(bool isRunning READ isRunning NOTIFY onIsRunningChanged) |
1244 | - |
1245 | -public: |
1246 | - ABUpdateAdaptor(ABUpdate *parent = 0); |
1247 | - ~ABUpdateAdaptor(); |
1248 | - |
1249 | - bool needsUpdate() const; |
1250 | - bool isRunning() const; |
1251 | - |
1252 | -public Q_SLOTS: |
1253 | - void startUpdate(); |
1254 | - void cancelUpdate(); |
1255 | - |
1256 | -Q_SIGNALS: |
1257 | - void onNeedsUpdateChanged(); |
1258 | - void onIsRunningChanged(); |
1259 | - void updateDone(); |
1260 | - void updateError(const QString &errorMessage); |
1261 | - |
1262 | -private: |
1263 | - ABUpdate *m_abUpdate; |
1264 | - bool m_needsUpdate; |
1265 | - bool m_isRunning; |
1266 | -}; |
1267 | |
1268 | === removed file 'updater/ab-update-buteo-import.cpp' |
1269 | --- updater/ab-update-buteo-import.cpp 2015-09-29 14:15:42 +0000 |
1270 | +++ updater/ab-update-buteo-import.cpp 1970-01-01 00:00:00 +0000 |
1271 | @@ -1,730 +0,0 @@ |
1272 | -/* |
1273 | - * Copyright 2015 Canonical Ltd. |
1274 | - * |
1275 | - * This file is part of address-book-service. |
1276 | - * |
1277 | - * sync-monitor is free software; you can redistribute it and/or modify |
1278 | - * it under the terms of the GNU General Public License as published by |
1279 | - * the Free Software Foundation; version 3. |
1280 | - * |
1281 | - * contact-service-app is distributed in the hope that it will be useful, |
1282 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1283 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1284 | - * GNU General Public License for more details. |
1285 | - * |
1286 | - * You should have received a copy of the GNU General Public License |
1287 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1288 | - */ |
1289 | - |
1290 | -#include "ab-update-buteo-import.h" |
1291 | - |
1292 | -#include <Accounts/Manager> |
1293 | -#include <Accounts/Account> |
1294 | -#include <Accounts/AccountService> |
1295 | - |
1296 | -#include <QtCore/QDebug> |
1297 | -#include <QtCore/QScopedPointer> |
1298 | -#include <QtCore/QTimer> |
1299 | - |
1300 | -#include <QtDBus/QDBusReply> |
1301 | - |
1302 | -#include <QtXml/QDomDocument> |
1303 | - |
1304 | -#include <QtContacts/QContactManager> |
1305 | -#include <QtContacts/QContact> |
1306 | -#include <QtContacts/QContactGuid> |
1307 | -#include <QtContacts/QContactExtendedDetail> |
1308 | -#include <QtContacts/QContactDetailFilter> |
1309 | -#include <QtContacts/QContactIntersectionFilter> |
1310 | -#include <QtContacts/QContactFavorite> |
1311 | -#include <QtContacts/QContactName> |
1312 | -#include <QtContacts/QContactPhoneNumber> |
1313 | -#include <QtContacts/QContactEmailAddress> |
1314 | - |
1315 | -#include "config.h" |
1316 | - |
1317 | -#define BUTEO_DBUS_SERVICE_NAME "com.meego.msyncd" |
1318 | -#define BUTEO_DBUS_OBJECT_PATH "/synchronizer" |
1319 | -#define BUTEO_DBUS_INTERFACE "com.meego.msyncd" |
1320 | - |
1321 | -using namespace QtContacts; |
1322 | - |
1323 | -ButeoImport::ButeoImport(QObject *parent) |
1324 | - : ABUpdateModule(parent) |
1325 | -{ |
1326 | -} |
1327 | - |
1328 | -ButeoImport::~ButeoImport() |
1329 | -{ |
1330 | -} |
1331 | - |
1332 | -QString ButeoImport::name() const |
1333 | -{ |
1334 | - return QStringLiteral("Buteo"); |
1335 | -} |
1336 | - |
1337 | -bool ButeoImport::loadAccounts(QList<quint32> &accountsToUpdate, QList<quint32> &newAccounts) |
1338 | -{ |
1339 | - // check which account already has a source |
1340 | - Accounts::Manager mgr; |
1341 | - accountsToUpdate = mgr.accountList("contacts"); |
1342 | - |
1343 | - qDebug() << "Accounts" << accountsToUpdate; |
1344 | - // check which account does not have a source |
1345 | - QMap<QString, quint32> srcs = sources(); |
1346 | - for(QMap<QString, uint>::const_iterator i = srcs.begin(); |
1347 | - i != srcs.end(); |
1348 | - i++) { |
1349 | - qDebug() << "Source" << i.key() << "Account" << i.value(); |
1350 | - // remove ids that already has a source from the idList |
1351 | - if (i.value() > 0) { |
1352 | - newAccounts << i.value(); |
1353 | - accountsToUpdate.removeOne(i.value()); |
1354 | - } |
1355 | - } |
1356 | - |
1357 | - // no accounts to update |
1358 | - if (accountsToUpdate.isEmpty() && newAccounts.isEmpty()) { |
1359 | - return true; |
1360 | - } |
1361 | - |
1362 | - if (!prepareButeo()) { |
1363 | - qWarning() << "Fail to connect with buteo service"; |
1364 | - return false; |
1365 | - } |
1366 | - |
1367 | - // check if all new accounts has a sync profile |
1368 | - Q_FOREACH(const quint32 &accountId, newAccounts) { |
1369 | - QDBusReply<QStringList> reply = m_buteoInterface->call("syncProfilesByKey", |
1370 | - "accountid", |
1371 | - QString::number(accountId)); |
1372 | - if (reply.value().isEmpty()) { |
1373 | - qDebug() << "Account does not have a sync profile" << accountId; |
1374 | - accountsToUpdate << accountId; |
1375 | - newAccounts.removeOne(accountId); |
1376 | - } |
1377 | - } |
1378 | - |
1379 | - return true; |
1380 | -} |
1381 | - |
1382 | -bool ButeoImport::enableContactsService(quint32 accountId) |
1383 | -{ |
1384 | - Accounts::Manager mgr; |
1385 | - QScopedPointer<Accounts::Account> account(mgr.account(accountId)); |
1386 | - |
1387 | - if (account) { |
1388 | - Q_FOREACH(Accounts::Service service, account->services()) { |
1389 | - if (service.serviceType() == "contacts") { |
1390 | - account->selectService(service); |
1391 | - account->setEnabled(true); |
1392 | - account->syncAndBlock(); |
1393 | - } |
1394 | - } |
1395 | - return true; |
1396 | - } else { |
1397 | - return false; |
1398 | - } |
1399 | -} |
1400 | - |
1401 | -QString ButeoImport::accountName(quint32 accountId) |
1402 | -{ |
1403 | - Accounts::Manager mgr; |
1404 | - QScopedPointer<Accounts::Account> account(mgr.account(accountId)); |
1405 | - return account ? account->displayName() : QString(); |
1406 | -} |
1407 | - |
1408 | -QStringList ButeoImport::runningSyncs() const |
1409 | -{ |
1410 | - if (m_buteoInterface.isNull()) { |
1411 | - return QStringList(); |
1412 | - } |
1413 | - |
1414 | - QDBusReply<QStringList> result = m_buteoInterface->call("runningSyncs"); |
1415 | - if (result.error().isValid()) { |
1416 | - qWarning() << "Fail to retrieve running syncs" << result.error(); |
1417 | - return QStringList(); |
1418 | - } |
1419 | - |
1420 | - return result.value(); |
1421 | -} |
1422 | - |
1423 | -QString ButeoImport::profileName(const QString &xml) const |
1424 | -{ |
1425 | - QDomDocument doc; |
1426 | - QString errorMsg; |
1427 | - int errorLine; |
1428 | - int errorColumn; |
1429 | - |
1430 | - if (doc.setContent(xml, &errorMsg, &errorLine, &errorColumn)) { |
1431 | - QDomNodeList profileElements = doc.elementsByTagName("profile"); |
1432 | - if (!profileElements.isEmpty()) { |
1433 | - QDomElement e = profileElements.item(0).toElement(); |
1434 | - return e.attribute("name"); |
1435 | - } else { |
1436 | - qWarning() << "Invalid profile" << xml; |
1437 | - } |
1438 | - } else { |
1439 | - qWarning() << "Fail to parse profile:" << xml; |
1440 | - qWarning() << "Error:" << errorMsg << errorLine << errorColumn; |
1441 | - } |
1442 | - return QString(); |
1443 | -} |
1444 | - |
1445 | -QString ButeoImport::profileName(quint32 accountId) const |
1446 | -{ |
1447 | - if (m_buteoInterface.isNull()) { |
1448 | - return QString(); |
1449 | - } |
1450 | - |
1451 | - QDBusReply<QStringList> reply = m_buteoInterface->call("syncProfilesByKey", |
1452 | - "accountid", |
1453 | - QString::number(accountId)); |
1454 | - if (!reply.value().isEmpty()) { |
1455 | - return this->profileName(reply.value().first()); |
1456 | - } |
1457 | - return QString(); |
1458 | -} |
1459 | - |
1460 | -bool ButeoImport::startSync(const QString &profile) const |
1461 | -{ |
1462 | - if (m_buteoInterface.isNull()) { |
1463 | - qWarning() << "Buteo interface is not valid"; |
1464 | - return false; |
1465 | - } |
1466 | - |
1467 | - QDBusReply<bool> result = m_buteoInterface->call("startSync", profile); |
1468 | - if (result.error().isValid()) { |
1469 | - qWarning() << "Fail to start sync for profile" << profile << result.error().message(); |
1470 | - return false; |
1471 | - } |
1472 | - |
1473 | - return result.value(); |
1474 | -} |
1475 | - |
1476 | -bool ButeoImport::matchFavorites() |
1477 | -{ |
1478 | - QMap<QString, QString> parameters; |
1479 | - parameters.insert(ADDRESS_BOOK_SHOW_INVISIBLE_PROP, "true"); |
1480 | - QScopedPointer<QContactManager> manager(new QContactManager("galera", parameters)); |
1481 | - |
1482 | - // load old favorites |
1483 | - QContactDetailFilter folksFavorite; |
1484 | - folksFavorite.setDetailType(QContactDetail::TypeFavorite, QContactFavorite::FieldFavorite); |
1485 | - folksFavorite.setValue(true); |
1486 | - |
1487 | - QContactFetchHint hint; |
1488 | - hint.setDetailTypesHint(QList<QContactDetail::DetailType>() |
1489 | - << QContactDetail::TypeName |
1490 | - << QContactDetail::TypeEmailAddress |
1491 | - << QContactDetail::TypePhoneNumber); |
1492 | - QList<QContact> favorites = manager->contacts(folksFavorite, QList<QContactSortOrder>(), hint); |
1493 | - qDebug() << "number of folks favorites" << favorites.size(); |
1494 | - |
1495 | - // try to match with new contacts |
1496 | - QList<QContact> toUpdate; |
1497 | - |
1498 | - Q_FOREACH(const QContact &f, favorites) { |
1499 | - QContactIntersectionFilter iFilter; |
1500 | - |
1501 | - qDebug() << "Try to match contact" << f; |
1502 | - // No favorite |
1503 | - QContactDetailFilter noFavorite; |
1504 | - noFavorite.setDetailType(QContactDetail::TypeFavorite, QContactFavorite::FieldFavorite); |
1505 | - noFavorite.setValue(false); |
1506 | - iFilter.append(noFavorite); |
1507 | - |
1508 | - // By name |
1509 | - QContactDetailFilter firstNameFilter; |
1510 | - firstNameFilter.setDetailType(QContactDetail::TypeName, QContactName::FieldFirstName); |
1511 | - firstNameFilter.setValue(f.detail<QContactName>().firstName()); |
1512 | - iFilter.append(firstNameFilter); |
1513 | - |
1514 | - QContactDetailFilter lastNameFilter; |
1515 | - lastNameFilter.setDetailType(QContactDetail::TypeName, QContactName::FieldLastName); |
1516 | - lastNameFilter.setValue(f.detail<QContactName>().lastName()); |
1517 | - iFilter.append(lastNameFilter); |
1518 | - |
1519 | - // By Email |
1520 | - Q_FOREACH(const QContactEmailAddress &e, f.details<QContactEmailAddress>()) { |
1521 | - QContactDetailFilter emailFilter; |
1522 | - emailFilter.setDetailType(QContactDetail::TypeEmailAddress, QContactEmailAddress::FieldEmailAddress); |
1523 | - emailFilter.setValue(e.emailAddress()); |
1524 | - iFilter.append(emailFilter); |
1525 | - } |
1526 | - |
1527 | - // By Phone |
1528 | - Q_FOREACH(const QContactPhoneNumber &p, f.details<QContactPhoneNumber>()) { |
1529 | - QContactDetailFilter phoneFilter; |
1530 | - phoneFilter.setDetailType(QContactDetail::TypePhoneNumber, QContactPhoneNumber::FieldNumber); |
1531 | - phoneFilter.setValue(p.number()); |
1532 | - iFilter.append(phoneFilter); |
1533 | - } |
1534 | - |
1535 | - QList<QContact> contacts = manager->contacts(iFilter); |
1536 | - qDebug() << "Number of contacts that match with old favorite" << contacts.size(); |
1537 | - |
1538 | - Q_FOREACH(QContact c, contacts) { |
1539 | - qDebug() << "Mark new contact as favorite" << c; |
1540 | - QContactFavorite fav = c.detail<QContactFavorite>(); |
1541 | - fav.setFavorite(true); |
1542 | - c.saveDetail(&fav); |
1543 | - toUpdate << c; |
1544 | - } |
1545 | - } |
1546 | - |
1547 | - |
1548 | - if (!toUpdate.isEmpty()) { |
1549 | - if (!manager->saveContacts(&toUpdate)) { |
1550 | - qWarning() << "Fail to save favorite contacts"; |
1551 | - return false; |
1552 | - } |
1553 | - } |
1554 | - return true; |
1555 | - |
1556 | -} |
1557 | - |
1558 | -ABUpdateModule::ImportError ButeoImport::parseError(int errorCode) const |
1559 | -{ |
1560 | - switch (errorCode) |
1561 | - { |
1562 | - case 9: //SYNC_AUTHENTICATION_FAILURE: |
1563 | - return ABUpdateModule::FailToAuthenticate; |
1564 | - case 11: //SYNC_CONNECTION_ERROR: |
1565 | - return ABUpdateModule::ConnectionError; |
1566 | - case 14: //SYNC_PLUGIN_ERROR: |
1567 | - case 15: //SYNC_PLUGIN_TIMEOUT: |
1568 | - return ABUpdateModule::FailToConnectWithButeo; |
1569 | - default: |
1570 | - return ABUpdateModule::SyncError; |
1571 | - } |
1572 | -} |
1573 | - |
1574 | -bool ButeoImport::needsUpdate() |
1575 | -{ |
1576 | - // check settings |
1577 | - QSettings settings; |
1578 | - if (settings.value(SETTINGS_BUTEO_KEY, false).toBool()) { |
1579 | - qDebug() << "Buteo has already been updated."; |
1580 | - return false; |
1581 | - } |
1582 | - |
1583 | - // check if we have old sources that need to be updated |
1584 | - QList<quint32> accountsToUpdate; |
1585 | - QList<quint32> newAccounts; |
1586 | - if (loadAccounts(accountsToUpdate, newAccounts)) { |
1587 | - if (accountsToUpdate.isEmpty() && newAccounts.isEmpty()) { |
1588 | - qDebug() << "No account to update"; |
1589 | - // update settings key |
1590 | - QSettings settings; |
1591 | - settings.setValue(SETTINGS_BUTEO_KEY, true); |
1592 | - settings.sync(); |
1593 | - return false; |
1594 | - } |
1595 | - qDebug() << accountsToUpdate.size() << "accounts, to update"; |
1596 | - qDebug() << newAccounts.size() << "accounts, to sync"; |
1597 | - } else { |
1598 | - qWarning() << "Fail to load online accounts"; |
1599 | - } |
1600 | - |
1601 | - return true; |
1602 | -} |
1603 | - |
1604 | -bool ButeoImport::prepareToUpdate() |
1605 | -{ |
1606 | - return true; |
1607 | -} |
1608 | - |
1609 | -bool ButeoImport::update() |
1610 | -{ |
1611 | - if (!m_importLock.tryLock()) { |
1612 | - qWarning() << "Fail to lock import mutex"; |
1613 | - onError("", ButeoImport::InernalError); |
1614 | - return false; |
1615 | - } |
1616 | - |
1617 | - m_initialAccountToProfiles.clear(); |
1618 | - m_pendingAccountToProfiles.clear(); |
1619 | - m_failToSyncProfiles.clear(); |
1620 | - |
1621 | - QList<quint32> accountsToUpdate; |
1622 | - QList<quint32> newAccounts; |
1623 | - if (!loadAccounts(accountsToUpdate, newAccounts)) { |
1624 | - // fail to load accounts information |
1625 | - m_importLock.unlock(); |
1626 | - qWarning() << "Fail to load accounts information"; |
1627 | - onError("", ButeoImport::OnlineAccountNotFound); |
1628 | - return false; |
1629 | - } |
1630 | - |
1631 | - if (accountsToUpdate.isEmpty() && newAccounts.isEmpty()) { |
1632 | - qDebug() << "No accounts to update"; |
1633 | - // if there is not account to update just commit the update |
1634 | - m_importLock.unlock(); |
1635 | - Q_EMIT updated(); |
1636 | - return true; |
1637 | - } |
1638 | - |
1639 | - |
1640 | - if (!accountsToUpdate.isEmpty()) { |
1641 | - qDebug() << "Will create buteo profile for" << accountsToUpdate << "accounts"; |
1642 | - m_initialAccountToProfiles = createProfileForAccounts(accountsToUpdate); |
1643 | - if (m_initialAccountToProfiles.isEmpty()) { |
1644 | - // fail to create profiles |
1645 | - m_importLock.unlock(); |
1646 | - qWarning() << "Fail to create profiles"; |
1647 | - onError("", ButeoImport::FailToCreateButeoProfiles); |
1648 | - return false; |
1649 | - } |
1650 | - } |
1651 | - |
1652 | - // start sync for new accounts to make sure that they are all in sync |
1653 | - Q_FOREACH(quint32 accountId, newAccounts) { |
1654 | - QString profileName = this->profileName(accountId); |
1655 | - if (!profileName.isEmpty()) { |
1656 | - qDebug() << "Manually start sync for" << profileName; |
1657 | - m_initialAccountToProfiles.insert(accountId, profileName); |
1658 | - if (!startSync(profileName)) { |
1659 | - qWarning() << "Fail to start sync" << profileName; |
1660 | - m_initialAccountToProfiles.remove(accountId); |
1661 | - } |
1662 | - } |
1663 | - } |
1664 | - |
1665 | - m_pendingAccountToProfiles = m_initialAccountToProfiles; |
1666 | - |
1667 | - return true; |
1668 | -} |
1669 | - |
1670 | -QMap<QString, quint32> ButeoImport::sources() const |
1671 | -{ |
1672 | - QMap<QString, quint32> result; |
1673 | - QScopedPointer<QContactManager> manager(new QContactManager("galera")); |
1674 | - QContactDetailFilter sourceFilter; |
1675 | - sourceFilter.setDetailType(QContactDetail::TypeType, QContactType::FieldType); |
1676 | - sourceFilter.setValue( QContactType::TypeGroup); |
1677 | - Q_FOREACH(const QContact &c, manager->contacts(sourceFilter)) { |
1678 | - uint accountId = 0; |
1679 | - // skip local source |
1680 | - if (c.id().toString().endsWith("source@system-address-book")) { |
1681 | - continue; |
1682 | - } |
1683 | - |
1684 | - Q_FOREACH(const QContactExtendedDetail &xDet, c.details<QContactExtendedDetail>()) { |
1685 | - if (xDet.name() == "ACCOUNT-ID") { |
1686 | - if (xDet.data().isValid()) { |
1687 | - accountId = xDet.data().toString().toUInt(); |
1688 | - } |
1689 | - break; |
1690 | - } |
1691 | - } |
1692 | - |
1693 | - result.insert(c.id().toString(), accountId); |
1694 | - } |
1695 | - |
1696 | - return result; |
1697 | -} |
1698 | - |
1699 | -bool ButeoImport::prepareButeo() |
1700 | -{ |
1701 | - if (!m_buteoInterface.isNull()) { |
1702 | - return true; |
1703 | - } |
1704 | - |
1705 | - m_buteoInterface.reset(new QDBusInterface(BUTEO_DBUS_SERVICE_NAME, |
1706 | - BUTEO_DBUS_OBJECT_PATH, |
1707 | - BUTEO_DBUS_INTERFACE)); |
1708 | - |
1709 | - if (!m_buteoInterface->isValid()) { |
1710 | - m_buteoInterface.reset(); |
1711 | - qWarning() << "Fail to connect with syncfw"; |
1712 | - return false; |
1713 | - } |
1714 | - |
1715 | - connect(m_buteoInterface.data(), |
1716 | - SIGNAL(signalProfileChanged(QString, int, QString)), |
1717 | - SLOT(onProfileChanged(QString, int, QString))); |
1718 | - connect(m_buteoInterface.data(), |
1719 | - SIGNAL(syncStatus(QString,int,QString,int)), |
1720 | - SLOT(onSyncStatusChanged(QString,int,QString,int))); |
1721 | - |
1722 | - return true; |
1723 | -} |
1724 | - |
1725 | -QMap<quint32, QString> ButeoImport::createProfileForAccounts(QList<quint32> ids) |
1726 | -{ |
1727 | - QMap<quint32, QString> map; |
1728 | - if (m_buteoInterface.isNull()) { |
1729 | - qWarning() << "Buteo interface is not valid"; |
1730 | - return map; |
1731 | - } |
1732 | - |
1733 | - Q_FOREACH(quint32 id, ids) { |
1734 | - if (!enableContactsService(id)) { |
1735 | - qWarning() << "Fail to enable contacts service for account:" << id; |
1736 | - continue; |
1737 | - } |
1738 | - |
1739 | - QDBusReply<QString> result = m_buteoInterface->call("createSyncProfileForAccount", id); |
1740 | - if (result.error().isValid()) { |
1741 | - qWarning() << "Fail to create profile for account" << id << result.error(); |
1742 | - } else if (!result.value().isEmpty()) { |
1743 | - qDebug() << "Profile created" << result.value() << id; |
1744 | - map.insert(id, result.value()); |
1745 | - } else { |
1746 | - qWarning() << "Fail to create profile for account" << id; |
1747 | - } |
1748 | - } |
1749 | - return map; |
1750 | -} |
1751 | - |
1752 | -bool ButeoImport::removeProfile(const QString &profileId) |
1753 | -{ |
1754 | - if (m_buteoInterface.isNull()) { |
1755 | - qWarning() << "Buteo interface is not valid"; |
1756 | - return false; |
1757 | - } |
1758 | - |
1759 | - // check for account |
1760 | - quint32 accountId = m_initialAccountToProfiles.key(profileId, 0); |
1761 | - if (accountId == 0) { |
1762 | - qWarning() << "Fail to find account related with profile" << profileId; |
1763 | - return false; |
1764 | - } |
1765 | - |
1766 | - // check for source |
1767 | - QMap<QString, quint32> listOfSources = sources(); |
1768 | - QString sourceId = listOfSources.key(accountId, ""); |
1769 | - |
1770 | - // remove source |
1771 | - if (!sourceId.isEmpty()) { |
1772 | - QScopedPointer<QContactManager> manager(new QContactManager("galera")); |
1773 | - if (!manager->removeContact(QContactId::fromString(sourceId))) { |
1774 | - qWarning() << "Fail to remove contact source:" << sourceId; |
1775 | - return false; |
1776 | - } else { |
1777 | - qDebug() << "Source removed" << sourceId; |
1778 | - } |
1779 | - } else { |
1780 | - qDebug() << "No source was created for account" << accountId; |
1781 | - } |
1782 | - |
1783 | - // remove profile |
1784 | - return buteoRemoveProfile(profileId); |
1785 | -} |
1786 | - |
1787 | -bool ButeoImport::buteoRemoveProfile(const QString &profileId) const |
1788 | -{ |
1789 | - QDBusReply<bool> result = m_buteoInterface->call("removeProfile", profileId); |
1790 | - if (result.error().isValid()) { |
1791 | - qWarning() << "Fail to remove profile" << profileId << result.error(); |
1792 | - return false; |
1793 | - } |
1794 | - return true; |
1795 | -} |
1796 | - |
1797 | -bool ButeoImport::removeSources(const QStringList &sources) |
1798 | -{ |
1799 | - if (sources.isEmpty()) { |
1800 | - return true; |
1801 | - } |
1802 | - |
1803 | - bool result = true; |
1804 | - QScopedPointer<QContactManager> manager(new QContactManager("galera")); |
1805 | - Q_FOREACH(const QString &source, sources) { |
1806 | - if (!manager->removeContact(QContactId::fromString(source))) { |
1807 | - qWarning() << "Fail to remove source" << source; |
1808 | - result = false; |
1809 | - } |
1810 | - } |
1811 | - |
1812 | - return result; |
1813 | -} |
1814 | - |
1815 | -bool ButeoImport::commit() |
1816 | -{ |
1817 | - Q_ASSERT(m_accountToProfiles.isEmpty()); |
1818 | - |
1819 | - // update new favorites |
1820 | - matchFavorites(); |
1821 | - |
1822 | - // remove old sources |
1823 | - QStringList oldSources; |
1824 | - QMap<QString, quint32> srcs = sources(); |
1825 | - |
1826 | - for(QMap<QString, uint>::const_iterator i = srcs.begin(); |
1827 | - i != srcs.end(); |
1828 | - i++) { |
1829 | - if (i.value() == 0) { |
1830 | - qDebug() << "Remove source" << i.key(); |
1831 | - oldSources << i.key(); |
1832 | - } |
1833 | - } |
1834 | - removeSources(oldSources); |
1835 | - |
1836 | - // all accounts synced |
1837 | - m_importLock.unlock(); |
1838 | - |
1839 | - // update settings key |
1840 | - QSettings settings; |
1841 | - settings.setValue(SETTINGS_BUTEO_KEY, true); |
1842 | - settings.sync(); |
1843 | - |
1844 | - // disable address-book-service safe-mode |
1845 | - QDBusMessage setSafeMode = QDBusMessage::createMethodCall("com.canonical.pim", |
1846 | - "/com/canonical/pim/AddressBook", |
1847 | - "org.freedesktop.DBus.Properties", |
1848 | - "Set"); |
1849 | - QList<QVariant> args; |
1850 | - args << "com.canonical.pim.AddressBook" |
1851 | - << "safeMode" |
1852 | - << QVariant::fromValue(QDBusVariant(false)); |
1853 | - setSafeMode.setArguments(args); |
1854 | - QDBusReply<void> reply = QDBusConnection::sessionBus().call(setSafeMode); |
1855 | - if (reply.error().isValid()) { |
1856 | - qWarning() << "Fail to disable safe-mode" << reply.error().message(); |
1857 | - } else { |
1858 | - qDebug() << "Server safe mode disabled"; |
1859 | - } |
1860 | - |
1861 | - // WORKAROUND: wait 4 secs to fire update done, this is necessary because the contacts will be set as favorite |
1862 | - // just after the signal be fired and the changes can not have the same timestamp that the creation |
1863 | - QTimer::singleShot(4000, this, SIGNAL(updated())); |
1864 | - return true; |
1865 | -} |
1866 | - |
1867 | -bool ButeoImport::rollback() |
1868 | -{ |
1869 | - // remove all profiles and new sources |
1870 | - Q_FOREACH(const QString &profile, m_failToSyncProfiles) { |
1871 | - removeProfile(profile); |
1872 | - } |
1873 | - m_failToSyncProfiles.clear(); |
1874 | - return true; |
1875 | -} |
1876 | - |
1877 | -void ButeoImport::onError(const QString &accountName, int errorCode) |
1878 | -{ |
1879 | - m_lastError = ABUpdateModule::ImportError(errorCode); |
1880 | - Q_EMIT updateError(accountName, m_lastError); |
1881 | -} |
1882 | - |
1883 | -bool ButeoImport::requireInternetConnection() |
1884 | -{ |
1885 | - return true; |
1886 | -} |
1887 | - |
1888 | -bool ButeoImport::canUpdate() |
1889 | -{ |
1890 | - if (!prepareButeo()) { |
1891 | - qWarning() << "Fail to connect with contact sync service. We can not continue the upgrade"; |
1892 | - return false; |
1893 | - } |
1894 | - |
1895 | - // check for any running sync |
1896 | - QStringList syncs = runningSyncs(); |
1897 | - if (!syncs.isEmpty()) { |
1898 | - qWarning() << "Sync running" << syncs << "no way to check for outdated information"; |
1899 | - return false; |
1900 | - } |
1901 | - |
1902 | - return true; |
1903 | -} |
1904 | - |
1905 | -ButeoImport::ImportError ButeoImport::lastError() const |
1906 | -{ |
1907 | - return m_lastError; |
1908 | -} |
1909 | - |
1910 | -void ButeoImport::onProfileChanged(const QString &profileName, int changeType, const QString &profileAsXml) |
1911 | -{ |
1912 | - Q_UNUSED(profileAsXml); |
1913 | - /* |
1914 | - * 0 (ADDITION): Profile was added. |
1915 | - * 1 (MODIFICATION): Profile was modified. |
1916 | - * 2 (DELETION): Profile was deleted. |
1917 | - */ |
1918 | - switch(changeType) { |
1919 | - case 0: |
1920 | - // profile created sync should start soon |
1921 | - qDebug() << "Profile created" << profileName; |
1922 | - break; |
1923 | - case 1: |
1924 | - break; |
1925 | - case 2: |
1926 | - { |
1927 | - quint32 accountId = m_initialAccountToProfiles.key(profileName, 0); |
1928 | - if (accountId > 0) { |
1929 | - qDebug() << "Profile removed" << accountId << profileName; |
1930 | - m_pendingAccountToProfiles.remove(accountId); |
1931 | - if (m_pendingAccountToProfiles.isEmpty()) { |
1932 | - // all accounts removed |
1933 | - m_importLock.unlock(); |
1934 | - } |
1935 | - } |
1936 | - break; |
1937 | - } |
1938 | - } |
1939 | -} |
1940 | - |
1941 | -void ButeoImport::onSyncStatusChanged(const QString &profileName, |
1942 | - int status, |
1943 | - const QString &message, |
1944 | - int moreDetails) |
1945 | -{ |
1946 | - Q_UNUSED(message); |
1947 | - Q_UNUSED(moreDetails); |
1948 | - |
1949 | - if (!m_pendingAccountToProfiles.values().contains(profileName)) { |
1950 | - qDebug() << "Profile not found" << profileName; |
1951 | - return; |
1952 | - } |
1953 | - quint32 accountId = m_pendingAccountToProfiles.key(profileName, 0); |
1954 | - qDebug() << "SyncStatus" |
1955 | - << "\n\tProfile:" << profileName |
1956 | - << "\n\tAccount:" << accountId |
1957 | - << "\n\tStatus:" << status |
1958 | - << "\n\tMessage:" << message |
1959 | - << "\n\tDetails:" << moreDetails; |
1960 | - /* |
1961 | - * 0 (QUEUED): Sync request has been queued or was already in the |
1962 | - * queue when sync start was requested. |
1963 | - * 1 (STARTED): Sync session has been started. |
1964 | - * 2 (PROGRESS): Sync session is progressing. |
1965 | - * 3 (ERROR): Sync session has encountered an error and has been stopped, |
1966 | - * or the session could not be started at all. |
1967 | - * 4 (DONE): Sync session was successfully completed. |
1968 | - * 5 (ABORTED): Sync session was aborted. |
1969 | - */ |
1970 | - switch(status) { |
1971 | - case 0: |
1972 | - case 1: |
1973 | - case 2: |
1974 | - return; |
1975 | - case 3: |
1976 | - qWarning() << "Sync error for account:" << accountId << "and profile" << profileName; |
1977 | - m_failToSyncProfiles << profileName; |
1978 | - m_lastError = parseError(moreDetails); |
1979 | - break; |
1980 | - case 4: |
1981 | - qDebug() << "Sync finished for account:" << accountId << "and profile" << profileName; |
1982 | - break; |
1983 | - case 5: |
1984 | - qWarning() << "Sync aborted for account:" << accountId << "and profile" << profileName; |
1985 | - m_failToSyncProfiles << profileName; |
1986 | - break; |
1987 | - } |
1988 | - |
1989 | - if (accountId > 0) { |
1990 | - m_pendingAccountToProfiles.remove(accountId); |
1991 | - if (m_pendingAccountToProfiles.isEmpty()) { |
1992 | - qDebug() << "All accounts has fineshed the sync, number of accounts that fail to sync:" << m_failToSyncProfiles.size(); |
1993 | - if (m_failToSyncProfiles.isEmpty()) { |
1994 | - Q_EMIT updated(); |
1995 | - } else { |
1996 | - QMetaObject::invokeMethod(this, "onError", Qt::QueuedConnection, |
1997 | - Q_ARG(QString, ""), Q_ARG(int, m_lastError)); |
1998 | - } |
1999 | - } |
2000 | - } |
2001 | -} |
2002 | |
2003 | === removed file 'updater/ab-update-buteo-import.h' |
2004 | --- updater/ab-update-buteo-import.h 2015-09-29 14:37:03 +0000 |
2005 | +++ updater/ab-update-buteo-import.h 1970-01-01 00:00:00 +0000 |
2006 | @@ -1,74 +0,0 @@ |
2007 | -/* |
2008 | - * Copyright 2015 Canonical Ltd. |
2009 | - * |
2010 | - * This file is part of address-book-service. |
2011 | - * |
2012 | - * sync-monitor is free software; you can redistribute it and/or modify |
2013 | - * it under the terms of the GNU General Public License as published by |
2014 | - * the Free Software Foundation; version 3. |
2015 | - * |
2016 | - * contact-service-app is distributed in the hope that it will be useful, |
2017 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2018 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2019 | - * GNU General Public License for more details. |
2020 | - * |
2021 | - * You should have received a copy of the GNU General Public License |
2022 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2023 | - */ |
2024 | - |
2025 | -#include <QtCore/QObject> |
2026 | -#include <QtCore/QMap> |
2027 | -#include <QtCore/QMutex> |
2028 | -#include <QtCore/QEventLoop> |
2029 | -#include <QtDBus/QDBusInterface> |
2030 | - |
2031 | -#include "ab-update-module.h" |
2032 | - |
2033 | -class ButeoImport : public ABUpdateModule |
2034 | -{ |
2035 | - Q_OBJECT |
2036 | -public: |
2037 | - ButeoImport(QObject *parent = 0); |
2038 | - ~ButeoImport(); |
2039 | - |
2040 | - QString name() const override; |
2041 | - bool needsUpdate() override; |
2042 | - bool prepareToUpdate() override; |
2043 | - bool update() override; |
2044 | - bool requireInternetConnection() override; |
2045 | - bool canUpdate() override; |
2046 | - bool commit() override; |
2047 | - bool rollback() override; |
2048 | - ImportError lastError() const override; |
2049 | - |
2050 | -private Q_SLOTS: |
2051 | - void onProfileChanged(const QString &profileName, int changeType, const QString &profileAsXml); |
2052 | - void onSyncStatusChanged(const QString &aProfileName, int aStatus, const QString &aMessage, int aMoreDetails); |
2053 | - void onError(const QString &accountName, int errorCode); |
2054 | - |
2055 | -private: |
2056 | - QScopedPointer<QDBusInterface> m_buteoInterface; |
2057 | - QMap<quint32, QString> m_initialAccountToProfiles; |
2058 | - QMap<quint32, QString> m_pendingAccountToProfiles; |
2059 | - QStringList m_failToSyncProfiles; |
2060 | - QMutex m_importLock; |
2061 | - ImportError m_lastError; |
2062 | - |
2063 | - QMap<QString, quint32> sources() const; |
2064 | - QMap<quint32, QString> createProfileForAccounts(QList<quint32> ids); |
2065 | - bool prepareButeo(); |
2066 | - bool createAccounts(QList<quint32> ids); |
2067 | - bool removeProfile(const QString &profileId); |
2068 | - bool buteoRemoveProfile(const QString &profileId) const; |
2069 | - bool removeSources(const QStringList &sources); |
2070 | - |
2071 | - bool loadAccounts(QList<quint32> &accountsToUpdate, QList<quint32> &newAccounts); |
2072 | - bool enableContactsService(quint32 accountId); |
2073 | - QString accountName(quint32 accountId); |
2074 | - QStringList runningSyncs() const; |
2075 | - QString profileName(const QString &xml) const; |
2076 | - QString profileName(quint32 accountId) const; |
2077 | - bool startSync(const QString &profile) const; |
2078 | - bool matchFavorites(); |
2079 | - ImportError parseError(int errorCode) const; |
2080 | -}; |
2081 | |
2082 | === removed file 'updater/ab-update-module.cpp' |
2083 | --- updater/ab-update-module.cpp 2015-09-03 19:09:36 +0000 |
2084 | +++ updater/ab-update-module.cpp 1970-01-01 00:00:00 +0000 |
2085 | @@ -1,28 +0,0 @@ |
2086 | -/* |
2087 | - * Copyright 2015 Canonical Ltd. |
2088 | - * |
2089 | - * This file is part of address-book-service. |
2090 | - * |
2091 | - * sync-monitor is free software; you can redistribute it and/or modify |
2092 | - * it under the terms of the GNU General Public License as published by |
2093 | - * the Free Software Foundation; version 3. |
2094 | - * |
2095 | - * contact-service-app is distributed in the hope that it will be useful, |
2096 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2097 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2098 | - * GNU General Public License for more details. |
2099 | - * |
2100 | - * You should have received a copy of the GNU General Public License |
2101 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2102 | - */ |
2103 | - |
2104 | -#include "ab-update-module.h" |
2105 | - |
2106 | -ABUpdateModule::ABUpdateModule(QObject *parent) |
2107 | - : QObject(parent) |
2108 | -{ |
2109 | -} |
2110 | - |
2111 | -ABUpdateModule::~ABUpdateModule() |
2112 | -{ |
2113 | -} |
2114 | |
2115 | === removed file 'updater/ab-update-module.h' |
2116 | --- updater/ab-update-module.h 2015-09-29 14:15:42 +0000 |
2117 | +++ updater/ab-update-module.h 1970-01-01 00:00:00 +0000 |
2118 | @@ -1,56 +0,0 @@ |
2119 | -/* |
2120 | - * Copyright 2015 Canonical Ltd. |
2121 | - * |
2122 | - * This file is part of address-book-service. |
2123 | - * |
2124 | - * sync-monitor is free software; you can redistribute it and/or modify |
2125 | - * it under the terms of the GNU General Public License as published by |
2126 | - * the Free Software Foundation; version 3. |
2127 | - * |
2128 | - * contact-service-app is distributed in the hope that it will be useful, |
2129 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2130 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2131 | - * GNU General Public License for more details. |
2132 | - * |
2133 | - * You should have received a copy of the GNU General Public License |
2134 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2135 | - */ |
2136 | - |
2137 | -#pragma once |
2138 | -#include <QtCore/QObject> |
2139 | - |
2140 | -class ABUpdateModule : public QObject |
2141 | -{ |
2142 | - Q_OBJECT |
2143 | - Q_ENUMS(ImportError) |
2144 | - |
2145 | -public: |
2146 | - enum ImportError { |
2147 | - ApplicationAreadyUpdated = 0, |
2148 | - ConnectionError, |
2149 | - FailToConnectWithButeo, |
2150 | - FailToCreateButeoProfiles, |
2151 | - FailToAuthenticate, |
2152 | - InernalError, |
2153 | - OnlineAccountNotFound, |
2154 | - SyncAlreadyRunning, |
2155 | - SyncError |
2156 | - }; |
2157 | - |
2158 | - ABUpdateModule(QObject *parent = 0); |
2159 | - ~ABUpdateModule() override; |
2160 | - |
2161 | - virtual QString name() const = 0; |
2162 | - virtual bool needsUpdate() = 0; |
2163 | - virtual bool prepareToUpdate() = 0; |
2164 | - virtual bool update() = 0; |
2165 | - virtual bool canUpdate() = 0; |
2166 | - virtual bool requireInternetConnection() = 0; |
2167 | - virtual bool commit() = 0; |
2168 | - virtual bool rollback() = 0; |
2169 | - virtual ImportError lastError() const = 0; |
2170 | - |
2171 | -Q_SIGNALS: |
2172 | - void updated(); |
2173 | - void updateError(const QString &accountName, ABUpdateModule::ImportError errorCode); |
2174 | -}; |
2175 | |
2176 | === removed file 'updater/ab-update.cpp' |
2177 | --- updater/ab-update.cpp 2015-09-29 14:37:03 +0000 |
2178 | +++ updater/ab-update.cpp 1970-01-01 00:00:00 +0000 |
2179 | @@ -1,366 +0,0 @@ |
2180 | -/* |
2181 | - * Copyright 2015 Canonical Ltd. |
2182 | - * |
2183 | - * This file is part of address-book-service. |
2184 | - * |
2185 | - * sync-monitor is free software; you can redistribute it and/or modify |
2186 | - * it under the terms of the GNU General Public License as published by |
2187 | - * the Free Software Foundation; version 3. |
2188 | - * |
2189 | - * contact-service-app is distributed in the hope that it will be useful, |
2190 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2191 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2192 | - * GNU General Public License for more details. |
2193 | - * |
2194 | - * You should have received a copy of the GNU General Public License |
2195 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2196 | - */ |
2197 | - |
2198 | -#include "ab-update.h" |
2199 | -#include "ab-update-module.h" |
2200 | -#include "ab-update-buteo-import.h" |
2201 | -#include "ab-notify-message.h" |
2202 | -#include "ab-i18n.h" |
2203 | - |
2204 | -#include <QtCore/QDebug> |
2205 | -#include <QtCore/QTimer> |
2206 | -#include <QtCore/QCoreApplication> |
2207 | -#include <QtCore/QDir> |
2208 | -#include <QtNetwork/QNetworkConfiguration> |
2209 | - |
2210 | -#define TRANSFER_ICON "/usr/share/icons/suru/status/scalable/transfer-progress.svg" |
2211 | -#define TRANSFER_ICON_PAUSED "/usr/share/icons/suru/status/scalable/transfer-paused.svg" |
2212 | -#define TRANSFER_ICON_ERROR "/usr/share/icons/suru/status/scalable/transfer-error.svg" |
2213 | - |
2214 | - |
2215 | -ABUpdate::ABUpdate(QObject *parent) |
2216 | - : QObject(parent), |
2217 | - m_netManager(new QNetworkConfigurationManager), |
2218 | - m_needsUpdate(false), |
2219 | - m_isRunning(false), |
2220 | - m_activeModule(-1), |
2221 | - m_skipNetworkTest(false), |
2222 | - m_silenceMode(false), |
2223 | - m_lockFile(QDir::tempPath() + "/address-book-updater.lock") |
2224 | -{ |
2225 | - // load update modules (this can be a plugin system in the future) |
2226 | - m_updateModules << new ButeoImport; |
2227 | - m_lockFile.setStaleLockTime(0); |
2228 | -} |
2229 | - |
2230 | -ABUpdate::~ABUpdate() |
2231 | -{ |
2232 | - qDeleteAll(m_updateModules); |
2233 | -} |
2234 | - |
2235 | -QList<ABUpdateModule*> ABUpdate::needsUpdate() const |
2236 | -{ |
2237 | - QList<ABUpdateModule*> result; |
2238 | - Q_FOREACH(ABUpdateModule *module, m_updateModules) { |
2239 | - bool mNeedsUpdate = module->needsUpdate(); |
2240 | - qDebug() << "Check if module needs update" << module->name() << ":" << mNeedsUpdate; |
2241 | - if (mNeedsUpdate) { |
2242 | - result << module; |
2243 | - } |
2244 | - } |
2245 | - return result; |
2246 | -} |
2247 | - |
2248 | -bool ABUpdate::isRunning() |
2249 | -{ |
2250 | - if (m_lock.tryLock()) { |
2251 | - m_lock.unlock(); |
2252 | - return false; |
2253 | - } |
2254 | - return true; |
2255 | -} |
2256 | - |
2257 | -void ABUpdate::skipNetworkTest() |
2258 | -{ |
2259 | - m_skipNetworkTest = true; |
2260 | -} |
2261 | - |
2262 | -void ABUpdate::setSilenceMode(bool flag) |
2263 | -{ |
2264 | - m_silenceMode = flag; |
2265 | -} |
2266 | - |
2267 | -void ABUpdate::startUpdate() |
2268 | -{ |
2269 | - qDebug() << "Start update..."; |
2270 | - if (!m_lockFile.tryLock()) { |
2271 | - qWarning() << "Lock file is locked. Removing it..."; |
2272 | - m_lockFile.removeStaleLockFile(); |
2273 | - } |
2274 | - |
2275 | - if (m_waitingForIntenert) { |
2276 | - m_waitingForIntenert = false; |
2277 | - m_netManager->disconnect(this); |
2278 | - } |
2279 | - |
2280 | - if (isRunning()) { |
2281 | - qWarning() << "Update already running."; |
2282 | - if (!m_silenceMode) { |
2283 | - ABNotifyMessage *msg = new ABNotifyMessage(true, this); |
2284 | - //if force is set and the app is waiting for internet continue anyway |
2285 | - msg->show(_("Account update"), |
2286 | - QString(_("%1 contact sync account upgrade already in progress")).arg("Google"), |
2287 | - TRANSFER_ICON); |
2288 | - } |
2289 | - return; |
2290 | - } |
2291 | - |
2292 | - // check if any module needs a upgrade |
2293 | - QList<ABUpdateModule*> modulesToUpdate = needsUpdate(); |
2294 | - if (modulesToUpdate.isEmpty()) { |
2295 | - qDebug() << "No module to update."; |
2296 | - notifyDone(); |
2297 | - return; |
2298 | - } |
2299 | - |
2300 | - m_lock.lock(); |
2301 | - m_modulesToUpdate = modulesToUpdate; |
2302 | - qDebug() << "Modules to update" << m_modulesToUpdate.size(); |
2303 | - if (isOnline(false)) { |
2304 | - notifyStart(); |
2305 | - } else { |
2306 | - qWarning() << "No internet abort"; |
2307 | - notifyNoInternet(); |
2308 | - updateNextModule(); |
2309 | - } |
2310 | -} |
2311 | - |
2312 | -void ABUpdate::startUpdateWhenConnected() |
2313 | -{ |
2314 | - qDebug() << "Start update when connected..."; |
2315 | - |
2316 | - if (isRunning()) { |
2317 | - qWarning() << "Update already running."; |
2318 | - return; |
2319 | - } |
2320 | - |
2321 | - if (isOnline(true)) { |
2322 | - startUpdate(); |
2323 | - } else { |
2324 | - notifyNoInternet(); |
2325 | - waitForInternet(); |
2326 | - } |
2327 | -} |
2328 | - |
2329 | -void ABUpdate::startUpdate(ABUpdateModule *module) |
2330 | -{ |
2331 | - qDebug() << "Start update for" << module->name(); |
2332 | - m_activeModule = m_updateModules.indexOf(module); |
2333 | - if (!module->canUpdate()) { |
2334 | - qWarning() << "Module can not be updated" << module->name(); |
2335 | - onModuleUpdateError("", ABUpdateModule::InernalError); |
2336 | - } else { |
2337 | - if (!module->prepareToUpdate()) { |
2338 | - qWarning() << "Fail to prepare to update:" << module->name(); |
2339 | - updateNextModule(); |
2340 | - } else { |
2341 | - connect(module, |
2342 | - SIGNAL(updated()), |
2343 | - SLOT(onModuleUpdated())); |
2344 | - connect(module, |
2345 | - SIGNAL(updateError(QString, ABUpdateModule::ImportError)), |
2346 | - SLOT(onModuleUpdateError(QString, ABUpdateModule::ImportError))); |
2347 | - module->update(); |
2348 | - } |
2349 | - } |
2350 | -} |
2351 | - |
2352 | -bool ABUpdate::isOnline(bool checkConnectionType) const |
2353 | -{ |
2354 | - if (m_skipNetworkTest) { |
2355 | - return true; |
2356 | - } |
2357 | - |
2358 | - if (!m_netManager->isOnline()) { |
2359 | - return false; |
2360 | - } else if (checkConnectionType) { |
2361 | - QNetworkConfiguration::BearerType bearerType = m_netManager->defaultConfiguration().bearerType(); |
2362 | - return ((bearerType == QNetworkConfiguration::BearerWLAN) || |
2363 | - (bearerType == QNetworkConfiguration::BearerEthernet)); |
2364 | - } else { |
2365 | - return true; |
2366 | - } |
2367 | -} |
2368 | - |
2369 | -void ABUpdate::waitForInternet() |
2370 | -{ |
2371 | - qDebug() << "Not internet connection wait before start upgrade"; |
2372 | - m_waitingForIntenert = true; |
2373 | - connect(m_netManager.data(), |
2374 | - SIGNAL(onlineStateChanged(bool)), |
2375 | - SLOT(onOnlineStateChanged())); |
2376 | - connect(m_netManager.data(), |
2377 | - SIGNAL(updateCompleted()), |
2378 | - SLOT(onOnlineStateChanged())); |
2379 | - connect(m_netManager.data(), |
2380 | - SIGNAL(configurationAdded(QNetworkConfiguration)), |
2381 | - SLOT(onOnlineStateChanged())); |
2382 | - connect(m_netManager.data(), |
2383 | - SIGNAL(configurationChanged(QNetworkConfiguration)), |
2384 | - SLOT(onOnlineStateChanged())); |
2385 | - connect(m_netManager.data(), |
2386 | - SIGNAL(configurationRemoved(QNetworkConfiguration)), |
2387 | - SLOT(onOnlineStateChanged())); |
2388 | -} |
2389 | - |
2390 | -QString ABUpdate::errorMessage(ABUpdateModule::ImportError error) const |
2391 | -{ |
2392 | - switch (error) |
2393 | - { |
2394 | - case ABUpdateModule::ApplicationAreadyUpdated: |
2395 | - return _("Contacts app is updated already!"); |
2396 | - case ABUpdateModule::ConnectionError: |
2397 | - return _("Fail to connect to internet!"); |
2398 | - case ABUpdateModule::FailToConnectWithButeo: |
2399 | - return _("Fail to connect to contact sync service!"); |
2400 | - case ABUpdateModule::FailToCreateButeoProfiles: |
2401 | - return _("Fail to create sync profile!"); |
2402 | - case ABUpdateModule::FailToAuthenticate: |
2403 | - return _("Fail to authenticate!"); |
2404 | - case ABUpdateModule::InernalError: |
2405 | - return _("Internal error during the sync!"); |
2406 | - case ABUpdateModule::OnlineAccountNotFound: |
2407 | - return _("Online account not found!"); |
2408 | - case ABUpdateModule::SyncAlreadyRunning: |
2409 | - return _("Update already in progress!"); |
2410 | - case ABUpdateModule::SyncError: |
2411 | - default: |
2412 | - return _("Fail to sync contacts!"); |
2413 | - } |
2414 | -} |
2415 | - |
2416 | -void ABUpdate::updateNextModule() |
2417 | -{ |
2418 | - qDebug() << "Update next module" << m_modulesToUpdate.size(); |
2419 | - if (m_modulesToUpdate.isEmpty()) { |
2420 | - notifyDone(); |
2421 | - } else { |
2422 | - startUpdate(m_modulesToUpdate.takeFirst()); |
2423 | - } |
2424 | -} |
2425 | - |
2426 | - |
2427 | -void ABUpdate::cancelUpdate() |
2428 | -{ |
2429 | -} |
2430 | - |
2431 | -void ABUpdate::onModuleUpdated() |
2432 | -{ |
2433 | - ABUpdateModule *module = m_updateModules.at(m_activeModule); |
2434 | - module->disconnect(this); |
2435 | - if (!module->commit()) { |
2436 | - qDebug() << "Fail to commit final changes for module" << module->name(); |
2437 | - onModuleUpdateError("", ABUpdateModule::InernalError); |
2438 | - return; |
2439 | - } |
2440 | - |
2441 | - qDebug() << "Update complete for:" << module->name(); |
2442 | - if (m_silenceMode) { |
2443 | - updateNextModule(); |
2444 | - } else { |
2445 | - ABNotifyMessage *msg = new ABNotifyMessage(true, this); |
2446 | - msg->show(_("Account update"), |
2447 | - _("Contact sync upgrade complete."), |
2448 | - TRANSFER_ICON); |
2449 | - connect(msg, SIGNAL(messageClosed()), SLOT(updateNextModule())); |
2450 | - } |
2451 | -} |
2452 | - |
2453 | -void ABUpdate::onModuleUpdateError(const QString &accountName, ABUpdateModule::ImportError error) |
2454 | -{ |
2455 | - ABUpdateModule *module = m_updateModules.at(m_activeModule); |
2456 | - module->disconnect(this); |
2457 | - |
2458 | - qWarning() << "Fail to update module" << module->name() << accountName << module->lastError(); |
2459 | - module->rollback(); |
2460 | - |
2461 | - if (m_silenceMode) { |
2462 | - updateNextModule(); |
2463 | - } else { |
2464 | - ABNotifyMessage *msg = new ABNotifyMessage(true, this); |
2465 | - msg->setProperty("MODULE", QVariant::fromValue<QObject*>(module)); |
2466 | - msg->askYesOrNo(_("Fail to update"), |
2467 | - QString(_("%1.\nDo you want to retry now?")).arg(errorMessage(error)), |
2468 | - TRANSFER_ICON_ERROR); |
2469 | - connect(msg, SIGNAL(questionAccepted()), this, SLOT(onModuleUpdateRetry())); |
2470 | - connect(msg, SIGNAL(questionRejected()), SLOT(onModuleUpdateNoRetry())); |
2471 | - connect(msg, SIGNAL(messageClosed()), SLOT(onModuleUpdateNoRetry())); |
2472 | - } |
2473 | -} |
2474 | - |
2475 | -void ABUpdate::onModuleUpdateRetry() |
2476 | -{ |
2477 | - QObject *sender = QObject::sender(); |
2478 | - disconnect(sender); |
2479 | - |
2480 | - ABUpdateModule *module = qobject_cast<ABUpdateModule*>(sender->property("MODULE").value<QObject*>()); |
2481 | - m_modulesToUpdate << module; |
2482 | - updateNextModule(); |
2483 | -} |
2484 | - |
2485 | -void ABUpdate::onModuleUpdateNoRetry() |
2486 | -{ |
2487 | - QObject *sender = QObject::sender(); |
2488 | - disconnect(sender); |
2489 | - |
2490 | - ABNotifyMessage *msg = new ABNotifyMessage(true, this); |
2491 | - msg->show(_("Fail to update"), |
2492 | - _("To retry later open Contacts app and press the sync button."), |
2493 | - TRANSFER_ICON); |
2494 | - connect(msg, SIGNAL(messageClosed()), SLOT(updateNextModule())); |
2495 | -} |
2496 | - |
2497 | -void ABUpdate::onOnlineStateChanged() |
2498 | -{ |
2499 | - if (isOnline(true)) { |
2500 | - qDebug() << "Network is online resume upddate process."; |
2501 | - m_waitingForIntenert = false; |
2502 | - m_netManager->disconnect(this); |
2503 | - QTimer::singleShot(5000, this, SLOT(continueUpdateWithInternet())); |
2504 | - } |
2505 | -} |
2506 | - |
2507 | -void ABUpdate::continueUpdateWithInternet() |
2508 | -{ |
2509 | - if (isOnline(true)) { |
2510 | - startUpdate(); |
2511 | - } else { |
2512 | - waitForInternet(); |
2513 | - } |
2514 | -} |
2515 | - |
2516 | -void ABUpdate::notifyStart() |
2517 | -{ |
2518 | - if (m_silenceMode) { |
2519 | - updateNextModule(); |
2520 | - } else { |
2521 | - ABNotifyMessage *msg = new ABNotifyMessage(true, this); |
2522 | - msg->show(_("Account update"), |
2523 | - QString(_("%1 contact sync account upgrade in progress")).arg("Google"), |
2524 | - TRANSFER_ICON); |
2525 | - connect(msg, SIGNAL(messageClosed()), SLOT(updateNextModule())); |
2526 | - } |
2527 | -} |
2528 | - |
2529 | -void ABUpdate::notifyNoInternet() |
2530 | -{ |
2531 | - if (!m_silenceMode) { |
2532 | - ABNotifyMessage *msg = new ABNotifyMessage(true, this); |
2533 | - msg->show(_("Account update"), |
2534 | - QString(_("%1 contact sync account needs upgrade. Please connect with the internet.")).arg("Google"), |
2535 | - TRANSFER_ICON_PAUSED); |
2536 | - } |
2537 | -} |
2538 | - |
2539 | -void ABUpdate::notifyDone() |
2540 | -{ |
2541 | - m_activeModule = -1; |
2542 | - m_lock.unlock(); |
2543 | - qDebug() << "Send update done"; |
2544 | - Q_EMIT updateDone(); |
2545 | -} |
2546 | |
2547 | === removed file 'updater/ab-update.h' |
2548 | --- updater/ab-update.h 2015-09-18 13:24:00 +0000 |
2549 | +++ updater/ab-update.h 1970-01-01 00:00:00 +0000 |
2550 | @@ -1,87 +0,0 @@ |
2551 | -/* |
2552 | - * Copyright 2015 Canonical Ltd. |
2553 | - * |
2554 | - * This file is part of address-book-service. |
2555 | - * |
2556 | - * sync-monitor is free software; you can redistribute it and/or modify |
2557 | - * it under the terms of the GNU General Public License as published by |
2558 | - * the Free Software Foundation; version 3. |
2559 | - * |
2560 | - * contact-service-app is distributed in the hope that it will be useful, |
2561 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2562 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2563 | - * GNU General Public License for more details. |
2564 | - * |
2565 | - * You should have received a copy of the GNU General Public License |
2566 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2567 | - */ |
2568 | - |
2569 | -#pragma once |
2570 | - |
2571 | -#include "ab-update-module.h" |
2572 | - |
2573 | -#include <QtCore/QObject> |
2574 | -#include <QtCore/QMutex> |
2575 | -#include <QtCore/QLockFile> |
2576 | -#include <QtCore/QScopedPointer> |
2577 | -#include <QtNetwork/QNetworkConfigurationManager> |
2578 | - |
2579 | - |
2580 | -class ABUpdate : public QObject |
2581 | -{ |
2582 | - Q_OBJECT |
2583 | -public: |
2584 | - ABUpdate(QObject *parent = 0); |
2585 | - ~ABUpdate() override; |
2586 | - |
2587 | - QList<ABUpdateModule*> needsUpdate() const; |
2588 | - bool isRunning(); |
2589 | - |
2590 | - // test |
2591 | - void skipNetworkTest(); |
2592 | - void setSilenceMode(bool flag); |
2593 | - |
2594 | -public Q_SLOTS: |
2595 | - void startUpdate(); |
2596 | - void startUpdateWhenConnected(); |
2597 | - void cancelUpdate(); |
2598 | - |
2599 | -Q_SIGNALS: |
2600 | - void onNeedsUpdateChanged(); |
2601 | - void onIsRunningChanged(); |
2602 | - void updateDone(); |
2603 | - void updateError(const QString &accountName, ABUpdateModule::ImportError); |
2604 | - |
2605 | -private Q_SLOTS: |
2606 | - void onModuleUpdated(); |
2607 | - void onModuleUpdateError(const QString &accountName, ABUpdateModule::ImportError error); |
2608 | - void onOnlineStateChanged(); |
2609 | - void continueUpdateWithInternet(); |
2610 | - void updateNextModule(); |
2611 | - void onModuleUpdateRetry(); |
2612 | - void onModuleUpdateNoRetry(); |
2613 | - |
2614 | -private: |
2615 | - QScopedPointer<QNetworkConfigurationManager> m_netManager; |
2616 | - QList<ABUpdateModule*> m_updateModules; |
2617 | - QList<ABUpdateModule*> m_modulesToUpdate; |
2618 | - QMutex m_lock; |
2619 | - QLockFile m_lockFile; |
2620 | - bool m_needsUpdate; |
2621 | - bool m_isRunning; |
2622 | - bool m_waitingForIntenert; |
2623 | - int m_activeModule; |
2624 | - bool m_skipNetworkTest; |
2625 | - bool m_silenceMode; |
2626 | - |
2627 | - void notifyStart(); |
2628 | - void notifyNoInternet(); |
2629 | - void notifyDone(); |
2630 | - |
2631 | - void startUpdate(ABUpdateModule *module); |
2632 | - bool isOnline(bool checkConnectionType) const; |
2633 | - void waitForInternet(); |
2634 | - QString errorMessage(ABUpdateModule::ImportError error) const; |
2635 | - |
2636 | -}; |
2637 | - |
2638 | |
2639 | === removed file 'updater/main.cpp' |
2640 | --- updater/main.cpp 2015-09-16 20:57:19 +0000 |
2641 | +++ updater/main.cpp 1970-01-01 00:00:00 +0000 |
2642 | @@ -1,77 +0,0 @@ |
2643 | -/* |
2644 | - * Copyright 2015 Canonical Ltd. |
2645 | - * |
2646 | - * This file is part of address-book-service. |
2647 | - * |
2648 | - * sync-monitor is free software; you can redistribute it and/or modify |
2649 | - * it under the terms of the GNU General Public License as published by |
2650 | - * the Free Software Foundation; version 3. |
2651 | - * |
2652 | - * contact-service-app is distributed in the hope that it will be useful, |
2653 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2654 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2655 | - * GNU General Public License for more details. |
2656 | - * |
2657 | - * You should have received a copy of the GNU General Public License |
2658 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2659 | - */ |
2660 | - |
2661 | -#include <QtCore/QCoreApplication> |
2662 | -#include <QtCore/QScopedPointer> |
2663 | -#include <QtCore/QTimer> |
2664 | -#include <QtCore/QDebug> |
2665 | -#include <QtCore/QDateTime> |
2666 | -#include <QtDBus/QDBusConnection> |
2667 | - |
2668 | -#include "ab-update-adaptor.h" |
2669 | -#include "ab-update.h" |
2670 | -#include "dbus-service-defs.h" |
2671 | -#include "config.h" |
2672 | - |
2673 | -namespace C { |
2674 | -#include <libintl.h> |
2675 | -} |
2676 | - |
2677 | -int main(int argc, char **argv) |
2678 | -{ |
2679 | - QCoreApplication::setOrganizationName(SETTINGS_ORG); |
2680 | - QCoreApplication::setApplicationName("AddressBookUpdate"); |
2681 | - |
2682 | - setlocale(LC_ALL, ""); |
2683 | - C::bindtextdomain(GETTEXT_PACKAGE, GETTEXT_LOCALEDIR); |
2684 | - C::bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
2685 | - |
2686 | - QCoreApplication app(argc, argv); |
2687 | - |
2688 | - // AddressBook updater |
2689 | - QScopedPointer<ABUpdate> abUpdate(new ABUpdate); |
2690 | - QScopedPointer<ABUpdateAdaptor> abUpdateAdaptor(new ABUpdateAdaptor(abUpdate.data())); |
2691 | - |
2692 | - |
2693 | - // connect to D-Bus and register as an object: |
2694 | - QDBusConnection connection = QDBusConnection::sessionBus(); |
2695 | - bool ret = connection.registerService(CPIM_UPDATE_SERVICE_NAME); |
2696 | - if (!ret) { |
2697 | - qWarning() << "Fail to register service:" << CPIM_UPDATE_SERVICE_NAME; |
2698 | - return -1; |
2699 | - } |
2700 | - |
2701 | - ret = connection.registerObject(CPIM_UPDATE_OBJECT_PATH, abUpdate.data()); |
2702 | - if (!ret) { |
2703 | - qWarning() << "Fail to register object:" << CPIM_UPDATE_SERVICE_NAME; |
2704 | - return -2; |
2705 | - } |
2706 | - |
2707 | - if (app.arguments().contains("--sync")) { |
2708 | - QTimer::singleShot(0, abUpdate.data(), SLOT(startUpdateWhenConnected())); |
2709 | - } |
2710 | - QObject::connect(abUpdate.data(), SIGNAL(updateDone()), |
2711 | - &app, SLOT(quit())); |
2712 | - |
2713 | - qDebug() << "Updater started" << QDateTime::currentDateTime(); |
2714 | - app.exec(); |
2715 | - qDebug() << "Updater finished" << QDateTime::currentDateTime(); |
2716 | - |
2717 | - connection.unregisterObject(CPIM_UPDATE_OBJECT_PATH); |
2718 | - connection.unregisterService(CPIM_UPDATE_SERVICE_NAME); |
2719 | -} |
2720 | |
2721 | === modified file 'upstart/CMakeLists.txt' |
2722 | --- upstart/CMakeLists.txt 2015-09-03 17:03:46 +0000 |
2723 | +++ upstart/CMakeLists.txt 2015-10-07 13:33:41 +0000 |
2724 | @@ -1,7 +1,5 @@ |
2725 | configure_file(address-book-service.conf.in ${CMAKE_CURRENT_BINARY_DIR}/address-book-service.conf) |
2726 | -configure_file(address-book-updater.conf.in ${CMAKE_CURRENT_BINARY_DIR}/address-book-updater.conf) |
2727 | |
2728 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/address-book-service.conf |
2729 | - ${CMAKE_CURRENT_BINARY_DIR}/address-book-updater.conf |
2730 | DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/upstart/sessions/) |
2731 | |
2732 | |
2733 | === removed file 'upstart/address-book-updater.conf.in' |
2734 | --- upstart/address-book-updater.conf.in 2015-09-16 01:06:33 +0000 |
2735 | +++ upstart/address-book-updater.conf.in 1970-01-01 00:00:00 +0000 |
2736 | @@ -1,7 +0,0 @@ |
2737 | -description "address-book-update" |
2738 | -author "Renato Araujo Oliveira Filho <renato.filho@canonical.com>" |
2739 | - |
2740 | -start on started address-book-service and started msyncd |
2741 | -stop on runlevel [06] |
2742 | - |
2743 | -exec @CMAKE_INSTALL_FULL_LIBEXECDIR@/address-book-updater --sync |
FAILED: Continuous integration, rev:165 jenkins. qa.ubuntu. com/job/ address- book-service- ci/433/ jenkins. qa.ubuntu. com/job/ address- book-service- vivid-armhf- ci/117/ console jenkins. qa.ubuntu. com/job/ address- book-service- vivid-i386- ci/117/ console jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 4534/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 4531/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/address- book-service- ci/433/ rebuild
http://