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
1=== modified file 'buteo-contact-client/UAuth.cpp'
2--- buteo-contact-client/UAuth.cpp 2015-10-15 19:20:20 +0000
3+++ buteo-contact-client/UAuth.cpp 2015-12-11 14:23:51 +0000
4@@ -94,6 +94,7 @@
5 LOG_DEBUG("Account is not created... Cannot authenticate");
6 return false;
7 }
8+ connect(d->mAccount.data(), SIGNAL(removed()), SIGNAL(accountRemoved()));
9 mDisplayName = d->mAccount->displayName();
10 }
11
12
13=== modified file 'buteo-contact-client/UAuth.h'
14--- buteo-contact-client/UAuth.h 2015-07-21 19:15:51 +0000
15+++ buteo-contact-client/UAuth.h 2015-12-11 14:23:51 +0000
16@@ -55,6 +55,7 @@
17 signals:
18 void success();
19 void failed();
20+ void accountRemoved();
21
22 protected:
23 QString mToken;
24
25=== modified file 'buteo-contact-client/UContactsBackend.cpp'
26--- buteo-contact-client/UContactsBackend.cpp 2015-10-15 19:20:20 +0000
27+++ buteo-contact-client/UContactsBackend.cpp 2015-12-11 14:23:51 +0000
28@@ -80,6 +80,15 @@
29 filter.setValue(QContactType::TypeGroup);
30
31 QList<QContact> sources = iMgr->contacts(filter);
32+
33+ // WORKAROUND: sometimes EDS crash while querying for sources we use a second
34+ // query to make sure that the source does not exists.
35+ // The crash happens on sqlite3 library, check bug #1517252 for more info
36+ // FIXME: Remove this when bug #1517252 get fixed.
37+ if (sources.isEmpty()) {
38+ sources = iMgr->contacts(filter);
39+ }
40+
41 Q_FOREACH(const QContact &contact, sources) {
42 QContactExtendedDetail exd = UContactsCustomDetail::getCustomField(contact,
43 "ACCOUNT-ID");
44@@ -106,12 +115,6 @@
45 label.setLabel(syncTarget + " ");
46 contact.saveDetail(&label);
47
48- // set the new source as default
49- QContactExtendedDetail isDefault;
50- isDefault.setName("IS-PRIMARY");
51- isDefault.setData(true);
52- contact.saveDetail(&isDefault);
53-
54 // Link source with account
55 QContactExtendedDetail accountId;
56 accountId.setName("ACCOUNT-ID");
57@@ -508,6 +511,13 @@
58 }
59 }
60
61+void UContactsBackend::removeSyncTarget()
62+{
63+ if (iMgr && !mSyncTargetId.isEmpty()) {
64+ iMgr->removeContact(QContactId::fromString(QString("qtcontacts:galera::source@%1").arg(mSyncTargetId)));
65+ }
66+}
67+
68 QString
69 UContactsBackend::getRemoteId(const QContact &contact)
70 {
71
72=== modified file 'buteo-contact-client/UContactsBackend.h'
73--- buteo-contact-client/UContactsBackend.h 2015-09-14 18:29:11 +0000
74+++ buteo-contact-client/UContactsBackend.h 2015-12-11 14:23:51 +0000
75@@ -213,6 +213,10 @@
76 */
77 void reloadCache();
78
79+ /*!
80+ * \brief Remove backend source
81+ */
82+ void removeSyncTarget();
83
84 QContactManager *manager() const;
85
86
87=== modified file 'buteo-contact-client/UContactsClient.cpp'
88--- buteo-contact-client/UContactsClient.cpp 2015-10-15 19:20:20 +0000
89+++ buteo-contact-client/UContactsClient.cpp 2015-12-11 14:23:51 +0000
90@@ -142,6 +142,7 @@
91 }
92
93 // sign in.
94+ connect(d->mAuth, SIGNAL(accountRemoved()), SLOT(onAccountRemoved()));
95 connect(d->mAuth, SIGNAL(success()), SLOT(start()));
96 connect(d->mAuth, SIGNAL(failed()), SLOT(onAuthenticationError()));
97
98@@ -269,6 +270,18 @@
99 emit syncFinished (Sync::SYNC_AUTHENTICATION_FAILURE);
100 }
101
102+void UContactsClient::onAccountRemoved()
103+{
104+ Q_D(UContactsClient);
105+
106+ LOG_WARNING("ABORT: Account removed while syncing");
107+ d->mAborted = true;
108+ d->mRemoteSource->abort();
109+ d->mContactBackend->removeSyncTarget();
110+
111+ emit syncFinished(Sync::SYNC_ABORTED);
112+}
113+
114 bool
115 UContactsClient::start()
116 {
117
118=== modified file 'buteo-contact-client/UContactsClient.h'
119--- buteo-contact-client/UContactsClient.h 2015-08-04 18:54:37 +0000
120+++ buteo-contact-client/UContactsClient.h 2015-12-11 14:23:51 +0000
121@@ -140,6 +140,7 @@
122 private slots:
123 bool start();
124 void onAuthenticationError();
125+ void onAccountRemoved();
126 void onStateChanged(int progress);
127 void onSyncFinished(Sync::SyncStatus status);
128 void fireSyncFinishedSucessfully();

Subscribers

People subscribed via source and target branches