@@ -21,6 +21,7 @@
2121
2222#include <QFile>
2323#include <QStringList>
24+#include <QDebug>
2425
2526AccountsService::AccountsService(QObject* parent)
2627 : QObject(parent),
@@ -56,15 +57,15 @@ void AccountsService::setUser(const QString &user)
5657 m_user = user;
5758 Q_EMIT userChanged();
5859
59− updateDemoEdges();
60− updateEnableLauncherWhileLocked();
61− updateEnableIndicatorsWhileLocked();
62− updateBackgroundFile();
63− updateStatsWelcomeScreen();
64− updatePasswordDisplayHint();
65− updateFailedLogins();
66− updateHereEnabled();
67− updateHereLicensePath();
60+ updateDemoEdges(false);
61+ updateEnableLauncherWhileLocked(false);
62+ updateEnableIndicatorsWhileLocked(false);
63+ updateBackgroundFile(false);
64+ updateStatsWelcomeScreen(false);
65+ updatePasswordDisplayHint(false);
66+ updateFailedLogins(false);
67+ updateHereEnabled(false);
68+ updateHereLicensePath(false);
6869}
6970
7071bool AccountsService::demoEdges() const
@@ -123,89 +124,232 @@ bool AccountsService::hereLicensePathValid() const
123124 return !m_hereLicensePath.isNull();
124125}
125126
126−void AccountsService::updateDemoEdges()
127+void AccountsService::updateDemoEdges(bool async)
127128{
128− auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
129− if (m_demoEdges != demoEdges) {
130− m_demoEdges = demoEdges;
131− Q_EMIT demoEdgesChanged();
132− }
129+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.canonical.unity.AccountsService", "demo-edges");
130+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
131+
132+ connect(watcher, &QDBusPendingCallWatcher::finished,
133+ this, [this](QDBusPendingCallWatcher* watcher) {
134+
135+ QDBusPendingReply<QDBusVariant> reply = *watcher;
136+ if (reply.isError()) {
137+ qWarning() << "Failed to get 'demo-edges' property";
138+ watcher->deleteLater();
139+ return;
140+ }
141+
142+ auto demoEdges = reply.value().variant().toBool();
143+ if (m_demoEdges != demoEdges) {
144+ m_demoEdges = demoEdges;
145+ Q_EMIT demoEdgesChanged();
146+ }
147+ watcher->deleteLater();
148+ });
149+ if (!async) watcher->waitForFinished();
133150}
134151
135−void AccountsService::updateEnableLauncherWhileLocked()
152+void AccountsService::updateEnableLauncherWhileLocked(bool async)
136153{
137− auto enableLauncherWhileLocked = m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableLauncherWhileLocked").toBool();
138− if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
139− m_enableLauncherWhileLocked = enableLauncherWhileLocked;
140− Q_EMIT enableLauncherWhileLockedChanged();
141− }
154+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableLauncherWhileLocked");
155+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
156+
157+ connect(watcher, &QDBusPendingCallWatcher::finished,
158+ this, [this](QDBusPendingCallWatcher* watcher) {
159+
160+ QDBusPendingReply<QDBusVariant> reply = *watcher;
161+ if (reply.isError()) {
162+ qWarning() << "Failed to get 'EnableLauncherWhileLocked' property";
163+ watcher->deleteLater();
164+ return;
165+ }
166+
167+ auto enableLauncherWhileLocked = reply.value().variant().toBool();
168+ if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
169+ m_enableLauncherWhileLocked = enableLauncherWhileLocked;
170+ Q_EMIT enableLauncherWhileLockedChanged();
171+ }
172+ watcher->deleteLater();
173+ });
174+ if (!async) watcher->waitForFinished();
142175}
143176
144−void AccountsService::updateEnableIndicatorsWhileLocked()
177+void AccountsService::updateEnableIndicatorsWhileLocked(bool async)
145178{
146− auto enableIndicatorsWhileLocked = m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableIndicatorsWhileLocked").toBool();
147− if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
148− m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
149− Q_EMIT enableIndicatorsWhileLockedChanged();
150− }
179+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableIndicatorsWhileLocked");
180+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
181+
182+ connect(watcher, &QDBusPendingCallWatcher::finished,
183+ this, [this](QDBusPendingCallWatcher* watcher) {
184+
185+ QDBusPendingReply<QDBusVariant> reply = *watcher;
186+ if (reply.isError()) {
187+ qWarning() << "Failed to get 'EnableIndicatorsWhileLocked' property";
188+ watcher->deleteLater();
189+ return;
190+ }
191+
192+ auto enableIndicatorsWhileLocked = reply.value().variant().toBool();
193+ if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
194+ m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
195+ Q_EMIT enableIndicatorsWhileLockedChanged();
196+ }
197+ watcher->deleteLater();
198+ });
199+ if (!async) watcher->waitForFinished();
151200}
152201
153−void AccountsService::updateBackgroundFile()
202+void AccountsService::updateBackgroundFile(bool async)
154203{
155− QString backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
156− if (m_backgroundFile != backgroundFile) {
157− m_backgroundFile = backgroundFile;
158− Q_EMIT backgroundFileChanged();
159− }
204+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "org.freedesktop.Accounts.User", "BackgroundFile");
205+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
206+
207+ connect(watcher, &QDBusPendingCallWatcher::finished,
208+ this, [this](QDBusPendingCallWatcher* watcher) {
209+
210+ QDBusPendingReply<QDBusVariant> reply = *watcher;
211+ if (reply.isError()) {
212+ qWarning() << "Failed to get 'BackgroundFile' property";
213+ watcher->deleteLater();
214+ return;
215+ }
216+
217+ auto backgroundFile = reply.value().variant().toString();
218+ if (m_backgroundFile != backgroundFile) {
219+ m_backgroundFile = backgroundFile;
220+ Q_EMIT backgroundFileChanged();
221+ }
222+ watcher->deleteLater();
223+ });
224+ if (!async) watcher->waitForFinished();
160225}
161226
162−void AccountsService::updateStatsWelcomeScreen()
227+void AccountsService::updateStatsWelcomeScreen(bool async)
163228{
164− bool statsWelcomeScreen = m_service->getUserProperty(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen").toBool();
165− if (m_statsWelcomeScreen != statsWelcomeScreen) {
166− m_statsWelcomeScreen = statsWelcomeScreen;
167− Q_EMIT statsWelcomeScreenChanged();
168− }
229+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen");
230+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
231+
232+ connect(watcher, &QDBusPendingCallWatcher::finished,
233+ this, [this](QDBusPendingCallWatcher* watcher) {
234+
235+ QDBusPendingReply<QDBusVariant> reply = *watcher;
236+ if (reply.isError()) {
237+ qWarning() << "Failed to get 'StatsWelcomeScreen' property";
238+ watcher->deleteLater();
239+ return;
240+ }
241+
242+ auto statsWelcomeScreen = reply.value().variant().toBool();
243+ if (m_statsWelcomeScreen != statsWelcomeScreen) {
244+ m_statsWelcomeScreen = statsWelcomeScreen;
245+ Q_EMIT statsWelcomeScreenChanged();
246+ }
247+ watcher->deleteLater();
248+ });
249+ if (!async) watcher->waitForFinished();
169250}
170251
171−void AccountsService::updatePasswordDisplayHint()
252+void AccountsService::updatePasswordDisplayHint(bool async)
172253{
173− PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "PasswordDisplayHint").toInt();
174− if (m_passwordDisplayHint != passwordDisplayHint) {
175− m_passwordDisplayHint = passwordDisplayHint;
176− Q_EMIT passwordDisplayHintChanged();
177− }
254+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen");
255+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
256+
257+ connect(watcher, &QDBusPendingCallWatcher::finished,
258+ this, [this](QDBusPendingCallWatcher* watcher) {
259+
260+ QDBusPendingReply<QDBusVariant> reply = *watcher;
261+ if (reply.isError()) {
262+ qWarning() << "Failed to get 'StatsWelcomeScreen' property";
263+ watcher->deleteLater();
264+ return;
265+ }
266+
267+ PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().variant().toInt();
268+ if (m_passwordDisplayHint != passwordDisplayHint) {
269+ m_passwordDisplayHint = passwordDisplayHint;
270+ Q_EMIT passwordDisplayHintChanged();
271+ }
272+ watcher->deleteLater();
273+ });
274+ if (!async) watcher->waitForFinished();
178275}
179276
180−void AccountsService::updateFailedLogins()
277+void AccountsService::updateFailedLogins(bool async)
181278{
182− uint failedLogins = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService.Private", "FailedLogins").toUInt();
183− if (m_failedLogins != failedLogins) {
184− m_failedLogins = failedLogins;
185− Q_EMIT failedLoginsChanged();
186− }
279+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.canonical.unity.AccountsService.Private", "FailedLogins");
280+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
281+
282+ connect(watcher, &QDBusPendingCallWatcher::finished,
283+ this, [this](QDBusPendingCallWatcher* watcher) {
284+
285+ QDBusPendingReply<QDBusVariant> reply = *watcher;
286+ if (reply.isError()) {
287+ qWarning() << "Failed to get 'FailedLogins' property";
288+ watcher->deleteLater();
289+ return;
290+ }
291+
292+ uint failedLogins = reply.value().variant().toUInt();
293+ if (m_failedLogins != failedLogins) {
294+ m_failedLogins = failedLogins;
295+ Q_EMIT failedLoginsChanged();
296+ }
297+ watcher->deleteLater();
298+ });
299+ if (!async) watcher->waitForFinished();
187300}
188301
189−void AccountsService::updateHereEnabled()
302+void AccountsService::updateHereEnabled(bool async)
190303{
191− bool hereEnabled = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted").toBool();
192− if (m_hereEnabled != hereEnabled) {
193− m_hereEnabled = hereEnabled;
194− Q_EMIT hereEnabledChanged();
195− }
304+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted");
305+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
306+
307+ connect(watcher, &QDBusPendingCallWatcher::finished,
308+ this, [this](QDBusPendingCallWatcher* watcher) {
309+
310+ QDBusPendingReply<QDBusVariant> reply = *watcher;
311+ if (reply.isError()) {
312+ qWarning() << "Failed to get 'LicenseAccepted' property";
313+ watcher->deleteLater();
314+ return;
315+ }
316+
317+ auto hereEnabled = reply.value().variant().toBool();
318+ if (m_hereEnabled != hereEnabled) {
319+ m_hereEnabled = hereEnabled;
320+ Q_EMIT hereEnabledChanged();
321+ }
322+ watcher->deleteLater();
323+ });
324+ if (!async) watcher->waitForFinished();
196325}
197326
198−void AccountsService::updateHereLicensePath()
327+void AccountsService::updateHereLicensePath(bool async)
199328{
200− QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
329+ QDBusPendingReply<QDBusVariant> pendingReply = m_service->getUserPropertyAsync(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath");
330+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
201331
202− if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
203− hereLicensePath = "";
332+ connect(watcher, &QDBusPendingCallWatcher::finished,
333+ this, [this](QDBusPendingCallWatcher* watcher) {
204334
205− if (m_hereLicensePath.isNull() || m_hereLicensePath != hereLicensePath) {
206− m_hereLicensePath = hereLicensePath;
207− Q_EMIT hereLicensePathChanged();
208− }
335+ QDBusPendingReply<QDBusVariant> reply = *watcher;
336+ if (reply.isError()) {
337+ qWarning() << "Failed to get 'LicenseBasePath' property";
338+ watcher->deleteLater();
339+ return;
340+ }
341+
342+ auto hereLicensePath = reply.value().variant().toString();
343+ if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
344+ hereLicensePath = "";
345+
346+ if (m_hereLicensePath.isNull() || m_hereLicensePath != hereLicensePath) {
347+ m_hereLicensePath = hereLicensePath;
348+ Q_EMIT hereLicensePathChanged();
349+ }
350+ watcher->deleteLater();
351+ });
352+ if (!async) watcher->waitForFinished();
209353}
210354
211355uint AccountsService::failedLogins() const