@@ -23,10 +23,9 @@
23#include <QStringList>
23#include <QStringList>
24#include <QDebug>
24#include <QDebug>
26−AccountsService::AccountsService(QObject* parent)
26+AccountsService::AccountsService(QObject* parent, const QString &user)
27− : QObject(parent),
27+ : QObject(parent),
28 m_service(new AccountsServiceDBusAdaptor(this)),
28 m_service(new AccountsServiceDBusAdaptor(this)),
30 m_demoEdges(false),
29 m_demoEdges(false),
31 m_enableLauncherWhileLocked(false),
30 m_enableLauncherWhileLocked(false),
32 m_enableIndicatorsWhileLocked(false),
31 m_enableIndicatorsWhileLocked(false),
@@ -36,12 +35,10 @@ AccountsService::AccountsService(QObject* parent)
36 m_hereEnabled(false),
35 m_hereEnabled(false),
37 m_hereLicensePath() // null means not set yet
36 m_hereLicensePath() // null means not set yet
39− connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
38+ connect(m_service, &AccountsServiceDBusAdaptor::propertiesChanged, this, &AccountsService::onPropertiesChanged);
40− this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
41− connect(m_service, SIGNAL(maybeChanged(const QString &)),
39+ connect(m_service, &AccountsServiceDBusAdaptor::maybeChanged, this, &AccountsService::onMaybeChanged);
42− this, SLOT(maybeChanged(const QString &)));
44− setUser(qgetenv("USER"));
41+ setUser(!user.isEmpty() ? user : QString::fromUtf8(qgetenv("USER")));
47QString AccountsService::user() const
44QString AccountsService::user() const
@@ -173,19 +170,18 @@ void AccountsService::updateEnableLauncherWhileLocked(bool async)
173 connect(watcher, &QDBusPendingCallWatcher::finished,
170 connect(watcher, &QDBusPendingCallWatcher::finished,
174 this, [this](QDBusPendingCallWatcher* watcher) {
171 this, [this](QDBusPendingCallWatcher* watcher) {
176− QDBusPendingReply<QDBusVariant> reply = *watcher;
173+ QDBusPendingReply<QVariant> reply = *watcher;
174+ watcher->deleteLater();
177 if (reply.isError()) {
175 if (reply.isError()) {
178 qWarning() << "Failed to get 'EnableLauncherWhileLocked' property - " << reply.error().message();
176 qWarning() << "Failed to get 'EnableLauncherWhileLocked' property - " << reply.error().message();
179− watcher->deleteLater();
183− auto enableLauncherWhileLocked = reply.value().variant().toBool();
180+ const bool enableLauncherWhileLocked = reply.value().toBool();
184 if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
181 if (m_enableLauncherWhileLocked != enableLauncherWhileLocked) {
185 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
182 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
186 Q_EMIT enableLauncherWhileLockedChanged();
183 Q_EMIT enableLauncherWhileLockedChanged();
188− watcher->deleteLater();
190 if (!async) {
186 if (!async) {
191 watcher->waitForFinished();
187 watcher->waitForFinished();
@@ -203,19 +199,18 @@ void AccountsService::updateEnableIndicatorsWhileLocked(bool async)
203 connect(watcher, &QDBusPendingCallWatcher::finished,
199 connect(watcher, &QDBusPendingCallWatcher::finished,
204 this, [this](QDBusPendingCallWatcher* watcher) {
200 this, [this](QDBusPendingCallWatcher* watcher) {
206− QDBusPendingReply<QDBusVariant> reply = *watcher;
202+ QDBusPendingReply<QVariant> reply = *watcher;
203+ watcher->deleteLater();
207 if (reply.isError()) {
204 if (reply.isError()) {
208 qWarning() << "Failed to get 'EnableIndicatorsWhileLocked' property - " << reply.error().message();
205 qWarning() << "Failed to get 'EnableIndicatorsWhileLocked' property - " << reply.error().message();
209− watcher->deleteLater();
213− auto enableIndicatorsWhileLocked = reply.value().variant().toBool();
209+ const bool enableIndicatorsWhileLocked = reply.value().toBool();
214 if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
210 if (m_enableIndicatorsWhileLocked != enableIndicatorsWhileLocked) {
215 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
211 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
216 Q_EMIT enableIndicatorsWhileLockedChanged();
212 Q_EMIT enableIndicatorsWhileLockedChanged();
218− watcher->deleteLater();
220 if (!async) {
215 if (!async) {
221 watcher->waitForFinished();
216 watcher->waitForFinished();
@@ -233,19 +228,18 @@ void AccountsService::updateBackgroundFile(bool async)
233 connect(watcher, &QDBusPendingCallWatcher::finished,
228 connect(watcher, &QDBusPendingCallWatcher::finished,
234 this, [this](QDBusPendingCallWatcher* watcher) {
229 this, [this](QDBusPendingCallWatcher* watcher) {
236− QDBusPendingReply<QDBusVariant> reply = *watcher;
231+ QDBusPendingReply<QVariant> reply = *watcher;
232+ watcher->deleteLater();
237 if (reply.isError()) {
233 if (reply.isError()) {
238 qWarning() << "Failed to get 'BackgroundFile' property - " << reply.error().message();
234 qWarning() << "Failed to get 'BackgroundFile' property - " << reply.error().message();
239− watcher->deleteLater();
243− auto backgroundFile = reply.value().variant().toString();
238+ const QString backgroundFile = reply.value().toString();
244 if (m_backgroundFile != backgroundFile) {
239 if (m_backgroundFile != backgroundFile) {
245 m_backgroundFile = backgroundFile;
240 m_backgroundFile = backgroundFile;
246 Q_EMIT backgroundFileChanged();
241 Q_EMIT backgroundFileChanged();
248− watcher->deleteLater();
250 if (!async) {
244 if (!async) {
251 watcher->waitForFinished();
245 watcher->waitForFinished();
@@ -263,19 +257,18 @@ void AccountsService::updateStatsWelcomeScreen(bool async)
263 connect(watcher, &QDBusPendingCallWatcher::finished,
257 connect(watcher, &QDBusPendingCallWatcher::finished,
264 this, [this](QDBusPendingCallWatcher* watcher) {
258 this, [this](QDBusPendingCallWatcher* watcher) {
266− QDBusPendingReply<QDBusVariant> reply = *watcher;
260+ QDBusPendingReply<QVariant> reply = *watcher;
261+ watcher->deleteLater();
267 if (reply.isError()) {
262 if (reply.isError()) {
268 qWarning() << "Failed to get 'StatsWelcomeScreen' property - " << reply.error().message();
263 qWarning() << "Failed to get 'StatsWelcomeScreen' property - " << reply.error().message();
269− watcher->deleteLater();
273− auto statsWelcomeScreen = reply.value().variant().toBool();
267+ const bool statsWelcomeScreen = reply.value().toBool();
274 if (m_statsWelcomeScreen != statsWelcomeScreen) {
268 if (m_statsWelcomeScreen != statsWelcomeScreen) {
275 m_statsWelcomeScreen = statsWelcomeScreen;
269 m_statsWelcomeScreen = statsWelcomeScreen;
276 Q_EMIT statsWelcomeScreenChanged();
270 Q_EMIT statsWelcomeScreenChanged();
278− watcher->deleteLater();
280 if (!async) {
273 if (!async) {
281 watcher->waitForFinished();
274 watcher->waitForFinished();
@@ -293,19 +286,18 @@ void AccountsService::updatePasswordDisplayHint(bool async)
293 connect(watcher, &QDBusPendingCallWatcher::finished,
286 connect(watcher, &QDBusPendingCallWatcher::finished,
294 this, [this](QDBusPendingCallWatcher* watcher) {
287 this, [this](QDBusPendingCallWatcher* watcher) {
296− QDBusPendingReply<QDBusVariant> reply = *watcher;
289+ QDBusPendingReply<QVariant> reply = *watcher;
290+ watcher->deleteLater();
297 if (reply.isError()) {
291 if (reply.isError()) {
298 qWarning() << "Failed to get 'PasswordDisplayHint' property - " << reply.error().message();
292 qWarning() << "Failed to get 'PasswordDisplayHint' property - " << reply.error().message();
299− watcher->deleteLater();
303− PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().variant().toInt();
296+ const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt();
304 if (m_passwordDisplayHint != passwordDisplayHint) {
297 if (m_passwordDisplayHint != passwordDisplayHint) {
305 m_passwordDisplayHint = passwordDisplayHint;
298 m_passwordDisplayHint = passwordDisplayHint;
306 Q_EMIT passwordDisplayHintChanged();
299 Q_EMIT passwordDisplayHintChanged();
308− watcher->deleteLater();
310 if (!async) {
302 if (!async) {
311 watcher->waitForFinished();
303 watcher->waitForFinished();
@@ -323,19 +315,18 @@ void AccountsService::updateFailedLogins(bool async)
323 connect(watcher, &QDBusPendingCallWatcher::finished,
315 connect(watcher, &QDBusPendingCallWatcher::finished,
324 this, [this](QDBusPendingCallWatcher* watcher) {
316 this, [this](QDBusPendingCallWatcher* watcher) {
326− QDBusPendingReply<QDBusVariant> reply = *watcher;
318+ QDBusPendingReply<QVariant> reply = *watcher;
319+ watcher->deleteLater();
327 if (reply.isError()) {
320 if (reply.isError()) {
328 qWarning() << "Failed to get 'FailedLogins' property - " << reply.error().message();
321 qWarning() << "Failed to get 'FailedLogins' property - " << reply.error().message();
329− watcher->deleteLater();
333− uint failedLogins = reply.value().variant().toUInt();
325+ const uint failedLogins = reply.value().toUInt();
334 if (m_failedLogins != failedLogins) {
326 if (m_failedLogins != failedLogins) {
335 m_failedLogins = failedLogins;
327 m_failedLogins = failedLogins;
336 Q_EMIT failedLoginsChanged();
328 Q_EMIT failedLoginsChanged();
338− watcher->deleteLater();
340 if (!async) {
331 if (!async) {
341 watcher->waitForFinished();
332 watcher->waitForFinished();
@@ -353,19 +344,18 @@ void AccountsService::updateHereEnabled(bool async)
353 connect(watcher, &QDBusPendingCallWatcher::finished,
344 connect(watcher, &QDBusPendingCallWatcher::finished,
354 this, [this](QDBusPendingCallWatcher* watcher) {
345 this, [this](QDBusPendingCallWatcher* watcher) {
356− QDBusPendingReply<QDBusVariant> reply = *watcher;
347+ QDBusPendingReply<QVariant> reply = *watcher;
348+ watcher->deleteLater();
357 if (reply.isError()) {
349 if (reply.isError()) {
358 qWarning() << "Failed to get 'LicenseAccepted' property - " << reply.error().message();
350 qWarning() << "Failed to get 'LicenseAccepted' property - " << reply.error().message();
359− watcher->deleteLater();
363− auto hereEnabled = reply.value().variant().toBool();
354+ const bool hereEnabled = reply.value().toBool();
364 if (m_hereEnabled != hereEnabled) {
355 if (m_hereEnabled != hereEnabled) {
365 m_hereEnabled = hereEnabled;
356 m_hereEnabled = hereEnabled;
366 Q_EMIT hereEnabledChanged();
357 Q_EMIT hereEnabledChanged();
368− watcher->deleteLater();
370 if (!async) {
360 if (!async) {
371 watcher->waitForFinished();
361 watcher->waitForFinished();
@@ -383,14 +373,14 @@ void AccountsService::updateHereLicensePath(bool async)
383 connect(watcher, &QDBusPendingCallWatcher::finished,
373 connect(watcher, &QDBusPendingCallWatcher::finished,
384 this, [this](QDBusPendingCallWatcher* watcher) {
374 this, [this](QDBusPendingCallWatcher* watcher) {
386− QDBusPendingReply<QDBusVariant> reply = *watcher;
376+ QDBusPendingReply<QVariant> reply = *watcher;
377+ watcher->deleteLater();
387 if (reply.isError()) {
378 if (reply.isError()) {
388 qWarning() << "Failed to get 'LicenseBasePath' property - " << reply.error().message();
379 qWarning() << "Failed to get 'LicenseBasePath' property - " << reply.error().message();
389− watcher->deleteLater();
393− auto hereLicensePath = reply.value().variant().toString();
383+ QString hereLicensePath = reply.value().toString();
394 if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
384 if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
395 hereLicensePath = "";
385 hereLicensePath = "";
@@ -398,7 +388,6 @@ void AccountsService::updateHereLicensePath(bool async)
398 m_hereLicensePath = hereLicensePath;
388 m_hereLicensePath = hereLicensePath;
399 Q_EMIT hereLicensePathChanged();
389 Q_EMIT hereLicensePathChanged();
401− watcher->deleteLater();
403 if (!async) {
392 if (!async) {
404 watcher->waitForFinished();
393 watcher->waitForFinished();
@@ -421,7 +410,7 @@ void AccountsService::setFailedLogins(uint failedLogins)
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)
426 if (m_user != user) {
415 if (m_user != user) {
@@ -459,7 +448,7 @@ void AccountsService::propertiesChanged(const QString &user, const QString &inte
462−void AccountsService::maybeChanged(const QString &user)
451+void AccountsService::onMaybeChanged(const QString &user)
464 if (m_user != user) {
453 if (m_user != user) {