@@ -21,6 +21,7 @@
22#include <QFile>
22#include <QFile>
23#include <QStringList>
23#include <QStringList>
25AccountsService::AccountsService(QObject* parent)
26AccountsService::AccountsService(QObject* parent)
26 : QObject(parent),
27 : QObject(parent),
@@ -56,15 +57,15 @@ void AccountsService::setUser(const QString &user)
56 m_user = user;
57 m_user = user;
57 Q_EMIT userChanged();
58 Q_EMIT userChanged();
59− updateDemoEdges();
60+ updateDemoEdges(false);
60− updateEnableLauncherWhileLocked();
61+ updateEnableLauncherWhileLocked(false);
61− updateEnableIndicatorsWhileLocked();
62+ updateEnableIndicatorsWhileLocked(false);
62− updateBackgroundFile();
63+ updateBackgroundFile(false);
63− updateStatsWelcomeScreen();
64+ updateStatsWelcomeScreen(false);
64− updatePasswordDisplayHint();
65+ updatePasswordDisplayHint(false);
65− updateFailedLogins();
66+ updateFailedLogins(false);
66− updateHereEnabled();
67+ updateHereEnabled(false);
67− updateHereLicensePath();
68+ updateHereLicensePath(false);
70bool AccountsService::demoEdges() const
71bool AccountsService::demoEdges() const
@@ -74,8 +75,12 @@ bool AccountsService::demoEdges() const
75void AccountsService::setDemoEdges(bool demoEdges)
76void AccountsService::setDemoEdges(bool demoEdges)
78+ if (m_demoEdges != demoEdges) {
77− m_demoEdges = demoEdges;
79+ m_demoEdges = demoEdges;
78− m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
80+ m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
82+ Q_EMIT demoEdgesChanged();
81bool AccountsService::enableLauncherWhileLocked() const
86bool AccountsService::enableLauncherWhileLocked() const
@@ -110,7 +115,12 @@ bool AccountsService::hereEnabled() const
111void AccountsService::setHereEnabled(bool enabled)
116void AccountsService::setHereEnabled(bool enabled)
118+ if (m_hereEnabled != enabled) {
119+ m_hereEnabled = enabled;
113− m_service->setUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted", enabled);
120+ m_service->setUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted", enabled);
122+ Q_EMIT hereEnabledChanged();
116QString AccountsService::hereLicensePath() const
126QString AccountsService::hereLicensePath() const
@@ -123,88 +133,276 @@ bool AccountsService::hereLicensePathValid() const
123 return !m_hereLicensePath.isNull();
133 return !m_hereLicensePath.isNull();
126−void AccountsService::updateDemoEdges()
136+void AccountsService::updateDemoEdges(bool async)
138+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
128− auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
139+ "com.canonical.unity.AccountsService",
141+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
143+ connect(watcher, &QDBusPendingCallWatcher::finished,
144+ this, [this](QDBusPendingCallWatcher* watcher) {
146+ QDBusPendingReply<QDBusVariant> reply = *watcher;
147+ if (reply.isError()) {
148+ qWarning() << "Failed to get 'demo-edges' property - " << reply.error().message();
149+ watcher->deleteLater();
153+ auto demoEdges = reply.value().variant().toBool();
129− if (m_demoEdges != demoEdges) {
154+ if (m_demoEdges != demoEdges) {
130− m_demoEdges = demoEdges;
155+ m_demoEdges = demoEdges;
131− Q_EMIT demoEdgesChanged();
156+ Q_EMIT demoEdgesChanged();
158+ watcher->deleteLater();
161+ watcher->waitForFinished();
135−void AccountsService::updateEnableLauncherWhileLocked()
166+void AccountsService::updateEnableLauncherWhileLocked(bool async)
168+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
137− auto enableLauncherWhileLocked = m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableLauncherWhileLocked").toBool();
169+ "com.ubuntu.AccountsService.SecurityPrivacy",
170+ "EnableLauncherWhileLocked");
171+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
173+ connect(watcher, &QDBusPendingCallWatcher::finished,
174+ this, [this](QDBusPendingCallWatcher* watcher) {
176+ QDBusPendingReply<QDBusVariant> reply = *watcher;
177+ if (reply.isError()) {
178+ qWarning() << "Failed to get 'EnableLauncherWhileLocked' property - " << reply.error().message();
179+ watcher->deleteLater();
183+ auto enableLauncherWhileLocked = reply.value().variant().toBool();
138− if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
184+ if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
139− m_enableLauncherWhileLocked = enableLauncherWhileLocked;
185+ m_enableLauncherWhileLocked = enableLauncherWhileLocked;
140− Q_EMIT enableLauncherWhileLockedChanged();
186+ Q_EMIT enableLauncherWhileLockedChanged();
188+ watcher->deleteLater();
191+ watcher->waitForFinished();
144−void AccountsService::updateEnableIndicatorsWhileLocked()
196+void AccountsService::updateEnableIndicatorsWhileLocked(bool async)
198+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
146− auto enableIndicatorsWhileLocked = m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "EnableIndicatorsWhileLocked").toBool();
199+ "com.ubuntu.AccountsService.SecurityPrivacy",
200+ "EnableIndicatorsWhileLocked");
201+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
203+ connect(watcher, &QDBusPendingCallWatcher::finished,
204+ this, [this](QDBusPendingCallWatcher* watcher) {
206+ QDBusPendingReply<QDBusVariant> reply = *watcher;
207+ if (reply.isError()) {
208+ qWarning() << "Failed to get 'EnableIndicatorsWhileLocked' property - " << reply.error().message();
209+ watcher->deleteLater();
213+ auto enableIndicatorsWhileLocked = reply.value().variant().toBool();
147− if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
214+ if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
148− m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
215+ m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
149− Q_EMIT enableIndicatorsWhileLockedChanged();
216+ Q_EMIT enableIndicatorsWhileLockedChanged();
218+ watcher->deleteLater();
221+ watcher->waitForFinished();
153−void AccountsService::updateBackgroundFile()
226+void AccountsService::updateBackgroundFile(bool async)
228+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
155− QString backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
229+ "org.freedesktop.Accounts.User",
231+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
233+ connect(watcher, &QDBusPendingCallWatcher::finished,
234+ this, [this](QDBusPendingCallWatcher* watcher) {
236+ QDBusPendingReply<QDBusVariant> reply = *watcher;
237+ if (reply.isError()) {
238+ qWarning() << "Failed to get 'BackgroundFile' property - " << reply.error().message();
239+ watcher->deleteLater();
243+ auto backgroundFile = reply.value().variant().toString();
156− if (m_backgroundFile != backgroundFile) {
244+ if (m_backgroundFile != backgroundFile) {
157− m_backgroundFile = backgroundFile;
245+ m_backgroundFile = backgroundFile;
158− Q_EMIT backgroundFileChanged();
246+ Q_EMIT backgroundFileChanged();
248+ watcher->deleteLater();
251+ watcher->waitForFinished();
162−void AccountsService::updateStatsWelcomeScreen()
256+void AccountsService::updateStatsWelcomeScreen(bool async)
258+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
164− bool statsWelcomeScreen = m_service->getUserProperty(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen").toBool();
259+ "com.ubuntu.touch.AccountsService.SecurityPrivacy",
260+ "StatsWelcomeScreen");
261+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
263+ connect(watcher, &QDBusPendingCallWatcher::finished,
264+ this, [this](QDBusPendingCallWatcher* watcher) {
266+ QDBusPendingReply<QDBusVariant> reply = *watcher;
267+ if (reply.isError()) {
268+ qWarning() << "Failed to get 'StatsWelcomeScreen' property - " << reply.error().message();
269+ watcher->deleteLater();
273+ auto statsWelcomeScreen = reply.value().variant().toBool();
165− if (m_statsWelcomeScreen != statsWelcomeScreen) {
274+ if (m_statsWelcomeScreen != statsWelcomeScreen) {
166− m_statsWelcomeScreen = statsWelcomeScreen;
275+ m_statsWelcomeScreen = statsWelcomeScreen;
167− Q_EMIT statsWelcomeScreenChanged();
276+ Q_EMIT statsWelcomeScreenChanged();
278+ watcher->deleteLater();
281+ watcher->waitForFinished();
171−void AccountsService::updatePasswordDisplayHint()
286+void AccountsService::updatePasswordDisplayHint(bool async)
288+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
173− PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)m_service->getUserProperty(m_user, "com.ubuntu.AccountsService.SecurityPrivacy", "PasswordDisplayHint").toInt();
289+ "com.ubuntu.AccountsService.SecurityPrivacy",
290+ "PasswordDisplayHint");
291+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
293+ connect(watcher, &QDBusPendingCallWatcher::finished,
294+ this, [this](QDBusPendingCallWatcher* watcher) {
296+ QDBusPendingReply<QDBusVariant> reply = *watcher;
297+ if (reply.isError()) {
298+ qWarning() << "Failed to get 'PasswordDisplayHint' property - " << reply.error().message();
299+ watcher->deleteLater();
303+ PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().variant().toInt();
174− if (m_passwordDisplayHint != passwordDisplayHint) {
304+ if (m_passwordDisplayHint != passwordDisplayHint) {
175− m_passwordDisplayHint = passwordDisplayHint;
305+ m_passwordDisplayHint = passwordDisplayHint;
176− Q_EMIT passwordDisplayHintChanged();
306+ Q_EMIT passwordDisplayHintChanged();
308+ watcher->deleteLater();
311+ watcher->waitForFinished();
180−void AccountsService::updateFailedLogins()
316+void AccountsService::updateFailedLogins(bool async)
318+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
182− uint failedLogins = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService.Private", "FailedLogins").toUInt();
319+ "com.canonical.unity.AccountsService.Private",
321+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
323+ connect(watcher, &QDBusPendingCallWatcher::finished,
324+ this, [this](QDBusPendingCallWatcher* watcher) {
326+ QDBusPendingReply<QDBusVariant> reply = *watcher;
327+ if (reply.isError()) {
328+ qWarning() << "Failed to get 'FailedLogins' property - " << reply.error().message();
329+ watcher->deleteLater();
333+ uint failedLogins = reply.value().variant().toUInt();
183− if (m_failedLogins != failedLogins) {
334+ if (m_failedLogins != failedLogins) {
184− m_failedLogins = failedLogins;
335+ m_failedLogins = failedLogins;
185− Q_EMIT failedLoginsChanged();
336+ Q_EMIT failedLoginsChanged();
338+ watcher->deleteLater();
341+ watcher->waitForFinished();
189−void AccountsService::updateHereEnabled()
346+void AccountsService::updateHereEnabled(bool async)
348+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
191− bool hereEnabled = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted").toBool();
349+ "com.ubuntu.location.providers.here.AccountsService",
351+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
353+ connect(watcher, &QDBusPendingCallWatcher::finished,
354+ this, [this](QDBusPendingCallWatcher* watcher) {
356+ QDBusPendingReply<QDBusVariant> reply = *watcher;
357+ if (reply.isError()) {
358+ qWarning() << "Failed to get 'LicenseAccepted' property - " << reply.error().message();
359+ watcher->deleteLater();
363+ auto hereEnabled = reply.value().variant().toBool();
192− if (m_hereEnabled != hereEnabled) {
364+ if (m_hereEnabled != hereEnabled) {
193− m_hereEnabled = hereEnabled;
365+ m_hereEnabled = hereEnabled;
194− Q_EMIT hereEnabledChanged();
366+ Q_EMIT hereEnabledChanged();
368+ watcher->deleteLater();
371+ watcher->waitForFinished();
198−void AccountsService::updateHereLicensePath()
376+void AccountsService::updateHereLicensePath(bool async)
378+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
200− QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
379+ "com.ubuntu.location.providers.here.AccountsService",
381+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
383+ connect(watcher, &QDBusPendingCallWatcher::finished,
384+ this, [this](QDBusPendingCallWatcher* watcher) {
386+ QDBusPendingReply<QDBusVariant> reply = *watcher;
387+ if (reply.isError()) {
388+ qWarning() << "Failed to get 'LicenseBasePath' property - " << reply.error().message();
389+ watcher->deleteLater();
393+ auto hereLicensePath = reply.value().variant().toString();
202− if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
394+ if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
203− hereLicensePath = "";
395+ hereLicensePath = "";
205− if (m_hereLicensePath.isNull() || m_hereLicensePath != hereLicensePath) {
397+ if (m_hereLicensePath.isNull() || m_hereLicensePath != hereLicensePath) {
206− m_hereLicensePath = hereLicensePath;
398+ m_hereLicensePath = hereLicensePath;
207− Q_EMIT hereLicensePathChanged();
399+ Q_EMIT hereLicensePathChanged();
401+ watcher->deleteLater();
404+ watcher->waitForFinished();
@@ -215,8 +413,12 @@ uint AccountsService::failedLogins() const
216void AccountsService::setFailedLogins(uint failedLogins)
414void AccountsService::setFailedLogins(uint failedLogins)
416+ if (m_failedLogins != failedLogins) {
218− m_failedLogins = failedLogins;
417+ m_failedLogins = failedLogins;
219− m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService.Private", "FailedLogins", failedLogins);
418+ m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService.Private", "FailedLogins", failedLogins);
420+ Q_EMIT failedLoginsChanged();
222void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
424void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)