Merge lp:~renatofilho/buteo-syncfw/ubuntu-changes into lp:~phablet-team/buteo-syncfw/ubuntu
- ubuntu-changes
- Merge into ubuntu
Proposed by
Renato Araujo Oliveira Filho
Status: | Merged |
---|---|
Approved by: | Michael Sheldon |
Approved revision: | 280 |
Merged at revision: | 278 |
Proposed branch: | lp:~renatofilho/buteo-syncfw/ubuntu-changes |
Merge into: | lp:~phablet-team/buteo-syncfw/ubuntu |
Diff against target: |
3177 lines (+584/-1725) 28 files modified
debian/patches/0001-Check-for-WLAN-or-ETHERNET-connections.patch (+47/-0) debian/patches/0001-Disable-sheduled-syncs-over-cellular-connections.patch (+25/-0) debian/patches/0001-Ubuntu-phone-changes.patch (+0/-1544) debian/patches/0002-Fixed-FUNCTION_CALL_TRACE-macro.patch (+36/-0) debian/patches/0003-Added-upstart-service-file.patch (+59/-0) debian/patches/series (+4/-1) libbuteosyncfw/common/Logger.cpp (+2/-2) libbuteosyncfw/common/NetworkManager.cpp (+79/-17) libbuteosyncfw/common/NetworkManager.h (+15/-3) libbuteosyncfw/common/SyncCommonDefs.h (+17/-0) libbuteosyncfw/common/TransportTracker.cpp (+12/-12) libbuteosyncfw/common/TransportTracker.h (+4/-3) libbuteosyncfw/profile/ProfileManager.cpp (+9/-5) libbuteosyncfw/profile/SyncProfile.cpp (+5/-8) msyncd/AccountsHelper.cpp (+48/-16) msyncd/AccountsHelper.h (+29/-30) msyncd/SyncDBusAdaptor.cpp (+8/-0) msyncd/SyncDBusAdaptor.h (+5/-0) msyncd/SyncDBusInterface.h (+22/-15) msyncd/SyncOnChangeScheduler.cpp (+9/-0) msyncd/SyncOnChangeScheduler.h (+2/-1) msyncd/SyncSession.h (+1/-1) msyncd/gschemas/com.meego.msyncd.gschema.xml (+10/-0) msyncd/msyncd-app.pro (+4/-1) msyncd/msyncd-lib.pro (+1/-1) msyncd/synchronizer.cpp (+115/-59) msyncd/synchronizer.h (+14/-4) unittests/tests/msyncdtests/TransportTrackerTest.cpp (+2/-2) |
To merge this branch: | bzr merge lp:~renatofilho/buteo-syncfw/ubuntu-changes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Sheldon (community) | Approve | ||
Ken VanDine | Approve | ||
Review via email: mp+271128@code.launchpad.net |
Commit message
Remove patches already applied on trunk.
Create individual patches for ubuntu specific changes.
Description of the change
To post a comment you must log in.
- 279. By Renato Araujo Oliveira Filho
-
Remove patches already applied on trunk.
Create individual patches for ubuntu specific changes.
- 280. By Renato Araujo Oliveira Filho
-
Check for specific WLAN or ETHERNET connection to avoid problems with Unknown types.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote : | # |
Looks good, I found one BOM added in msyncd/
review:
Needs Fixing
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote : | # |
> Looks good, I found one BOM added in msyncd/
> removed though.
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) : | # |
Revision history for this message
Michael Sheldon (michael-sheldon) : | # |
review:
Approve
- 281. By Renato Araujo Oliveira Filho
-
Disable debug messages.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'debian/patches/0001-Check-for-WLAN-or-ETHERNET-connections.patch' | |||
2 | --- debian/patches/0001-Check-for-WLAN-or-ETHERNET-connections.patch 1970-01-01 00:00:00 +0000 | |||
3 | +++ debian/patches/0001-Check-for-WLAN-or-ETHERNET-connections.patch 2015-09-30 18:13:56 +0000 | |||
4 | @@ -0,0 +1,47 @@ | |||
5 | 1 | From 161e8b4ad64be49822630b601c87fa97ce030de1 Mon Sep 17 00:00:00 2001 | ||
6 | 2 | From: Renato Araujo Oliveira Filho <renato.filho@canonical.com> | ||
7 | 3 | Date: Tue, 22 Sep 2015 12:41:16 -0300 | ||
8 | 4 | Subject: [PATCH] Check for WLAN or ETHERNET connections. | ||
9 | 5 | |||
10 | 6 | Check for specific WLAN or ETHERNET connection to avoid problems with | ||
11 | 7 | Unknown types. | ||
12 | 8 | --- | ||
13 | 9 | libbuteosyncfw/common/NetworkManager.cpp | 11 ++++++----- | ||
14 | 10 | 1 file changed, 6 insertions(+), 5 deletions(-) | ||
15 | 11 | |||
16 | 12 | diff --git a/libbuteosyncfw/common/NetworkManager.cpp b/libbuteosyncfw/common/NetworkManager.cpp | ||
17 | 13 | index 811694c..418105a 100644 | ||
18 | 14 | --- a/libbuteosyncfw/common/NetworkManager.cpp | ||
19 | 15 | +++ b/libbuteosyncfw/common/NetworkManager.cpp | ||
20 | 16 | @@ -1,4 +1,4 @@ | ||
21 | 17 | -/* | ||
22 | 18 | +/* | ||
23 | 19 | * This file is part of buteo-syncfw package | ||
24 | 20 | * | ||
25 | 21 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
26 | 22 | @@ -167,17 +167,18 @@ void NetworkManager::idleRefresh() | ||
27 | 23 | { | ||
28 | 24 | // FIXME: due this bug lp:#1444162 on nm the QNetworkConfigurationManager | ||
29 | 25 | // returns the wrong default connection. | ||
30 | 26 | - // We will consider the connection with the smallest bearer as the | ||
31 | 27 | - // default connection, with that wifi and ethernet will be the first one | ||
32 | 28 | - // https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1444162 | ||
33 | 29 | + // We will consider the first active connection as default connection | ||
34 | 30 | + // unless that there is a WLAN or Ethernet connection active | ||
35 | 31 | connectionType = activeConfigs.first().bearerType(); | ||
36 | 32 | bearerTypeName = activeConfigs.first().bearerTypeName(); | ||
37 | 33 | foreach(const QNetworkConfiguration &conf, activeConfigs) | ||
38 | 34 | { | ||
39 | 35 | - if (conf.bearerType() < connectionType) | ||
40 | 36 | + if ((conf.bearerType() == QNetworkConfiguration::BearerWLAN) || | ||
41 | 37 | + (conf.bearerType() == QNetworkConfiguration::BearerEthernet)) | ||
42 | 38 | { | ||
43 | 39 | connectionType = conf.bearerType(); | ||
44 | 40 | bearerTypeName = conf.bearerTypeName(); | ||
45 | 41 | + break; | ||
46 | 42 | } | ||
47 | 43 | } | ||
48 | 44 | } | ||
49 | 45 | -- | ||
50 | 46 | 2.1.4 | ||
51 | 47 | |||
52 | 0 | 48 | ||
53 | === added file 'debian/patches/0001-Disable-sheduled-syncs-over-cellular-connections.patch' | |||
54 | --- debian/patches/0001-Disable-sheduled-syncs-over-cellular-connections.patch 1970-01-01 00:00:00 +0000 | |||
55 | +++ debian/patches/0001-Disable-sheduled-syncs-over-cellular-connections.patch 2015-09-30 18:13:56 +0000 | |||
56 | @@ -0,0 +1,25 @@ | |||
57 | 1 | From b8ebc30e204c977f5f25d6176d5a82be3e399c4a Mon Sep 17 00:00:00 2001 | ||
58 | 2 | From: Renato Araujo Oliveira Filho <renato.filho@canonical.com> | ||
59 | 3 | Date: Tue, 15 Sep 2015 10:18:05 -0300 | ||
60 | 4 | Subject: [PATCH 1/3] Disable sheduled syncs over cellular connections. | ||
61 | 5 | |||
62 | 6 | --- | ||
63 | 7 | msyncd/gschemas/com.meego.msyncd.gschema.xml | 2 +- | ||
64 | 8 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
65 | 9 | |||
66 | 10 | diff --git a/msyncd/gschemas/com.meego.msyncd.gschema.xml b/msyncd/gschemas/com.meego.msyncd.gschema.xml | ||
67 | 11 | index 4e410d5..f5b90fb 100644 | ||
68 | 12 | --- a/msyncd/gschemas/com.meego.msyncd.gschema.xml | ||
69 | 13 | +++ b/msyncd/gschemas/com.meego.msyncd.gschema.xml | ||
70 | 14 | @@ -4,7 +4,7 @@ | ||
71 | 15 | <key name="allow-scheduled-sync-over-cellular" type="b"> | ||
72 | 16 | <summary>Scheduled Sync over cellular</summary> | ||
73 | 17 | <description>Allow scheduled syncs to run over cellular connections.</description> | ||
74 | 18 | - <default>true</default> | ||
75 | 19 | + <default>false</default> | ||
76 | 20 | </key> | ||
77 | 21 | </schema> | ||
78 | 22 | </schemalist> | ||
79 | 23 | -- | ||
80 | 24 | 2.1.4 | ||
81 | 25 | |||
82 | 0 | 26 | ||
83 | === removed file 'debian/patches/0001-Ubuntu-phone-changes.patch' | |||
84 | --- debian/patches/0001-Ubuntu-phone-changes.patch 2015-09-11 14:15:49 +0000 | |||
85 | +++ debian/patches/0001-Ubuntu-phone-changes.patch 1970-01-01 00:00:00 +0000 | |||
86 | @@ -1,1544 +0,0 @@ | |||
87 | 1 | From 090b3f497a52d9bdf891bdac418705f5adb18e1c Mon Sep 17 00:00:00 2001 | ||
88 | 2 | From: Renato Araujo Oliveira Filho <renato.filho@canonical.com> | ||
89 | 3 | Date: Fri, 3 Jul 2015 13:59:00 -0300 | ||
90 | 4 | Subject: [PATCH] Fire 'enableSOC' for accounts already created. | ||
91 | 5 | |||
92 | 6 | Make sure the the signal 'enableSOC' is fired even for accounts that already exists. | ||
93 | 7 | Fire 'AccountsHelper' signals on idle after the constructor, to allow connections after create object. | ||
94 | 8 | |||
95 | 9 | Save profile before fire 'signalProfileChanged'. | ||
96 | 10 | |||
97 | 11 | The profile should be saved before fire the signal 'signalProfileChanged', otherwise the receiver that retrieve the profile will have a old version of it. | ||
98 | 12 | |||
99 | 13 | Start a sync just after create a new profile. | ||
100 | 14 | |||
101 | 15 | After create a online-account we want that account to get sync. | ||
102 | 16 | |||
103 | 17 | Wait untill network connection is available to sync. | ||
104 | 18 | |||
105 | 19 | Wait for internet connection before sync scheduled sync requests. | ||
106 | 20 | |||
107 | 21 | Does not run scheduled sync over mobile data connection. | ||
108 | 22 | |||
109 | 23 | Check for internet connection type before run a scheduled sync. | ||
110 | 24 | |||
111 | 25 | Added upstart service file. | ||
112 | 26 | |||
113 | 27 | Create upstart file to start msyncd service. | ||
114 | 28 | |||
115 | 29 | Avoid sync twice. | ||
116 | 30 | |||
117 | 31 | Remove pending syncs from 'iWaitingOnlineSyncs' and 'iSyncOnChangeScheduler', before run a sync to avoid sync twice. | ||
118 | 32 | |||
119 | 33 | Fixed compilation warnings. | ||
120 | 34 | |||
121 | 35 | Create a gschema to store system-wide configuration. | ||
122 | 36 | |||
123 | 37 | Check for '/com/meego/msyncd/allow-scheduled-sync-over-gsm' settings to confirm if sync over gsm is enabled for scheduled syncs. | ||
124 | 38 | |||
125 | 39 | Add new profiles into the Sync On Change list. | ||
126 | 40 | |||
127 | 41 | Profiles created while the server is running should be added to Sync On Change list. | ||
128 | 42 | |||
129 | 43 | Fixed AccountsHelper 'scheduleUpdated' emission. | ||
130 | 44 | |||
131 | 45 | Make sure that the signal get fired for the correct profile. | ||
132 | 46 | |||
133 | 47 | Fire a new sync if profile data changes. | ||
134 | 48 | |||
135 | 49 | Fixed profile creation for new accounts. | ||
136 | 50 | |||
137 | 51 | Set the new profile enabled only if account and service are enabled. | ||
138 | 52 | |||
139 | 53 | Fix 'lastSuccessfulSyncTime' function. | ||
140 | 54 | |||
141 | 55 | Fixed an use case where the sync log only contains one failed sync. | ||
142 | 56 | |||
143 | 57 | Expose "createProfileForAccount" in the DBUS service. | ||
144 | 58 | |||
145 | 59 | Allow the client to create a profile for a specified account it it does not exists | ||
146 | 60 | --- | ||
147 | 61 | libbuteosyncfw/common/Logger.cpp | 4 +- | ||
148 | 62 | libbuteosyncfw/common/NetworkManager.cpp | 96 +++++++++--- | ||
149 | 63 | libbuteosyncfw/common/NetworkManager.h | 18 ++- | ||
150 | 64 | libbuteosyncfw/common/SyncCommonDefs.h | 17 +++ | ||
151 | 65 | libbuteosyncfw/common/TransportTracker.cpp | 24 +-- | ||
152 | 66 | libbuteosyncfw/common/TransportTracker.h | 7 +- | ||
153 | 67 | libbuteosyncfw/profile/ProfileManager.cpp | 14 +- | ||
154 | 68 | libbuteosyncfw/profile/SyncProfile.cpp | 13 +- | ||
155 | 69 | msyncd/AccountsHelper.cpp | 66 +++++--- | ||
156 | 70 | msyncd/AccountsHelper.h | 59 ++++--- | ||
157 | 71 | msyncd/SyncDBusAdaptor.cpp | 8 + | ||
158 | 72 | msyncd/SyncDBusAdaptor.h | 5 + | ||
159 | 73 | msyncd/SyncDBusInterface.h | 37 +++-- | ||
160 | 74 | msyncd/SyncOnChangeScheduler.cpp | 9 ++ | ||
161 | 75 | msyncd/SyncOnChangeScheduler.h | 3 +- | ||
162 | 76 | msyncd/SyncSession.h | 2 +- | ||
163 | 77 | msyncd/bin/msyncd.conf | 15 ++ | ||
164 | 78 | msyncd/gschemas/com.meego.msyncd.gschema.xml | 10 ++ | ||
165 | 79 | msyncd/msyncd-app.pro | 8 +- | ||
166 | 80 | msyncd/msyncd-lib.pro | 2 +- | ||
167 | 81 | msyncd/synchronizer.cpp | 169 ++++++++++++++------- | ||
168 | 82 | msyncd/synchronizer.h | 18 ++- | ||
169 | 83 | .../tests/msyncdtests/TransportTrackerTest.cpp | 4 +- | ||
170 | 84 | 23 files changed, 427 insertions(+), 181 deletions(-) | ||
171 | 85 | create mode 100644 msyncd/bin/msyncd.conf | ||
172 | 86 | create mode 100644 msyncd/gschemas/com.meego.msyncd.gschema.xml | ||
173 | 87 | |||
174 | 88 | diff --git a/libbuteosyncfw/common/Logger.cpp b/libbuteosyncfw/common/Logger.cpp | ||
175 | 89 | index c6468bd..557b725 100644 | ||
176 | 90 | --- a/libbuteosyncfw/common/Logger.cpp | ||
177 | 91 | +++ b/libbuteosyncfw/common/Logger.cpp | ||
178 | 92 | @@ -206,7 +206,7 @@ void Logger::write(int aLevel, const char *aMsg) | ||
179 | 93 | { | ||
180 | 94 | if(aLevel >= QtCriticalMsg) | ||
181 | 95 | { | ||
182 | 96 | - syslog(LOG_CRIT, sysLogMsg.toLocal8Bit().data()); | ||
183 | 97 | + syslog(LOG_CRIT, "%s", sysLogMsg.toLocal8Bit().data()); | ||
184 | 98 | } | ||
185 | 99 | return; | ||
186 | 100 | } | ||
187 | 101 | @@ -217,7 +217,7 @@ void Logger::write(int aLevel, const char *aMsg) | ||
188 | 102 | return; | ||
189 | 103 | } | ||
190 | 104 | |||
191 | 105 | - syslog(syslogLevel[aLevel], sysLogMsg.toLocal8Bit().data()); | ||
192 | 106 | + syslog(syslogLevel[aLevel], "%s", sysLogMsg.toLocal8Bit().data()); | ||
193 | 107 | |||
194 | 108 | if (iFileStream != 0) | ||
195 | 109 | { | ||
196 | 110 | diff --git a/libbuteosyncfw/common/NetworkManager.cpp b/libbuteosyncfw/common/NetworkManager.cpp | ||
197 | 111 | index 6e430d4..811694c 100644 | ||
198 | 112 | --- a/libbuteosyncfw/common/NetworkManager.cpp | ||
199 | 113 | +++ b/libbuteosyncfw/common/NetworkManager.cpp | ||
200 | 114 | @@ -36,13 +36,40 @@ bool NetworkManager::m_isSessionActive = false; | ||
201 | 115 | NetworkManager::NetworkManager(QObject *parent /* = 0*/) : | ||
202 | 116 | QObject(parent), m_networkConfigManager(0), m_networkSession(0), | ||
203 | 117 | m_isOnline(false), m_errorEmitted(false), | ||
204 | 118 | - m_sessionTimer(0) | ||
205 | 119 | + m_sessionTimer(0), m_connectionType(Sync::INTERNET_CONNECTION_UNKNOWN) | ||
206 | 120 | { | ||
207 | 121 | FUNCTION_CALL_TRACE; | ||
208 | 122 | m_networkConfigManager = new QNetworkConfigurationManager(); | ||
209 | 123 | Q_ASSERT(m_networkConfigManager); | ||
210 | 124 | - connect(m_networkConfigManager, SIGNAL(onlineStateChanged(bool)), | ||
211 | 125 | - SLOT(slotOnlineStateChanged(bool))); | ||
212 | 126 | + | ||
213 | 127 | + // check for network status and configuration change (switch wifi, ethernet, mobile) a | ||
214 | 128 | + connect(m_networkConfigManager, | ||
215 | 129 | + SIGNAL(onlineStateChanged(bool)), | ||
216 | 130 | + SLOT(slotConfigurationChanged()), | ||
217 | 131 | + Qt::QueuedConnection); | ||
218 | 132 | + connect(m_networkConfigManager, | ||
219 | 133 | + SIGNAL(configurationAdded(QNetworkConfiguration)), | ||
220 | 134 | + SLOT(slotConfigurationChanged()), | ||
221 | 135 | + Qt::QueuedConnection); | ||
222 | 136 | + connect(m_networkConfigManager, | ||
223 | 137 | + SIGNAL(configurationChanged(QNetworkConfiguration)), | ||
224 | 138 | + SLOT(slotConfigurationChanged()), | ||
225 | 139 | + Qt::QueuedConnection); | ||
226 | 140 | + connect(m_networkConfigManager, | ||
227 | 141 | + SIGNAL(configurationRemoved(QNetworkConfiguration)), | ||
228 | 142 | + SLOT(slotConfigurationChanged()), | ||
229 | 143 | + Qt::QueuedConnection); | ||
230 | 144 | + connect(m_networkConfigManager, | ||
231 | 145 | + SIGNAL(updateCompleted()), | ||
232 | 146 | + SLOT(slotConfigurationChanged()), | ||
233 | 147 | + Qt::QueuedConnection); | ||
234 | 148 | + | ||
235 | 149 | + connect(&m_idleRefreshTimer, | ||
236 | 150 | + SIGNAL(timeout()), | ||
237 | 151 | + SLOT(idleRefresh()), | ||
238 | 152 | + Qt::QueuedConnection); | ||
239 | 153 | + m_idleRefreshTimer.setSingleShot(true); | ||
240 | 154 | + | ||
241 | 155 | m_isOnline = m_networkConfigManager->isOnline(); | ||
242 | 156 | LOG_DEBUG("Online status::" << m_isOnline); | ||
243 | 157 | m_sessionTimer = new QTimer(this); | ||
244 | 158 | @@ -72,6 +99,11 @@ bool NetworkManager::isOnline() | ||
245 | 159 | return m_isOnline; | ||
246 | 160 | } | ||
247 | 161 | |||
248 | 162 | +Sync::InternetConnectionType NetworkManager::connectionType() const | ||
249 | 163 | +{ | ||
250 | 164 | + return m_connectionType; | ||
251 | 165 | +} | ||
252 | 166 | + | ||
253 | 167 | void NetworkManager::connectSession(bool connectInBackground /* = false*/) | ||
254 | 168 | { | ||
255 | 169 | FUNCTION_CALL_TRACE; | ||
256 | 170 | @@ -110,12 +142,55 @@ void NetworkManager::sessionConnectionTimeout() | ||
257 | 171 | { | ||
258 | 172 | if (!m_errorEmitted && m_networkSession) { | ||
259 | 173 | if (!m_networkSession->isOpen()) { | ||
260 | 174 | - qWarning() << "No network reply received after 10 seconds, emitting session error."; | ||
261 | 175 | + LOG_WARNING("No network reply received after 10 seconds, emitting session error."); | ||
262 | 176 | slotSessionError(m_networkSession->error()); | ||
263 | 177 | } | ||
264 | 178 | } | ||
265 | 179 | } | ||
266 | 180 | |||
267 | 181 | +void NetworkManager::slotConfigurationChanged() | ||
268 | 182 | +{ | ||
269 | 183 | + // wait for 3 secs before update connection status | ||
270 | 184 | + // this avoid problems with connections that take a while to be stabilished | ||
271 | 185 | + m_idleRefreshTimer.start(3000); | ||
272 | 186 | +} | ||
273 | 187 | + | ||
274 | 188 | +void NetworkManager::idleRefresh() | ||
275 | 189 | +{ | ||
276 | 190 | + FUNCTION_CALL_TRACE; | ||
277 | 191 | + QList<QNetworkConfiguration> activeConfigs = m_networkConfigManager->allConfigurations(QNetworkConfiguration::Active); | ||
278 | 192 | + QNetworkConfiguration::BearerType connectionType = QNetworkConfiguration::BearerUnknown; | ||
279 | 193 | + QString bearerTypeName; | ||
280 | 194 | + | ||
281 | 195 | + bool isOnline = activeConfigs.size() > 0; | ||
282 | 196 | + if (isOnline) | ||
283 | 197 | + { | ||
284 | 198 | + // FIXME: due this bug lp:#1444162 on nm the QNetworkConfigurationManager | ||
285 | 199 | + // returns the wrong default connection. | ||
286 | 200 | + // We will consider the connection with the smallest bearer as the | ||
287 | 201 | + // default connection, with that wifi and ethernet will be the first one | ||
288 | 202 | + // https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1444162 | ||
289 | 203 | + connectionType = activeConfigs.first().bearerType(); | ||
290 | 204 | + bearerTypeName = activeConfigs.first().bearerTypeName(); | ||
291 | 205 | + foreach(const QNetworkConfiguration &conf, activeConfigs) | ||
292 | 206 | + { | ||
293 | 207 | + if (conf.bearerType() < connectionType) | ||
294 | 208 | + { | ||
295 | 209 | + connectionType = conf.bearerType(); | ||
296 | 210 | + bearerTypeName = conf.bearerTypeName(); | ||
297 | 211 | + } | ||
298 | 212 | + } | ||
299 | 213 | + } | ||
300 | 214 | + LOG_DEBUG("New state:" << isOnline << " New type: " << bearerTypeName << "(" << connectionType << ")"); | ||
301 | 215 | + if ((isOnline != m_isOnline) || | ||
302 | 216 | + ((Sync::InternetConnectionType)connectionType != m_connectionType)) | ||
303 | 217 | + { | ||
304 | 218 | + m_isOnline = isOnline; | ||
305 | 219 | + m_connectionType = (Sync::InternetConnectionType) connectionType; | ||
306 | 220 | + emit statusChanged(m_isOnline, m_connectionType); | ||
307 | 221 | + } | ||
308 | 222 | +} | ||
309 | 223 | + | ||
310 | 224 | void NetworkManager::disconnectSession() | ||
311 | 225 | { | ||
312 | 226 | FUNCTION_CALL_TRACE; | ||
313 | 227 | @@ -134,19 +209,6 @@ void NetworkManager::disconnectSession() | ||
314 | 228 | } | ||
315 | 229 | } | ||
316 | 230 | |||
317 | 231 | -void NetworkManager::slotOnlineStateChanged(bool isOnline) | ||
318 | 232 | -{ | ||
319 | 233 | - FUNCTION_CALL_TRACE; | ||
320 | 234 | - LOG_DEBUG("Online status changed, is online is now::" << isOnline); | ||
321 | 235 | - if(m_isOnline != isOnline) | ||
322 | 236 | - { | ||
323 | 237 | - if (m_sessionTimer->isActive()) | ||
324 | 238 | - m_sessionTimer->stop(); | ||
325 | 239 | - m_isOnline = isOnline; | ||
326 | 240 | - emit valueChanged(m_isOnline); | ||
327 | 241 | - } | ||
328 | 242 | -} | ||
329 | 243 | - | ||
330 | 244 | void NetworkManager::slotSessionState(QNetworkSession::State status) | ||
331 | 245 | { | ||
332 | 246 | FUNCTION_CALL_TRACE; | ||
333 | 247 | diff --git a/libbuteosyncfw/common/NetworkManager.h b/libbuteosyncfw/common/NetworkManager.h | ||
334 | 248 | index 5a7c696..e375551 100644 | ||
335 | 249 | --- a/libbuteosyncfw/common/NetworkManager.h | ||
336 | 250 | +++ b/libbuteosyncfw/common/NetworkManager.h | ||
337 | 251 | @@ -24,8 +24,9 @@ | ||
338 | 252 | #define NETWORKMANAGER_H_ | ||
339 | 253 | |||
340 | 254 | #include <QNetworkSession> | ||
341 | 255 | +#include <QTimer> | ||
342 | 256 | +#include "SyncCommonDefs.h" | ||
343 | 257 | |||
344 | 258 | -class QTimer; | ||
345 | 259 | class QNetworkConfigurationManager; | ||
346 | 260 | |||
347 | 261 | namespace Buteo | ||
348 | 262 | @@ -61,6 +62,13 @@ namespace Buteo | ||
349 | 263 | */ | ||
350 | 264 | bool isOnline(); | ||
351 | 265 | |||
352 | 266 | + /*! \brief Returns the type of connection used by the device. | ||
353 | 267 | + * | ||
354 | 268 | + | ||
355 | 269 | + * @return Sync::InternetConnectionType the type of connection. | ||
356 | 270 | + */ | ||
357 | 271 | + Sync::InternetConnectionType connectionType() const; | ||
358 | 272 | + | ||
359 | 273 | /*! \brief Connects a new network session. If a session was already | ||
360 | 274 | * open, the signal connectionSuccess will be emitted immediately, | ||
361 | 275 | * else the function will return and the signal connectionSuccess or | ||
362 | 276 | @@ -84,7 +92,7 @@ signals: | ||
363 | 277 | * | ||
364 | 278 | * @param aConnected If true, the device is online | ||
365 | 279 | */ | ||
366 | 280 | - void valueChanged(bool aConnected); | ||
367 | 281 | + void statusChanged(bool aConnected, Sync::InternetConnectionType aType); | ||
368 | 282 | |||
369 | 283 | /*! \brief This signal is emitted when a network session gets | ||
370 | 284 | * connected | ||
371 | 285 | @@ -105,11 +113,15 @@ signals: | ||
372 | 286 | static int m_refCount; // Reference counter for number of open connections | ||
373 | 287 | bool m_errorEmitted; // Network error emited flag | ||
374 | 288 | QTimer *m_sessionTimer; | ||
375 | 289 | + Sync::InternetConnectionType m_connectionType; | ||
376 | 290 | + QTimer m_idleRefreshTimer; | ||
377 | 291 | + | ||
378 | 292 | private slots: | ||
379 | 293 | - void slotOnlineStateChanged(bool isOnline); | ||
380 | 294 | void slotSessionState(QNetworkSession::State status); | ||
381 | 295 | void slotSessionError(QNetworkSession::SessionError error); | ||
382 | 296 | void sessionConnectionTimeout(); | ||
383 | 297 | + void slotConfigurationChanged(); | ||
384 | 298 | + void idleRefresh(); | ||
385 | 299 | }; | ||
386 | 300 | } | ||
387 | 301 | |||
388 | 302 | diff --git a/libbuteosyncfw/common/SyncCommonDefs.h b/libbuteosyncfw/common/SyncCommonDefs.h | ||
389 | 303 | index 495b71c..ab35d26 100644 | ||
390 | 304 | --- a/libbuteosyncfw/common/SyncCommonDefs.h | ||
391 | 305 | +++ b/libbuteosyncfw/common/SyncCommonDefs.h | ||
392 | 306 | @@ -26,6 +26,7 @@ | ||
393 | 307 | |||
394 | 308 | #include <QMetaType> | ||
395 | 309 | #include <QDir> | ||
396 | 310 | +#include <QtNetwork/QNetworkConfiguration> | ||
397 | 311 | |||
398 | 312 | namespace Sync { | ||
399 | 313 | |||
400 | 314 | @@ -83,6 +84,22 @@ enum ConnectivityType { | ||
401 | 315 | CONNECTIVITY_INTERNET | ||
402 | 316 | }; | ||
403 | 317 | |||
404 | 318 | +enum InternetConnectionType { | ||
405 | 319 | + INTERNET_CONNECTION_UNKNOWN = QNetworkConfiguration::BearerUnknown, | ||
406 | 320 | + INTERNET_CONNECTION_ETHERNET = QNetworkConfiguration::BearerEthernet, | ||
407 | 321 | + INTERNET_CONNECTION_WLAN = QNetworkConfiguration::BearerWLAN, | ||
408 | 322 | + INTERNET_CONNECTION_2G = QNetworkConfiguration::Bearer2G, | ||
409 | 323 | + INTERNET_CONNECTION_3G = QNetworkConfiguration::Bearer3G, | ||
410 | 324 | + INTERNET_CONNECTION_4G = QNetworkConfiguration::Bearer4G, | ||
411 | 325 | + INTERNET_CONNECTION_CDMA2000 = QNetworkConfiguration::BearerCDMA2000, | ||
412 | 326 | + INTERNET_CONNECTION_WCDMA = QNetworkConfiguration::BearerWCDMA, | ||
413 | 327 | + INTERNET_CONNECTION_HSPA = QNetworkConfiguration::BearerHSPA, | ||
414 | 328 | + INTERNET_CONNECTION_BLUETOOTH = QNetworkConfiguration::BearerBluetooth, | ||
415 | 329 | + INTERNET_CONNECTION_WIMAX = QNetworkConfiguration::BearerWiMAX, | ||
416 | 330 | + INTERNET_CONNECTION_EVDO = QNetworkConfiguration::BearerEVDO, | ||
417 | 331 | + INTERNET_CONNECTION_LTE = QNetworkConfiguration::BearerLTE | ||
418 | 332 | +}; | ||
419 | 333 | + | ||
420 | 334 | } // namespace Sync | ||
421 | 335 | |||
422 | 336 | Q_DECLARE_METATYPE( Sync::SyncStatus ); | ||
423 | 337 | diff --git a/libbuteosyncfw/common/TransportTracker.cpp b/libbuteosyncfw/common/TransportTracker.cpp | ||
424 | 338 | index 7890cf5..0cd5632 100644 | ||
425 | 339 | --- a/libbuteosyncfw/common/TransportTracker.cpp | ||
426 | 340 | +++ b/libbuteosyncfw/common/TransportTracker.cpp | ||
427 | 341 | @@ -66,7 +66,7 @@ TransportTracker::TransportTracker(QObject *aParent) : | ||
428 | 342 | |||
429 | 343 | // BT | ||
430 | 344 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) | ||
431 | 345 | - | ||
432 | 346 | + | ||
433 | 347 | // Set the bluetooth state | ||
434 | 348 | iTransportStates[Sync::CONNECTIVITY_BT] = btConnectivityStatus(); | ||
435 | 349 | |||
436 | 350 | @@ -97,8 +97,9 @@ TransportTracker::TransportTracker(QObject *aParent) : | ||
437 | 351 | { | ||
438 | 352 | iTransportStates[Sync::CONNECTIVITY_INTERNET] = | ||
439 | 353 | iInternet->isOnline(); | ||
440 | 354 | - connect(iInternet, SIGNAL(valueChanged(bool)), | ||
441 | 355 | - this, SLOT(onInternetStateChanged(bool)) /*, Qt::QueuedConnection*/); | ||
442 | 356 | + connect(iInternet, | ||
443 | 357 | + SIGNAL(statusChanged(bool, Sync::InternetConnectionType)), | ||
444 | 358 | + SLOT(onInternetStateChanged(bool, Sync::InternetConnectionType)) /*, Qt::QueuedConnection*/); | ||
445 | 359 | } | ||
446 | 360 | else | ||
447 | 361 | { | ||
448 | 362 | @@ -143,7 +144,7 @@ void TransportTracker::onBtStateChanged(bool aState) | ||
449 | 363 | void TransportTracker::onBtStateChanged(QString aKey, QDBusVariant aValue) | ||
450 | 364 | { | ||
451 | 365 | FUNCTION_CALL_TRACE; | ||
452 | 366 | - | ||
453 | 367 | + | ||
454 | 368 | if (aKey == "Powered") | ||
455 | 369 | { | ||
456 | 370 | bool btPowered = aValue.variant().toBool(); | ||
457 | 371 | @@ -153,12 +154,13 @@ void TransportTracker::onBtStateChanged(QString aKey, QDBusVariant aValue) | ||
458 | 372 | } | ||
459 | 373 | #endif | ||
460 | 374 | |||
461 | 375 | -void TransportTracker::onInternetStateChanged(bool aConnected) | ||
462 | 376 | +void TransportTracker::onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType) | ||
463 | 377 | { | ||
464 | 378 | FUNCTION_CALL_TRACE; | ||
465 | 379 | |||
466 | 380 | LOG_DEBUG("Internet state changed:" << aConnected); | ||
467 | 381 | updateState(Sync::CONNECTIVITY_INTERNET, aConnected); | ||
468 | 382 | + emit networkStateChanged(aConnected, aType); | ||
469 | 383 | } | ||
470 | 384 | |||
471 | 385 | void TransportTracker::updateState(Sync::ConnectivityType aType, | ||
472 | 386 | @@ -175,19 +177,17 @@ void TransportTracker::updateState(Sync::ConnectivityType aType, | ||
473 | 387 | } | ||
474 | 388 | if(oldState != aState) | ||
475 | 389 | { | ||
476 | 390 | - if (aType != Sync::CONNECTIVITY_INTERNET) { | ||
477 | 391 | + if (aType != Sync::CONNECTIVITY_INTERNET) | ||
478 | 392 | + { | ||
479 | 393 | emit connectivityStateChanged(aType, aState); | ||
480 | 394 | } | ||
481 | 395 | - else { | ||
482 | 396 | - emit networkStateChanged(aState); | ||
483 | 397 | - } | ||
484 | 398 | } | ||
485 | 399 | } | ||
486 | 400 | |||
487 | 401 | bool TransportTracker::btConnectivityStatus() | ||
488 | 402 | { | ||
489 | 403 | FUNCTION_CALL_TRACE; | ||
490 | 404 | - | ||
491 | 405 | + | ||
492 | 406 | bool btOn = false; | ||
493 | 407 | QDBusConnection *systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, | ||
494 | 408 | QStringLiteral("buteo_system_bus2"))); | ||
495 | 409 | @@ -207,7 +207,7 @@ bool TransportTracker::btConnectivityStatus() | ||
496 | 410 | QList<QVariant> adapterList = reply.arguments(); | ||
497 | 411 | // We will take the first adapter in the list | ||
498 | 412 | QString adapterPath = qdbus_cast<QDBusObjectPath>(adapterList.at(0)).path(); | ||
499 | 413 | - | ||
500 | 414 | + | ||
501 | 415 | if (!adapterPath.isEmpty() || !adapterPath.isNull()) | ||
502 | 416 | { | ||
503 | 417 | // Retrive the properties of the adapter and check for "Powered" key | ||
504 | 418 | @@ -222,7 +222,7 @@ bool TransportTracker::btConnectivityStatus() | ||
505 | 419 | delete systemBus; | ||
506 | 420 | return btOn; | ||
507 | 421 | } | ||
508 | 422 | - | ||
509 | 423 | + | ||
510 | 424 | QDBusArgument arg = reply.arguments().at(0).value<QDBusArgument>(); | ||
511 | 425 | if (arg.currentType() == QDBusArgument::MapType) | ||
512 | 426 | { | ||
513 | 427 | diff --git a/libbuteosyncfw/common/TransportTracker.h b/libbuteosyncfw/common/TransportTracker.h | ||
514 | 428 | index 67456cf..495ebcb 100644 | ||
515 | 429 | --- a/libbuteosyncfw/common/TransportTracker.h | ||
516 | 430 | +++ b/libbuteosyncfw/common/TransportTracker.h | ||
517 | 431 | @@ -78,8 +78,9 @@ signals: | ||
518 | 432 | /*! \brief Signal emitted when a n/w state changes | ||
519 | 433 | * | ||
520 | 434 | * @param aState New state. True if available, false if not. | ||
521 | 435 | + * @param aType Connection type. The type of connetcion with the Internet. | ||
522 | 436 | */ | ||
523 | 437 | - void networkStateChanged(bool aState); | ||
524 | 438 | + void networkStateChanged(bool aState, Sync::InternetConnectionType aType); | ||
525 | 439 | |||
526 | 440 | /*! \brief Signal emitted when a network session is successfully opened | ||
527 | 441 | */ | ||
528 | 442 | @@ -99,7 +100,7 @@ private slots: | ||
529 | 443 | void onBtStateChanged(QString aKey, QDBusVariant aValue); | ||
530 | 444 | #endif | ||
531 | 445 | |||
532 | 446 | - void onInternetStateChanged(bool aConnected); | ||
533 | 447 | + void onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType); | ||
534 | 448 | |||
535 | 449 | private: | ||
536 | 450 | |||
537 | 451 | @@ -127,7 +128,7 @@ private: | ||
538 | 452 | friend class TransportTrackerTest; | ||
539 | 453 | friend class SynchronizerTest; | ||
540 | 454 | #endif | ||
541 | 455 | - | ||
542 | 456 | + | ||
543 | 457 | bool btConnectivityStatus(); | ||
544 | 458 | |||
545 | 459 | }; | ||
546 | 460 | diff --git a/libbuteosyncfw/profile/ProfileManager.cpp b/libbuteosyncfw/profile/ProfileManager.cpp | ||
547 | 461 | index f1e4b2a..81406d9 100644 | ||
548 | 462 | --- a/libbuteosyncfw/profile/ProfileManager.cpp | ||
549 | 463 | +++ b/libbuteosyncfw/profile/ProfileManager.cpp | ||
550 | 464 | @@ -129,7 +129,6 @@ ProfileManagerPrivate::ProfileManagerPrivate(const QString &aPrimaryPath, | ||
551 | 465 | |||
552 | 466 | Profile *ProfileManagerPrivate::load(const QString &aName, const QString &aType) | ||
553 | 467 | { | ||
554 | 468 | - | ||
555 | 469 | QString profilePath = findProfileFile(aName, aType); | ||
556 | 470 | QString backupProfilePath = profilePath + BACKUP_EXT; | ||
557 | 471 | |||
558 | 472 | @@ -739,6 +738,14 @@ QString ProfileManager::updateProfile(const Profile &aProfile) | ||
559 | 473 | bool exists = d_ptr->profileExists(aProfile.name(),aProfile.type()); | ||
560 | 474 | |||
561 | 475 | QString profileId(""); | ||
562 | 476 | + | ||
563 | 477 | + // We need to save before emit the signalProfileChanged, if this is the first | ||
564 | 478 | + // update the profile will only exists on disk after the save and any operation | ||
565 | 479 | + // using this profile triggered by the signal will fail. | ||
566 | 480 | + if(d_ptr->save(aProfile)) { | ||
567 | 481 | + profileId = aProfile.name(); | ||
568 | 482 | + } | ||
569 | 483 | + | ||
570 | 484 | // Profile did not exist, it was a new one. Add it and emit signal with "added" value: | ||
571 | 485 | if (!exists) { | ||
572 | 486 | emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_ADDED,aProfile.toString()); | ||
573 | 487 | @@ -746,9 +753,6 @@ QString ProfileManager::updateProfile(const Profile &aProfile) | ||
574 | 488 | emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_MODIFIED,aProfile.toString()); | ||
575 | 489 | } | ||
576 | 490 | |||
577 | 491 | - if(d_ptr->save(aProfile)) { | ||
578 | 492 | - profileId = aProfile.name(); | ||
579 | 493 | - } | ||
580 | 494 | return profileId; | ||
581 | 495 | } | ||
582 | 496 | |||
583 | 497 | @@ -1254,7 +1258,7 @@ QDateTime ProfileManager::getNextRetryInterval(const SyncProfile* aProfile) | ||
584 | 498 | !iSyncRetriesInfo[aProfile->name()].isEmpty()) | ||
585 | 499 | { | ||
586 | 500 | quint32 mins = iSyncRetriesInfo[aProfile->name()].takeFirst(); | ||
587 | 501 | - nextRetryInterval = QDateTime::currentDateTime().addSecs(mins * 60); | ||
588 | 502 | + nextRetryInterval = QDateTime::currentDateTime().addSecs(mins * 60); | ||
589 | 503 | LOG_DEBUG("syncretries : retry for profile" << aProfile->name() << "in" << mins <<"minutes"); | ||
590 | 504 | LOG_DEBUG("syncretries :" << iSyncRetriesInfo[aProfile->name()].count() <<"attempts remain"); | ||
591 | 505 | } | ||
592 | 506 | diff --git a/libbuteosyncfw/profile/SyncProfile.cpp b/libbuteosyncfw/profile/SyncProfile.cpp | ||
593 | 507 | index 564aec5..7cd80d3 100644 | ||
594 | 508 | --- a/libbuteosyncfw/profile/SyncProfile.cpp | ||
595 | 509 | +++ b/libbuteosyncfw/profile/SyncProfile.cpp | ||
596 | 510 | @@ -259,14 +259,11 @@ QDateTime SyncProfile::lastSuccessfulSyncTime () const | ||
597 | 511 | if (d_ptr->iLog) | ||
598 | 512 | { | ||
599 | 513 | QList<const SyncResults*> allResults = d_ptr->iLog->allResults(); | ||
600 | 514 | - if (allResults.size () > 0) | ||
601 | 515 | - { | ||
602 | 516 | - lastSuccessSyncTime = allResults.at (0)->syncTime (); | ||
603 | 517 | - foreach (const SyncResults* result, allResults) { | ||
604 | 518 | - if ((result->majorCode () == SyncResults::SYNC_RESULT_SUCCESS) && | ||
605 | 519 | - (result->minorCode () == SyncResults::NO_ERROR) && | ||
606 | 520 | - (result->syncTime () > lastSuccessSyncTime)) | ||
607 | 521 | - lastSuccessSyncTime = result->syncTime (); | ||
608 | 522 | + foreach (const SyncResults* result, allResults) { | ||
609 | 523 | + if ((result->majorCode () == SyncResults::SYNC_RESULT_SUCCESS) && | ||
610 | 524 | + (result->minorCode () == SyncResults::NO_ERROR) && | ||
611 | 525 | + (lastSyncTime().isNull() || (result->syncTime () > lastSuccessSyncTime))) { | ||
612 | 526 | + lastSuccessSyncTime = result->syncTime (); | ||
613 | 527 | } | ||
614 | 528 | } | ||
615 | 529 | } | ||
616 | 530 | diff --git a/msyncd/AccountsHelper.cpp b/msyncd/AccountsHelper.cpp | ||
617 | 531 | index 064d14f..960132c 100644 | ||
618 | 532 | --- a/msyncd/AccountsHelper.cpp | ||
619 | 533 | +++ b/msyncd/AccountsHelper.cpp | ||
620 | 534 | @@ -26,6 +26,8 @@ | ||
621 | 535 | #include "Profile.h" | ||
622 | 536 | #include "ProfileEngineDefs.h" | ||
623 | 537 | |||
624 | 538 | +#include <QTimer> | ||
625 | 539 | + | ||
626 | 540 | static const QString ACCOUNTS_GLOBAL_SERVICE("global"); | ||
627 | 541 | |||
628 | 542 | using namespace Buteo; | ||
629 | 543 | @@ -36,13 +38,15 @@ AccountsHelper::AccountsHelper(ProfileManager &aProfileManager, QObject *aParent | ||
630 | 544 | iAccountManager = new Accounts::Manager(this); | ||
631 | 545 | // Connect to signal for account creation, deletion, and modification | ||
632 | 546 | QObject::connect(iAccountManager, SIGNAL(accountCreated(Accounts::AccountId)), | ||
633 | 547 | - this, SLOT(slotAccountCreated(Accounts::AccountId))); | ||
634 | 548 | + this, SLOT(createProfileForAccount(Accounts::AccountId))); | ||
635 | 549 | QObject::connect(iAccountManager, SIGNAL(accountRemoved(Accounts::AccountId)), | ||
636 | 550 | this, SLOT(slotAccountRemoved(Accounts::AccountId))); | ||
637 | 551 | QObject::connect(iAccountManager, SIGNAL(accountUpdated(Accounts::AccountId)), | ||
638 | 552 | this, SLOT(slotAccountUpdated(Accounts::AccountId))); | ||
639 | 553 | |||
640 | 554 | - registerAccountListeners(); | ||
641 | 555 | + // load accounts after return from contructor, to allow connection with class singals | ||
642 | 556 | + // that can be fired by 'registerAccountListeners' function | ||
643 | 557 | + QTimer::singleShot(0, this, SLOT(registerAccountListeners())); | ||
644 | 558 | } | ||
645 | 559 | |||
646 | 560 | AccountsHelper::~AccountsHelper() | ||
647 | 561 | @@ -54,9 +58,10 @@ AccountsHelper::~AccountsHelper() | ||
648 | 562 | // their parent, aka, the manager | ||
649 | 563 | } | ||
650 | 564 | |||
651 | 565 | -void AccountsHelper::slotAccountCreated(Accounts::AccountId id) | ||
652 | 566 | +QString AccountsHelper::createProfileForAccount(Accounts::AccountId id) | ||
653 | 567 | { | ||
654 | 568 | FUNCTION_CALL_TRACE; | ||
655 | 569 | + QString profileName; | ||
656 | 570 | Accounts::Account *newAccount = iAccountManager->account(id); | ||
657 | 571 | bool profileFoundAndCreated = false; | ||
658 | 572 | |||
659 | 573 | @@ -66,7 +71,7 @@ void AccountsHelper::slotAccountCreated(Accounts::AccountId id) | ||
660 | 574 | Accounts::ServiceList serviceList = newAccount->services(); | ||
661 | 575 | foreach(Accounts::Service service, serviceList) | ||
662 | 576 | { | ||
663 | 577 | - // Look for a sync profile that matches the service name | ||
664 | 578 | + // Look for a sync profile that matches the service name (template) | ||
665 | 579 | LOG_DEBUG("Looking for sync profile::" << service.name()); | ||
666 | 580 | SyncProfile *syncProfile = iProfileManager.syncProfile(service.name()); | ||
667 | 581 | LOG_DEBUG("Found profile::" << service.name()); | ||
668 | 582 | @@ -74,7 +79,7 @@ void AccountsHelper::slotAccountCreated(Accounts::AccountId id) | ||
669 | 583 | (true == syncProfile->boolKey(KEY_USE_ACCOUNTS, false)) | ||
670 | 584 | ) | ||
671 | 585 | { | ||
672 | 586 | - addAccountIfNotExists(newAccount, service, syncProfile); | ||
673 | 587 | + profileName = addAccountIfNotExists(newAccount, service, syncProfile); | ||
674 | 588 | profileFoundAndCreated = true; | ||
675 | 589 | } | ||
676 | 590 | if(0 != syncProfile) | ||
677 | 591 | @@ -86,7 +91,7 @@ void AccountsHelper::slotAccountCreated(Accounts::AccountId id) | ||
678 | 592 | |||
679 | 593 | if (profileFoundAndCreated == false) | ||
680 | 594 | { | ||
681 | 595 | - // Fetch the key "remote_service_name" from the account settings and | ||
682 | 596 | + // Fetch the key "remote_service_name" from the account settings and | ||
683 | 597 | // use it to create a profile | ||
684 | 598 | QString profileName = newAccount->valueAsString(REMOTE_SERVICE_NAME); | ||
685 | 599 | LOG_DEBUG("Profile name from account setting:" << profileName); | ||
686 | 600 | @@ -97,10 +102,15 @@ void AccountsHelper::slotAccountCreated(Accounts::AccountId id) | ||
687 | 601 | if (syncProfile->boolKey (KEY_USE_ACCOUNTS, false) == true) | ||
688 | 602 | createProfileForAccount (newAccount, profileName, syncProfile); | ||
689 | 603 | |||
690 | 604 | + profileName = syncProfile->name(); | ||
691 | 605 | delete syncProfile; | ||
692 | 606 | } | ||
693 | 607 | } | ||
694 | 608 | + } else { | ||
695 | 609 | + LOG_DEBUG("Account not found:" << id); | ||
696 | 610 | } | ||
697 | 611 | + | ||
698 | 612 | + return profileName; | ||
699 | 613 | } | ||
700 | 614 | |||
701 | 615 | void AccountsHelper::slotAccountRemoved(Accounts::AccountId id) | ||
702 | 616 | @@ -186,7 +196,7 @@ void AccountsHelper::slotAccountEnabledChanged(const QString &serviceName, bool | ||
703 | 617 | foreach(SyncProfile *profile, profiles) | ||
704 | 618 | { | ||
705 | 619 | // See if the service name matches | ||
706 | 620 | - if(serviceName == profile->name()) | ||
707 | 621 | + if(serviceName == profile->key(REMOTE_SERVICE_NAME)) | ||
708 | 622 | { | ||
709 | 623 | // Check if the status really changed here | ||
710 | 624 | // saving the account can trigger the emition of enabledChanged() | ||
711 | 625 | @@ -331,16 +341,16 @@ void AccountsHelper::createProfileForAccount(Accounts::Account *account, | ||
712 | 626 | delete newProfile; | ||
713 | 627 | } | ||
714 | 628 | |||
715 | 629 | -void AccountsHelper::addAccountIfNotExists(Accounts::Account *account, | ||
716 | 630 | - Accounts::Service service, | ||
717 | 631 | - const SyncProfile *baseProfile) | ||
718 | 632 | +QString AccountsHelper::addAccountIfNotExists(Accounts::Account *account, | ||
719 | 633 | + Accounts::Service service, | ||
720 | 634 | + const SyncProfile *baseProfile) | ||
721 | 635 | { | ||
722 | 636 | FUNCTION_CALL_TRACE; | ||
723 | 637 | |||
724 | 638 | Profile *serviceProfile = iProfileManager.profile(service.name(), Profile::TYPE_SYNC); | ||
725 | 639 | if (!serviceProfile) { | ||
726 | 640 | LOG_DEBUG ("!!!! Service not supported !!!!"); | ||
727 | 641 | - return; | ||
728 | 642 | + return QString(); | ||
729 | 643 | } | ||
730 | 644 | |||
731 | 645 | QString profileName ; | ||
732 | 646 | @@ -367,9 +377,11 @@ void AccountsHelper::addAccountIfNotExists(Accounts::Account *account, | ||
733 | 647 | // Add the account ID to the profile | ||
734 | 648 | newProfile->setKey(KEY_ACCOUNT_ID, QString::number(account->id())); | ||
735 | 649 | // Check if service is enabled | ||
736 | 650 | - LOG_DEBUG("Service:: " << service.displayName() << "enabled status::" << account->enabled()); | ||
737 | 651 | + LOG_DEBUG("Service:: " << service.displayName() << | ||
738 | 652 | + "enabled status::" << (account->enabled() && account->enabledServices().contains(service))); | ||
739 | 653 | // Set profile as enabled | ||
740 | 654 | - newProfile->setEnabled(account->enabled()); | ||
741 | 655 | + newProfile->setEnabled(account->enabled() && | ||
742 | 656 | + account->enabledServices().contains(service)); | ||
743 | 657 | setSyncSchedule (newProfile, account->id(), true); | ||
744 | 658 | |||
745 | 659 | // Save the newly created profile | ||
746 | 660 | @@ -398,6 +410,8 @@ void AccountsHelper::addAccountIfNotExists(Accounts::Account *account, | ||
747 | 661 | { | ||
748 | 662 | delete profile; | ||
749 | 663 | } | ||
750 | 664 | + | ||
751 | 665 | + return profileName; | ||
752 | 666 | } | ||
753 | 667 | |||
754 | 668 | void AccountsHelper::addSetting(Accounts::AccountId id, QString key, QVariant value) { | ||
755 | 669 | @@ -448,12 +462,27 @@ void AccountsHelper::slotSchedulerSettingsChanged(const char *aKey) | ||
756 | 670 | void AccountsHelper::registerAccountListener(Accounts::AccountId id) | ||
757 | 671 | { | ||
758 | 672 | FUNCTION_CALL_TRACE; | ||
759 | 673 | + | ||
760 | 674 | Accounts::Account *account = iAccountManager->account(id); | ||
761 | 675 | + if (iAccountList.contains(account)) { | ||
762 | 676 | + return; | ||
763 | 677 | + } | ||
764 | 678 | iAccountList.append(account); | ||
765 | 679 | // Callback for account enabled/disabled | ||
766 | 680 | - QObject::connect(account, SIGNAL(enabledChanged(const QString&, bool)), | ||
767 | 681 | - this, SLOT(slotAccountEnabledChanged(const QString&, bool))); | ||
768 | 682 | - | ||
769 | 683 | + QObject::connect(account, | ||
770 | 684 | + SIGNAL(enabledChanged(const QString&, bool)), | ||
771 | 685 | + SLOT(slotAccountEnabledChanged(const QString&, bool)), | ||
772 | 686 | + Qt::UniqueConnection); | ||
773 | 687 | + | ||
774 | 688 | + // Account SyncOnChange | ||
775 | 689 | + QList<SyncProfile*> profiles = getProfilesByAccountId(id); | ||
776 | 690 | + foreach(SyncProfile *profile, profiles) | ||
777 | 691 | + { | ||
778 | 692 | + if(profile->isSOCProfile()) | ||
779 | 693 | + { | ||
780 | 694 | + emit enableSOC(profile->name()); | ||
781 | 695 | + } | ||
782 | 696 | + } | ||
783 | 697 | account->selectService(); | ||
784 | 698 | account->beginGroup("scheduler"); | ||
785 | 699 | LOG_DEBUG("Watching Group :" << account->group()); | ||
786 | 700 | @@ -463,5 +492,8 @@ void AccountsHelper::registerAccountListener(Accounts::AccountId id) | ||
787 | 701 | return; | ||
788 | 702 | } | ||
789 | 703 | iAcctWatchMap[watch] = id; | ||
790 | 704 | - QObject::connect(watch, SIGNAL(notify(const char *)), this, SLOT(slotSchedulerSettingsChanged(const char *))); | ||
791 | 705 | + QObject::connect(watch, | ||
792 | 706 | + SIGNAL(notify(const char *)), | ||
793 | 707 | + SLOT(slotSchedulerSettingsChanged(const char *)), | ||
794 | 708 | + Qt::UniqueConnection); | ||
795 | 709 | } | ||
796 | 710 | diff --git a/msyncd/AccountsHelper.h b/msyncd/AccountsHelper.h | ||
797 | 711 | index 1f9508b..a2f8a9c 100644 | ||
798 | 712 | --- a/msyncd/AccountsHelper.h | ||
799 | 713 | +++ b/msyncd/AccountsHelper.h | ||
800 | 714 | @@ -29,12 +29,12 @@ | ||
801 | 715 | #include <Accounts/account.h> | ||
802 | 716 | |||
803 | 717 | namespace Buteo { | ||
804 | 718 | - | ||
805 | 719 | + | ||
806 | 720 | class Profile; | ||
807 | 721 | class AccountsHelperTest; | ||
808 | 722 | class ProfileManager; | ||
809 | 723 | class SyncProfile; | ||
810 | 724 | - | ||
811 | 725 | + | ||
812 | 726 | const QString REMOTE_SERVICE_NAME("remote_service_name"); | ||
813 | 727 | |||
814 | 728 | /*! \brief Helper Class towards Accounts::Manager and various SSO related | ||
815 | 729 | @@ -57,7 +57,7 @@ public: | ||
816 | 730 | * | ||
817 | 731 | */ | ||
818 | 732 | virtual ~AccountsHelper(); | ||
819 | 733 | - | ||
820 | 734 | + | ||
821 | 735 | /*! \brief Returns sync profiles that correspond to a given account ID | ||
822 | 736 | * | ||
823 | 737 | * \param id - The account ID. | ||
824 | 738 | @@ -68,30 +68,31 @@ public: | ||
825 | 739 | |||
826 | 740 | public Q_SLOTS: | ||
827 | 741 | |||
828 | 742 | - /*! \brief slot for Accounts::Manager accountCreated signal | ||
829 | 743 | - * | ||
830 | 744 | - * \param id Accounts Id | ||
831 | 745 | - */ | ||
832 | 746 | - void slotAccountCreated(Accounts::AccountId id); | ||
833 | 747 | + /*! \brief This method is used to create a profile for a specified | ||
834 | 748 | + * account | ||
835 | 749 | + * \param id Accounts Id | ||
836 | 750 | + * \return A string with the new profile name | ||
837 | 751 | + */ | ||
838 | 752 | + QString createProfileForAccount(Accounts::AccountId id); | ||
839 | 753 | |||
840 | 754 | - /*! \brief slot for Accounts::Manager accountRemoved signal | ||
841 | 755 | - * | ||
842 | 756 | - * \param id of the accounts | ||
843 | 757 | - */ | ||
844 | 758 | + /*! \brief slot for Accounts::Manager accountRemoved signal | ||
845 | 759 | + * | ||
846 | 760 | + * \param id of the accounts | ||
847 | 761 | + */ | ||
848 | 762 | void slotAccountRemoved(Accounts::AccountId id); | ||
849 | 763 | |||
850 | 764 | - /*! \brief slot for Accounts::Account enabledChanged signal | ||
851 | 765 | - * | ||
852 | 766 | - * \param serviceName The service that was enabled/disabled. Empty if the | ||
853 | 767 | + /*! \brief slot for Accounts::Account enabledChanged signal | ||
854 | 768 | + * | ||
855 | 769 | + * \param serviceName The service that was enabled/disabled. Empty if the | ||
856 | 770 | * entire account is enabled/disabled | ||
857 | 771 | * \param enabled Boolean indicating enabled (true) or disabled (false) | ||
858 | 772 | - */ | ||
859 | 773 | + */ | ||
860 | 774 | void slotAccountEnabledChanged(const QString &serviceName, bool enabled); | ||
861 | 775 | - | ||
862 | 776 | - /*! \brief slot for Accounts::Manager displayNameChanged signal | ||
863 | 777 | - * * | ||
864 | 778 | - * \param id of the accounts | ||
865 | 779 | - */ | ||
866 | 780 | + | ||
867 | 781 | + /*! \brief slot for Accounts::Manager displayNameChanged signal | ||
868 | 782 | + * * | ||
869 | 783 | + * \param id of the accounts | ||
870 | 784 | + */ | ||
871 | 785 | void slotAccountUpdated(Accounts::AccountId id); | ||
872 | 786 | |||
873 | 787 | void slotSchedulerSettingsChanged(const char *aKey); | ||
874 | 788 | @@ -102,22 +103,20 @@ Q_SIGNALS: | ||
875 | 789 | void removeProfile(QString profileId); | ||
876 | 790 | void removeScheduledSync(const QString& profileId); | ||
877 | 791 | |||
878 | 792 | -private: | ||
879 | 793 | +private Q_SLOTS: | ||
880 | 794 | |||
881 | 795 | - /*! | ||
882 | 796 | - * \brief This method is used to create a profile for a specified | ||
883 | 797 | - * account | ||
884 | 798 | - */ | ||
885 | 799 | + void registerAccountListeners(); | ||
886 | 800 | + | ||
887 | 801 | +private: | ||
888 | 802 | void createProfileForAccount(Accounts::Account* account, | ||
889 | 803 | const QString profileName, | ||
890 | 804 | const SyncProfile* baseProfile); | ||
891 | 805 | |||
892 | 806 | - void addAccountIfNotExists(Accounts::Account *account, | ||
893 | 807 | - Accounts::Service service, | ||
894 | 808 | - const SyncProfile *baseProfile); | ||
895 | 809 | + QString addAccountIfNotExists(Accounts::Account *account, | ||
896 | 810 | + Accounts::Service service, | ||
897 | 811 | + const SyncProfile *baseProfile); | ||
898 | 812 | |||
899 | 813 | void setSyncSchedule(SyncProfile *syncProfile, Accounts::AccountId id, bool aCreateNew = false); | ||
900 | 814 | - void registerAccountListeners(); | ||
901 | 815 | |||
902 | 816 | void addSetting(Accounts::AccountId id, QString key, QVariant value); | ||
903 | 817 | |||
904 | 818 | diff --git a/msyncd/SyncDBusAdaptor.cpp b/msyncd/SyncDBusAdaptor.cpp | ||
905 | 819 | index 1b08b49..fd43324 100644 | ||
906 | 820 | --- a/msyncd/SyncDBusAdaptor.cpp | ||
907 | 821 | +++ b/msyncd/SyncDBusAdaptor.cpp | ||
908 | 822 | @@ -206,3 +206,11 @@ void SyncDBusAdaptor::isSyncedExternally(uint aAccountId, const QString aClientP | ||
909 | 823 | QMetaObject::invokeMethod(parent(), "isSyncedExternally", Q_ARG(uint, aAccountId), Q_ARG(QString, aClientProfileName)); | ||
910 | 824 | } | ||
911 | 825 | |||
912 | 826 | +QString SyncDBusAdaptor::createSyncProfileForAccount(uint aAccountId) | ||
913 | 827 | +{ | ||
914 | 828 | + // handle method call com.meego.msyncd.createSyncProfileForAccount | ||
915 | 829 | + QString out0; | ||
916 | 830 | + QMetaObject::invokeMethod(parent(), "createSyncProfileForAccount", Q_RETURN_ARG(QString, out0), Q_ARG(uint, aAccountId)); | ||
917 | 831 | + return out0; | ||
918 | 832 | +} | ||
919 | 833 | + | ||
920 | 834 | diff --git a/msyncd/SyncDBusAdaptor.h b/msyncd/SyncDBusAdaptor.h | ||
921 | 835 | index 2aaf803..e15f50b 100644 | ||
922 | 836 | --- a/msyncd/SyncDBusAdaptor.h | ||
923 | 837 | +++ b/msyncd/SyncDBusAdaptor.h | ||
924 | 838 | @@ -157,6 +157,10 @@ class SyncDBusAdaptor: public QDBusAbstractAdaptor | ||
925 | 839 | " <arg direction=\"out\" type=\"au\"/>\n" | ||
926 | 840 | " <annotation value=\"QList<uint>\" name=\"com.trolltech.QtDBus.QtTypeName.Out0\"/>\n" | ||
927 | 841 | " </method>\n" | ||
928 | 842 | +" <method name=\"createSyncProfileForAccount\">\n" | ||
929 | 843 | +" <arg direction=\"out\" type=\"s\"/>\n" | ||
930 | 844 | +" <arg direction=\"in\" type=\"u\" name=\"aAccountId\"/>\n" | ||
931 | 845 | +" </method>\n" | ||
932 | 846 | " <method name=\"status\">\n" | ||
933 | 847 | " <arg direction=\"out\" type=\"i\"/>\n" | ||
934 | 848 | " <arg direction=\"in\" type=\"u\" name=\"aAccountId\"/>\n" | ||
935 | 849 | @@ -198,6 +202,7 @@ public Q_SLOTS: // METHODS | ||
936 | 850 | QList<uint> syncingAccounts(); | ||
937 | 851 | bool updateProfile(const QString &aProfileAsXml); | ||
938 | 852 | Q_NOREPLY void isSyncedExternally(uint aAccountId, const QString aClientProfileName); | ||
939 | 853 | + QString createSyncProfileForAccount(uint aAccountId); | ||
940 | 854 | Q_SIGNALS: // SIGNALS | ||
941 | 855 | void backupDone(); | ||
942 | 856 | void backupInProgress(); | ||
943 | 857 | diff --git a/msyncd/SyncDBusInterface.h b/msyncd/SyncDBusInterface.h | ||
944 | 858 | index 27b5d21..21c9c0e 100644 | ||
945 | 859 | --- a/msyncd/SyncDBusInterface.h | ||
946 | 860 | +++ b/msyncd/SyncDBusInterface.h | ||
947 | 861 | @@ -103,29 +103,29 @@ signals: | ||
948 | 862 | * | ||
949 | 863 | */ | ||
950 | 864 | void signalProfileChanged(QString aProfileName, int aChangeType , QString aProfileAsXml); | ||
951 | 865 | - | ||
952 | 866 | - | ||
953 | 867 | + | ||
954 | 868 | + | ||
955 | 869 | /*! \brief Notifies about Backup start. | ||
956 | 870 | * | ||
957 | 871 | * This signal is sent when the backup framework is backing the sync related | ||
958 | 872 | * data | ||
959 | 873 | */ | ||
960 | 874 | void backupInProgress (); | ||
961 | 875 | - | ||
962 | 876 | + | ||
963 | 877 | /*! \brief Notifies about Backup done. | ||
964 | 878 | * | ||
965 | 879 | * This signal is sent when the backup framework has completed backing the sync related | ||
966 | 880 | * data. | ||
967 | 881 | */ | ||
968 | 882 | void backupDone(); | ||
969 | 883 | - | ||
970 | 884 | + | ||
971 | 885 | /*! \brief Notifies about Restore start. | ||
972 | 886 | * | ||
973 | 887 | * This signal is sent when the backup framework is restoring the sync related | ||
974 | 888 | * data | ||
975 | 889 | */ | ||
976 | 890 | void restoreInProgress(); | ||
977 | 891 | - | ||
978 | 892 | + | ||
979 | 893 | /*! \brief Notifies about Restore Done. | ||
980 | 894 | * | ||
981 | 895 | * This signal is sent when the backup framework has restored the sync related | ||
982 | 896 | @@ -160,7 +160,7 @@ signals: | ||
983 | 897 | * \param aNextSyncTime This is an out parameter. The next sync time. | ||
984 | 898 | */ | ||
985 | 899 | void statusChanged(unsigned int aAccountId, int aNewStatus, int aFailedReason, qlonglong aPrevSyncTime, qlonglong aNextSyncTime); | ||
986 | 900 | - | ||
987 | 901 | + | ||
988 | 902 | /*! \brief Returns the connectivity state of a specific medium like | ||
989 | 903 | * bluetooth, USB or network. | ||
990 | 904 | * \see SyncCommonDefs::ConnectivityType for arguments | ||
991 | 905 | @@ -257,16 +257,16 @@ public slots: | ||
992 | 906 | * \return Profile name list. | ||
993 | 907 | */ | ||
994 | 908 | virtual QStringList runningSyncs() = 0; | ||
995 | 909 | - | ||
996 | 910 | - | ||
997 | 911 | + | ||
998 | 912 | + | ||
999 | 913 | /*! | ||
1000 | 914 | * \brief This function returns true if backup/restore in progress else | ||
1001 | 915 | * false. | ||
1002 | 916 | */ | ||
1003 | 917 | virtual bool getBackUpRestoreState() = 0; | ||
1004 | 918 | - | ||
1005 | 919 | - | ||
1006 | 920 | - /*! | ||
1007 | 921 | + | ||
1008 | 922 | + | ||
1009 | 923 | + /*! | ||
1010 | 924 | * \brief sets the schedule for a profile | ||
1011 | 925 | * | ||
1012 | 926 | * This Function helps in setting a schedule to profile | ||
1013 | 927 | @@ -312,7 +312,7 @@ public slots: | ||
1014 | 928 | * \return The sync profile as Xml string. | ||
1015 | 929 | */ | ||
1016 | 930 | virtual QString syncProfile(const QString &aProfileId) = 0; | ||
1017 | 931 | - | ||
1018 | 932 | + | ||
1019 | 933 | /*! \brief Gets a sync profiles matching the key-value. | ||
1020 | 934 | * | ||
1021 | 935 | * Loads and merges also all sub-profiles that are referenced from the | ||
1022 | 936 | @@ -323,7 +323,7 @@ public slots: | ||
1023 | 937 | * \return The sync profiles as Xml string list. | ||
1024 | 938 | */ | ||
1025 | 939 | virtual QStringList syncProfilesByKey(const QString &aKey, const QString &aValue) = 0; | ||
1026 | 940 | - | ||
1027 | 941 | + | ||
1028 | 942 | /*! \brief Gets a profiles matching the profile type. | ||
1029 | 943 | * | ||
1030 | 944 | * \param aType Type of the profile service/storage/sync. | ||
1031 | 945 | @@ -336,13 +336,13 @@ public slots: | ||
1032 | 946 | * \param aAccountId The account ID. | ||
1033 | 947 | */ | ||
1034 | 948 | virtual Q_NOREPLY void start(unsigned int aAccountId) = 0; | ||
1035 | 949 | - | ||
1036 | 950 | + | ||
1037 | 951 | /*! \brief Stops sync for all profiles matching the given account ID. | ||
1038 | 952 | * | ||
1039 | 953 | * \param aAccountId The account ID. | ||
1040 | 954 | */ | ||
1041 | 955 | virtual Q_NOREPLY void stop(unsigned int aAccountId) = 0; | ||
1042 | 956 | - | ||
1043 | 957 | + | ||
1044 | 958 | /*! \brief Returns the list of account IDs for which sync is ongoing | ||
1045 | 959 | * | ||
1046 | 960 | * \return The list of account IDs currectly syncing. | ||
1047 | 961 | @@ -373,6 +373,13 @@ public slots: | ||
1048 | 962 | * having several services enabled | ||
1049 | 963 | */ | ||
1050 | 964 | virtual Q_NOREPLY void isSyncedExternally(unsigned int aAccountId, const QString aClientProfileName) = 0; | ||
1051 | 965 | + | ||
1052 | 966 | + /*! \brief Create a sync profile for the account if it does not exists | ||
1053 | 967 | + * | ||
1054 | 968 | + * \param aAccountId The account ID. | ||
1055 | 969 | + * \return The profile name if the profile was created successful or empty if it fails | ||
1056 | 970 | + */ | ||
1057 | 971 | + virtual QString createSyncProfileForAccount(uint aAccountId) = 0; | ||
1058 | 972 | }; | ||
1059 | 973 | |||
1060 | 974 | } | ||
1061 | 975 | diff --git a/msyncd/SyncOnChangeScheduler.cpp b/msyncd/SyncOnChangeScheduler.cpp | ||
1062 | 976 | index b7f5b75..389618d 100644 | ||
1063 | 977 | --- a/msyncd/SyncOnChangeScheduler.cpp | ||
1064 | 978 | +++ b/msyncd/SyncOnChangeScheduler.cpp | ||
1065 | 979 | @@ -14,6 +14,11 @@ SyncOnChangeScheduler::SyncOnChangeScheduler() | ||
1066 | 980 | SyncOnChangeScheduler::~SyncOnChangeScheduler() | ||
1067 | 981 | { | ||
1068 | 982 | FUNCTION_CALL_TRACE; | ||
1069 | 983 | + foreach(QObject *o, iSOCTimers.values()) { | ||
1070 | 984 | + delete o; | ||
1071 | 985 | + } | ||
1072 | 986 | + iSOCTimers.clear(); | ||
1073 | 987 | + iSOCProfileNames.clear(); | ||
1074 | 988 | } | ||
1075 | 989 | |||
1076 | 990 | bool SyncOnChangeScheduler::addProfile(const SyncProfile* aProfile) | ||
1077 | 991 | @@ -30,6 +35,7 @@ bool SyncOnChangeScheduler::addProfile(const SyncProfile* aProfile) | ||
1078 | 992 | Qt::QueuedConnection); | ||
1079 | 993 | SOCtimer->fire(); | ||
1080 | 994 | scheduled = true; | ||
1081 | 995 | + iSOCTimers.insert(aProfile->name(), SOCtimer); | ||
1082 | 996 | LOG_DEBUG("Sync on change scheduled for profile"<< aProfile->name()); | ||
1083 | 997 | } | ||
1084 | 998 | else if(aProfile) | ||
1085 | 999 | @@ -43,12 +49,15 @@ void SyncOnChangeScheduler::removeProfile(const QString &aProfileName) | ||
1086 | 1000 | { | ||
1087 | 1001 | FUNCTION_CALL_TRACE; | ||
1088 | 1002 | iSOCProfileNames.removeAll(aProfileName); | ||
1089 | 1003 | + // cancel timer | ||
1090 | 1004 | + delete iSOCTimers.take(aProfileName); | ||
1091 | 1005 | } | ||
1092 | 1006 | |||
1093 | 1007 | void SyncOnChangeScheduler::sync(const SyncProfile* aProfile) | ||
1094 | 1008 | { | ||
1095 | 1009 | FUNCTION_CALL_TRACE; | ||
1096 | 1010 | iSOCProfileNames.removeAll(aProfile->name()); | ||
1097 | 1011 | + iSOCTimers.remove(aProfile->name()); | ||
1098 | 1012 | SyncOnChangeTimer *SOCtimer = qobject_cast<SyncOnChangeTimer*>(sender()); | ||
1099 | 1013 | if(SOCtimer) | ||
1100 | 1014 | { | ||
1101 | 1015 | diff --git a/msyncd/SyncOnChangeScheduler.h b/msyncd/SyncOnChangeScheduler.h | ||
1102 | 1016 | index 14168bf..aac2241 100644 | ||
1103 | 1017 | --- a/msyncd/SyncOnChangeScheduler.h | ||
1104 | 1018 | +++ b/msyncd/SyncOnChangeScheduler.h | ||
1105 | 1019 | @@ -40,7 +40,7 @@ public: | ||
1106 | 1020 | * | ||
1107 | 1021 | * Once the SOC is initiated (by sending a syncNow signal), the profile is | ||
1108 | 1022 | * removed automatically | ||
1109 | 1023 | - * | ||
1110 | 1024 | + * | ||
1111 | 1025 | * @param aProfile pointer to sync profile | ||
1112 | 1026 | * @return true if SOC could be scheduled, false otherwise | ||
1113 | 1027 | */ | ||
1114 | 1028 | @@ -63,6 +63,7 @@ private Q_SLOTS: | ||
1115 | 1029 | |||
1116 | 1030 | private: | ||
1117 | 1031 | QStringList iSOCProfileNames; | ||
1118 | 1032 | + QMap<QString, QObject*> iSOCTimers; | ||
1119 | 1033 | }; | ||
1120 | 1034 | |||
1121 | 1035 | class SyncOnChangeTimer : public QObject | ||
1122 | 1036 | diff --git a/msyncd/SyncSession.h b/msyncd/SyncSession.h | ||
1123 | 1037 | index 401692c..4a3cde7 100644 | ||
1124 | 1038 | --- a/msyncd/SyncSession.h | ||
1125 | 1039 | +++ b/msyncd/SyncSession.h | ||
1126 | 1040 | @@ -182,7 +182,7 @@ public: | ||
1127 | 1041 | void setProfileCreated(bool aProfileCreated); | ||
1128 | 1042 | |||
1129 | 1043 | //! \brief Maps sync failure error code from stack to SyncStatus | ||
1130 | 1044 | - Sync::SyncStatus mapToSyncStatusError(int aErrorCode); | ||
1131 | 1045 | + Sync::SyncStatus mapToSyncStatusError(int aErrorCode); | ||
1132 | 1046 | |||
1133 | 1047 | signals: | ||
1134 | 1048 | |||
1135 | 1049 | diff --git a/msyncd/bin/msyncd.conf b/msyncd/bin/msyncd.conf | ||
1136 | 1050 | new file mode 100644 | ||
1137 | 1051 | index 0000000..d383006 | ||
1138 | 1052 | --- /dev/null | ||
1139 | 1053 | +++ b/msyncd/bin/msyncd.conf | ||
1140 | 1054 | @@ -0,0 +1,15 @@ | ||
1141 | 1055 | +description "address-book-service" | ||
1142 | 1056 | +author "Bill Filler <bill.filler@canonical.com>" | ||
1143 | 1057 | + | ||
1144 | 1058 | +start on started unity8-dash | ||
1145 | 1059 | +stop on runlevel [06] | ||
1146 | 1060 | + | ||
1147 | 1061 | +# give some time to nm be ready | ||
1148 | 1062 | +pre-start script | ||
1149 | 1063 | + sleep 10; | ||
1150 | 1064 | +end script | ||
1151 | 1065 | + | ||
1152 | 1066 | +respawn | ||
1153 | 1067 | + | ||
1154 | 1068 | +env MSYNCD_LOGGING_LEVEL=10 | ||
1155 | 1069 | +exec /usr/bin/msyncd | ||
1156 | 1070 | diff --git a/msyncd/gschemas/com.meego.msyncd.gschema.xml b/msyncd/gschemas/com.meego.msyncd.gschema.xml | ||
1157 | 1071 | new file mode 100644 | ||
1158 | 1072 | index 0000000..4e410d5 | ||
1159 | 1073 | --- /dev/null | ||
1160 | 1074 | +++ b/msyncd/gschemas/com.meego.msyncd.gschema.xml | ||
1161 | 1075 | @@ -0,0 +1,10 @@ | ||
1162 | 1076 | +<?xml version="1.0" encoding="UTF-8"?> | ||
1163 | 1077 | +<schemalist> | ||
1164 | 1078 | + <schema id="com.meego.msyncd" path="/com/meego/msyncd/"> | ||
1165 | 1079 | + <key name="allow-scheduled-sync-over-cellular" type="b"> | ||
1166 | 1080 | + <summary>Scheduled Sync over cellular</summary> | ||
1167 | 1081 | + <description>Allow scheduled syncs to run over cellular connections.</description> | ||
1168 | 1082 | + <default>true</default> | ||
1169 | 1083 | + </key> | ||
1170 | 1084 | + </schema> | ||
1171 | 1085 | +</schemalist> | ||
1172 | 1086 | diff --git a/msyncd/msyncd-app.pro b/msyncd/msyncd-app.pro | ||
1173 | 1087 | index 1d5d338..5dd614e 100644 | ||
1174 | 1088 | --- a/msyncd/msyncd-app.pro | ||
1175 | 1089 | +++ b/msyncd/msyncd-app.pro | ||
1176 | 1090 | @@ -59,13 +59,19 @@ target.path = /usr/bin/ | ||
1177 | 1091 | loglevel.files = bin/set_sync_log_level | ||
1178 | 1092 | loglevel.path = /etc/buteo/ | ||
1179 | 1093 | service.files = bin/msyncd.service | ||
1180 | 1094 | +upstart.files = bin/msyncd.conf | ||
1181 | 1095 | service.path = /usr/lib/systemd/user/ | ||
1182 | 1096 | +upstart.path = /usr/share/upstart/sessions/ | ||
1183 | 1097 | syncwidget.path = /etc/syncwidget/ | ||
1184 | 1098 | syncwidget.files = com.meego.msyncd | ||
1185 | 1099 | +gschemas.path = /usr/share/glib-2.0/schemas | ||
1186 | 1100 | +gschemas.files = gschemas/com.meego.msyncd.gschema.xml | ||
1187 | 1101 | INSTALLS += target \ | ||
1188 | 1102 | loglevel \ | ||
1189 | 1103 | syncwidget \ | ||
1190 | 1104 | - service | ||
1191 | 1105 | + service \ | ||
1192 | 1106 | + upstart \ | ||
1193 | 1107 | + gschemas | ||
1194 | 1108 | |||
1195 | 1109 | # ##################################################################### | ||
1196 | 1110 | # make coverage (debug) | ||
1197 | 1111 | diff --git a/msyncd/msyncd-lib.pro b/msyncd/msyncd-lib.pro | ||
1198 | 1112 | index 12a398c..ff7043e 100644 | ||
1199 | 1113 | --- a/msyncd/msyncd-lib.pro | ||
1200 | 1114 | +++ b/msyncd/msyncd-lib.pro | ||
1201 | 1115 | @@ -19,7 +19,7 @@ INCLUDEPATH += . \ | ||
1202 | 1116 | ../libbuteosyncfw/profile | ||
1203 | 1117 | |||
1204 | 1118 | |||
1205 | 1119 | -PKGCONFIG += dbus-1 | ||
1206 | 1120 | +PKGCONFIG += dbus-1 gio-2.0 | ||
1207 | 1121 | |||
1208 | 1122 | equals(QT_MAJOR_VERSION, 4): { | ||
1209 | 1123 | PKGCONFIG += libsignon-qt accounts-qt | ||
1210 | 1124 | diff --git a/msyncd/synchronizer.cpp b/msyncd/synchronizer.cpp | ||
1211 | 1125 | index b516ccd..6fccca6 100644 | ||
1212 | 1126 | --- a/msyncd/synchronizer.cpp | ||
1213 | 1127 | +++ b/msyncd/synchronizer.cpp | ||
1214 | 1128 | @@ -1,4 +1,4 @@ | ||
1215 | 1129 | -/* | ||
1216 | 1130 | +/* | ||
1217 | 1131 | * This file is part of buteo-syncfw package | ||
1218 | 1132 | * | ||
1219 | 1133 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
1220 | 1134 | @@ -21,6 +21,7 @@ | ||
1221 | 1135 | * 02110-1301 USA | ||
1222 | 1136 | * | ||
1223 | 1137 | */ | ||
1224 | 1138 | +#include <gio/gio.h> | ||
1225 | 1139 | #include "synchronizer.h" | ||
1226 | 1140 | #include "SyncDBusAdaptor.h" | ||
1227 | 1141 | #include "SyncSession.h" | ||
1228 | 1142 | @@ -51,11 +52,11 @@ | ||
1229 | 1143 | #include <fcntl.h> | ||
1230 | 1144 | #include <termios.h> | ||
1231 | 1145 | |||
1232 | 1146 | + | ||
1233 | 1147 | using namespace Buteo; | ||
1234 | 1148 | |||
1235 | 1149 | static const QString SYNC_DBUS_OBJECT = "/synchronizer"; | ||
1236 | 1150 | static const QString SYNC_DBUS_SERVICE = "com.meego.msyncd"; | ||
1237 | 1151 | - | ||
1238 | 1152 | static const QString BT_PROPERTIES_NAME = "Name"; | ||
1239 | 1153 | |||
1240 | 1154 | // Maximum time in milliseconds to wait for a thread to stop | ||
1241 | 1155 | @@ -71,10 +72,9 @@ Synchronizer::Synchronizer( QCoreApplication* aApplication ) | ||
1242 | 1156 | iClosing(false), | ||
1243 | 1157 | iSOCEnabled(false), | ||
1244 | 1158 | iSyncUIInterface(NULL) | ||
1245 | 1159 | - | ||
1246 | 1160 | { | ||
1247 | 1161 | + iSettings = g_settings_new_with_path("com.meego.msyncd", "/com/meego/msyncd/"); | ||
1248 | 1162 | FUNCTION_CALL_TRACE; | ||
1249 | 1163 | - | ||
1250 | 1164 | this->setParent(aApplication); | ||
1251 | 1165 | } | ||
1252 | 1166 | |||
1253 | 1167 | @@ -86,6 +86,7 @@ Synchronizer::~Synchronizer() | ||
1254 | 1168 | delete iSyncUIInterface; | ||
1255 | 1169 | iSyncUIInterface = NULL; | ||
1256 | 1170 | } | ||
1257 | 1171 | + g_object_unref(iSettings); | ||
1258 | 1172 | } | ||
1259 | 1173 | |||
1260 | 1174 | bool Synchronizer::initialize() | ||
1261 | 1175 | @@ -115,8 +116,9 @@ bool Synchronizer::initialize() | ||
1262 | 1176 | this, SLOT(slotSyncStatus(QString, int, QString, int)), | ||
1263 | 1177 | Qt::QueuedConnection); | ||
1264 | 1178 | |||
1265 | 1179 | + // use queued connection because the profile will be stored after the signal | ||
1266 | 1180 | connect(&iProfileManager ,SIGNAL(signalProfileChanged(QString,int,QString)), | ||
1267 | 1181 | - this, SIGNAL(signalProfileChanged(QString,int,QString))); | ||
1268 | 1182 | + this, SLOT(slotProfileChanged(QString,int,QString)), Qt::QueuedConnection); | ||
1269 | 1183 | |||
1270 | 1184 | iNetworkManager = new NetworkManager(this); | ||
1271 | 1185 | Q_ASSERT(iNetworkManager); | ||
1272 | 1186 | @@ -127,8 +129,9 @@ bool Synchronizer::initialize() | ||
1273 | 1187 | { | ||
1274 | 1188 | iServerActivator = new ServerActivator(iProfileManager, | ||
1275 | 1189 | *iTransportTracker, this); | ||
1276 | 1190 | - connect(iTransportTracker, SIGNAL(networkStateChanged(bool)), | ||
1277 | 1191 | - this, SLOT(onNetworkStateChanged(bool))); | ||
1278 | 1192 | + connect(iTransportTracker, | ||
1279 | 1193 | + SIGNAL(networkStateChanged(bool,Sync::InternetConnectionType)), | ||
1280 | 1194 | + SLOT(onNetworkStateChanged(bool,Sync::InternetConnectionType))); | ||
1281 | 1195 | } | ||
1282 | 1196 | |||
1283 | 1197 | // Initialize account manager. | ||
1284 | 1198 | @@ -184,7 +187,7 @@ bool Synchronizer::initialize() | ||
1285 | 1199 | else | ||
1286 | 1200 | { | ||
1287 | 1201 | QObject::connect(&iSyncOnChangeScheduler, SIGNAL(syncNow(QString)), | ||
1288 | 1202 | - this, SLOT(startSync(QString)), | ||
1289 | 1203 | + this, SLOT(startScheduledSync(QString)), | ||
1290 | 1204 | Qt::QueuedConnection); | ||
1291 | 1205 | iSOCEnabled = true; | ||
1292 | 1206 | } | ||
1293 | 1207 | @@ -200,7 +203,7 @@ void Synchronizer::enableSOCSlot(const QString& aProfileName) | ||
1294 | 1208 | { | ||
1295 | 1209 | FUNCTION_CALL_TRACE; | ||
1296 | 1210 | SyncProfile* profile = iProfileManager.syncProfile(aProfileName); | ||
1297 | 1211 | - if(!iSOCEnabled) | ||
1298 | 1212 | + if(profile->isSOCProfile() && !iSOCEnabled) | ||
1299 | 1213 | { | ||
1300 | 1214 | QHash<QString,QList<SyncProfile*> > aSOCStorageMap; | ||
1301 | 1215 | QList<SyncProfile*> SOCProfiles; | ||
1302 | 1216 | @@ -217,13 +220,13 @@ void Synchronizer::enableSOCSlot(const QString& aProfileName) | ||
1303 | 1217 | else | ||
1304 | 1218 | { | ||
1305 | 1219 | QObject::connect(&iSyncOnChangeScheduler, SIGNAL(syncNow(const QString&)), | ||
1306 | 1220 | - this, SLOT(startSync(const QString&)), | ||
1307 | 1221 | + this, SLOT(startScheduledSync(const QString&)), | ||
1308 | 1222 | Qt::QueuedConnection); | ||
1309 | 1223 | iSOCEnabled = true; | ||
1310 | 1224 | LOG_DEBUG("Sync on change enabled for profile" << aProfileName); | ||
1311 | 1225 | } | ||
1312 | 1226 | } | ||
1313 | 1227 | - else | ||
1314 | 1228 | + else if (profile->isSOCProfile()) | ||
1315 | 1229 | { | ||
1316 | 1230 | iSyncOnChange.addProfile("hcontacts", profile); | ||
1317 | 1231 | } | ||
1318 | 1232 | @@ -291,55 +294,27 @@ bool Synchronizer::startScheduledSync(QString aProfileName) | ||
1319 | 1233 | // All scheduled syncs are online syncs | ||
1320 | 1234 | // Add this to the waiting online syncs and it will be started when we | ||
1321 | 1235 | // receive a session connection status from the NetworkManager | ||
1322 | 1236 | - bool sessionConnected = !iWaitingOnlineSyncs.isEmpty(); | ||
1323 | 1237 | - if(!iWaitingOnlineSyncs.contains(aProfileName)) | ||
1324 | 1238 | + bool accept = acceptScheduledSync(iNetworkManager->isOnline(), iNetworkManager->connectionType()); | ||
1325 | 1239 | + if(accept) | ||
1326 | 1240 | { | ||
1327 | 1241 | - iWaitingOnlineSyncs.append(aProfileName); | ||
1328 | 1242 | + startSync(aProfileName, true); | ||
1329 | 1243 | } | ||
1330 | 1244 | - if(!sessionConnected) | ||
1331 | 1245 | + else if (!iWaitingOnlineSyncs.contains(aProfileName)) | ||
1332 | 1246 | { | ||
1333 | 1247 | - QObject::connect(iNetworkManager, SIGNAL(connectionSuccess()), this, | ||
1334 | 1248 | - SLOT(slotNetworkSessionOpened()), Qt::QueuedConnection); | ||
1335 | 1249 | - QObject::connect(iNetworkManager, SIGNAL(connectionError()), this, | ||
1336 | 1250 | - SLOT(slotNetworkSessionError()), Qt::QueuedConnection); | ||
1337 | 1251 | - // Request for a network session | ||
1338 | 1252 | - iNetworkManager->connectSession(true); | ||
1339 | 1253 | + LOG_DEBUG("Wait for internet connection:" << aProfileName); | ||
1340 | 1254 | + if (iNetworkManager->isOnline()) | ||
1341 | 1255 | + { | ||
1342 | 1256 | + LOG_DEBUG("Connection over mobile data plan. The sync will be postponed untill a full connection is available;"); | ||
1343 | 1257 | + } | ||
1344 | 1258 | + else | ||
1345 | 1259 | + { | ||
1346 | 1260 | + LOG_DEBUG("Device offline. Wait for internet connection."); | ||
1347 | 1261 | + } | ||
1348 | 1262 | + iWaitingOnlineSyncs.append(aProfileName); | ||
1349 | 1263 | } | ||
1350 | 1264 | return true; | ||
1351 | 1265 | } | ||
1352 | 1266 | |||
1353 | 1267 | -void Synchronizer::slotNetworkSessionOpened() | ||
1354 | 1268 | -{ | ||
1355 | 1269 | - FUNCTION_CALL_TRACE; | ||
1356 | 1270 | - QObject::disconnect(iNetworkManager, SIGNAL(connectionSuccess()), this, | ||
1357 | 1271 | - SLOT(slotNetworkSessionOpened())); | ||
1358 | 1272 | - QObject::disconnect(iNetworkManager, SIGNAL(connectionError()), this, | ||
1359 | 1273 | - SLOT(slotNetworkSessionError())); | ||
1360 | 1274 | - foreach(QString profileName, iWaitingOnlineSyncs) | ||
1361 | 1275 | - { | ||
1362 | 1276 | - startSync(profileName, true); | ||
1363 | 1277 | - } | ||
1364 | 1278 | - iWaitingOnlineSyncs.clear(); | ||
1365 | 1279 | -} | ||
1366 | 1280 | - | ||
1367 | 1281 | -void Synchronizer::slotNetworkSessionError() | ||
1368 | 1282 | -{ | ||
1369 | 1283 | - FUNCTION_CALL_TRACE; | ||
1370 | 1284 | - QObject::disconnect(iNetworkManager, SIGNAL(connectionSuccess()), this, | ||
1371 | 1285 | - SLOT(slotNetworkSessionOpened())); | ||
1372 | 1286 | - QObject::disconnect(iNetworkManager, SIGNAL(connectionError()), this, | ||
1373 | 1287 | - SLOT(slotNetworkSessionError())); | ||
1374 | 1288 | - // Cancel all open sessions | ||
1375 | 1289 | - foreach(QString profileName, iWaitingOnlineSyncs) | ||
1376 | 1290 | - { | ||
1377 | 1291 | - SyncResults syncResults(QDateTime::currentDateTime(), SyncResults::SYNC_RESULT_FAILED, SyncResults::CONNECTION_ERROR); | ||
1378 | 1292 | - iProfileManager.saveSyncResults(profileName, syncResults); | ||
1379 | 1293 | - reschedule(profileName); | ||
1380 | 1294 | - } | ||
1381 | 1295 | - iWaitingOnlineSyncs.clear(); | ||
1382 | 1296 | - iNetworkManager->disconnectSession(); | ||
1383 | 1297 | -} | ||
1384 | 1298 | - | ||
1385 | 1299 | bool Synchronizer::setSyncSchedule(QString aProfileId , QString aScheduleAsXml) | ||
1386 | 1300 | { | ||
1387 | 1301 | bool status = false; | ||
1388 | 1302 | @@ -364,6 +339,11 @@ bool Synchronizer::saveSyncResults(QString aProfileId, QString aSyncResults) | ||
1389 | 1303 | return status; | ||
1390 | 1304 | } | ||
1391 | 1305 | |||
1392 | 1306 | +QString Synchronizer::createSyncProfileForAccount(uint aAccountId) | ||
1393 | 1307 | +{ | ||
1394 | 1308 | + return iAccounts->createProfileForAccount(aAccountId); | ||
1395 | 1309 | +} | ||
1396 | 1310 | + | ||
1397 | 1311 | bool Synchronizer::startSync(const QString &aProfileName, bool aScheduled) | ||
1398 | 1312 | { | ||
1399 | 1313 | FUNCTION_CALL_TRACE; | ||
1400 | 1314 | @@ -378,6 +358,12 @@ bool Synchronizer::startSync(const QString &aProfileName, bool aScheduled) | ||
1401 | 1315 | |||
1402 | 1316 | LOG_DEBUG( "Start sync requested for profile:" << aProfileName ); | ||
1403 | 1317 | |||
1404 | 1318 | + // This function can be called from a client app as manual sync: | ||
1405 | 1319 | + // If we receive a manual sync to a profile that is peding to sync due a | ||
1406 | 1320 | + // data change we can remove it from the iSyncOnChangeScheduler, to avoid a | ||
1407 | 1321 | + // second sync. | ||
1408 | 1322 | + iSyncOnChangeScheduler.removeProfile(aProfileName); | ||
1409 | 1323 | + | ||
1410 | 1324 | if (iActiveSessions.contains(aProfileName)) | ||
1411 | 1325 | { | ||
1412 | 1326 | LOG_DEBUG( "Sync already in progress" ); | ||
1413 | 1327 | @@ -389,6 +375,14 @@ bool Synchronizer::startSync(const QString &aProfileName, bool aScheduled) | ||
1414 | 1328 | emit syncStatus(aProfileName, Sync::SYNC_QUEUED, "", 0); | ||
1415 | 1329 | return true; | ||
1416 | 1330 | } | ||
1417 | 1331 | + else if (!aScheduled && iWaitingOnlineSyncs.contains(aProfileName)) | ||
1418 | 1332 | + { | ||
1419 | 1333 | + // Manual sync is allowed to happen in any kind of connection | ||
1420 | 1334 | + // if sync is not scheduled remove it from iWaitingOnlineSyncs to avoid | ||
1421 | 1335 | + // sync it twice later | ||
1422 | 1336 | + iWaitingOnlineSyncs.removeOne(aProfileName); | ||
1423 | 1337 | + LOG_DEBUG("Removing" << aProfileName << "from online waiting list."); | ||
1424 | 1338 | + } | ||
1425 | 1339 | |||
1426 | 1340 | SyncProfile *profile = iProfileManager.syncProfile(aProfileName); | ||
1427 | 1341 | if (!profile) | ||
1428 | 1342 | @@ -520,7 +514,7 @@ bool Synchronizer::startSyncNow(SyncSession *aSession) | ||
1429 | 1343 | return false; | ||
1430 | 1344 | } | ||
1431 | 1345 | |||
1432 | 1346 | - LOG_DEBUG("Disable sync on change"); | ||
1433 | 1347 | + LOG_DEBUG("Disable sync on change:" << iSOCEnabled << profile->isSOCProfile()); | ||
1434 | 1348 | //As sync is ongoing, disable sync on change for now, we can query later if | ||
1435 | 1349 | //there are changes. | ||
1436 | 1350 | if(iSOCEnabled) | ||
1437 | 1351 | @@ -754,7 +748,7 @@ bool Synchronizer::startNextSync() | ||
1438 | 1352 | } | ||
1439 | 1353 | |||
1440 | 1354 | QString profileName = session->profileName(); | ||
1441 | 1355 | - LOG_DEBUG( "Trying to start next sync in queue. Profile:" << profileName ); | ||
1442 | 1356 | + LOG_DEBUG( "Trying to start next sync in queue. Profile:" << profileName << session->isScheduled()); | ||
1443 | 1357 | |||
1444 | 1358 | #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) | ||
1445 | 1359 | QBatteryInfo iDeviceInfo; | ||
1446 | 1360 | @@ -1516,6 +1510,36 @@ void Synchronizer::onNewSession(const QString &aDestination) | ||
1447 | 1361 | } | ||
1448 | 1362 | } | ||
1449 | 1363 | |||
1450 | 1364 | +void Synchronizer::slotProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml) | ||
1451 | 1365 | +{ | ||
1452 | 1366 | + // start sync when a new profile is added | ||
1453 | 1367 | + switch (aChangeType) | ||
1454 | 1368 | + { | ||
1455 | 1369 | + case ProfileManager::PROFILE_ADDED: | ||
1456 | 1370 | + enableSOCSlot(aProfileName); | ||
1457 | 1371 | + startSync(aProfileName); | ||
1458 | 1372 | + break; | ||
1459 | 1373 | + | ||
1460 | 1374 | + case ProfileManager::PROFILE_REMOVED: | ||
1461 | 1375 | + iSyncOnChangeScheduler.removeProfile(aProfileName); | ||
1462 | 1376 | + iWaitingOnlineSyncs.removeAll(aProfileName); | ||
1463 | 1377 | + break; | ||
1464 | 1378 | + | ||
1465 | 1379 | + case ProfileManager::PROFILE_MODIFIED: | ||
1466 | 1380 | + { | ||
1467 | 1381 | + // schedule a new sync in case of profile changed; | ||
1468 | 1382 | + // Example if the profile change from disable -> enable | ||
1469 | 1383 | + SyncProfile *profile = iProfileManager.syncProfile(aProfileName); | ||
1470 | 1384 | + if (profile->isEnabled()) { | ||
1471 | 1385 | + startScheduledSync(aProfileName); | ||
1472 | 1386 | + } | ||
1473 | 1387 | + } | ||
1474 | 1388 | + break; | ||
1475 | 1389 | + } | ||
1476 | 1390 | + | ||
1477 | 1391 | + emit signalProfileChanged(aProfileName, aChangeType, aProfileAsXml); | ||
1478 | 1392 | +} | ||
1479 | 1393 | + | ||
1480 | 1394 | void Synchronizer::reschedule(const QString &aProfileName) | ||
1481 | 1395 | { | ||
1482 | 1396 | FUNCTION_CALL_TRACE; | ||
1483 | 1397 | @@ -1903,10 +1927,24 @@ QStringList Synchronizer::syncProfilesByType(const QString &aType) | ||
1484 | 1398 | return iProfileManager.profileNames(aType); | ||
1485 | 1399 | } | ||
1486 | 1400 | |||
1487 | 1401 | -void Synchronizer::onNetworkStateChanged(bool aState) | ||
1488 | 1402 | +void Synchronizer::onNetworkStateChanged(bool aState, Sync::InternetConnectionType type) | ||
1489 | 1403 | { | ||
1490 | 1404 | FUNCTION_CALL_TRACE; | ||
1491 | 1405 | - if(!aState) { | ||
1492 | 1406 | + LOG_DEBUG("Network state changed: OnLine:" << aState << " connection type:" << type); | ||
1493 | 1407 | + if (acceptScheduledSync(aState, type)) | ||
1494 | 1408 | + { | ||
1495 | 1409 | + LOG_DEBUG("Restart sync for profiles that need network"); | ||
1496 | 1410 | + QStringList profiles(iWaitingOnlineSyncs); | ||
1497 | 1411 | + iWaitingOnlineSyncs.clear(); | ||
1498 | 1412 | + foreach(QString profileName, profiles) | ||
1499 | 1413 | + { | ||
1500 | 1414 | + // start sync now, we do not need to call 'startScheduledSync' since that function | ||
1501 | 1415 | + // only checks for internet connection | ||
1502 | 1416 | + startSync(profileName, true); | ||
1503 | 1417 | + } | ||
1504 | 1418 | + } | ||
1505 | 1419 | + else if (!aState) | ||
1506 | 1420 | + { | ||
1507 | 1421 | QList<QString> profiles = iActiveSessions.keys(); | ||
1508 | 1422 | foreach(QString profileId, profiles) | ||
1509 | 1423 | { | ||
1510 | 1424 | @@ -1919,8 +1957,8 @@ void Synchronizer::onNetworkStateChanged(bool aState) | ||
1511 | 1425 | delete profile; | ||
1512 | 1426 | profile = NULL; | ||
1513 | 1427 | } | ||
1514 | 1428 | - else { | ||
1515 | 1429 | - | ||
1516 | 1430 | + else | ||
1517 | 1431 | + { | ||
1518 | 1432 | LOG_DEBUG("No profile found with aProfileId"<<profileId); | ||
1519 | 1433 | } | ||
1520 | 1434 | } | ||
1521 | 1435 | @@ -2069,6 +2107,19 @@ void Synchronizer::removeExternalSyncStatus(const SyncProfile *aProfile) | ||
1522 | 1436 | } | ||
1523 | 1437 | } | ||
1524 | 1438 | |||
1525 | 1439 | +bool Synchronizer::acceptScheduledSync(bool aConnected, Sync::InternetConnectionType aType) const | ||
1526 | 1440 | +{ | ||
1527 | 1441 | + static QList<Sync::InternetConnectionType> allowedTypes; | ||
1528 | 1442 | + if (allowedTypes.isEmpty()) | ||
1529 | 1443 | + { | ||
1530 | 1444 | + allowedTypes << Sync::INTERNET_CONNECTION_WLAN | ||
1531 | 1445 | + << Sync::INTERNET_CONNECTION_ETHERNET; | ||
1532 | 1446 | + } | ||
1533 | 1447 | + | ||
1534 | 1448 | + return (aConnected && (g_settings_get_boolean(iSettings, "allow-scheduled-sync-over-cellular") || | ||
1535 | 1449 | + allowedTypes.contains(aType))); | ||
1536 | 1450 | +} | ||
1537 | 1451 | + | ||
1538 | 1452 | void Synchronizer::isSyncedExternally(unsigned int aAccountId, const QString aClientProfileName) | ||
1539 | 1453 | { | ||
1540 | 1454 | LOG_DEBUG("Received isSyncedExternally request for account:" << aAccountId); | ||
1541 | 1455 | diff --git a/msyncd/synchronizer.h b/msyncd/synchronizer.h | ||
1542 | 1456 | index 5564802..8c07eda 100644 | ||
1543 | 1457 | --- a/msyncd/synchronizer.h | ||
1544 | 1458 | +++ b/msyncd/synchronizer.h | ||
1545 | 1459 | @@ -44,7 +44,9 @@ | ||
1546 | 1460 | #include <QMap> | ||
1547 | 1461 | #include <QString> | ||
1548 | 1462 | #include <QDBusInterface> | ||
1549 | 1463 | +#include <QScopedPointer> | ||
1550 | 1464 | |||
1551 | 1465 | +struct _GSettings; | ||
1552 | 1466 | |||
1553 | 1467 | namespace Buteo { | ||
1554 | 1468 | |||
1555 | 1469 | @@ -137,6 +139,9 @@ public slots: | ||
1556 | 1470 | //! \see SyncDBusInterface::saveSyncResults | ||
1557 | 1471 | virtual bool saveSyncResults(QString aProfileId,QString aSyncResults); | ||
1558 | 1472 | |||
1559 | 1473 | + //! \see SyncDBusInterface::createSyncProfileForAccount | ||
1560 | 1474 | + virtual QString createSyncProfileForAccount(uint aAccountId); | ||
1561 | 1475 | + | ||
1562 | 1476 | /*! \brief To get lastSyncResult. | ||
1563 | 1477 | * \param aProfileId | ||
1564 | 1478 | * \return QString of syncResult. | ||
1565 | 1479 | @@ -257,9 +262,7 @@ private slots: | ||
1566 | 1480 | |||
1567 | 1481 | void onNewSession(const QString &aDestination); | ||
1568 | 1482 | |||
1569 | 1483 | - void slotNetworkSessionOpened(); | ||
1570 | 1484 | - | ||
1571 | 1485 | - void slotNetworkSessionError(); | ||
1572 | 1486 | + void slotProfileChanged(QString aProfileName, int aChangeType , QString aProfileAsXml); | ||
1573 | 1487 | |||
1574 | 1488 | /*! \brief Starts a server plug-in | ||
1575 | 1489 | * | ||
1576 | 1490 | @@ -273,7 +276,7 @@ private slots: | ||
1577 | 1491 | */ | ||
1578 | 1492 | void stopServer(const QString &aProfileName); | ||
1579 | 1493 | |||
1580 | 1494 | - void onNetworkStateChanged(bool aState); | ||
1581 | 1495 | + void onNetworkStateChanged(bool aState, Sync::InternetConnectionType type); | ||
1582 | 1496 | |||
1583 | 1497 | /*! \brief call this to request the sync daemon to enable soc | ||
1584 | 1498 | * for a profile. The sync daemon decides as of now for which storages | ||
1585 | 1499 | @@ -385,6 +388,12 @@ private: | ||
1586 | 1500 | */ | ||
1587 | 1501 | void removeExternalSyncStatus(const SyncProfile *aProfile); | ||
1588 | 1502 | |||
1589 | 1503 | + /*! \brief Check if sheduled sync is allowed for this type of connection. | ||
1590 | 1504 | + * | ||
1591 | 1505 | + * @param aType the connection type; | ||
1592 | 1506 | + */ | ||
1593 | 1507 | + bool acceptScheduledSync(bool aConnected, Sync::InternetConnectionType aType) const; | ||
1594 | 1508 | + | ||
1595 | 1509 | QMap<QString, SyncSession*> iActiveSessions; | ||
1596 | 1510 | |||
1597 | 1511 | QMap<QString, bool> iExternalSyncProfileStatus; | ||
1598 | 1512 | @@ -446,6 +455,7 @@ private: | ||
1599 | 1513 | #endif | ||
1600 | 1514 | |||
1601 | 1515 | QDBusInterface *iSyncUIInterface; | ||
1602 | 1516 | + _GSettings *iSettings; | ||
1603 | 1517 | }; | ||
1604 | 1518 | |||
1605 | 1519 | } | ||
1606 | 1520 | diff --git a/unittests/tests/msyncdtests/TransportTrackerTest.cpp b/unittests/tests/msyncdtests/TransportTrackerTest.cpp | ||
1607 | 1521 | index 8cc5309..c69a315 100644 | ||
1608 | 1522 | --- a/unittests/tests/msyncdtests/TransportTrackerTest.cpp | ||
1609 | 1523 | +++ b/unittests/tests/msyncdtests/TransportTrackerTest.cpp | ||
1610 | 1524 | @@ -89,7 +89,7 @@ void TransportTrackerTest :: testStateChanged() | ||
1611 | 1525 | { | ||
1612 | 1526 | qRegisterMetaType<Sync::ConnectivityType>("Sync::ConnectivityType"); | ||
1613 | 1527 | QSignalSpy connectivityStateSpy(iTransportTracker, SIGNAL(connectivityStateChanged(Sync::ConnectivityType, bool))); | ||
1614 | 1528 | - QSignalSpy networkStateSpy(iTransportTracker, SIGNAL(networkStateChanged(bool))); | ||
1615 | 1529 | + QSignalSpy networkStateSpy(iTransportTracker, SIGNAL(networkStateChanged(bool,Sync::InternetConnectionType))); | ||
1616 | 1530 | |||
1617 | 1531 | // change USB state and verify | ||
1618 | 1532 | bool usbCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_USB); | ||
1619 | 1533 | @@ -115,7 +115,7 @@ void TransportTrackerTest :: testStateChanged() | ||
1620 | 1534 | |||
1621 | 1535 | // change internet state and verify | ||
1622 | 1536 | bool internetCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_INTERNET); | ||
1623 | 1537 | - iTransportTracker->onInternetStateChanged(!internetCurrentState); | ||
1624 | 1538 | + iTransportTracker->onInternetStateChanged(!internetCurrentState, Sync::INTERNET_CONNECTION_UNKNOWN); | ||
1625 | 1539 | QCOMPARE(iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_INTERNET), !internetCurrentState); | ||
1626 | 1540 | QEXPECT_FAIL("", "IMO connectivityStateChanged() should be emitted also for CONNECTIVITY_INTERNET", Continue); | ||
1627 | 1541 | QCOMPARE(connectivityStateSpy.count(), 1); | ||
1628 | 1542 | -- | ||
1629 | 1543 | 2.1.4 | ||
1630 | 1544 | |||
1631 | 1545 | 0 | ||
1632 | === added file 'debian/patches/0002-Fixed-FUNCTION_CALL_TRACE-macro.patch' | |||
1633 | --- debian/patches/0002-Fixed-FUNCTION_CALL_TRACE-macro.patch 1970-01-01 00:00:00 +0000 | |||
1634 | +++ debian/patches/0002-Fixed-FUNCTION_CALL_TRACE-macro.patch 2015-09-30 18:13:56 +0000 | |||
1635 | @@ -0,0 +1,36 @@ | |||
1636 | 1 | From 512bdd8f480c0790797521884145e3e6d8661254 Mon Sep 17 00:00:00 2001 | ||
1637 | 2 | From: Renato Araujo Oliveira Filho <renato.filho@canonical.com> | ||
1638 | 3 | Date: Mon, 14 Sep 2015 17:38:48 -0300 | ||
1639 | 4 | Subject: [PATCH 2/3] Fixed 'FUNCTION_CALL_TRACE' macro. | ||
1640 | 5 | |||
1641 | 6 | Make sure that the macro print the correct elapsed time during the debug. | ||
1642 | 7 | --- | ||
1643 | 8 | libbuteosyncfw/common/LogMacros.h | 5 ++++- | ||
1644 | 9 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
1645 | 10 | |||
1646 | 11 | diff --git a/libbuteosyncfw/common/LogMacros.h b/libbuteosyncfw/common/LogMacros.h | ||
1647 | 12 | index bac9ef6..90f2c6f 100644 | ||
1648 | 13 | --- a/libbuteosyncfw/common/LogMacros.h | ||
1649 | 14 | +++ b/libbuteosyncfw/common/LogMacros.h | ||
1650 | 15 | @@ -29,6 +29,7 @@ | ||
1651 | 16 | #include <QTime> | ||
1652 | 17 | #include <QDebug> | ||
1653 | 18 | #include <QDateTime> | ||
1654 | 19 | +#include <QScopedPointer> | ||
1655 | 20 | #include "Logger.h" | ||
1656 | 21 | |||
1657 | 22 | //! Helper macro for writing log messages. Avoid using directly. | ||
1658 | 23 | @@ -52,7 +53,9 @@ | ||
1659 | 24 | * Creates a trace message to log when the function is entered and exited. | ||
1660 | 25 | * Logs also to time spent in the function. | ||
1661 | 26 | */ | ||
1662 | 27 | -# define FUNCTION_CALL_TRACE if (Buteo::Logger::instance()->getLogLevel() >= 9) Buteo::LogTimer timerDebugVariable(QString(__PRETTY_FUNCTION__)); | ||
1663 | 28 | +# define FUNCTION_CALL_TRACE QScopedPointer<Buteo::LogTimer> timerDebugVariable; \ | ||
1664 | 29 | + if (Buteo::Logger::instance()->getLogLevel() >= 9) \ | ||
1665 | 30 | + timerDebugVariable.reset(new Buteo::LogTimer(QString(__PRETTY_FUNCTION__))); | ||
1666 | 31 | |||
1667 | 32 | namespace Buteo { | ||
1668 | 33 | |||
1669 | 34 | -- | ||
1670 | 35 | 2.1.4 | ||
1671 | 36 | |||
1672 | 0 | 37 | ||
1673 | === added file 'debian/patches/0003-Added-upstart-service-file.patch' | |||
1674 | --- debian/patches/0003-Added-upstart-service-file.patch 1970-01-01 00:00:00 +0000 | |||
1675 | +++ debian/patches/0003-Added-upstart-service-file.patch 2015-09-30 18:13:56 +0000 | |||
1676 | @@ -0,0 +1,59 @@ | |||
1677 | 1 | From e10289937804ad6d779843753727b661d2e14e43 Mon Sep 17 00:00:00 2001 | ||
1678 | 2 | From: Renato Araujo Oliveira Filho <renato.filho@canonical.com> | ||
1679 | 3 | Date: Fri, 3 Jul 2015 14:49:13 -0300 | ||
1680 | 4 | Subject: [PATCH 1/2] Added upstart service file. | ||
1681 | 5 | |||
1682 | 6 | Create upstart file to start msyncd service. | ||
1683 | 7 | --- | ||
1684 | 8 | msyncd/bin/msyncd.conf | 14 ++++++++++++++ | ||
1685 | 9 | msyncd/msyncd-app.pro | 5 ++++- | ||
1686 | 10 | 2 files changed, 18 insertions(+), 1 deletion(-) | ||
1687 | 11 | create mode 100644 msyncd/bin/msyncd.conf | ||
1688 | 12 | |||
1689 | 13 | diff --git a/msyncd/bin/msyncd.conf b/msyncd/bin/msyncd.conf | ||
1690 | 14 | new file mode 100644 | ||
1691 | 15 | index 0000000..7224f87 | ||
1692 | 16 | --- /dev/null | ||
1693 | 17 | +++ b/msyncd/bin/msyncd.conf | ||
1694 | 18 | @@ -0,0 +1,14 @@ | ||
1695 | 19 | +description "address-book-service" | ||
1696 | 20 | +author "Bill Filler <bill.filler@canonical.com>" | ||
1697 | 21 | + | ||
1698 | 22 | +start on started unity8-dash | ||
1699 | 23 | +stop on runlevel [06] | ||
1700 | 24 | + | ||
1701 | 25 | +# give some time to nm be ready | ||
1702 | 26 | +pre-start script | ||
1703 | 27 | + sleep 10; | ||
1704 | 28 | +end script | ||
1705 | 29 | + | ||
1706 | 30 | +respawn | ||
1707 | 31 | + | ||
1708 | 32 | +exec /usr/bin/msyncd | ||
1709 | 33 | diff --git a/msyncd/msyncd-app.pro b/msyncd/msyncd-app.pro | ||
1710 | 34 | index be59a8c..ca0a53d 100644 | ||
1711 | 35 | --- a/msyncd/msyncd-app.pro | ||
1712 | 36 | +++ b/msyncd/msyncd-app.pro | ||
1713 | 37 | @@ -59,7 +59,9 @@ target.path = /usr/bin/ | ||
1714 | 38 | loglevel.files = bin/set_sync_log_level | ||
1715 | 39 | loglevel.path = /etc/buteo/ | ||
1716 | 40 | service.files = bin/msyncd.service | ||
1717 | 41 | +upstart.files = bin/msyncd.conf | ||
1718 | 42 | service.path = /usr/lib/systemd/user/ | ||
1719 | 43 | +upstart.path = /usr/share/upstart/sessions/ | ||
1720 | 44 | syncwidget.path = /etc/syncwidget/ | ||
1721 | 45 | syncwidget.files = com.meego.msyncd | ||
1722 | 46 | gschemas.path = /usr/share/glib-2.0/schemas | ||
1723 | 47 | @@ -68,7 +70,8 @@ INSTALLS += target \ | ||
1724 | 48 | loglevel \ | ||
1725 | 49 | syncwidget \ | ||
1726 | 50 | service \ | ||
1727 | 51 | - gschemas | ||
1728 | 52 | + gschemas \ | ||
1729 | 53 | + upstart | ||
1730 | 54 | |||
1731 | 55 | # ##################################################################### | ||
1732 | 56 | # make coverage (debug) | ||
1733 | 57 | -- | ||
1734 | 58 | 2.1.4 | ||
1735 | 59 | |||
1736 | 0 | 60 | ||
1737 | === modified file 'debian/patches/series' | |||
1738 | --- debian/patches/series 2015-09-11 14:15:49 +0000 | |||
1739 | +++ debian/patches/series 2015-09-30 18:13:56 +0000 | |||
1740 | @@ -1,2 +1,5 @@ | |||
1741 | 1 | 0001-Ubuntu-phone-changes.patch | ||
1742 | 2 | libdir.patch | 1 | libdir.patch |
1743 | 2 | 0001-Disable-sheduled-syncs-over-cellular-connections.patch | ||
1744 | 3 | 0002-Fixed-FUNCTION_CALL_TRACE-macro.patch | ||
1745 | 4 | 0003-Added-upstart-service-file.patch | ||
1746 | 5 | 0001-Check-for-WLAN-or-ETHERNET-connections.patch | ||
1747 | 3 | 6 | ||
1748 | === modified file 'libbuteosyncfw/common/Logger.cpp' | |||
1749 | --- libbuteosyncfw/common/Logger.cpp 2014-07-22 04:21:03 +0000 | |||
1750 | +++ libbuteosyncfw/common/Logger.cpp 2015-09-30 18:13:56 +0000 | |||
1751 | @@ -206,7 +206,7 @@ | |||
1752 | 206 | { | 206 | { |
1753 | 207 | if(aLevel >= QtCriticalMsg) | 207 | if(aLevel >= QtCriticalMsg) |
1754 | 208 | { | 208 | { |
1756 | 209 | syslog(LOG_CRIT, sysLogMsg.toLocal8Bit().data()); | 209 | syslog(LOG_CRIT, "%s", sysLogMsg.toLocal8Bit().data()); |
1757 | 210 | } | 210 | } |
1758 | 211 | return; | 211 | return; |
1759 | 212 | } | 212 | } |
1760 | @@ -217,7 +217,7 @@ | |||
1761 | 217 | return; | 217 | return; |
1762 | 218 | } | 218 | } |
1763 | 219 | 219 | ||
1765 | 220 | syslog(syslogLevel[aLevel], sysLogMsg.toLocal8Bit().data()); | 220 | syslog(syslogLevel[aLevel], "%s", sysLogMsg.toLocal8Bit().data()); |
1766 | 221 | 221 | ||
1767 | 222 | if (iFileStream != 0) | 222 | if (iFileStream != 0) |
1768 | 223 | { | 223 | { |
1769 | 224 | 224 | ||
1770 | === modified file 'libbuteosyncfw/common/NetworkManager.cpp' | |||
1771 | --- libbuteosyncfw/common/NetworkManager.cpp 2014-09-19 13:49:12 +0000 | |||
1772 | +++ libbuteosyncfw/common/NetworkManager.cpp 2015-09-30 18:13:56 +0000 | |||
1773 | @@ -36,13 +36,40 @@ | |||
1774 | 36 | NetworkManager::NetworkManager(QObject *parent /* = 0*/) : | 36 | NetworkManager::NetworkManager(QObject *parent /* = 0*/) : |
1775 | 37 | QObject(parent), m_networkConfigManager(0), m_networkSession(0), | 37 | QObject(parent), m_networkConfigManager(0), m_networkSession(0), |
1776 | 38 | m_isOnline(false), m_errorEmitted(false), | 38 | m_isOnline(false), m_errorEmitted(false), |
1778 | 39 | m_sessionTimer(0) | 39 | m_sessionTimer(0), m_connectionType(Sync::INTERNET_CONNECTION_UNKNOWN) |
1779 | 40 | { | 40 | { |
1780 | 41 | FUNCTION_CALL_TRACE; | 41 | FUNCTION_CALL_TRACE; |
1781 | 42 | m_networkConfigManager = new QNetworkConfigurationManager(); | 42 | m_networkConfigManager = new QNetworkConfigurationManager(); |
1782 | 43 | Q_ASSERT(m_networkConfigManager); | 43 | Q_ASSERT(m_networkConfigManager); |
1785 | 44 | connect(m_networkConfigManager, SIGNAL(onlineStateChanged(bool)), | 44 | |
1786 | 45 | SLOT(slotOnlineStateChanged(bool))); | 45 | // check for network status and configuration change (switch wifi, ethernet, mobile) a |
1787 | 46 | connect(m_networkConfigManager, | ||
1788 | 47 | SIGNAL(onlineStateChanged(bool)), | ||
1789 | 48 | SLOT(slotConfigurationChanged()), | ||
1790 | 49 | Qt::QueuedConnection); | ||
1791 | 50 | connect(m_networkConfigManager, | ||
1792 | 51 | SIGNAL(configurationAdded(QNetworkConfiguration)), | ||
1793 | 52 | SLOT(slotConfigurationChanged()), | ||
1794 | 53 | Qt::QueuedConnection); | ||
1795 | 54 | connect(m_networkConfigManager, | ||
1796 | 55 | SIGNAL(configurationChanged(QNetworkConfiguration)), | ||
1797 | 56 | SLOT(slotConfigurationChanged()), | ||
1798 | 57 | Qt::QueuedConnection); | ||
1799 | 58 | connect(m_networkConfigManager, | ||
1800 | 59 | SIGNAL(configurationRemoved(QNetworkConfiguration)), | ||
1801 | 60 | SLOT(slotConfigurationChanged()), | ||
1802 | 61 | Qt::QueuedConnection); | ||
1803 | 62 | connect(m_networkConfigManager, | ||
1804 | 63 | SIGNAL(updateCompleted()), | ||
1805 | 64 | SLOT(slotConfigurationChanged()), | ||
1806 | 65 | Qt::QueuedConnection); | ||
1807 | 66 | |||
1808 | 67 | connect(&m_idleRefreshTimer, | ||
1809 | 68 | SIGNAL(timeout()), | ||
1810 | 69 | SLOT(idleRefresh()), | ||
1811 | 70 | Qt::QueuedConnection); | ||
1812 | 71 | m_idleRefreshTimer.setSingleShot(true); | ||
1813 | 72 | |||
1814 | 46 | m_isOnline = m_networkConfigManager->isOnline(); | 73 | m_isOnline = m_networkConfigManager->isOnline(); |
1815 | 47 | LOG_DEBUG("Online status::" << m_isOnline); | 74 | LOG_DEBUG("Online status::" << m_isOnline); |
1816 | 48 | m_sessionTimer = new QTimer(this); | 75 | m_sessionTimer = new QTimer(this); |
1817 | @@ -72,6 +99,11 @@ | |||
1818 | 72 | return m_isOnline; | 99 | return m_isOnline; |
1819 | 73 | } | 100 | } |
1820 | 74 | 101 | ||
1821 | 102 | Sync::InternetConnectionType NetworkManager::connectionType() const | ||
1822 | 103 | { | ||
1823 | 104 | return m_connectionType; | ||
1824 | 105 | } | ||
1825 | 106 | |||
1826 | 75 | void NetworkManager::connectSession(bool connectInBackground /* = false*/) | 107 | void NetworkManager::connectSession(bool connectInBackground /* = false*/) |
1827 | 76 | { | 108 | { |
1828 | 77 | FUNCTION_CALL_TRACE; | 109 | FUNCTION_CALL_TRACE; |
1829 | @@ -110,12 +142,55 @@ | |||
1830 | 110 | { | 142 | { |
1831 | 111 | if (!m_errorEmitted && m_networkSession) { | 143 | if (!m_errorEmitted && m_networkSession) { |
1832 | 112 | if (!m_networkSession->isOpen()) { | 144 | if (!m_networkSession->isOpen()) { |
1834 | 113 | qWarning() << "No network reply received after 10 seconds, emitting session error."; | 145 | LOG_WARNING("No network reply received after 10 seconds, emitting session error."); |
1835 | 114 | slotSessionError(m_networkSession->error()); | 146 | slotSessionError(m_networkSession->error()); |
1836 | 115 | } | 147 | } |
1837 | 116 | } | 148 | } |
1838 | 117 | } | 149 | } |
1839 | 118 | 150 | ||
1840 | 151 | void NetworkManager::slotConfigurationChanged() | ||
1841 | 152 | { | ||
1842 | 153 | // wait for 3 secs before update connection status | ||
1843 | 154 | // this avoid problems with connections that take a while to be stabilished | ||
1844 | 155 | m_idleRefreshTimer.start(3000); | ||
1845 | 156 | } | ||
1846 | 157 | |||
1847 | 158 | void NetworkManager::idleRefresh() | ||
1848 | 159 | { | ||
1849 | 160 | FUNCTION_CALL_TRACE; | ||
1850 | 161 | QList<QNetworkConfiguration> activeConfigs = m_networkConfigManager->allConfigurations(QNetworkConfiguration::Active); | ||
1851 | 162 | QNetworkConfiguration::BearerType connectionType = QNetworkConfiguration::BearerUnknown; | ||
1852 | 163 | QString bearerTypeName; | ||
1853 | 164 | |||
1854 | 165 | bool isOnline = activeConfigs.size() > 0; | ||
1855 | 166 | if (isOnline) | ||
1856 | 167 | { | ||
1857 | 168 | // FIXME: due this bug lp:#1444162 on nm the QNetworkConfigurationManager | ||
1858 | 169 | // returns the wrong default connection. | ||
1859 | 170 | // We will consider the connection with the smallest bearer as the | ||
1860 | 171 | // default connection, with that wifi and ethernet will be the first one | ||
1861 | 172 | // https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1444162 | ||
1862 | 173 | connectionType = activeConfigs.first().bearerType(); | ||
1863 | 174 | bearerTypeName = activeConfigs.first().bearerTypeName(); | ||
1864 | 175 | foreach(const QNetworkConfiguration &conf, activeConfigs) | ||
1865 | 176 | { | ||
1866 | 177 | if (conf.bearerType() < connectionType) | ||
1867 | 178 | { | ||
1868 | 179 | connectionType = conf.bearerType(); | ||
1869 | 180 | bearerTypeName = conf.bearerTypeName(); | ||
1870 | 181 | } | ||
1871 | 182 | } | ||
1872 | 183 | } | ||
1873 | 184 | LOG_DEBUG("New state:" << isOnline << " New type: " << bearerTypeName << "(" << connectionType << ")"); | ||
1874 | 185 | if ((isOnline != m_isOnline) || | ||
1875 | 186 | ((Sync::InternetConnectionType)connectionType != m_connectionType)) | ||
1876 | 187 | { | ||
1877 | 188 | m_isOnline = isOnline; | ||
1878 | 189 | m_connectionType = (Sync::InternetConnectionType) connectionType; | ||
1879 | 190 | emit statusChanged(m_isOnline, m_connectionType); | ||
1880 | 191 | } | ||
1881 | 192 | } | ||
1882 | 193 | |||
1883 | 119 | void NetworkManager::disconnectSession() | 194 | void NetworkManager::disconnectSession() |
1884 | 120 | { | 195 | { |
1885 | 121 | FUNCTION_CALL_TRACE; | 196 | FUNCTION_CALL_TRACE; |
1886 | @@ -134,19 +209,6 @@ | |||
1887 | 134 | } | 209 | } |
1888 | 135 | } | 210 | } |
1889 | 136 | 211 | ||
1890 | 137 | void NetworkManager::slotOnlineStateChanged(bool isOnline) | ||
1891 | 138 | { | ||
1892 | 139 | FUNCTION_CALL_TRACE; | ||
1893 | 140 | LOG_DEBUG("Online status changed, is online is now::" << isOnline); | ||
1894 | 141 | if(m_isOnline != isOnline) | ||
1895 | 142 | { | ||
1896 | 143 | if (m_sessionTimer->isActive()) | ||
1897 | 144 | m_sessionTimer->stop(); | ||
1898 | 145 | m_isOnline = isOnline; | ||
1899 | 146 | emit valueChanged(m_isOnline); | ||
1900 | 147 | } | ||
1901 | 148 | } | ||
1902 | 149 | |||
1903 | 150 | void NetworkManager::slotSessionState(QNetworkSession::State status) | 212 | void NetworkManager::slotSessionState(QNetworkSession::State status) |
1904 | 151 | { | 213 | { |
1905 | 152 | FUNCTION_CALL_TRACE; | 214 | FUNCTION_CALL_TRACE; |
1906 | 153 | 215 | ||
1907 | === modified file 'libbuteosyncfw/common/NetworkManager.h' | |||
1908 | --- libbuteosyncfw/common/NetworkManager.h 2014-05-28 03:22:34 +0000 | |||
1909 | +++ libbuteosyncfw/common/NetworkManager.h 2015-09-30 18:13:56 +0000 | |||
1910 | @@ -24,8 +24,9 @@ | |||
1911 | 24 | #define NETWORKMANAGER_H_ | 24 | #define NETWORKMANAGER_H_ |
1912 | 25 | 25 | ||
1913 | 26 | #include <QNetworkSession> | 26 | #include <QNetworkSession> |
1914 | 27 | #include <QTimer> | ||
1915 | 28 | #include "SyncCommonDefs.h" | ||
1916 | 27 | 29 | ||
1917 | 28 | class QTimer; | ||
1918 | 29 | class QNetworkConfigurationManager; | 30 | class QNetworkConfigurationManager; |
1919 | 30 | 31 | ||
1920 | 31 | namespace Buteo | 32 | namespace Buteo |
1921 | @@ -61,6 +62,13 @@ | |||
1922 | 61 | */ | 62 | */ |
1923 | 62 | bool isOnline(); | 63 | bool isOnline(); |
1924 | 63 | 64 | ||
1925 | 65 | /*! \brief Returns the type of connection used by the device. | ||
1926 | 66 | * | ||
1927 | 67 | |||
1928 | 68 | * @return Sync::InternetConnectionType the type of connection. | ||
1929 | 69 | */ | ||
1930 | 70 | Sync::InternetConnectionType connectionType() const; | ||
1931 | 71 | |||
1932 | 64 | /*! \brief Connects a new network session. If a session was already | 72 | /*! \brief Connects a new network session. If a session was already |
1933 | 65 | * open, the signal connectionSuccess will be emitted immediately, | 73 | * open, the signal connectionSuccess will be emitted immediately, |
1934 | 66 | * else the function will return and the signal connectionSuccess or | 74 | * else the function will return and the signal connectionSuccess or |
1935 | @@ -84,7 +92,7 @@ | |||
1936 | 84 | * | 92 | * |
1937 | 85 | * @param aConnected If true, the device is online | 93 | * @param aConnected If true, the device is online |
1938 | 86 | */ | 94 | */ |
1940 | 87 | void valueChanged(bool aConnected); | 95 | void statusChanged(bool aConnected, Sync::InternetConnectionType aType); |
1941 | 88 | 96 | ||
1942 | 89 | /*! \brief This signal is emitted when a network session gets | 97 | /*! \brief This signal is emitted when a network session gets |
1943 | 90 | * connected | 98 | * connected |
1944 | @@ -105,11 +113,15 @@ | |||
1945 | 105 | static int m_refCount; // Reference counter for number of open connections | 113 | static int m_refCount; // Reference counter for number of open connections |
1946 | 106 | bool m_errorEmitted; // Network error emited flag | 114 | bool m_errorEmitted; // Network error emited flag |
1947 | 107 | QTimer *m_sessionTimer; | 115 | QTimer *m_sessionTimer; |
1948 | 116 | Sync::InternetConnectionType m_connectionType; | ||
1949 | 117 | QTimer m_idleRefreshTimer; | ||
1950 | 118 | |||
1951 | 108 | private slots: | 119 | private slots: |
1952 | 109 | void slotOnlineStateChanged(bool isOnline); | ||
1953 | 110 | void slotSessionState(QNetworkSession::State status); | 120 | void slotSessionState(QNetworkSession::State status); |
1954 | 111 | void slotSessionError(QNetworkSession::SessionError error); | 121 | void slotSessionError(QNetworkSession::SessionError error); |
1955 | 112 | void sessionConnectionTimeout(); | 122 | void sessionConnectionTimeout(); |
1956 | 123 | void slotConfigurationChanged(); | ||
1957 | 124 | void idleRefresh(); | ||
1958 | 113 | }; | 125 | }; |
1959 | 114 | } | 126 | } |
1960 | 115 | 127 | ||
1961 | 116 | 128 | ||
1962 | === modified file 'libbuteosyncfw/common/SyncCommonDefs.h' | |||
1963 | --- libbuteosyncfw/common/SyncCommonDefs.h 2014-06-06 06:40:13 +0000 | |||
1964 | +++ libbuteosyncfw/common/SyncCommonDefs.h 2015-09-30 18:13:56 +0000 | |||
1965 | @@ -26,6 +26,7 @@ | |||
1966 | 26 | 26 | ||
1967 | 27 | #include <QMetaType> | 27 | #include <QMetaType> |
1968 | 28 | #include <QDir> | 28 | #include <QDir> |
1969 | 29 | #include <QtNetwork/QNetworkConfiguration> | ||
1970 | 29 | 30 | ||
1971 | 30 | namespace Sync { | 31 | namespace Sync { |
1972 | 31 | 32 | ||
1973 | @@ -83,6 +84,22 @@ | |||
1974 | 83 | CONNECTIVITY_INTERNET | 84 | CONNECTIVITY_INTERNET |
1975 | 84 | }; | 85 | }; |
1976 | 85 | 86 | ||
1977 | 87 | enum InternetConnectionType { | ||
1978 | 88 | INTERNET_CONNECTION_UNKNOWN = QNetworkConfiguration::BearerUnknown, | ||
1979 | 89 | INTERNET_CONNECTION_ETHERNET = QNetworkConfiguration::BearerEthernet, | ||
1980 | 90 | INTERNET_CONNECTION_WLAN = QNetworkConfiguration::BearerWLAN, | ||
1981 | 91 | INTERNET_CONNECTION_2G = QNetworkConfiguration::Bearer2G, | ||
1982 | 92 | INTERNET_CONNECTION_3G = QNetworkConfiguration::Bearer3G, | ||
1983 | 93 | INTERNET_CONNECTION_4G = QNetworkConfiguration::Bearer4G, | ||
1984 | 94 | INTERNET_CONNECTION_CDMA2000 = QNetworkConfiguration::BearerCDMA2000, | ||
1985 | 95 | INTERNET_CONNECTION_WCDMA = QNetworkConfiguration::BearerWCDMA, | ||
1986 | 96 | INTERNET_CONNECTION_HSPA = QNetworkConfiguration::BearerHSPA, | ||
1987 | 97 | INTERNET_CONNECTION_BLUETOOTH = QNetworkConfiguration::BearerBluetooth, | ||
1988 | 98 | INTERNET_CONNECTION_WIMAX = QNetworkConfiguration::BearerWiMAX, | ||
1989 | 99 | INTERNET_CONNECTION_EVDO = QNetworkConfiguration::BearerEVDO, | ||
1990 | 100 | INTERNET_CONNECTION_LTE = QNetworkConfiguration::BearerLTE | ||
1991 | 101 | }; | ||
1992 | 102 | |||
1993 | 86 | } // namespace Sync | 103 | } // namespace Sync |
1994 | 87 | 104 | ||
1995 | 88 | Q_DECLARE_METATYPE( Sync::SyncStatus ); | 105 | Q_DECLARE_METATYPE( Sync::SyncStatus ); |
1996 | 89 | 106 | ||
1997 | === modified file 'libbuteosyncfw/common/TransportTracker.cpp' | |||
1998 | --- libbuteosyncfw/common/TransportTracker.cpp 2014-09-12 11:53:27 +0000 | |||
1999 | +++ libbuteosyncfw/common/TransportTracker.cpp 2015-09-30 18:13:56 +0000 | |||
2000 | @@ -66,7 +66,7 @@ | |||
2001 | 66 | 66 | ||
2002 | 67 | // BT | 67 | // BT |
2003 | 68 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) | 68 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
2005 | 69 | 69 | ||
2006 | 70 | // Set the bluetooth state | 70 | // Set the bluetooth state |
2007 | 71 | iTransportStates[Sync::CONNECTIVITY_BT] = btConnectivityStatus(); | 71 | iTransportStates[Sync::CONNECTIVITY_BT] = btConnectivityStatus(); |
2008 | 72 | 72 | ||
2009 | @@ -97,8 +97,9 @@ | |||
2010 | 97 | { | 97 | { |
2011 | 98 | iTransportStates[Sync::CONNECTIVITY_INTERNET] = | 98 | iTransportStates[Sync::CONNECTIVITY_INTERNET] = |
2012 | 99 | iInternet->isOnline(); | 99 | iInternet->isOnline(); |
2015 | 100 | connect(iInternet, SIGNAL(valueChanged(bool)), | 100 | connect(iInternet, |
2016 | 101 | this, SLOT(onInternetStateChanged(bool)) /*, Qt::QueuedConnection*/); | 101 | SIGNAL(statusChanged(bool, Sync::InternetConnectionType)), |
2017 | 102 | SLOT(onInternetStateChanged(bool, Sync::InternetConnectionType)) /*, Qt::QueuedConnection*/); | ||
2018 | 102 | } | 103 | } |
2019 | 103 | else | 104 | else |
2020 | 104 | { | 105 | { |
2021 | @@ -143,7 +144,7 @@ | |||
2022 | 143 | void TransportTracker::onBtStateChanged(QString aKey, QDBusVariant aValue) | 144 | void TransportTracker::onBtStateChanged(QString aKey, QDBusVariant aValue) |
2023 | 144 | { | 145 | { |
2024 | 145 | FUNCTION_CALL_TRACE; | 146 | FUNCTION_CALL_TRACE; |
2026 | 146 | 147 | ||
2027 | 147 | if (aKey == "Powered") | 148 | if (aKey == "Powered") |
2028 | 148 | { | 149 | { |
2029 | 149 | bool btPowered = aValue.variant().toBool(); | 150 | bool btPowered = aValue.variant().toBool(); |
2030 | @@ -153,12 +154,13 @@ | |||
2031 | 153 | } | 154 | } |
2032 | 154 | #endif | 155 | #endif |
2033 | 155 | 156 | ||
2035 | 156 | void TransportTracker::onInternetStateChanged(bool aConnected) | 157 | void TransportTracker::onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType) |
2036 | 157 | { | 158 | { |
2037 | 158 | FUNCTION_CALL_TRACE; | 159 | FUNCTION_CALL_TRACE; |
2038 | 159 | 160 | ||
2039 | 160 | LOG_DEBUG("Internet state changed:" << aConnected); | 161 | LOG_DEBUG("Internet state changed:" << aConnected); |
2040 | 161 | updateState(Sync::CONNECTIVITY_INTERNET, aConnected); | 162 | updateState(Sync::CONNECTIVITY_INTERNET, aConnected); |
2041 | 163 | emit networkStateChanged(aConnected, aType); | ||
2042 | 162 | } | 164 | } |
2043 | 163 | 165 | ||
2044 | 164 | void TransportTracker::updateState(Sync::ConnectivityType aType, | 166 | void TransportTracker::updateState(Sync::ConnectivityType aType, |
2045 | @@ -175,19 +177,17 @@ | |||
2046 | 175 | } | 177 | } |
2047 | 176 | if(oldState != aState) | 178 | if(oldState != aState) |
2048 | 177 | { | 179 | { |
2050 | 178 | if (aType != Sync::CONNECTIVITY_INTERNET) { | 180 | if (aType != Sync::CONNECTIVITY_INTERNET) |
2051 | 181 | { | ||
2052 | 179 | emit connectivityStateChanged(aType, aState); | 182 | emit connectivityStateChanged(aType, aState); |
2053 | 180 | } | 183 | } |
2054 | 181 | else { | ||
2055 | 182 | emit networkStateChanged(aState); | ||
2056 | 183 | } | ||
2057 | 184 | } | 184 | } |
2058 | 185 | } | 185 | } |
2059 | 186 | 186 | ||
2060 | 187 | bool TransportTracker::btConnectivityStatus() | 187 | bool TransportTracker::btConnectivityStatus() |
2061 | 188 | { | 188 | { |
2062 | 189 | FUNCTION_CALL_TRACE; | 189 | FUNCTION_CALL_TRACE; |
2064 | 190 | 190 | ||
2065 | 191 | bool btOn = false; | 191 | bool btOn = false; |
2066 | 192 | QDBusConnection *systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, | 192 | QDBusConnection *systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, |
2067 | 193 | QStringLiteral("buteo_system_bus2"))); | 193 | QStringLiteral("buteo_system_bus2"))); |
2068 | @@ -207,7 +207,7 @@ | |||
2069 | 207 | QList<QVariant> adapterList = reply.arguments(); | 207 | QList<QVariant> adapterList = reply.arguments(); |
2070 | 208 | // We will take the first adapter in the list | 208 | // We will take the first adapter in the list |
2071 | 209 | QString adapterPath = qdbus_cast<QDBusObjectPath>(adapterList.at(0)).path(); | 209 | QString adapterPath = qdbus_cast<QDBusObjectPath>(adapterList.at(0)).path(); |
2073 | 210 | 210 | ||
2074 | 211 | if (!adapterPath.isEmpty() || !adapterPath.isNull()) | 211 | if (!adapterPath.isEmpty() || !adapterPath.isNull()) |
2075 | 212 | { | 212 | { |
2076 | 213 | // Retrive the properties of the adapter and check for "Powered" key | 213 | // Retrive the properties of the adapter and check for "Powered" key |
2077 | @@ -222,7 +222,7 @@ | |||
2078 | 222 | delete systemBus; | 222 | delete systemBus; |
2079 | 223 | return btOn; | 223 | return btOn; |
2080 | 224 | } | 224 | } |
2082 | 225 | 225 | ||
2083 | 226 | QDBusArgument arg = reply.arguments().at(0).value<QDBusArgument>(); | 226 | QDBusArgument arg = reply.arguments().at(0).value<QDBusArgument>(); |
2084 | 227 | if (arg.currentType() == QDBusArgument::MapType) | 227 | if (arg.currentType() == QDBusArgument::MapType) |
2085 | 228 | { | 228 | { |
2086 | 229 | 229 | ||
2087 | === modified file 'libbuteosyncfw/common/TransportTracker.h' | |||
2088 | --- libbuteosyncfw/common/TransportTracker.h 2014-09-12 11:53:27 +0000 | |||
2089 | +++ libbuteosyncfw/common/TransportTracker.h 2015-09-30 18:13:56 +0000 | |||
2090 | @@ -78,8 +78,9 @@ | |||
2091 | 78 | /*! \brief Signal emitted when a n/w state changes | 78 | /*! \brief Signal emitted when a n/w state changes |
2092 | 79 | * | 79 | * |
2093 | 80 | * @param aState New state. True if available, false if not. | 80 | * @param aState New state. True if available, false if not. |
2094 | 81 | * @param aType Connection type. The type of connetcion with the Internet. | ||
2095 | 81 | */ | 82 | */ |
2097 | 82 | void networkStateChanged(bool aState); | 83 | void networkStateChanged(bool aState, Sync::InternetConnectionType aType); |
2098 | 83 | 84 | ||
2099 | 84 | /*! \brief Signal emitted when a network session is successfully opened | 85 | /*! \brief Signal emitted when a network session is successfully opened |
2100 | 85 | */ | 86 | */ |
2101 | @@ -99,7 +100,7 @@ | |||
2102 | 99 | void onBtStateChanged(QString aKey, QDBusVariant aValue); | 100 | void onBtStateChanged(QString aKey, QDBusVariant aValue); |
2103 | 100 | #endif | 101 | #endif |
2104 | 101 | 102 | ||
2106 | 102 | void onInternetStateChanged(bool aConnected); | 103 | void onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType); |
2107 | 103 | 104 | ||
2108 | 104 | private: | 105 | private: |
2109 | 105 | 106 | ||
2110 | @@ -127,7 +128,7 @@ | |||
2111 | 127 | friend class TransportTrackerTest; | 128 | friend class TransportTrackerTest; |
2112 | 128 | friend class SynchronizerTest; | 129 | friend class SynchronizerTest; |
2113 | 129 | #endif | 130 | #endif |
2115 | 130 | 131 | ||
2116 | 131 | bool btConnectivityStatus(); | 132 | bool btConnectivityStatus(); |
2117 | 132 | 133 | ||
2118 | 133 | }; | 134 | }; |
2119 | 134 | 135 | ||
2120 | === modified file 'libbuteosyncfw/profile/ProfileManager.cpp' | |||
2121 | --- libbuteosyncfw/profile/ProfileManager.cpp 2015-03-05 06:24:35 +0000 | |||
2122 | +++ libbuteosyncfw/profile/ProfileManager.cpp 2015-09-30 18:13:56 +0000 | |||
2123 | @@ -129,7 +129,6 @@ | |||
2124 | 129 | 129 | ||
2125 | 130 | Profile *ProfileManagerPrivate::load(const QString &aName, const QString &aType) | 130 | Profile *ProfileManagerPrivate::load(const QString &aName, const QString &aType) |
2126 | 131 | { | 131 | { |
2127 | 132 | |||
2128 | 133 | QString profilePath = findProfileFile(aName, aType); | 132 | QString profilePath = findProfileFile(aName, aType); |
2129 | 134 | QString backupProfilePath = profilePath + BACKUP_EXT; | 133 | QString backupProfilePath = profilePath + BACKUP_EXT; |
2130 | 135 | 134 | ||
2131 | @@ -739,6 +738,14 @@ | |||
2132 | 739 | bool exists = d_ptr->profileExists(aProfile.name(),aProfile.type()); | 738 | bool exists = d_ptr->profileExists(aProfile.name(),aProfile.type()); |
2133 | 740 | 739 | ||
2134 | 741 | QString profileId(""); | 740 | QString profileId(""); |
2135 | 741 | |||
2136 | 742 | // We need to save before emit the signalProfileChanged, if this is the first | ||
2137 | 743 | // update the profile will only exists on disk after the save and any operation | ||
2138 | 744 | // using this profile triggered by the signal will fail. | ||
2139 | 745 | if(d_ptr->save(aProfile)) { | ||
2140 | 746 | profileId = aProfile.name(); | ||
2141 | 747 | } | ||
2142 | 748 | |||
2143 | 742 | // Profile did not exist, it was a new one. Add it and emit signal with "added" value: | 749 | // Profile did not exist, it was a new one. Add it and emit signal with "added" value: |
2144 | 743 | if (!exists) { | 750 | if (!exists) { |
2145 | 744 | emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_ADDED,aProfile.toString()); | 751 | emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_ADDED,aProfile.toString()); |
2146 | @@ -746,9 +753,6 @@ | |||
2147 | 746 | emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_MODIFIED,aProfile.toString()); | 753 | emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_MODIFIED,aProfile.toString()); |
2148 | 747 | } | 754 | } |
2149 | 748 | 755 | ||
2150 | 749 | if(d_ptr->save(aProfile)) { | ||
2151 | 750 | profileId = aProfile.name(); | ||
2152 | 751 | } | ||
2153 | 752 | return profileId; | 756 | return profileId; |
2154 | 753 | } | 757 | } |
2155 | 754 | 758 | ||
2156 | @@ -1254,7 +1258,7 @@ | |||
2157 | 1254 | !iSyncRetriesInfo[aProfile->name()].isEmpty()) | 1258 | !iSyncRetriesInfo[aProfile->name()].isEmpty()) |
2158 | 1255 | { | 1259 | { |
2159 | 1256 | quint32 mins = iSyncRetriesInfo[aProfile->name()].takeFirst(); | 1260 | quint32 mins = iSyncRetriesInfo[aProfile->name()].takeFirst(); |
2161 | 1257 | nextRetryInterval = QDateTime::currentDateTime().addSecs(mins * 60); | 1261 | nextRetryInterval = QDateTime::currentDateTime().addSecs(mins * 60); |
2162 | 1258 | LOG_DEBUG("syncretries : retry for profile" << aProfile->name() << "in" << mins <<"minutes"); | 1262 | LOG_DEBUG("syncretries : retry for profile" << aProfile->name() << "in" << mins <<"minutes"); |
2163 | 1259 | LOG_DEBUG("syncretries :" << iSyncRetriesInfo[aProfile->name()].count() <<"attempts remain"); | 1263 | LOG_DEBUG("syncretries :" << iSyncRetriesInfo[aProfile->name()].count() <<"attempts remain"); |
2164 | 1260 | } | 1264 | } |
2165 | 1261 | 1265 | ||
2166 | === modified file 'libbuteosyncfw/profile/SyncProfile.cpp' | |||
2167 | --- libbuteosyncfw/profile/SyncProfile.cpp 2015-01-30 06:49:01 +0000 | |||
2168 | +++ libbuteosyncfw/profile/SyncProfile.cpp 2015-09-30 18:13:56 +0000 | |||
2169 | @@ -259,14 +259,11 @@ | |||
2170 | 259 | if (d_ptr->iLog) | 259 | if (d_ptr->iLog) |
2171 | 260 | { | 260 | { |
2172 | 261 | QList<const SyncResults*> allResults = d_ptr->iLog->allResults(); | 261 | QList<const SyncResults*> allResults = d_ptr->iLog->allResults(); |
2181 | 262 | if (allResults.size () > 0) | 262 | foreach (const SyncResults* result, allResults) { |
2182 | 263 | { | 263 | if ((result->majorCode () == SyncResults::SYNC_RESULT_SUCCESS) && |
2183 | 264 | lastSuccessSyncTime = allResults.at (0)->syncTime (); | 264 | (result->minorCode () == SyncResults::NO_ERROR) && |
2184 | 265 | foreach (const SyncResults* result, allResults) { | 265 | (lastSyncTime().isNull() || (result->syncTime () > lastSuccessSyncTime))) { |
2185 | 266 | if ((result->majorCode () == SyncResults::SYNC_RESULT_SUCCESS) && | 266 | lastSuccessSyncTime = result->syncTime (); |
2178 | 267 | (result->minorCode () == SyncResults::NO_ERROR) && | ||
2179 | 268 | (result->syncTime () > lastSuccessSyncTime)) | ||
2180 | 269 | lastSuccessSyncTime = result->syncTime (); | ||
2186 | 270 | } | 267 | } |
2187 | 271 | } | 268 | } |
2188 | 272 | } | 269 | } |
2189 | 273 | 270 | ||
2190 | === modified file 'msyncd/AccountsHelper.cpp' | |||
2191 | --- msyncd/AccountsHelper.cpp 2015-01-27 07:01:48 +0000 | |||
2192 | +++ msyncd/AccountsHelper.cpp 2015-09-30 18:13:56 +0000 | |||
2193 | @@ -26,6 +26,8 @@ | |||
2194 | 26 | #include "Profile.h" | 26 | #include "Profile.h" |
2195 | 27 | #include "ProfileEngineDefs.h" | 27 | #include "ProfileEngineDefs.h" |
2196 | 28 | 28 | ||
2197 | 29 | #include <QTimer> | ||
2198 | 30 | |||
2199 | 29 | static const QString ACCOUNTS_GLOBAL_SERVICE("global"); | 31 | static const QString ACCOUNTS_GLOBAL_SERVICE("global"); |
2200 | 30 | 32 | ||
2201 | 31 | using namespace Buteo; | 33 | using namespace Buteo; |
2202 | @@ -36,13 +38,15 @@ | |||
2203 | 36 | iAccountManager = new Accounts::Manager(this); | 38 | iAccountManager = new Accounts::Manager(this); |
2204 | 37 | // Connect to signal for account creation, deletion, and modification | 39 | // Connect to signal for account creation, deletion, and modification |
2205 | 38 | QObject::connect(iAccountManager, SIGNAL(accountCreated(Accounts::AccountId)), | 40 | QObject::connect(iAccountManager, SIGNAL(accountCreated(Accounts::AccountId)), |
2207 | 39 | this, SLOT(slotAccountCreated(Accounts::AccountId))); | 41 | this, SLOT(createProfileForAccount(Accounts::AccountId))); |
2208 | 40 | QObject::connect(iAccountManager, SIGNAL(accountRemoved(Accounts::AccountId)), | 42 | QObject::connect(iAccountManager, SIGNAL(accountRemoved(Accounts::AccountId)), |
2209 | 41 | this, SLOT(slotAccountRemoved(Accounts::AccountId))); | 43 | this, SLOT(slotAccountRemoved(Accounts::AccountId))); |
2210 | 42 | QObject::connect(iAccountManager, SIGNAL(accountUpdated(Accounts::AccountId)), | 44 | QObject::connect(iAccountManager, SIGNAL(accountUpdated(Accounts::AccountId)), |
2211 | 43 | this, SLOT(slotAccountUpdated(Accounts::AccountId))); | 45 | this, SLOT(slotAccountUpdated(Accounts::AccountId))); |
2212 | 44 | 46 | ||
2214 | 45 | registerAccountListeners(); | 47 | // load accounts after return from contructor, to allow connection with class singals |
2215 | 48 | // that can be fired by 'registerAccountListeners' function | ||
2216 | 49 | QTimer::singleShot(0, this, SLOT(registerAccountListeners())); | ||
2217 | 46 | } | 50 | } |
2218 | 47 | 51 | ||
2219 | 48 | AccountsHelper::~AccountsHelper() | 52 | AccountsHelper::~AccountsHelper() |
2220 | @@ -54,9 +58,10 @@ | |||
2221 | 54 | // their parent, aka, the manager | 58 | // their parent, aka, the manager |
2222 | 55 | } | 59 | } |
2223 | 56 | 60 | ||
2225 | 57 | void AccountsHelper::slotAccountCreated(Accounts::AccountId id) | 61 | QString AccountsHelper::createProfileForAccount(Accounts::AccountId id) |
2226 | 58 | { | 62 | { |
2227 | 59 | FUNCTION_CALL_TRACE; | 63 | FUNCTION_CALL_TRACE; |
2228 | 64 | QString profileName; | ||
2229 | 60 | Accounts::Account *newAccount = iAccountManager->account(id); | 65 | Accounts::Account *newAccount = iAccountManager->account(id); |
2230 | 61 | bool profileFoundAndCreated = false; | 66 | bool profileFoundAndCreated = false; |
2231 | 62 | 67 | ||
2232 | @@ -66,7 +71,7 @@ | |||
2233 | 66 | Accounts::ServiceList serviceList = newAccount->services(); | 71 | Accounts::ServiceList serviceList = newAccount->services(); |
2234 | 67 | foreach(Accounts::Service service, serviceList) | 72 | foreach(Accounts::Service service, serviceList) |
2235 | 68 | { | 73 | { |
2237 | 69 | // Look for a sync profile that matches the service name | 74 | // Look for a sync profile that matches the service name (template) |
2238 | 70 | LOG_DEBUG("Looking for sync profile::" << service.name()); | 75 | LOG_DEBUG("Looking for sync profile::" << service.name()); |
2239 | 71 | SyncProfile *syncProfile = iProfileManager.syncProfile(service.name()); | 76 | SyncProfile *syncProfile = iProfileManager.syncProfile(service.name()); |
2240 | 72 | LOG_DEBUG("Found profile::" << service.name()); | 77 | LOG_DEBUG("Found profile::" << service.name()); |
2241 | @@ -74,7 +79,7 @@ | |||
2242 | 74 | (true == syncProfile->boolKey(KEY_USE_ACCOUNTS, false)) | 79 | (true == syncProfile->boolKey(KEY_USE_ACCOUNTS, false)) |
2243 | 75 | ) | 80 | ) |
2244 | 76 | { | 81 | { |
2246 | 77 | addAccountIfNotExists(newAccount, service, syncProfile); | 82 | profileName = addAccountIfNotExists(newAccount, service, syncProfile); |
2247 | 78 | profileFoundAndCreated = true; | 83 | profileFoundAndCreated = true; |
2248 | 79 | } | 84 | } |
2249 | 80 | if(0 != syncProfile) | 85 | if(0 != syncProfile) |
2250 | @@ -86,7 +91,7 @@ | |||
2251 | 86 | 91 | ||
2252 | 87 | if (profileFoundAndCreated == false) | 92 | if (profileFoundAndCreated == false) |
2253 | 88 | { | 93 | { |
2255 | 89 | // Fetch the key "remote_service_name" from the account settings and | 94 | // Fetch the key "remote_service_name" from the account settings and |
2256 | 90 | // use it to create a profile | 95 | // use it to create a profile |
2257 | 91 | QString profileName = newAccount->valueAsString(REMOTE_SERVICE_NAME); | 96 | QString profileName = newAccount->valueAsString(REMOTE_SERVICE_NAME); |
2258 | 92 | LOG_DEBUG("Profile name from account setting:" << profileName); | 97 | LOG_DEBUG("Profile name from account setting:" << profileName); |
2259 | @@ -97,10 +102,15 @@ | |||
2260 | 97 | if (syncProfile->boolKey (KEY_USE_ACCOUNTS, false) == true) | 102 | if (syncProfile->boolKey (KEY_USE_ACCOUNTS, false) == true) |
2261 | 98 | createProfileForAccount (newAccount, profileName, syncProfile); | 103 | createProfileForAccount (newAccount, profileName, syncProfile); |
2262 | 99 | 104 | ||
2263 | 105 | profileName = syncProfile->name(); | ||
2264 | 100 | delete syncProfile; | 106 | delete syncProfile; |
2265 | 101 | } | 107 | } |
2266 | 102 | } | 108 | } |
2267 | 109 | } else { | ||
2268 | 110 | LOG_DEBUG("Account not found:" << id); | ||
2269 | 103 | } | 111 | } |
2270 | 112 | |||
2271 | 113 | return profileName; | ||
2272 | 104 | } | 114 | } |
2273 | 105 | 115 | ||
2274 | 106 | void AccountsHelper::slotAccountRemoved(Accounts::AccountId id) | 116 | void AccountsHelper::slotAccountRemoved(Accounts::AccountId id) |
2275 | @@ -186,7 +196,7 @@ | |||
2276 | 186 | foreach(SyncProfile *profile, profiles) | 196 | foreach(SyncProfile *profile, profiles) |
2277 | 187 | { | 197 | { |
2278 | 188 | // See if the service name matches | 198 | // See if the service name matches |
2280 | 189 | if(serviceName == profile->name()) | 199 | if(serviceName == profile->key(REMOTE_SERVICE_NAME)) |
2281 | 190 | { | 200 | { |
2282 | 191 | // Check if the status really changed here | 201 | // Check if the status really changed here |
2283 | 192 | // saving the account can trigger the emition of enabledChanged() | 202 | // saving the account can trigger the emition of enabledChanged() |
2284 | @@ -331,16 +341,16 @@ | |||
2285 | 331 | delete newProfile; | 341 | delete newProfile; |
2286 | 332 | } | 342 | } |
2287 | 333 | 343 | ||
2291 | 334 | void AccountsHelper::addAccountIfNotExists(Accounts::Account *account, | 344 | QString AccountsHelper::addAccountIfNotExists(Accounts::Account *account, |
2292 | 335 | Accounts::Service service, | 345 | Accounts::Service service, |
2293 | 336 | const SyncProfile *baseProfile) | 346 | const SyncProfile *baseProfile) |
2294 | 337 | { | 347 | { |
2295 | 338 | FUNCTION_CALL_TRACE; | 348 | FUNCTION_CALL_TRACE; |
2296 | 339 | 349 | ||
2297 | 340 | Profile *serviceProfile = iProfileManager.profile(service.name(), Profile::TYPE_SYNC); | 350 | Profile *serviceProfile = iProfileManager.profile(service.name(), Profile::TYPE_SYNC); |
2298 | 341 | if (!serviceProfile) { | 351 | if (!serviceProfile) { |
2299 | 342 | LOG_DEBUG ("!!!! Service not supported !!!!"); | 352 | LOG_DEBUG ("!!!! Service not supported !!!!"); |
2301 | 343 | return; | 353 | return QString(); |
2302 | 344 | } | 354 | } |
2303 | 345 | 355 | ||
2304 | 346 | QString profileName ; | 356 | QString profileName ; |
2305 | @@ -367,9 +377,11 @@ | |||
2306 | 367 | // Add the account ID to the profile | 377 | // Add the account ID to the profile |
2307 | 368 | newProfile->setKey(KEY_ACCOUNT_ID, QString::number(account->id())); | 378 | newProfile->setKey(KEY_ACCOUNT_ID, QString::number(account->id())); |
2308 | 369 | // Check if service is enabled | 379 | // Check if service is enabled |
2310 | 370 | LOG_DEBUG("Service:: " << service.displayName() << "enabled status::" << account->enabled()); | 380 | LOG_DEBUG("Service:: " << service.displayName() << |
2311 | 381 | "enabled status::" << (account->enabled() && account->enabledServices().contains(service))); | ||
2312 | 371 | // Set profile as enabled | 382 | // Set profile as enabled |
2314 | 372 | newProfile->setEnabled(account->enabled()); | 383 | newProfile->setEnabled(account->enabled() && |
2315 | 384 | account->enabledServices().contains(service)); | ||
2316 | 373 | setSyncSchedule (newProfile, account->id(), true); | 385 | setSyncSchedule (newProfile, account->id(), true); |
2317 | 374 | 386 | ||
2318 | 375 | // Save the newly created profile | 387 | // Save the newly created profile |
2319 | @@ -398,6 +410,8 @@ | |||
2320 | 398 | { | 410 | { |
2321 | 399 | delete profile; | 411 | delete profile; |
2322 | 400 | } | 412 | } |
2323 | 413 | |||
2324 | 414 | return profileName; | ||
2325 | 401 | } | 415 | } |
2326 | 402 | 416 | ||
2327 | 403 | void AccountsHelper::addSetting(Accounts::AccountId id, QString key, QVariant value) { | 417 | void AccountsHelper::addSetting(Accounts::AccountId id, QString key, QVariant value) { |
2328 | @@ -448,12 +462,27 @@ | |||
2329 | 448 | void AccountsHelper::registerAccountListener(Accounts::AccountId id) | 462 | void AccountsHelper::registerAccountListener(Accounts::AccountId id) |
2330 | 449 | { | 463 | { |
2331 | 450 | FUNCTION_CALL_TRACE; | 464 | FUNCTION_CALL_TRACE; |
2332 | 465 | |||
2333 | 451 | Accounts::Account *account = iAccountManager->account(id); | 466 | Accounts::Account *account = iAccountManager->account(id); |
2334 | 467 | if (iAccountList.contains(account)) { | ||
2335 | 468 | return; | ||
2336 | 469 | } | ||
2337 | 452 | iAccountList.append(account); | 470 | iAccountList.append(account); |
2338 | 453 | // Callback for account enabled/disabled | 471 | // Callback for account enabled/disabled |
2341 | 454 | QObject::connect(account, SIGNAL(enabledChanged(const QString&, bool)), | 472 | QObject::connect(account, |
2342 | 455 | this, SLOT(slotAccountEnabledChanged(const QString&, bool))); | 473 | SIGNAL(enabledChanged(const QString&, bool)), |
2343 | 474 | SLOT(slotAccountEnabledChanged(const QString&, bool)), | ||
2344 | 475 | Qt::UniqueConnection); | ||
2345 | 456 | 476 | ||
2346 | 477 | // Account SyncOnChange | ||
2347 | 478 | QList<SyncProfile*> profiles = getProfilesByAccountId(id); | ||
2348 | 479 | foreach(SyncProfile *profile, profiles) | ||
2349 | 480 | { | ||
2350 | 481 | if(profile->isSOCProfile()) | ||
2351 | 482 | { | ||
2352 | 483 | emit enableSOC(profile->name()); | ||
2353 | 484 | } | ||
2354 | 485 | } | ||
2355 | 457 | account->selectService(); | 486 | account->selectService(); |
2356 | 458 | account->beginGroup("scheduler"); | 487 | account->beginGroup("scheduler"); |
2357 | 459 | LOG_DEBUG("Watching Group :" << account->group()); | 488 | LOG_DEBUG("Watching Group :" << account->group()); |
2358 | @@ -463,5 +492,8 @@ | |||
2359 | 463 | return; | 492 | return; |
2360 | 464 | } | 493 | } |
2361 | 465 | iAcctWatchMap[watch] = id; | 494 | iAcctWatchMap[watch] = id; |
2363 | 466 | QObject::connect(watch, SIGNAL(notify(const char *)), this, SLOT(slotSchedulerSettingsChanged(const char *))); | 495 | QObject::connect(watch, |
2364 | 496 | SIGNAL(notify(const char *)), | ||
2365 | 497 | SLOT(slotSchedulerSettingsChanged(const char *)), | ||
2366 | 498 | Qt::UniqueConnection); | ||
2367 | 467 | } | 499 | } |
2368 | 468 | 500 | ||
2369 | === modified file 'msyncd/AccountsHelper.h' | |||
2370 | --- msyncd/AccountsHelper.h 2014-11-07 07:26:49 +0000 | |||
2371 | +++ msyncd/AccountsHelper.h 2015-09-30 18:13:56 +0000 | |||
2372 | @@ -29,12 +29,12 @@ | |||
2373 | 29 | #include <Accounts/account.h> | 29 | #include <Accounts/account.h> |
2374 | 30 | 30 | ||
2375 | 31 | namespace Buteo { | 31 | namespace Buteo { |
2377 | 32 | 32 | ||
2378 | 33 | class Profile; | 33 | class Profile; |
2379 | 34 | class AccountsHelperTest; | 34 | class AccountsHelperTest; |
2380 | 35 | class ProfileManager; | 35 | class ProfileManager; |
2381 | 36 | class SyncProfile; | 36 | class SyncProfile; |
2383 | 37 | 37 | ||
2384 | 38 | const QString REMOTE_SERVICE_NAME("remote_service_name"); | 38 | const QString REMOTE_SERVICE_NAME("remote_service_name"); |
2385 | 39 | 39 | ||
2386 | 40 | /*! \brief Helper Class towards Accounts::Manager and various SSO related | 40 | /*! \brief Helper Class towards Accounts::Manager and various SSO related |
2387 | @@ -57,7 +57,7 @@ | |||
2388 | 57 | * | 57 | * |
2389 | 58 | */ | 58 | */ |
2390 | 59 | virtual ~AccountsHelper(); | 59 | virtual ~AccountsHelper(); |
2392 | 60 | 60 | ||
2393 | 61 | /*! \brief Returns sync profiles that correspond to a given account ID | 61 | /*! \brief Returns sync profiles that correspond to a given account ID |
2394 | 62 | * | 62 | * |
2395 | 63 | * \param id - The account ID. | 63 | * \param id - The account ID. |
2396 | @@ -68,30 +68,31 @@ | |||
2397 | 68 | 68 | ||
2398 | 69 | public Q_SLOTS: | 69 | public Q_SLOTS: |
2399 | 70 | 70 | ||
2405 | 71 | /*! \brief slot for Accounts::Manager accountCreated signal | 71 | /*! \brief This method is used to create a profile for a specified |
2406 | 72 | * | 72 | * account |
2407 | 73 | * \param id Accounts Id | 73 | * \param id Accounts Id |
2408 | 74 | */ | 74 | * \return A string with the new profile name |
2409 | 75 | void slotAccountCreated(Accounts::AccountId id); | 75 | */ |
2410 | 76 | QString createProfileForAccount(Accounts::AccountId id); | ||
2411 | 76 | 77 | ||
2416 | 77 | /*! \brief slot for Accounts::Manager accountRemoved signal | 78 | /*! \brief slot for Accounts::Manager accountRemoved signal |
2417 | 78 | * | 79 | * |
2418 | 79 | * \param id of the accounts | 80 | * \param id of the accounts |
2419 | 80 | */ | 81 | */ |
2420 | 81 | void slotAccountRemoved(Accounts::AccountId id); | 82 | void slotAccountRemoved(Accounts::AccountId id); |
2421 | 82 | 83 | ||
2425 | 83 | /*! \brief slot for Accounts::Account enabledChanged signal | 84 | /*! \brief slot for Accounts::Account enabledChanged signal |
2426 | 84 | * | 85 | * |
2427 | 85 | * \param serviceName The service that was enabled/disabled. Empty if the | 86 | * \param serviceName The service that was enabled/disabled. Empty if the |
2428 | 86 | * entire account is enabled/disabled | 87 | * entire account is enabled/disabled |
2429 | 87 | * \param enabled Boolean indicating enabled (true) or disabled (false) | 88 | * \param enabled Boolean indicating enabled (true) or disabled (false) |
2431 | 88 | */ | 89 | */ |
2432 | 89 | void slotAccountEnabledChanged(const QString &serviceName, bool enabled); | 90 | void slotAccountEnabledChanged(const QString &serviceName, bool enabled); |
2438 | 90 | 91 | ||
2439 | 91 | /*! \brief slot for Accounts::Manager displayNameChanged signal | 92 | /*! \brief slot for Accounts::Manager displayNameChanged signal |
2440 | 92 | * * | 93 | * * |
2441 | 93 | * \param id of the accounts | 94 | * \param id of the accounts |
2442 | 94 | */ | 95 | */ |
2443 | 95 | void slotAccountUpdated(Accounts::AccountId id); | 96 | void slotAccountUpdated(Accounts::AccountId id); |
2444 | 96 | 97 | ||
2445 | 97 | void slotSchedulerSettingsChanged(const char *aKey); | 98 | void slotSchedulerSettingsChanged(const char *aKey); |
2446 | @@ -102,22 +103,20 @@ | |||
2447 | 102 | void removeProfile(QString profileId); | 103 | void removeProfile(QString profileId); |
2448 | 103 | void removeScheduledSync(const QString& profileId); | 104 | void removeScheduledSync(const QString& profileId); |
2449 | 104 | 105 | ||
2450 | 106 | private Q_SLOTS: | ||
2451 | 107 | |||
2452 | 108 | void registerAccountListeners(); | ||
2453 | 109 | |||
2454 | 105 | private: | 110 | private: |
2455 | 106 | |||
2456 | 107 | /*! | ||
2457 | 108 | * \brief This method is used to create a profile for a specified | ||
2458 | 109 | * account | ||
2459 | 110 | */ | ||
2460 | 111 | void createProfileForAccount(Accounts::Account* account, | 111 | void createProfileForAccount(Accounts::Account* account, |
2461 | 112 | const QString profileName, | 112 | const QString profileName, |
2462 | 113 | const SyncProfile* baseProfile); | 113 | const SyncProfile* baseProfile); |
2463 | 114 | 114 | ||
2467 | 115 | void addAccountIfNotExists(Accounts::Account *account, | 115 | QString addAccountIfNotExists(Accounts::Account *account, |
2468 | 116 | Accounts::Service service, | 116 | Accounts::Service service, |
2469 | 117 | const SyncProfile *baseProfile); | 117 | const SyncProfile *baseProfile); |
2470 | 118 | 118 | ||
2471 | 119 | void setSyncSchedule(SyncProfile *syncProfile, Accounts::AccountId id, bool aCreateNew = false); | 119 | void setSyncSchedule(SyncProfile *syncProfile, Accounts::AccountId id, bool aCreateNew = false); |
2472 | 120 | void registerAccountListeners(); | ||
2473 | 121 | 120 | ||
2474 | 122 | void addSetting(Accounts::AccountId id, QString key, QVariant value); | 121 | void addSetting(Accounts::AccountId id, QString key, QVariant value); |
2475 | 123 | 122 | ||
2476 | 124 | 123 | ||
2477 | === modified file 'msyncd/SyncDBusAdaptor.cpp' | |||
2478 | --- msyncd/SyncDBusAdaptor.cpp 2015-01-30 06:49:01 +0000 | |||
2479 | +++ msyncd/SyncDBusAdaptor.cpp 2015-09-30 18:13:56 +0000 | |||
2480 | @@ -206,3 +206,11 @@ | |||
2481 | 206 | QMetaObject::invokeMethod(parent(), "isSyncedExternally", Q_ARG(uint, aAccountId), Q_ARG(QString, aClientProfileName)); | 206 | QMetaObject::invokeMethod(parent(), "isSyncedExternally", Q_ARG(uint, aAccountId), Q_ARG(QString, aClientProfileName)); |
2482 | 207 | } | 207 | } |
2483 | 208 | 208 | ||
2484 | 209 | QString SyncDBusAdaptor::createSyncProfileForAccount(uint aAccountId) | ||
2485 | 210 | { | ||
2486 | 211 | // handle method call com.meego.msyncd.createSyncProfileForAccount | ||
2487 | 212 | QString out0; | ||
2488 | 213 | QMetaObject::invokeMethod(parent(), "createSyncProfileForAccount", Q_RETURN_ARG(QString, out0), Q_ARG(uint, aAccountId)); | ||
2489 | 214 | return out0; | ||
2490 | 215 | } | ||
2491 | 216 | |||
2492 | 209 | 217 | ||
2493 | === modified file 'msyncd/SyncDBusAdaptor.h' | |||
2494 | --- msyncd/SyncDBusAdaptor.h 2015-01-30 06:49:01 +0000 | |||
2495 | +++ msyncd/SyncDBusAdaptor.h 2015-09-30 18:13:56 +0000 | |||
2496 | @@ -157,6 +157,10 @@ | |||
2497 | 157 | " <arg direction=\"out\" type=\"au\"/>\n" | 157 | " <arg direction=\"out\" type=\"au\"/>\n" |
2498 | 158 | " <annotation value=\"QList<uint>\" name=\"com.trolltech.QtDBus.QtTypeName.Out0\"/>\n" | 158 | " <annotation value=\"QList<uint>\" name=\"com.trolltech.QtDBus.QtTypeName.Out0\"/>\n" |
2499 | 159 | " </method>\n" | 159 | " </method>\n" |
2500 | 160 | " <method name=\"createSyncProfileForAccount\">\n" | ||
2501 | 161 | " <arg direction=\"out\" type=\"s\"/>\n" | ||
2502 | 162 | " <arg direction=\"in\" type=\"u\" name=\"aAccountId\"/>\n" | ||
2503 | 163 | " </method>\n" | ||
2504 | 160 | " <method name=\"status\">\n" | 164 | " <method name=\"status\">\n" |
2505 | 161 | " <arg direction=\"out\" type=\"i\"/>\n" | 165 | " <arg direction=\"out\" type=\"i\"/>\n" |
2506 | 162 | " <arg direction=\"in\" type=\"u\" name=\"aAccountId\"/>\n" | 166 | " <arg direction=\"in\" type=\"u\" name=\"aAccountId\"/>\n" |
2507 | @@ -198,6 +202,7 @@ | |||
2508 | 198 | QList<uint> syncingAccounts(); | 202 | QList<uint> syncingAccounts(); |
2509 | 199 | bool updateProfile(const QString &aProfileAsXml); | 203 | bool updateProfile(const QString &aProfileAsXml); |
2510 | 200 | Q_NOREPLY void isSyncedExternally(uint aAccountId, const QString aClientProfileName); | 204 | Q_NOREPLY void isSyncedExternally(uint aAccountId, const QString aClientProfileName); |
2511 | 205 | QString createSyncProfileForAccount(uint aAccountId); | ||
2512 | 201 | Q_SIGNALS: // SIGNALS | 206 | Q_SIGNALS: // SIGNALS |
2513 | 202 | void backupDone(); | 207 | void backupDone(); |
2514 | 203 | void backupInProgress(); | 208 | void backupInProgress(); |
2515 | 204 | 209 | ||
2516 | === modified file 'msyncd/SyncDBusInterface.h' | |||
2517 | --- msyncd/SyncDBusInterface.h 2015-01-30 06:49:01 +0000 | |||
2518 | +++ msyncd/SyncDBusInterface.h 2015-09-30 18:13:56 +0000 | |||
2519 | @@ -103,29 +103,29 @@ | |||
2520 | 103 | * | 103 | * |
2521 | 104 | */ | 104 | */ |
2522 | 105 | void signalProfileChanged(QString aProfileName, int aChangeType , QString aProfileAsXml); | 105 | void signalProfileChanged(QString aProfileName, int aChangeType , QString aProfileAsXml); |
2525 | 106 | 106 | ||
2526 | 107 | 107 | ||
2527 | 108 | /*! \brief Notifies about Backup start. | 108 | /*! \brief Notifies about Backup start. |
2528 | 109 | * | 109 | * |
2529 | 110 | * This signal is sent when the backup framework is backing the sync related | 110 | * This signal is sent when the backup framework is backing the sync related |
2530 | 111 | * data | 111 | * data |
2531 | 112 | */ | 112 | */ |
2532 | 113 | void backupInProgress (); | 113 | void backupInProgress (); |
2534 | 114 | 114 | ||
2535 | 115 | /*! \brief Notifies about Backup done. | 115 | /*! \brief Notifies about Backup done. |
2536 | 116 | * | 116 | * |
2537 | 117 | * This signal is sent when the backup framework has completed backing the sync related | 117 | * This signal is sent when the backup framework has completed backing the sync related |
2538 | 118 | * data. | 118 | * data. |
2539 | 119 | */ | 119 | */ |
2540 | 120 | void backupDone(); | 120 | void backupDone(); |
2542 | 121 | 121 | ||
2543 | 122 | /*! \brief Notifies about Restore start. | 122 | /*! \brief Notifies about Restore start. |
2544 | 123 | * | 123 | * |
2545 | 124 | * This signal is sent when the backup framework is restoring the sync related | 124 | * This signal is sent when the backup framework is restoring the sync related |
2546 | 125 | * data | 125 | * data |
2547 | 126 | */ | 126 | */ |
2548 | 127 | void restoreInProgress(); | 127 | void restoreInProgress(); |
2550 | 128 | 128 | ||
2551 | 129 | /*! \brief Notifies about Restore Done. | 129 | /*! \brief Notifies about Restore Done. |
2552 | 130 | * | 130 | * |
2553 | 131 | * This signal is sent when the backup framework has restored the sync related | 131 | * This signal is sent when the backup framework has restored the sync related |
2554 | @@ -160,7 +160,7 @@ | |||
2555 | 160 | * \param aNextSyncTime This is an out parameter. The next sync time. | 160 | * \param aNextSyncTime This is an out parameter. The next sync time. |
2556 | 161 | */ | 161 | */ |
2557 | 162 | void statusChanged(unsigned int aAccountId, int aNewStatus, int aFailedReason, qlonglong aPrevSyncTime, qlonglong aNextSyncTime); | 162 | void statusChanged(unsigned int aAccountId, int aNewStatus, int aFailedReason, qlonglong aPrevSyncTime, qlonglong aNextSyncTime); |
2559 | 163 | 163 | ||
2560 | 164 | /*! \brief Returns the connectivity state of a specific medium like | 164 | /*! \brief Returns the connectivity state of a specific medium like |
2561 | 165 | * bluetooth, USB or network. | 165 | * bluetooth, USB or network. |
2562 | 166 | * \see SyncCommonDefs::ConnectivityType for arguments | 166 | * \see SyncCommonDefs::ConnectivityType for arguments |
2563 | @@ -257,16 +257,16 @@ | |||
2564 | 257 | * \return Profile name list. | 257 | * \return Profile name list. |
2565 | 258 | */ | 258 | */ |
2566 | 259 | virtual QStringList runningSyncs() = 0; | 259 | virtual QStringList runningSyncs() = 0; |
2569 | 260 | 260 | ||
2570 | 261 | 261 | ||
2571 | 262 | /*! | 262 | /*! |
2572 | 263 | * \brief This function returns true if backup/restore in progress else | 263 | * \brief This function returns true if backup/restore in progress else |
2573 | 264 | * false. | 264 | * false. |
2574 | 265 | */ | 265 | */ |
2575 | 266 | virtual bool getBackUpRestoreState() = 0; | 266 | virtual bool getBackUpRestoreState() = 0; |
2579 | 267 | 267 | ||
2580 | 268 | 268 | ||
2581 | 269 | /*! | 269 | /*! |
2582 | 270 | * \brief sets the schedule for a profile | 270 | * \brief sets the schedule for a profile |
2583 | 271 | * | 271 | * |
2584 | 272 | * This Function helps in setting a schedule to profile | 272 | * This Function helps in setting a schedule to profile |
2585 | @@ -312,7 +312,7 @@ | |||
2586 | 312 | * \return The sync profile as Xml string. | 312 | * \return The sync profile as Xml string. |
2587 | 313 | */ | 313 | */ |
2588 | 314 | virtual QString syncProfile(const QString &aProfileId) = 0; | 314 | virtual QString syncProfile(const QString &aProfileId) = 0; |
2590 | 315 | 315 | ||
2591 | 316 | /*! \brief Gets a sync profiles matching the key-value. | 316 | /*! \brief Gets a sync profiles matching the key-value. |
2592 | 317 | * | 317 | * |
2593 | 318 | * Loads and merges also all sub-profiles that are referenced from the | 318 | * Loads and merges also all sub-profiles that are referenced from the |
2594 | @@ -323,7 +323,7 @@ | |||
2595 | 323 | * \return The sync profiles as Xml string list. | 323 | * \return The sync profiles as Xml string list. |
2596 | 324 | */ | 324 | */ |
2597 | 325 | virtual QStringList syncProfilesByKey(const QString &aKey, const QString &aValue) = 0; | 325 | virtual QStringList syncProfilesByKey(const QString &aKey, const QString &aValue) = 0; |
2599 | 326 | 326 | ||
2600 | 327 | /*! \brief Gets a profiles matching the profile type. | 327 | /*! \brief Gets a profiles matching the profile type. |
2601 | 328 | * | 328 | * |
2602 | 329 | * \param aType Type of the profile service/storage/sync. | 329 | * \param aType Type of the profile service/storage/sync. |
2603 | @@ -336,13 +336,13 @@ | |||
2604 | 336 | * \param aAccountId The account ID. | 336 | * \param aAccountId The account ID. |
2605 | 337 | */ | 337 | */ |
2606 | 338 | virtual Q_NOREPLY void start(unsigned int aAccountId) = 0; | 338 | virtual Q_NOREPLY void start(unsigned int aAccountId) = 0; |
2608 | 339 | 339 | ||
2609 | 340 | /*! \brief Stops sync for all profiles matching the given account ID. | 340 | /*! \brief Stops sync for all profiles matching the given account ID. |
2610 | 341 | * | 341 | * |
2611 | 342 | * \param aAccountId The account ID. | 342 | * \param aAccountId The account ID. |
2612 | 343 | */ | 343 | */ |
2613 | 344 | virtual Q_NOREPLY void stop(unsigned int aAccountId) = 0; | 344 | virtual Q_NOREPLY void stop(unsigned int aAccountId) = 0; |
2615 | 345 | 345 | ||
2616 | 346 | /*! \brief Returns the list of account IDs for which sync is ongoing | 346 | /*! \brief Returns the list of account IDs for which sync is ongoing |
2617 | 347 | * | 347 | * |
2618 | 348 | * \return The list of account IDs currectly syncing. | 348 | * \return The list of account IDs currectly syncing. |
2619 | @@ -373,6 +373,13 @@ | |||
2620 | 373 | * having several services enabled | 373 | * having several services enabled |
2621 | 374 | */ | 374 | */ |
2622 | 375 | virtual Q_NOREPLY void isSyncedExternally(unsigned int aAccountId, const QString aClientProfileName) = 0; | 375 | virtual Q_NOREPLY void isSyncedExternally(unsigned int aAccountId, const QString aClientProfileName) = 0; |
2623 | 376 | |||
2624 | 377 | /*! \brief Create a sync profile for the account if it does not exists | ||
2625 | 378 | * | ||
2626 | 379 | * \param aAccountId The account ID. | ||
2627 | 380 | * \return The profile name if the profile was created successful or empty if it fails | ||
2628 | 381 | */ | ||
2629 | 382 | virtual QString createSyncProfileForAccount(uint aAccountId) = 0; | ||
2630 | 376 | }; | 383 | }; |
2631 | 377 | 384 | ||
2632 | 378 | } | 385 | } |
2633 | 379 | 386 | ||
2634 | === modified file 'msyncd/SyncOnChangeScheduler.cpp' | |||
2635 | --- msyncd/SyncOnChangeScheduler.cpp 2014-02-20 07:06:08 +0000 | |||
2636 | +++ msyncd/SyncOnChangeScheduler.cpp 2015-09-30 18:13:56 +0000 | |||
2637 | @@ -14,6 +14,11 @@ | |||
2638 | 14 | SyncOnChangeScheduler::~SyncOnChangeScheduler() | 14 | SyncOnChangeScheduler::~SyncOnChangeScheduler() |
2639 | 15 | { | 15 | { |
2640 | 16 | FUNCTION_CALL_TRACE; | 16 | FUNCTION_CALL_TRACE; |
2641 | 17 | foreach(QObject *o, iSOCTimers.values()) { | ||
2642 | 18 | delete o; | ||
2643 | 19 | } | ||
2644 | 20 | iSOCTimers.clear(); | ||
2645 | 21 | iSOCProfileNames.clear(); | ||
2646 | 17 | } | 22 | } |
2647 | 18 | 23 | ||
2648 | 19 | bool SyncOnChangeScheduler::addProfile(const SyncProfile* aProfile) | 24 | bool SyncOnChangeScheduler::addProfile(const SyncProfile* aProfile) |
2649 | @@ -30,6 +35,7 @@ | |||
2650 | 30 | Qt::QueuedConnection); | 35 | Qt::QueuedConnection); |
2651 | 31 | SOCtimer->fire(); | 36 | SOCtimer->fire(); |
2652 | 32 | scheduled = true; | 37 | scheduled = true; |
2653 | 38 | iSOCTimers.insert(aProfile->name(), SOCtimer); | ||
2654 | 33 | LOG_DEBUG("Sync on change scheduled for profile"<< aProfile->name()); | 39 | LOG_DEBUG("Sync on change scheduled for profile"<< aProfile->name()); |
2655 | 34 | } | 40 | } |
2656 | 35 | else if(aProfile) | 41 | else if(aProfile) |
2657 | @@ -43,12 +49,15 @@ | |||
2658 | 43 | { | 49 | { |
2659 | 44 | FUNCTION_CALL_TRACE; | 50 | FUNCTION_CALL_TRACE; |
2660 | 45 | iSOCProfileNames.removeAll(aProfileName); | 51 | iSOCProfileNames.removeAll(aProfileName); |
2661 | 52 | // cancel timer | ||
2662 | 53 | delete iSOCTimers.take(aProfileName); | ||
2663 | 46 | } | 54 | } |
2664 | 47 | 55 | ||
2665 | 48 | void SyncOnChangeScheduler::sync(const SyncProfile* aProfile) | 56 | void SyncOnChangeScheduler::sync(const SyncProfile* aProfile) |
2666 | 49 | { | 57 | { |
2667 | 50 | FUNCTION_CALL_TRACE; | 58 | FUNCTION_CALL_TRACE; |
2668 | 51 | iSOCProfileNames.removeAll(aProfile->name()); | 59 | iSOCProfileNames.removeAll(aProfile->name()); |
2669 | 60 | iSOCTimers.remove(aProfile->name()); | ||
2670 | 52 | SyncOnChangeTimer *SOCtimer = qobject_cast<SyncOnChangeTimer*>(sender()); | 61 | SyncOnChangeTimer *SOCtimer = qobject_cast<SyncOnChangeTimer*>(sender()); |
2671 | 53 | if(SOCtimer) | 62 | if(SOCtimer) |
2672 | 54 | { | 63 | { |
2673 | 55 | 64 | ||
2674 | === modified file 'msyncd/SyncOnChangeScheduler.h' | |||
2675 | --- msyncd/SyncOnChangeScheduler.h 2011-02-02 09:39:11 +0000 | |||
2676 | +++ msyncd/SyncOnChangeScheduler.h 2015-09-30 18:13:56 +0000 | |||
2677 | @@ -40,7 +40,7 @@ | |||
2678 | 40 | * | 40 | * |
2679 | 41 | * Once the SOC is initiated (by sending a syncNow signal), the profile is | 41 | * Once the SOC is initiated (by sending a syncNow signal), the profile is |
2680 | 42 | * removed automatically | 42 | * removed automatically |
2682 | 43 | * | 43 | * |
2683 | 44 | * @param aProfile pointer to sync profile | 44 | * @param aProfile pointer to sync profile |
2684 | 45 | * @return true if SOC could be scheduled, false otherwise | 45 | * @return true if SOC could be scheduled, false otherwise |
2685 | 46 | */ | 46 | */ |
2686 | @@ -63,6 +63,7 @@ | |||
2687 | 63 | 63 | ||
2688 | 64 | private: | 64 | private: |
2689 | 65 | QStringList iSOCProfileNames; | 65 | QStringList iSOCProfileNames; |
2690 | 66 | QMap<QString, QObject*> iSOCTimers; | ||
2691 | 66 | }; | 67 | }; |
2692 | 67 | 68 | ||
2693 | 68 | class SyncOnChangeTimer : public QObject | 69 | class SyncOnChangeTimer : public QObject |
2694 | 69 | 70 | ||
2695 | === modified file 'msyncd/SyncSession.h' | |||
2696 | --- msyncd/SyncSession.h 2011-02-03 09:58:25 +0000 | |||
2697 | +++ msyncd/SyncSession.h 2015-09-30 18:13:56 +0000 | |||
2698 | @@ -182,7 +182,7 @@ | |||
2699 | 182 | void setProfileCreated(bool aProfileCreated); | 182 | void setProfileCreated(bool aProfileCreated); |
2700 | 183 | 183 | ||
2701 | 184 | //! \brief Maps sync failure error code from stack to SyncStatus | 184 | //! \brief Maps sync failure error code from stack to SyncStatus |
2703 | 185 | Sync::SyncStatus mapToSyncStatusError(int aErrorCode); | 185 | Sync::SyncStatus mapToSyncStatusError(int aErrorCode); |
2704 | 186 | 186 | ||
2705 | 187 | signals: | 187 | signals: |
2706 | 188 | 188 | ||
2707 | 189 | 189 | ||
2708 | === added directory 'msyncd/gschemas' | |||
2709 | === added file 'msyncd/gschemas/com.meego.msyncd.gschema.xml' | |||
2710 | --- msyncd/gschemas/com.meego.msyncd.gschema.xml 1970-01-01 00:00:00 +0000 | |||
2711 | +++ msyncd/gschemas/com.meego.msyncd.gschema.xml 2015-09-30 18:13:56 +0000 | |||
2712 | @@ -0,0 +1,10 @@ | |||
2713 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2714 | 2 | <schemalist> | ||
2715 | 3 | <schema id="com.meego.msyncd" path="/com/meego/msyncd/"> | ||
2716 | 4 | <key name="allow-scheduled-sync-over-cellular" type="b"> | ||
2717 | 5 | <summary>Scheduled Sync over cellular</summary> | ||
2718 | 6 | <description>Allow scheduled syncs to run over cellular connections.</description> | ||
2719 | 7 | <default>true</default> | ||
2720 | 8 | </key> | ||
2721 | 9 | </schema> | ||
2722 | 10 | </schemalist> | ||
2723 | 0 | 11 | ||
2724 | === modified file 'msyncd/msyncd-app.pro' | |||
2725 | --- msyncd/msyncd-app.pro 2014-06-19 06:03:32 +0000 | |||
2726 | +++ msyncd/msyncd-app.pro 2015-09-30 18:13:56 +0000 | |||
2727 | @@ -62,10 +62,13 @@ | |||
2728 | 62 | service.path = /usr/lib/systemd/user/ | 62 | service.path = /usr/lib/systemd/user/ |
2729 | 63 | syncwidget.path = /etc/syncwidget/ | 63 | syncwidget.path = /etc/syncwidget/ |
2730 | 64 | syncwidget.files = com.meego.msyncd | 64 | syncwidget.files = com.meego.msyncd |
2731 | 65 | gschemas.path = /usr/share/glib-2.0/schemas | ||
2732 | 66 | gschemas.files = gschemas/com.meego.msyncd.gschema.xml | ||
2733 | 65 | INSTALLS += target \ | 67 | INSTALLS += target \ |
2734 | 66 | loglevel \ | 68 | loglevel \ |
2735 | 67 | syncwidget \ | 69 | syncwidget \ |
2737 | 68 | service | 70 | service \ |
2738 | 71 | gschemas | ||
2739 | 69 | 72 | ||
2740 | 70 | # ##################################################################### | 73 | # ##################################################################### |
2741 | 71 | # make coverage (debug) | 74 | # make coverage (debug) |
2742 | 72 | 75 | ||
2743 | === modified file 'msyncd/msyncd-lib.pro' | |||
2744 | --- msyncd/msyncd-lib.pro 2014-06-19 06:03:32 +0000 | |||
2745 | +++ msyncd/msyncd-lib.pro 2015-09-30 18:13:56 +0000 | |||
2746 | @@ -19,7 +19,7 @@ | |||
2747 | 19 | ../libbuteosyncfw/profile | 19 | ../libbuteosyncfw/profile |
2748 | 20 | 20 | ||
2749 | 21 | 21 | ||
2751 | 22 | PKGCONFIG += dbus-1 | 22 | PKGCONFIG += dbus-1 gio-2.0 |
2752 | 23 | 23 | ||
2753 | 24 | equals(QT_MAJOR_VERSION, 4): { | 24 | equals(QT_MAJOR_VERSION, 4): { |
2754 | 25 | PKGCONFIG += libsignon-qt accounts-qt | 25 | PKGCONFIG += libsignon-qt accounts-qt |
2755 | 26 | 26 | ||
2756 | === modified file 'msyncd/synchronizer.cpp' | |||
2757 | --- msyncd/synchronizer.cpp 2015-03-12 04:06:41 +0000 | |||
2758 | +++ msyncd/synchronizer.cpp 2015-09-30 18:13:56 +0000 | |||
2759 | @@ -1,4 +1,4 @@ | |||
2761 | 1 | /* | 1 | /* |
2762 | 2 | * This file is part of buteo-syncfw package | 2 | * This file is part of buteo-syncfw package |
2763 | 3 | * | 3 | * |
2764 | 4 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 4 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2765 | @@ -21,6 +21,7 @@ | |||
2766 | 21 | * 02110-1301 USA | 21 | * 02110-1301 USA |
2767 | 22 | * | 22 | * |
2768 | 23 | */ | 23 | */ |
2769 | 24 | #include <gio/gio.h> | ||
2770 | 24 | #include "synchronizer.h" | 25 | #include "synchronizer.h" |
2771 | 25 | #include "SyncDBusAdaptor.h" | 26 | #include "SyncDBusAdaptor.h" |
2772 | 26 | #include "SyncSession.h" | 27 | #include "SyncSession.h" |
2773 | @@ -51,11 +52,11 @@ | |||
2774 | 51 | #include <fcntl.h> | 52 | #include <fcntl.h> |
2775 | 52 | #include <termios.h> | 53 | #include <termios.h> |
2776 | 53 | 54 | ||
2777 | 55 | |||
2778 | 54 | using namespace Buteo; | 56 | using namespace Buteo; |
2779 | 55 | 57 | ||
2780 | 56 | static const QString SYNC_DBUS_OBJECT = "/synchronizer"; | 58 | static const QString SYNC_DBUS_OBJECT = "/synchronizer"; |
2781 | 57 | static const QString SYNC_DBUS_SERVICE = "com.meego.msyncd"; | 59 | static const QString SYNC_DBUS_SERVICE = "com.meego.msyncd"; |
2782 | 58 | |||
2783 | 59 | static const QString BT_PROPERTIES_NAME = "Name"; | 60 | static const QString BT_PROPERTIES_NAME = "Name"; |
2784 | 60 | 61 | ||
2785 | 61 | // Maximum time in milliseconds to wait for a thread to stop | 62 | // Maximum time in milliseconds to wait for a thread to stop |
2786 | @@ -71,10 +72,9 @@ | |||
2787 | 71 | iClosing(false), | 72 | iClosing(false), |
2788 | 72 | iSOCEnabled(false), | 73 | iSOCEnabled(false), |
2789 | 73 | iSyncUIInterface(NULL) | 74 | iSyncUIInterface(NULL) |
2790 | 74 | |||
2791 | 75 | { | 75 | { |
2792 | 76 | iSettings = g_settings_new_with_path("com.meego.msyncd", "/com/meego/msyncd/"); | ||
2793 | 76 | FUNCTION_CALL_TRACE; | 77 | FUNCTION_CALL_TRACE; |
2794 | 77 | |||
2795 | 78 | this->setParent(aApplication); | 78 | this->setParent(aApplication); |
2796 | 79 | } | 79 | } |
2797 | 80 | 80 | ||
2798 | @@ -86,6 +86,7 @@ | |||
2799 | 86 | delete iSyncUIInterface; | 86 | delete iSyncUIInterface; |
2800 | 87 | iSyncUIInterface = NULL; | 87 | iSyncUIInterface = NULL; |
2801 | 88 | } | 88 | } |
2802 | 89 | g_object_unref(iSettings); | ||
2803 | 89 | } | 90 | } |
2804 | 90 | 91 | ||
2805 | 91 | bool Synchronizer::initialize() | 92 | bool Synchronizer::initialize() |
2806 | @@ -115,8 +116,9 @@ | |||
2807 | 115 | this, SLOT(slotSyncStatus(QString, int, QString, int)), | 116 | this, SLOT(slotSyncStatus(QString, int, QString, int)), |
2808 | 116 | Qt::QueuedConnection); | 117 | Qt::QueuedConnection); |
2809 | 117 | 118 | ||
2810 | 119 | // use queued connection because the profile will be stored after the signal | ||
2811 | 118 | connect(&iProfileManager ,SIGNAL(signalProfileChanged(QString,int,QString)), | 120 | connect(&iProfileManager ,SIGNAL(signalProfileChanged(QString,int,QString)), |
2813 | 119 | this, SIGNAL(signalProfileChanged(QString,int,QString))); | 121 | this, SLOT(slotProfileChanged(QString,int,QString)), Qt::QueuedConnection); |
2814 | 120 | 122 | ||
2815 | 121 | iNetworkManager = new NetworkManager(this); | 123 | iNetworkManager = new NetworkManager(this); |
2816 | 122 | Q_ASSERT(iNetworkManager); | 124 | Q_ASSERT(iNetworkManager); |
2817 | @@ -127,8 +129,9 @@ | |||
2818 | 127 | { | 129 | { |
2819 | 128 | iServerActivator = new ServerActivator(iProfileManager, | 130 | iServerActivator = new ServerActivator(iProfileManager, |
2820 | 129 | *iTransportTracker, this); | 131 | *iTransportTracker, this); |
2823 | 130 | connect(iTransportTracker, SIGNAL(networkStateChanged(bool)), | 132 | connect(iTransportTracker, |
2824 | 131 | this, SLOT(onNetworkStateChanged(bool))); | 133 | SIGNAL(networkStateChanged(bool,Sync::InternetConnectionType)), |
2825 | 134 | SLOT(onNetworkStateChanged(bool,Sync::InternetConnectionType))); | ||
2826 | 132 | } | 135 | } |
2827 | 133 | 136 | ||
2828 | 134 | // Initialize account manager. | 137 | // Initialize account manager. |
2829 | @@ -184,7 +187,7 @@ | |||
2830 | 184 | else | 187 | else |
2831 | 185 | { | 188 | { |
2832 | 186 | QObject::connect(&iSyncOnChangeScheduler, SIGNAL(syncNow(QString)), | 189 | QObject::connect(&iSyncOnChangeScheduler, SIGNAL(syncNow(QString)), |
2834 | 187 | this, SLOT(startSync(QString)), | 190 | this, SLOT(startScheduledSync(QString)), |
2835 | 188 | Qt::QueuedConnection); | 191 | Qt::QueuedConnection); |
2836 | 189 | iSOCEnabled = true; | 192 | iSOCEnabled = true; |
2837 | 190 | } | 193 | } |
2838 | @@ -200,7 +203,7 @@ | |||
2839 | 200 | { | 203 | { |
2840 | 201 | FUNCTION_CALL_TRACE; | 204 | FUNCTION_CALL_TRACE; |
2841 | 202 | SyncProfile* profile = iProfileManager.syncProfile(aProfileName); | 205 | SyncProfile* profile = iProfileManager.syncProfile(aProfileName); |
2843 | 203 | if(!iSOCEnabled) | 206 | if(profile->isSOCProfile() && !iSOCEnabled) |
2844 | 204 | { | 207 | { |
2845 | 205 | QHash<QString,QList<SyncProfile*> > aSOCStorageMap; | 208 | QHash<QString,QList<SyncProfile*> > aSOCStorageMap; |
2846 | 206 | QList<SyncProfile*> SOCProfiles; | 209 | QList<SyncProfile*> SOCProfiles; |
2847 | @@ -217,13 +220,13 @@ | |||
2848 | 217 | else | 220 | else |
2849 | 218 | { | 221 | { |
2850 | 219 | QObject::connect(&iSyncOnChangeScheduler, SIGNAL(syncNow(const QString&)), | 222 | QObject::connect(&iSyncOnChangeScheduler, SIGNAL(syncNow(const QString&)), |
2852 | 220 | this, SLOT(startSync(const QString&)), | 223 | this, SLOT(startScheduledSync(const QString&)), |
2853 | 221 | Qt::QueuedConnection); | 224 | Qt::QueuedConnection); |
2854 | 222 | iSOCEnabled = true; | 225 | iSOCEnabled = true; |
2855 | 223 | LOG_DEBUG("Sync on change enabled for profile" << aProfileName); | 226 | LOG_DEBUG("Sync on change enabled for profile" << aProfileName); |
2856 | 224 | } | 227 | } |
2857 | 225 | } | 228 | } |
2859 | 226 | else | 229 | else if (profile->isSOCProfile()) |
2860 | 227 | { | 230 | { |
2861 | 228 | iSyncOnChange.addProfile("hcontacts", profile); | 231 | iSyncOnChange.addProfile("hcontacts", profile); |
2862 | 229 | } | 232 | } |
2863 | @@ -291,55 +294,27 @@ | |||
2864 | 291 | // All scheduled syncs are online syncs | 294 | // All scheduled syncs are online syncs |
2865 | 292 | // Add this to the waiting online syncs and it will be started when we | 295 | // Add this to the waiting online syncs and it will be started when we |
2866 | 293 | // receive a session connection status from the NetworkManager | 296 | // receive a session connection status from the NetworkManager |
2869 | 294 | bool sessionConnected = !iWaitingOnlineSyncs.isEmpty(); | 297 | bool accept = acceptScheduledSync(iNetworkManager->isOnline(), iNetworkManager->connectionType()); |
2870 | 295 | if(!iWaitingOnlineSyncs.contains(aProfileName)) | 298 | if(accept) |
2871 | 296 | { | 299 | { |
2873 | 297 | iWaitingOnlineSyncs.append(aProfileName); | 300 | startSync(aProfileName, true); |
2874 | 298 | } | 301 | } |
2876 | 299 | if(!sessionConnected) | 302 | else if (!iWaitingOnlineSyncs.contains(aProfileName)) |
2877 | 300 | { | 303 | { |
2884 | 301 | QObject::connect(iNetworkManager, SIGNAL(connectionSuccess()), this, | 304 | LOG_DEBUG("Wait for internet connection:" << aProfileName); |
2885 | 302 | SLOT(slotNetworkSessionOpened()), Qt::QueuedConnection); | 305 | if (iNetworkManager->isOnline()) |
2886 | 303 | QObject::connect(iNetworkManager, SIGNAL(connectionError()), this, | 306 | { |
2887 | 304 | SLOT(slotNetworkSessionError()), Qt::QueuedConnection); | 307 | LOG_DEBUG("Connection over mobile data plan. The sync will be postponed untill a full connection is available;"); |
2888 | 305 | // Request for a network session | 308 | } |
2889 | 306 | iNetworkManager->connectSession(true); | 309 | else |
2890 | 310 | { | ||
2891 | 311 | LOG_DEBUG("Device offline. Wait for internet connection."); | ||
2892 | 312 | } | ||
2893 | 313 | iWaitingOnlineSyncs.append(aProfileName); | ||
2894 | 307 | } | 314 | } |
2895 | 308 | return true; | 315 | return true; |
2896 | 309 | } | 316 | } |
2897 | 310 | 317 | ||
2898 | 311 | void Synchronizer::slotNetworkSessionOpened() | ||
2899 | 312 | { | ||
2900 | 313 | FUNCTION_CALL_TRACE; | ||
2901 | 314 | QObject::disconnect(iNetworkManager, SIGNAL(connectionSuccess()), this, | ||
2902 | 315 | SLOT(slotNetworkSessionOpened())); | ||
2903 | 316 | QObject::disconnect(iNetworkManager, SIGNAL(connectionError()), this, | ||
2904 | 317 | SLOT(slotNetworkSessionError())); | ||
2905 | 318 | foreach(QString profileName, iWaitingOnlineSyncs) | ||
2906 | 319 | { | ||
2907 | 320 | startSync(profileName, true); | ||
2908 | 321 | } | ||
2909 | 322 | iWaitingOnlineSyncs.clear(); | ||
2910 | 323 | } | ||
2911 | 324 | |||
2912 | 325 | void Synchronizer::slotNetworkSessionError() | ||
2913 | 326 | { | ||
2914 | 327 | FUNCTION_CALL_TRACE; | ||
2915 | 328 | QObject::disconnect(iNetworkManager, SIGNAL(connectionSuccess()), this, | ||
2916 | 329 | SLOT(slotNetworkSessionOpened())); | ||
2917 | 330 | QObject::disconnect(iNetworkManager, SIGNAL(connectionError()), this, | ||
2918 | 331 | SLOT(slotNetworkSessionError())); | ||
2919 | 332 | // Cancel all open sessions | ||
2920 | 333 | foreach(QString profileName, iWaitingOnlineSyncs) | ||
2921 | 334 | { | ||
2922 | 335 | SyncResults syncResults(QDateTime::currentDateTime(), SyncResults::SYNC_RESULT_FAILED, SyncResults::CONNECTION_ERROR); | ||
2923 | 336 | iProfileManager.saveSyncResults(profileName, syncResults); | ||
2924 | 337 | reschedule(profileName); | ||
2925 | 338 | } | ||
2926 | 339 | iWaitingOnlineSyncs.clear(); | ||
2927 | 340 | iNetworkManager->disconnectSession(); | ||
2928 | 341 | } | ||
2929 | 342 | |||
2930 | 343 | bool Synchronizer::setSyncSchedule(QString aProfileId , QString aScheduleAsXml) | 318 | bool Synchronizer::setSyncSchedule(QString aProfileId , QString aScheduleAsXml) |
2931 | 344 | { | 319 | { |
2932 | 345 | bool status = false; | 320 | bool status = false; |
2933 | @@ -364,6 +339,11 @@ | |||
2934 | 364 | return status; | 339 | return status; |
2935 | 365 | } | 340 | } |
2936 | 366 | 341 | ||
2937 | 342 | QString Synchronizer::createSyncProfileForAccount(uint aAccountId) | ||
2938 | 343 | { | ||
2939 | 344 | return iAccounts->createProfileForAccount(aAccountId); | ||
2940 | 345 | } | ||
2941 | 346 | |||
2942 | 367 | bool Synchronizer::startSync(const QString &aProfileName, bool aScheduled) | 347 | bool Synchronizer::startSync(const QString &aProfileName, bool aScheduled) |
2943 | 368 | { | 348 | { |
2944 | 369 | FUNCTION_CALL_TRACE; | 349 | FUNCTION_CALL_TRACE; |
2945 | @@ -378,6 +358,12 @@ | |||
2946 | 378 | 358 | ||
2947 | 379 | LOG_DEBUG( "Start sync requested for profile:" << aProfileName ); | 359 | LOG_DEBUG( "Start sync requested for profile:" << aProfileName ); |
2948 | 380 | 360 | ||
2949 | 361 | // This function can be called from a client app as manual sync: | ||
2950 | 362 | // If we receive a manual sync to a profile that is peding to sync due a | ||
2951 | 363 | // data change we can remove it from the iSyncOnChangeScheduler, to avoid a | ||
2952 | 364 | // second sync. | ||
2953 | 365 | iSyncOnChangeScheduler.removeProfile(aProfileName); | ||
2954 | 366 | |||
2955 | 381 | if (iActiveSessions.contains(aProfileName)) | 367 | if (iActiveSessions.contains(aProfileName)) |
2956 | 382 | { | 368 | { |
2957 | 383 | LOG_DEBUG( "Sync already in progress" ); | 369 | LOG_DEBUG( "Sync already in progress" ); |
2958 | @@ -389,6 +375,14 @@ | |||
2959 | 389 | emit syncStatus(aProfileName, Sync::SYNC_QUEUED, "", 0); | 375 | emit syncStatus(aProfileName, Sync::SYNC_QUEUED, "", 0); |
2960 | 390 | return true; | 376 | return true; |
2961 | 391 | } | 377 | } |
2962 | 378 | else if (!aScheduled && iWaitingOnlineSyncs.contains(aProfileName)) | ||
2963 | 379 | { | ||
2964 | 380 | // Manual sync is allowed to happen in any kind of connection | ||
2965 | 381 | // if sync is not scheduled remove it from iWaitingOnlineSyncs to avoid | ||
2966 | 382 | // sync it twice later | ||
2967 | 383 | iWaitingOnlineSyncs.removeOne(aProfileName); | ||
2968 | 384 | LOG_DEBUG("Removing" << aProfileName << "from online waiting list."); | ||
2969 | 385 | } | ||
2970 | 392 | 386 | ||
2971 | 393 | SyncProfile *profile = iProfileManager.syncProfile(aProfileName); | 387 | SyncProfile *profile = iProfileManager.syncProfile(aProfileName); |
2972 | 394 | if (!profile) | 388 | if (!profile) |
2973 | @@ -520,7 +514,7 @@ | |||
2974 | 520 | return false; | 514 | return false; |
2975 | 521 | } | 515 | } |
2976 | 522 | 516 | ||
2978 | 523 | LOG_DEBUG("Disable sync on change"); | 517 | LOG_DEBUG("Disable sync on change:" << iSOCEnabled << profile->isSOCProfile()); |
2979 | 524 | //As sync is ongoing, disable sync on change for now, we can query later if | 518 | //As sync is ongoing, disable sync on change for now, we can query later if |
2980 | 525 | //there are changes. | 519 | //there are changes. |
2981 | 526 | if(iSOCEnabled) | 520 | if(iSOCEnabled) |
2982 | @@ -754,7 +748,7 @@ | |||
2983 | 754 | } | 748 | } |
2984 | 755 | 749 | ||
2985 | 756 | QString profileName = session->profileName(); | 750 | QString profileName = session->profileName(); |
2987 | 757 | LOG_DEBUG( "Trying to start next sync in queue. Profile:" << profileName ); | 751 | LOG_DEBUG( "Trying to start next sync in queue. Profile:" << profileName << session->isScheduled()); |
2988 | 758 | 752 | ||
2989 | 759 | #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) | 753 | #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) |
2990 | 760 | QBatteryInfo iDeviceInfo; | 754 | QBatteryInfo iDeviceInfo; |
2991 | @@ -1516,6 +1510,41 @@ | |||
2992 | 1516 | } | 1510 | } |
2993 | 1517 | } | 1511 | } |
2994 | 1518 | 1512 | ||
2995 | 1513 | void Synchronizer::slotProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml) | ||
2996 | 1514 | { | ||
2997 | 1515 | // start sync when a new profile is added | ||
2998 | 1516 | switch (aChangeType) | ||
2999 | 1517 | { | ||
3000 | 1518 | case ProfileManager::PROFILE_ADDED: | ||
3001 | 1519 | { | ||
3002 | 1520 | enableSOCSlot(aProfileName); | ||
3003 | 1521 | SyncProfile *profile = iProfileManager.syncProfile(aProfileName); | ||
3004 | 1522 | if (profile && profile->isEnabled()) { | ||
3005 | 1523 | startSync(aProfileName); | ||
3006 | 1524 | } | ||
3007 | 1525 | } | ||
3008 | 1526 | break; | ||
3009 | 1527 | |||
3010 | 1528 | case ProfileManager::PROFILE_REMOVED: | ||
3011 | 1529 | iSyncOnChangeScheduler.removeProfile(aProfileName); | ||
3012 | 1530 | iWaitingOnlineSyncs.removeAll(aProfileName); | ||
3013 | 1531 | break; | ||
3014 | 1532 | |||
3015 | 1533 | case ProfileManager::PROFILE_MODIFIED: | ||
3016 | 1534 | { | ||
3017 | 1535 | // schedule a new sync in case of profile changed; | ||
3018 | 1536 | // Example if the profile change from disable -> enable | ||
3019 | 1537 | SyncProfile *profile = iProfileManager.syncProfile(aProfileName); | ||
3020 | 1538 | if (profile->isEnabled()) { | ||
3021 | 1539 | startScheduledSync(aProfileName); | ||
3022 | 1540 | } | ||
3023 | 1541 | } | ||
3024 | 1542 | break; | ||
3025 | 1543 | } | ||
3026 | 1544 | |||
3027 | 1545 | emit signalProfileChanged(aProfileName, aChangeType, aProfileAsXml); | ||
3028 | 1546 | } | ||
3029 | 1547 | |||
3030 | 1519 | void Synchronizer::reschedule(const QString &aProfileName) | 1548 | void Synchronizer::reschedule(const QString &aProfileName) |
3031 | 1520 | { | 1549 | { |
3032 | 1521 | FUNCTION_CALL_TRACE; | 1550 | FUNCTION_CALL_TRACE; |
3033 | @@ -1903,10 +1932,24 @@ | |||
3034 | 1903 | return iProfileManager.profileNames(aType); | 1932 | return iProfileManager.profileNames(aType); |
3035 | 1904 | } | 1933 | } |
3036 | 1905 | 1934 | ||
3038 | 1906 | void Synchronizer::onNetworkStateChanged(bool aState) | 1935 | void Synchronizer::onNetworkStateChanged(bool aState, Sync::InternetConnectionType type) |
3039 | 1907 | { | 1936 | { |
3040 | 1908 | FUNCTION_CALL_TRACE; | 1937 | FUNCTION_CALL_TRACE; |
3042 | 1909 | if(!aState) { | 1938 | LOG_DEBUG("Network state changed: OnLine:" << aState << " connection type:" << type); |
3043 | 1939 | if (acceptScheduledSync(aState, type)) | ||
3044 | 1940 | { | ||
3045 | 1941 | LOG_DEBUG("Restart sync for profiles that need network"); | ||
3046 | 1942 | QStringList profiles(iWaitingOnlineSyncs); | ||
3047 | 1943 | iWaitingOnlineSyncs.clear(); | ||
3048 | 1944 | foreach(QString profileName, profiles) | ||
3049 | 1945 | { | ||
3050 | 1946 | // start sync now, we do not need to call 'startScheduledSync' since that function | ||
3051 | 1947 | // only checks for internet connection | ||
3052 | 1948 | startSync(profileName, true); | ||
3053 | 1949 | } | ||
3054 | 1950 | } | ||
3055 | 1951 | else if (!aState) | ||
3056 | 1952 | { | ||
3057 | 1910 | QList<QString> profiles = iActiveSessions.keys(); | 1953 | QList<QString> profiles = iActiveSessions.keys(); |
3058 | 1911 | foreach(QString profileId, profiles) | 1954 | foreach(QString profileId, profiles) |
3059 | 1912 | { | 1955 | { |
3060 | @@ -1919,8 +1962,8 @@ | |||
3061 | 1919 | delete profile; | 1962 | delete profile; |
3062 | 1920 | profile = NULL; | 1963 | profile = NULL; |
3063 | 1921 | } | 1964 | } |
3066 | 1922 | else { | 1965 | else |
3067 | 1923 | 1966 | { | |
3068 | 1924 | LOG_DEBUG("No profile found with aProfileId"<<profileId); | 1967 | LOG_DEBUG("No profile found with aProfileId"<<profileId); |
3069 | 1925 | } | 1968 | } |
3070 | 1926 | } | 1969 | } |
3071 | @@ -2069,6 +2112,19 @@ | |||
3072 | 2069 | } | 2112 | } |
3073 | 2070 | } | 2113 | } |
3074 | 2071 | 2114 | ||
3075 | 2115 | bool Synchronizer::acceptScheduledSync(bool aConnected, Sync::InternetConnectionType aType) const | ||
3076 | 2116 | { | ||
3077 | 2117 | static QList<Sync::InternetConnectionType> allowedTypes; | ||
3078 | 2118 | if (allowedTypes.isEmpty()) | ||
3079 | 2119 | { | ||
3080 | 2120 | allowedTypes << Sync::INTERNET_CONNECTION_WLAN | ||
3081 | 2121 | << Sync::INTERNET_CONNECTION_ETHERNET; | ||
3082 | 2122 | } | ||
3083 | 2123 | |||
3084 | 2124 | return (aConnected && (g_settings_get_boolean(iSettings, "allow-scheduled-sync-over-cellular") || | ||
3085 | 2125 | allowedTypes.contains(aType))); | ||
3086 | 2126 | } | ||
3087 | 2127 | |||
3088 | 2072 | void Synchronizer::isSyncedExternally(unsigned int aAccountId, const QString aClientProfileName) | 2128 | void Synchronizer::isSyncedExternally(unsigned int aAccountId, const QString aClientProfileName) |
3089 | 2073 | { | 2129 | { |
3090 | 2074 | LOG_DEBUG("Received isSyncedExternally request for account:" << aAccountId); | 2130 | LOG_DEBUG("Received isSyncedExternally request for account:" << aAccountId); |
3091 | 2075 | 2131 | ||
3092 | === modified file 'msyncd/synchronizer.h' | |||
3093 | --- msyncd/synchronizer.h 2015-03-06 13:13:09 +0000 | |||
3094 | +++ msyncd/synchronizer.h 2015-09-30 18:13:56 +0000 | |||
3095 | @@ -44,7 +44,9 @@ | |||
3096 | 44 | #include <QMap> | 44 | #include <QMap> |
3097 | 45 | #include <QString> | 45 | #include <QString> |
3098 | 46 | #include <QDBusInterface> | 46 | #include <QDBusInterface> |
3099 | 47 | #include <QScopedPointer> | ||
3100 | 47 | 48 | ||
3101 | 49 | struct _GSettings; | ||
3102 | 48 | 50 | ||
3103 | 49 | namespace Buteo { | 51 | namespace Buteo { |
3104 | 50 | 52 | ||
3105 | @@ -137,6 +139,9 @@ | |||
3106 | 137 | //! \see SyncDBusInterface::saveSyncResults | 139 | //! \see SyncDBusInterface::saveSyncResults |
3107 | 138 | virtual bool saveSyncResults(QString aProfileId,QString aSyncResults); | 140 | virtual bool saveSyncResults(QString aProfileId,QString aSyncResults); |
3108 | 139 | 141 | ||
3109 | 142 | //! \see SyncDBusInterface::createSyncProfileForAccount | ||
3110 | 143 | virtual QString createSyncProfileForAccount(uint aAccountId); | ||
3111 | 144 | |||
3112 | 140 | /*! \brief To get lastSyncResult. | 145 | /*! \brief To get lastSyncResult. |
3113 | 141 | * \param aProfileId | 146 | * \param aProfileId |
3114 | 142 | * \return QString of syncResult. | 147 | * \return QString of syncResult. |
3115 | @@ -257,9 +262,7 @@ | |||
3116 | 257 | 262 | ||
3117 | 258 | void onNewSession(const QString &aDestination); | 263 | void onNewSession(const QString &aDestination); |
3118 | 259 | 264 | ||
3122 | 260 | void slotNetworkSessionOpened(); | 265 | void slotProfileChanged(QString aProfileName, int aChangeType , QString aProfileAsXml); |
3120 | 261 | |||
3121 | 262 | void slotNetworkSessionError(); | ||
3123 | 263 | 266 | ||
3124 | 264 | /*! \brief Starts a server plug-in | 267 | /*! \brief Starts a server plug-in |
3125 | 265 | * | 268 | * |
3126 | @@ -273,7 +276,7 @@ | |||
3127 | 273 | */ | 276 | */ |
3128 | 274 | void stopServer(const QString &aProfileName); | 277 | void stopServer(const QString &aProfileName); |
3129 | 275 | 278 | ||
3131 | 276 | void onNetworkStateChanged(bool aState); | 279 | void onNetworkStateChanged(bool aState, Sync::InternetConnectionType type); |
3132 | 277 | 280 | ||
3133 | 278 | /*! \brief call this to request the sync daemon to enable soc | 281 | /*! \brief call this to request the sync daemon to enable soc |
3134 | 279 | * for a profile. The sync daemon decides as of now for which storages | 282 | * for a profile. The sync daemon decides as of now for which storages |
3135 | @@ -385,6 +388,12 @@ | |||
3136 | 385 | */ | 388 | */ |
3137 | 386 | void removeExternalSyncStatus(const SyncProfile *aProfile); | 389 | void removeExternalSyncStatus(const SyncProfile *aProfile); |
3138 | 387 | 390 | ||
3139 | 391 | /*! \brief Check if sheduled sync is allowed for this type of connection. | ||
3140 | 392 | * | ||
3141 | 393 | * @param aType the connection type; | ||
3142 | 394 | */ | ||
3143 | 395 | bool acceptScheduledSync(bool aConnected, Sync::InternetConnectionType aType) const; | ||
3144 | 396 | |||
3145 | 388 | QMap<QString, SyncSession*> iActiveSessions; | 397 | QMap<QString, SyncSession*> iActiveSessions; |
3146 | 389 | 398 | ||
3147 | 390 | QMap<QString, bool> iExternalSyncProfileStatus; | 399 | QMap<QString, bool> iExternalSyncProfileStatus; |
3148 | @@ -446,6 +455,7 @@ | |||
3149 | 446 | #endif | 455 | #endif |
3150 | 447 | 456 | ||
3151 | 448 | QDBusInterface *iSyncUIInterface; | 457 | QDBusInterface *iSyncUIInterface; |
3152 | 458 | _GSettings *iSettings; | ||
3153 | 449 | }; | 459 | }; |
3154 | 450 | 460 | ||
3155 | 451 | } | 461 | } |
3156 | 452 | 462 | ||
3157 | === modified file 'unittests/tests/msyncdtests/TransportTrackerTest.cpp' | |||
3158 | --- unittests/tests/msyncdtests/TransportTrackerTest.cpp 2014-06-19 06:03:36 +0000 | |||
3159 | +++ unittests/tests/msyncdtests/TransportTrackerTest.cpp 2015-09-30 18:13:56 +0000 | |||
3160 | @@ -89,7 +89,7 @@ | |||
3161 | 89 | { | 89 | { |
3162 | 90 | qRegisterMetaType<Sync::ConnectivityType>("Sync::ConnectivityType"); | 90 | qRegisterMetaType<Sync::ConnectivityType>("Sync::ConnectivityType"); |
3163 | 91 | QSignalSpy connectivityStateSpy(iTransportTracker, SIGNAL(connectivityStateChanged(Sync::ConnectivityType, bool))); | 91 | QSignalSpy connectivityStateSpy(iTransportTracker, SIGNAL(connectivityStateChanged(Sync::ConnectivityType, bool))); |
3165 | 92 | QSignalSpy networkStateSpy(iTransportTracker, SIGNAL(networkStateChanged(bool))); | 92 | QSignalSpy networkStateSpy(iTransportTracker, SIGNAL(networkStateChanged(bool,Sync::InternetConnectionType))); |
3166 | 93 | 93 | ||
3167 | 94 | // change USB state and verify | 94 | // change USB state and verify |
3168 | 95 | bool usbCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_USB); | 95 | bool usbCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_USB); |
3169 | @@ -115,7 +115,7 @@ | |||
3170 | 115 | 115 | ||
3171 | 116 | // change internet state and verify | 116 | // change internet state and verify |
3172 | 117 | bool internetCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_INTERNET); | 117 | bool internetCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_INTERNET); |
3174 | 118 | iTransportTracker->onInternetStateChanged(!internetCurrentState); | 118 | iTransportTracker->onInternetStateChanged(!internetCurrentState, Sync::INTERNET_CONNECTION_UNKNOWN); |
3175 | 119 | QCOMPARE(iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_INTERNET), !internetCurrentState); | 119 | QCOMPARE(iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_INTERNET), !internetCurrentState); |
3176 | 120 | QEXPECT_FAIL("", "IMO connectivityStateChanged() should be emitted also for CONNECTIVITY_INTERNET", Continue); | 120 | QEXPECT_FAIL("", "IMO connectivityStateChanged() should be emitted also for CONNECTIVITY_INTERNET", Continue); |
3177 | 121 | QCOMPARE(connectivityStateSpy.count(), 1); | 121 | QCOMPARE(connectivityStateSpy.count(), 1); |
Looks good