@@ -23,10 +23,9 @@
2323#include <QStringList>
2424#include <QDebug>
2525
26−AccountsService::AccountsService(QObject* parent)
27− : QObject(parent),
26+AccountsService::AccountsService(QObject* parent, const QString &user)
27+ : QObject(parent),
2828 m_service(new AccountsServiceDBusAdaptor(this)),
29− m_user(""),
3029 m_demoEdges(false),
3130 m_enableLauncherWhileLocked(false),
3231 m_enableIndicatorsWhileLocked(false),
@@ -36,12 +35,10 @@ AccountsService::AccountsService(QObject* parent)
3635 m_hereEnabled(false),
3736 m_hereLicensePath() // null means not set yet
3837{
39− connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
40− this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
41− connect(m_service, SIGNAL(maybeChanged(const QString &)),
42− this, SLOT(maybeChanged(const QString &)));
38+ connect(m_service, &AccountsServiceDBusAdaptor::propertiesChanged, this, &AccountsService::onPropertiesChanged);
39+ connect(m_service, &AccountsServiceDBusAdaptor::maybeChanged, this, &AccountsService::onMaybeChanged);
4340
44− setUser(qgetenv("USER"));
41+ setUser(!user.isEmpty() ? user : QString::fromUtf8(qgetenv("USER")));
4542}
4643
4744QString AccountsService::user() const
@@ -173,19 +170,18 @@ void AccountsService::updateEnableLauncherWhileLocked(bool async)
173170 connect(watcher, &QDBusPendingCallWatcher::finished,
174171 this, [this](QDBusPendingCallWatcher* watcher) {
175172
176− QDBusPendingReply<QDBusVariant> reply = *watcher;
173+ QDBusPendingReply<QVariant> reply = *watcher;
174+ watcher->deleteLater();
177175 if (reply.isError()) {
178176 qWarning() << "Failed to get 'EnableLauncherWhileLocked' property - " << reply.error().message();
179− watcher->deleteLater();
180177 return;
181178 }
182179
183− auto enableLauncherWhileLocked = reply.value().variant().toBool();
180+ const bool enableLauncherWhileLocked = reply.value().toBool();
184181 if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
185182 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
186183 Q_EMIT enableLauncherWhileLockedChanged();
187184 }
188− watcher->deleteLater();
189185 });
190186 if (!async) {
191187 watcher->waitForFinished();
@@ -203,19 +199,18 @@ void AccountsService::updateEnableIndicatorsWhileLocked(bool async)
203199 connect(watcher, &QDBusPendingCallWatcher::finished,
204200 this, [this](QDBusPendingCallWatcher* watcher) {
205201
206− QDBusPendingReply<QDBusVariant> reply = *watcher;
202+ QDBusPendingReply<QVariant> reply = *watcher;
203+ watcher->deleteLater();
207204 if (reply.isError()) {
208205 qWarning() << "Failed to get 'EnableIndicatorsWhileLocked' property - " << reply.error().message();
209− watcher->deleteLater();
210206 return;
211207 }
212208
213− auto enableIndicatorsWhileLocked = reply.value().variant().toBool();
209+ const bool enableIndicatorsWhileLocked = reply.value().toBool();
214210 if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
215211 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
216212 Q_EMIT enableIndicatorsWhileLockedChanged();
217213 }
218− watcher->deleteLater();
219214 });
220215 if (!async) {
221216 watcher->waitForFinished();
@@ -233,19 +228,18 @@ void AccountsService::updateBackgroundFile(bool async)
233228 connect(watcher, &QDBusPendingCallWatcher::finished,
234229 this, [this](QDBusPendingCallWatcher* watcher) {
235230
236− QDBusPendingReply<QDBusVariant> reply = *watcher;
231+ QDBusPendingReply<QVariant> reply = *watcher;
232+ watcher->deleteLater();
237233 if (reply.isError()) {
238234 qWarning() << "Failed to get 'BackgroundFile' property - " << reply.error().message();
239− watcher->deleteLater();
240235 return;
241236 }
242237
243− auto backgroundFile = reply.value().variant().toString();
238+ const QString backgroundFile = reply.value().toString();
244239 if (m_backgroundFile != backgroundFile) {
245240 m_backgroundFile = backgroundFile;
246241 Q_EMIT backgroundFileChanged();
247242 }
248− watcher->deleteLater();
249243 });
250244 if (!async) {
251245 watcher->waitForFinished();
@@ -263,19 +257,18 @@ void AccountsService::updateStatsWelcomeScreen(bool async)
263257 connect(watcher, &QDBusPendingCallWatcher::finished,
264258 this, [this](QDBusPendingCallWatcher* watcher) {
265259
266− QDBusPendingReply<QDBusVariant> reply = *watcher;
260+ QDBusPendingReply<QVariant> reply = *watcher;
261+ watcher->deleteLater();
267262 if (reply.isError()) {
268263 qWarning() << "Failed to get 'StatsWelcomeScreen' property - " << reply.error().message();
269− watcher->deleteLater();
270264 return;
271265 }
272266
273− auto statsWelcomeScreen = reply.value().variant().toBool();
267+ const bool statsWelcomeScreen = reply.value().toBool();
274268 if (m_statsWelcomeScreen != statsWelcomeScreen) {
275269 m_statsWelcomeScreen = statsWelcomeScreen;
276270 Q_EMIT statsWelcomeScreenChanged();
277271 }
278− watcher->deleteLater();
279272 });
280273 if (!async) {
281274 watcher->waitForFinished();
@@ -293,19 +286,18 @@ void AccountsService::updatePasswordDisplayHint(bool async)
293286 connect(watcher, &QDBusPendingCallWatcher::finished,
294287 this, [this](QDBusPendingCallWatcher* watcher) {
295288
296− QDBusPendingReply<QDBusVariant> reply = *watcher;
289+ QDBusPendingReply<QVariant> reply = *watcher;
290+ watcher->deleteLater();
297291 if (reply.isError()) {
298292 qWarning() << "Failed to get 'PasswordDisplayHint' property - " << reply.error().message();
299− watcher->deleteLater();
300293 return;
301294 }
302295
303− PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().variant().toInt();
296+ const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt();
304297 if (m_passwordDisplayHint != passwordDisplayHint) {
305298 m_passwordDisplayHint = passwordDisplayHint;
306299 Q_EMIT passwordDisplayHintChanged();
307300 }
308− watcher->deleteLater();
309301 });
310302 if (!async) {
311303 watcher->waitForFinished();
@@ -323,19 +315,18 @@ void AccountsService::updateFailedLogins(bool async)
323315 connect(watcher, &QDBusPendingCallWatcher::finished,
324316 this, [this](QDBusPendingCallWatcher* watcher) {
325317
326− QDBusPendingReply<QDBusVariant> reply = *watcher;
318+ QDBusPendingReply<QVariant> reply = *watcher;
319+ watcher->deleteLater();
327320 if (reply.isError()) {
328321 qWarning() << "Failed to get 'FailedLogins' property - " << reply.error().message();
329− watcher->deleteLater();
330322 return;
331323 }
332324
333− uint failedLogins = reply.value().variant().toUInt();
325+ const uint failedLogins = reply.value().toUInt();
334326 if (m_failedLogins != failedLogins) {
335327 m_failedLogins = failedLogins;
336328 Q_EMIT failedLoginsChanged();
337329 }
338− watcher->deleteLater();
339330 });
340331 if (!async) {
341332 watcher->waitForFinished();
@@ -353,19 +344,18 @@ void AccountsService::updateHereEnabled(bool async)
353344 connect(watcher, &QDBusPendingCallWatcher::finished,
354345 this, [this](QDBusPendingCallWatcher* watcher) {
355346
356− QDBusPendingReply<QDBusVariant> reply = *watcher;
347+ QDBusPendingReply<QVariant> reply = *watcher;
348+ watcher->deleteLater();
357349 if (reply.isError()) {
358350 qWarning() << "Failed to get 'LicenseAccepted' property - " << reply.error().message();
359− watcher->deleteLater();
360351 return;
361352 }
362353
363− auto hereEnabled = reply.value().variant().toBool();
354+ const bool hereEnabled = reply.value().toBool();
364355 if (m_hereEnabled != hereEnabled) {
365356 m_hereEnabled = hereEnabled;
366357 Q_EMIT hereEnabledChanged();
367358 }
368− watcher->deleteLater();
369359 });
370360 if (!async) {
371361 watcher->waitForFinished();
@@ -383,14 +373,14 @@ void AccountsService::updateHereLicensePath(bool async)
383373 connect(watcher, &QDBusPendingCallWatcher::finished,
384374 this, [this](QDBusPendingCallWatcher* watcher) {
385375
386− QDBusPendingReply<QDBusVariant> reply = *watcher;
376+ QDBusPendingReply<QVariant> reply = *watcher;
377+ watcher->deleteLater();
387378 if (reply.isError()) {
388379 qWarning() << "Failed to get 'LicenseBasePath' property - " << reply.error().message();
389− watcher->deleteLater();
390380 return;
391381 }
392382
393− auto hereLicensePath = reply.value().variant().toString();
383+ QString hereLicensePath = reply.value().toString();
394384 if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
395385 hereLicensePath = "";
396386
@@ -398,7 +388,6 @@ void AccountsService::updateHereLicensePath(bool async)
398388 m_hereLicensePath = hereLicensePath;
399389 Q_EMIT hereLicensePathChanged();
400390 }
401− watcher->deleteLater();
402391 });
403392 if (!async) {
404393 watcher->waitForFinished();
@@ -421,7 +410,7 @@ void AccountsService::setFailedLogins(uint failedLogins)
421410 }
422411}
423412
424−void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
413+void AccountsService::onPropertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
425414{
426415 if (m_user != user) {
427416 return;
@@ -459,7 +448,7 @@ void AccountsService::propertiesChanged(const QString &user, const QString &inte
459448 }
460449}
461450
462−void AccountsService::maybeChanged(const QString &user)
451+void AccountsService::onMaybeChanged(const QString &user)
463452{
464453 if (m_user != user) {
465454 return;