Merge lp:~renatofilho/buteo-sync-plugins-contacts/no-default-account into lp:buteo-sync-plugins-contacts

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 9
Merged at revision: 9
Proposed branch: lp:~renatofilho/buteo-sync-plugins-contacts/no-default-account
Merge into: lp:buteo-sync-plugins-contacts
Diff against target: 128 lines (+36/-6)
6 files modified
buteo-contact-client/UAuth.cpp (+1/-0)
buteo-contact-client/UAuth.h (+1/-0)
buteo-contact-client/UContactsBackend.cpp (+16/-6)
buteo-contact-client/UContactsBackend.h (+4/-0)
buteo-contact-client/UContactsClient.cpp (+13/-0)
buteo-contact-client/UContactsClient.h (+1/-0)
To merge this branch: bzr merge lp:~renatofilho/buteo-sync-plugins-contacts/no-default-account
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+279152@code.launchpad.net

Commit message

Does not set new sources as default.

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

Looks good!

review: Approve
10. By Renato Araujo Oliveira Filho

Create a workaround to avoid problems with bug #1517252.

11. By Renato Araujo Oliveira Filho

Abort sync and remove syncTarget if the account get removed while the sync is running.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'buteo-contact-client/UAuth.cpp'
--- buteo-contact-client/UAuth.cpp 2015-10-15 19:20:20 +0000
+++ buteo-contact-client/UAuth.cpp 2015-12-11 14:23:51 +0000
@@ -94,6 +94,7 @@
94 LOG_DEBUG("Account is not created... Cannot authenticate");94 LOG_DEBUG("Account is not created... Cannot authenticate");
95 return false;95 return false;
96 }96 }
97 connect(d->mAccount.data(), SIGNAL(removed()), SIGNAL(accountRemoved()));
97 mDisplayName = d->mAccount->displayName();98 mDisplayName = d->mAccount->displayName();
98 }99 }
99100
100101
=== modified file 'buteo-contact-client/UAuth.h'
--- buteo-contact-client/UAuth.h 2015-07-21 19:15:51 +0000
+++ buteo-contact-client/UAuth.h 2015-12-11 14:23:51 +0000
@@ -55,6 +55,7 @@
55signals:55signals:
56 void success();56 void success();
57 void failed();57 void failed();
58 void accountRemoved();
5859
59protected:60protected:
60 QString mToken;61 QString mToken;
6162
=== modified file 'buteo-contact-client/UContactsBackend.cpp'
--- buteo-contact-client/UContactsBackend.cpp 2015-10-15 19:20:20 +0000
+++ buteo-contact-client/UContactsBackend.cpp 2015-12-11 14:23:51 +0000
@@ -80,6 +80,15 @@
80 filter.setValue(QContactType::TypeGroup);80 filter.setValue(QContactType::TypeGroup);
8181
82 QList<QContact> sources = iMgr->contacts(filter);82 QList<QContact> sources = iMgr->contacts(filter);
83
84 // WORKAROUND: sometimes EDS crash while querying for sources we use a second
85 // query to make sure that the source does not exists.
86 // The crash happens on sqlite3 library, check bug #1517252 for more info
87 // FIXME: Remove this when bug #1517252 get fixed.
88 if (sources.isEmpty()) {
89 sources = iMgr->contacts(filter);
90 }
91
83 Q_FOREACH(const QContact &contact, sources) {92 Q_FOREACH(const QContact &contact, sources) {
84 QContactExtendedDetail exd = UContactsCustomDetail::getCustomField(contact,93 QContactExtendedDetail exd = UContactsCustomDetail::getCustomField(contact,
85 "ACCOUNT-ID");94 "ACCOUNT-ID");
@@ -106,12 +115,6 @@
106 label.setLabel(syncTarget + " ");115 label.setLabel(syncTarget + " ");
107 contact.saveDetail(&label);116 contact.saveDetail(&label);
108117
109 // set the new source as default
110 QContactExtendedDetail isDefault;
111 isDefault.setName("IS-PRIMARY");
112 isDefault.setData(true);
113 contact.saveDetail(&isDefault);
114
115 // Link source with account118 // Link source with account
116 QContactExtendedDetail accountId;119 QContactExtendedDetail accountId;
117 accountId.setName("ACCOUNT-ID");120 accountId.setName("ACCOUNT-ID");
@@ -508,6 +511,13 @@
508 }511 }
509}512}
510513
514void UContactsBackend::removeSyncTarget()
515{
516 if (iMgr && !mSyncTargetId.isEmpty()) {
517 iMgr->removeContact(QContactId::fromString(QString("qtcontacts:galera::source@%1").arg(mSyncTargetId)));
518 }
519}
520
511QString521QString
512UContactsBackend::getRemoteId(const QContact &contact)522UContactsBackend::getRemoteId(const QContact &contact)
513{523{
514524
=== modified file 'buteo-contact-client/UContactsBackend.h'
--- buteo-contact-client/UContactsBackend.h 2015-09-14 18:29:11 +0000
+++ buteo-contact-client/UContactsBackend.h 2015-12-11 14:23:51 +0000
@@ -213,6 +213,10 @@
213 */213 */
214 void reloadCache();214 void reloadCache();
215215
216 /*!
217 * \brief Remove backend source
218 */
219 void removeSyncTarget();
216220
217 QContactManager *manager() const;221 QContactManager *manager() const;
218222
219223
=== modified file 'buteo-contact-client/UContactsClient.cpp'
--- buteo-contact-client/UContactsClient.cpp 2015-10-15 19:20:20 +0000
+++ buteo-contact-client/UContactsClient.cpp 2015-12-11 14:23:51 +0000
@@ -142,6 +142,7 @@
142 }142 }
143143
144 // sign in.144 // sign in.
145 connect(d->mAuth, SIGNAL(accountRemoved()), SLOT(onAccountRemoved()));
145 connect(d->mAuth, SIGNAL(success()), SLOT(start()));146 connect(d->mAuth, SIGNAL(success()), SLOT(start()));
146 connect(d->mAuth, SIGNAL(failed()), SLOT(onAuthenticationError()));147 connect(d->mAuth, SIGNAL(failed()), SLOT(onAuthenticationError()));
147148
@@ -269,6 +270,18 @@
269 emit syncFinished (Sync::SYNC_AUTHENTICATION_FAILURE);270 emit syncFinished (Sync::SYNC_AUTHENTICATION_FAILURE);
270}271}
271272
273void UContactsClient::onAccountRemoved()
274{
275 Q_D(UContactsClient);
276
277 LOG_WARNING("ABORT: Account removed while syncing");
278 d->mAborted = true;
279 d->mRemoteSource->abort();
280 d->mContactBackend->removeSyncTarget();
281
282 emit syncFinished(Sync::SYNC_ABORTED);
283}
284
272bool285bool
273UContactsClient::start()286UContactsClient::start()
274{287{
275288
=== modified file 'buteo-contact-client/UContactsClient.h'
--- buteo-contact-client/UContactsClient.h 2015-08-04 18:54:37 +0000
+++ buteo-contact-client/UContactsClient.h 2015-12-11 14:23:51 +0000
@@ -140,6 +140,7 @@
140private slots:140private slots:
141 bool start();141 bool start();
142 void onAuthenticationError();142 void onAuthenticationError();
143 void onAccountRemoved();
143 void onStateChanged(int progress);144 void onStateChanged(int progress);
144 void onSyncFinished(Sync::SyncStatus status);145 void onSyncFinished(Sync::SyncStatus status);
145 void fireSyncFinishedSucessfully();146 void fireSyncFinishedSucessfully();

Subscribers

People subscribed via source and target branches