on xenial help sign in
Have the greeter use AccountsService to determine its background. Fixes: https://bugs.launchpad.net/bugs/1218402.

Approved by PS Jenkins bot, Michael Zanetti.

commit897050378ca7cab55446d7a761de511bbe345580 authorMichael Terry <michael.terry@canonical.com> dateMon 9 Sep 2013, 14:21 (13 years ago) parent6fca6927417ab0
17 files changed+379−73
Components/EdgeDemo.qml+4−4 Greeter/GreeterContent.qml+19−2 Shell.qml+2 plugins/AccountsService/AccountsService.cpp+67−37 plugins/AccountsService/AccountsService.h+34−8 plugins/AccountsService/AccountsServiceDBusAdaptor.cpp+126 plugins/AccountsService/AccountsServiceDBusAdaptor.h+54 plugins/AccountsService/CMakeLists.txt+1 plugins/Unity/Launcher/CMakeLists.txt+1−1 plugins/Unity/Launcher/backend/launcherbackend.cpp+4−4 plugins/Unity/Launcher/backend/launcherbackend.h+2−2 tests/mocks/AccountsService/AccountsService.cpp+19−3 tests/mocks/AccountsService/AccountsService.h+22−3 tests/mocks/AccountsService/CMakeLists.txt+2 tests/plugins/AccountsService/CMakeLists.txt+1 tests/plugins/AccountsService/client.cpp+19−7 tests/plugins/Unity/Launcher/CMakeLists.txt+2−2
Components/EdgeDemo.qml+4−4
@@ -44,13 +44,13 @@ Item {
4444
4545 function hideEdgeDemoInShell() {
4646 var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);
47− AccountsService.setUserProperty(user, "demo-edges", false);
47+ AccountsService.demoEdges = false;
4848 d.showEdgeDemo = false;
4949 stopDemo();
5050 }
5151
5252 function hideEdgeDemoInGreeter() {
53− // TODO: AccountsService.setUserProperty("lightdm", "demo-edges", false);
53+ // TODO: AccountsService.demoEdges = false as lightdm user
5454 d.showEdgeDemoInGreeter = false;
5555 }
5656
@@ -80,7 +80,7 @@ Item {
8080 property QtObject leftEdgeDemo
8181 property QtObject finalEdgeDemo
8282 property bool showEdgeDemo: false
83− property bool showEdgeDemoInGreeter: d.showEdgeDemo // TODO: AccountsService.getUserProperty("lightdm", "demo-edges")
83+ property bool showEdgeDemoInGreeter: d.showEdgeDemo // TODO: AccountsService.demoEdges as lightdm user
8484
8585 onShowEdgeDemoInGreeterChanged: {
8686 if (!d.overlay && d.showEdgeDemoInGreeter) {
@@ -126,7 +126,7 @@ Item {
126126
127127 onSelected: {
128128 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole)
129− d.showEdgeDemo = AccountsService.getUserProperty(user, "demo-edges")
129+ d.showEdgeDemo = AccountsService.demoEdges
130130 }
131131 }
132132
Greeter/GreeterContent.qml+19−2
@@ -15,6 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18+import AccountsService 0.1
1819import Ubuntu.Components 0.1
1920import LightDM 0.1 as LightDM
2021import "../Components"
@@ -39,14 +40,30 @@ MouseArea {
3940 color: "black"
4041 }
4142
43+ property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : shell.defaultBackground
44+ onBackgroundValueChanged: wallpaper.source = backgroundValue
45+
4246 CrossFadeImage {
4347 id: wallpaper
44−
45− source: shell.background
4648 anchors.fill: parent
4749 fadeInFirst: false
4850 }
4951
52+ // See Shell.qml's backgroundSettings treatment for why we need a separate
53+ // Image, but it boils down to avoiding binding loop detection.
54+ Image {
55+ source: wallpaper.source
56+ height: 0
57+ width: 0
58+ sourceSize.height: 0
59+ sourceSize.width: 0
60+ onStatusChanged: {
61+ if (status == Image.Error && source != shell.defaultBackground) {
62+ wallpaper.source = shell.defaultBackground
63+ }
64+ }
65+ }
66+
5067 Rectangle {
5168 anchors.fill: parent
5269 color: "black"
Shell.qml+2
@@ -15,6 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18+import AccountsService 0.1
1819import GSettings 1.0
1920import Ubuntu.Application 0.1
2021import Ubuntu.Components 0.1
@@ -478,6 +479,7 @@ FocusScope {
478479 onSelected: {
479480 // Update launcher items for new user
480481 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
482+ AccountsService.user = user;
481483 LauncherModel.setUser(user);
482484 }
483485
plugins/AccountsService/AccountsService.cpp+67−37
@@ -17,58 +17,88 @@
1717 */
1818
1919#include "AccountsService.h"
20−#include <QDBusConnection>
21−#include <QDBusConnectionInterface>
22−#include <QDBusMessage>
23−#include <QDBusVariant>
20+#include "AccountsServiceDBusAdaptor.h"
21+
22+#include <QStringList>
2423
2524AccountsService::AccountsService(QObject* parent)
2625 : QObject(parent),
27− accounts_manager(NULL),
28− users()
26+ m_service(new AccountsServiceDBusAdaptor(this)),
27+ m_user(qgetenv("USER"))
2928{
30− auto connection = QDBusConnection::SM_BUSNAME();
31− auto interface = connection.interface();
32− interface->startService("org.freedesktop.Accounts");
33− accounts_manager = new QDBusInterface("org.freedesktop.Accounts",
34− "/org/freedesktop/Accounts",
35− "org.freedesktop.Accounts",
36− connection, this);
29+ connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
30+ this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
31+ connect(m_service, SIGNAL(maybeChanged(const QString &)),
32+ this, SLOT(maybeChanged(const QString &)));
3733}
3834
39−QVariant AccountsService::getUserProperty(const QString &user, const QString &property)
35+QString AccountsService::getUser()
4036{
41− auto iface = getUserInterface(user);
42− if (iface != nullptr && iface->isValid()) {
43− auto answer = iface->call("Get", "com.canonical.unity.AccountsService", property);
44− if (answer.type() == QDBusMessage::ReplyMessage) {
45− return answer.arguments()[0].value<QDBusVariant>().variant();
46− }
37+ return m_user;
38+}
39+
40+void AccountsService::setUser(const QString &user)
41+{
42+ m_user = user;
43+ Q_EMIT userChanged();
44+
45+ updateDemoEdges();
46+ updateBackgroundFile();
47+}
48+
49+bool AccountsService::getDemoEdges()
50+{
51+ return m_demoEdges;
52+}
53+
54+void AccountsService::setDemoEdges(bool demoEdges)
55+{
56+ m_demoEdges = demoEdges;
57+ m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
58+}
59+
60+QString AccountsService::getBackgroundFile()
61+{
62+ return m_backgroundFile;
63+}
64+
65+void AccountsService::updateDemoEdges()
66+{
67+ auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
68+ if (m_demoEdges != demoEdges) {
69+ m_demoEdges = demoEdges;
70+ Q_EMIT demoEdgesChanged();
4771 }
48− return QVariant();
4972}
5073
51−void AccountsService::setUserProperty(const QString &user, const QString &property, const QVariant &value)
74+void AccountsService::updateBackgroundFile()
5275{
53− auto iface = getUserInterface(user);
54− if (iface != nullptr && iface->isValid()) {
55− // The value needs to be carefully wrapped
56− iface->call("Set", "com.canonical.unity.AccountsService", property, QVariant::fromValue(QDBusVariant(value)));
76+ auto backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
77+ if (m_backgroundFile != backgroundFile) {
78+ m_backgroundFile = backgroundFile;
79+ Q_EMIT backgroundFileChanged();
5780 }
5881}
5982
60−QDBusInterface *AccountsService::getUserInterface(const QString &user)
83+void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
6184{
62− auto iface = users.value(user);
63− if (iface == nullptr && accounts_manager->isValid()) {
64− auto answer = accounts_manager->call("FindUserByName", user);
65− if (answer.type() == QDBusMessage::ReplyMessage) {
66− iface = new QDBusInterface("org.freedesktop.Accounts",
67− answer.arguments()[0].value<QDBusObjectPath>().path(),
68− "org.freedesktop.DBus.Properties",
69− accounts_manager->connection(), this);
70− users.insert(user, iface);
85+ if (m_user != user) {
86+ return;
87+ }
88+
89+ if (interface == "com.canonical.unity.AccountsService") {
90+ if (changed.contains("demo-edges")) {
91+ updateDemoEdges();
7192 }
7293 }
73− return iface;
94+}
95+
96+void AccountsService::maybeChanged(const QString &user)
97+{
98+ if (m_user != user) {
99+ return;
100+ }
101+
102+ // Standard properties might have changed
103+ updateBackgroundFile();
74104}
plugins/AccountsService/AccountsService.h+34−8
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012,2013 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -19,26 +19,52 @@
1919#ifndef UNITY_ACCOUNTSSERVICE_H
2020#define UNITY_ACCOUNTSSERVICE_H
2121
22−#include <QDBusInterface>
23−#include <QMap>
2422#include <QObject>
2523#include <QString>
2624
25+class AccountsServiceDBusAdaptor;
26+
2727class AccountsService: public QObject
2828{
2929 Q_OBJECT
30+ Q_PROPERTY (QString user
31+ READ getUser
32+ WRITE setUser
33+ NOTIFY userChanged)
34+ Q_PROPERTY (bool demoEdges
35+ READ getDemoEdges
36+ WRITE setDemoEdges
37+ NOTIFY demoEdgesChanged)
38+ Q_PROPERTY (QString backgroundFile
39+ READ getBackgroundFile
40+ NOTIFY backgroundFileChanged)
3041
3142public:
3243 explicit AccountsService(QObject *parent = 0);
3344
34− Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);
35− Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);
45+ QString getUser();
46+ void setUser(const QString &user);
47+ bool getDemoEdges();
48+ void setDemoEdges(bool demoEdges);
49+ QString getBackgroundFile();
50+
51+Q_SIGNALS:
52+ void userChanged();
53+ void demoEdgesChanged();
54+ void backgroundFileChanged();
55+
56+private Q_SLOTS:
57+ void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
58+ void maybeChanged(const QString &user);
3659
3760private:
38− QDBusInterface *getUserInterface(const QString &user);
61+ void updateDemoEdges();
62+ void updateBackgroundFile();
3963
40− QDBusInterface *accounts_manager;
41− QMap<QString, QDBusInterface *> users;
64+ AccountsServiceDBusAdaptor *m_service;
65+ QString m_user;
66+ bool m_demoEdges;
67+ QString m_backgroundFile;
4268};
4369
4470#endif
plugins/AccountsService/AccountsServiceDBusAdaptor.cppnew file+126
@@ -0,0 +1,126 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Author: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#include "AccountsServiceDBusAdaptor.h"
20+#include <QDBusConnection>
21+#include <QDBusConnectionInterface>
22+#include <QDBusMessage>
23+#include <QDBusVariant>
24+
25+AccountsServiceDBusAdaptor::AccountsServiceDBusAdaptor(QObject* parent)
26+ : QObject(parent),
27+ accounts_manager(NULL),
28+ users()
29+{
30+ auto connection = QDBusConnection::SM_BUSNAME();
31+ auto interface = connection.interface();
32+ interface->startService("org.freedesktop.Accounts");
33+ accounts_manager = new QDBusInterface("org.freedesktop.Accounts",
34+ "/org/freedesktop/Accounts",
35+ "org.freedesktop.Accounts",
36+ connection, this);
37+}
38+
39+QVariant AccountsServiceDBusAdaptor::getUserProperty(const QString &user, const QString &interface, const QString &property)
40+{
41+ auto iface = getUserInterface(user);
42+ if (iface != nullptr && iface->isValid()) {
43+ auto answer = iface->call("Get", interface, property);
44+ if (answer.type() == QDBusMessage::ReplyMessage) {
45+ return answer.arguments()[0].value<QDBusVariant>().variant();
46+ }
47+ }
48+ return QVariant();
49+}
50+
51+void AccountsServiceDBusAdaptor::setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value)
52+{
53+ auto iface = getUserInterface(user);
54+ if (iface != nullptr && iface->isValid()) {
55+ // The value needs to be carefully wrapped
56+ iface->call("Set", interface, property, QVariant::fromValue(QDBusVariant(value)));
57+ }
58+}
59+
60+void AccountsServiceDBusAdaptor::propertiesChangedSlot(const QString &interface, const QVariantMap &changed, const QStringList &invalid)
61+{
62+ // Merge changed and invalidated together
63+ QStringList combined;
64+ combined << invalid;
65+ combined << changed.keys();
66+ combined.removeDuplicates();
67+
68+ Q_EMIT propertiesChanged(getUserForPath(message().path()), interface, combined);
69+}
70+
71+void AccountsServiceDBusAdaptor::maybeChangedSlot()
72+{
73+ Q_EMIT maybeChanged(getUserForPath(message().path()));
74+}
75+
76+QString AccountsServiceDBusAdaptor::getUserForPath(const QString &path)
77+{
78+ QMap<QString, QDBusInterface *>::const_iterator i;
79+ for (i = users.constBegin(); i != users.constEnd(); ++i) {
80+ if (i.value()->path() == path) {
81+ return i.key();
82+ }
83+ }
84+ return QString();
85+}
86+
87+QDBusInterface *AccountsServiceDBusAdaptor::getUserInterface(const QString &user)
88+{
89+ auto iface = users.value(user);
90+ if (iface == nullptr && accounts_manager->isValid()) {
91+ auto answer = accounts_manager->call("FindUserByName", user);
92+ if (answer.type() == QDBusMessage::ReplyMessage) {
93+ auto path = answer.arguments()[0].value<QDBusObjectPath>().path();
94+
95+ iface = new QDBusInterface("org.freedesktop.Accounts",
96+ path,
97+ "org.freedesktop.DBus.Properties",
98+ accounts_manager->connection(), this);
99+
100+ // With its own pre-defined properties, AccountsService is oddly
101+ // close-lipped. It won't send out proper DBus.Properties notices,
102+ // but it does have one catch-all Changed() signal. So let's
103+ // listen to that.
104+ iface->connection().connect(
105+ iface->service(),
106+ path,
107+ "org.freedesktop.Accounts.User",
108+ "Changed",
109+ this,
110+ SLOT(maybeChangedSlot()));
111+
112+ // But custom properties do send out the right notifications, so
113+ // let's still listen there.
114+ iface->connection().connect(
115+ iface->service(),
116+ path,
117+ "org.freedesktop.DBus.Properties",
118+ "PropertiesChanged",
119+ this,
120+ SLOT(propertiesChangedSlot(QString, QVariantMap, QStringList)));
121+
122+ users.insert(user, iface);
123+ }
124+ }
125+ return iface;
126+}
plugins/AccountsService/AccountsServiceDBusAdaptor.hnew file+54
@@ -0,0 +1,54 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#ifndef UNITY_ACCOUNTSSERVICEDBUSADAPTOR_H
20+#define UNITY_ACCOUNTSSERVICEDBUSADAPTOR_H
21+
22+#include <QDBusContext>
23+#include <QDBusInterface>
24+#include <QMap>
25+#include <QObject>
26+#include <QString>
27+
28+class AccountsServiceDBusAdaptor: public QObject, public QDBusContext
29+{
30+ Q_OBJECT
31+
32+public:
33+ explicit AccountsServiceDBusAdaptor(QObject *parent = 0);
34+
35+ Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &interface, const QString &property);
36+ Q_INVOKABLE void setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value);
37+
38+Q_SIGNALS:
39+ void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
40+ void maybeChanged(const QString &user); // Standard properties might have changed
41+
42+private Q_SLOTS:
43+ void propertiesChangedSlot(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
44+ void maybeChangedSlot();
45+
46+private:
47+ QDBusInterface *getUserInterface(const QString &user);
48+ QString getUserForPath(const QString &path);
49+
50+ QDBusInterface *accounts_manager;
51+ QMap<QString, QDBusInterface *> users;
52+};
53+
54+#endif
plugins/AccountsService/CMakeLists.txt+1
@@ -4,6 +4,7 @@ add_definitions(-DSM_BUSNAME=systemBus)
44
55add_library(AccountsService-qml MODULE
66 AccountsService.cpp
7+ AccountsServiceDBusAdaptor.cpp
78 plugin.cpp
89 )
910
plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -17,7 +17,7 @@ set(QMLLAUNCHERPLUGIN_SRC
1717 quicklistmodel.cpp
1818 common/quicklistentry.cpp
1919 backend/launcherbackend.cpp
20− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
20+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
2121 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
2222 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
2323 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
plugins/Unity/Launcher/backend/launcherbackend.cpp+4−4
@@ -18,7 +18,7 @@
1818 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020
21−#include "AccountsService.h"
21+#include "AccountsServiceDBusAdaptor.h"
2222#include "launcherbackend.h"
2323
2424#include <QDir>
@@ -43,7 +43,7 @@ LauncherBackend::LauncherBackend(bool useStorage, QObject *parent):
4343 m_accounts(nullptr)
4444{
4545 if (useStorage) {
46− m_accounts = new AccountsService(this);
46+ m_accounts = new AccountsServiceDBusAdaptor(this);
4747 }
4848 m_user = qgetenv("USER");
4949 syncFromAccounts();
@@ -214,7 +214,7 @@ void LauncherBackend::syncFromAccounts()
214214 m_storedApps.clear();
215215
216216 if (m_accounts && !m_user.isEmpty()) {
217− QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
217+ QVariant variant = m_accounts->getUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items");
218218 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
219219 defaults = isDefaultsItem(apps);
220220 }
@@ -257,7 +257,7 @@ void LauncherBackend::syncToAccounts()
257257 items << itemToVariant(appId);
258258 }
259259
260− m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
260+ m_accounts->setUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items", QVariant::fromValue(items));
261261 }
262262}
263263
plugins/Unity/Launcher/backend/launcherbackend.h+2−2
@@ -25,7 +25,7 @@
2525#include <QSettings>
2626#include <QStringList>
2727
28−class AccountsService;
28+class AccountsServiceDBusAdaptor;
2929
3030/**
3131 * @brief An interface that provides all the data needed by the launcher.
@@ -156,7 +156,7 @@ private:
156156 QList<QString> m_storedApps;
157157 mutable QHash<QString, LauncherBackendItem*> m_itemCache;
158158
159− AccountsService *m_accounts;
159+ AccountsServiceDBusAdaptor *m_accounts;
160160 QString m_user;
161161};
162162
tests/mocks/AccountsService/AccountsService.cpp+19−3
@@ -23,11 +23,27 @@ AccountsService::AccountsService(QObject* parent)
2323{
2424}
2525
26−QVariant AccountsService::getUserProperty(const QString &, const QString &)
26+QString AccountsService::getUser()
2727{
28− return QVariant(false);
28+ return "testuser";
2929}
3030
31−void AccountsService::setUserProperty(const QString &, const QString &, const QVariant &)
31+void AccountsService::setUser(const QString &user)
3232{
33+ Q_UNUSED(user)
34+}
35+
36+bool AccountsService::getDemoEdges()
37+{
38+ return false;
39+}
40+
41+void AccountsService::setDemoEdges(bool demoEdges)
42+{
43+ Q_UNUSED(demoEdges)
44+}
45+
46+QString AccountsService::getBackgroundFile()
47+{
48+ return TOP_SRCDIR "/graphics/phone_background.jpg";
3349}
tests/mocks/AccountsService/AccountsService.h+22−3
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012,2013 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -27,12 +27,31 @@
2727class AccountsService: public QObject
2828{
2929 Q_OBJECT
30+ Q_PROPERTY (QString user
31+ READ getUser
32+ WRITE setUser
33+ NOTIFY userChanged)
34+ Q_PROPERTY (bool demoEdges
35+ READ getDemoEdges
36+ WRITE setDemoEdges
37+ NOTIFY demoEdgesChanged)
38+ Q_PROPERTY (QString backgroundFile
39+ READ getBackgroundFile
40+ NOTIFY backgroundFileChanged)
3041
3142public:
3243 explicit AccountsService(QObject *parent = 0);
3344
34− Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);
35− Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);
45+ QString getUser();
46+ void setUser(const QString &user);
47+ bool getDemoEdges();
48+ void setDemoEdges(bool demoEdges);
49+ QString getBackgroundFile();
50+
51+Q_SIGNALS:
52+ void userChanged();
53+ void demoEdgesChanged();
54+ void backgroundFileChanged();
3655};
3756
3857#endif
tests/mocks/AccountsService/CMakeLists.txt+2
@@ -1,3 +1,5 @@
1+add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
2+
13add_library(MockAccountsService-qml MODULE
24 AccountsService.cpp
35 plugin.cpp
tests/plugins/AccountsService/CMakeLists.txt+1
@@ -25,6 +25,7 @@ qt5_use_modules(mock-server Core DBus)
2525
2626add_executable(test-accountsservice
2727 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
28+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
2829 client.cpp
2930 )
3031qt5_use_modules(test-accountsservice Core DBus Test)
tests/plugins/AccountsService/client.cpp+19−7
@@ -18,6 +18,7 @@
1818 */
1919
2020#include "AccountsService.h"
21+#include "AccountsServiceDBusAdaptor.h"
2122#include <QSignalSpy>
2223#include <QTest>
2324
@@ -30,17 +31,28 @@ private Q_SLOTS:
3031 void testInvalids()
3132 {
3233 // Test various invalid calls
33− AccountsService session;
34− QCOMPARE(session.getUserProperty("NOPE", "demo-edges"), QVariant());
35− QCOMPARE(session.getUserProperty("testuser", "NOPE"), QVariant());
34+ AccountsServiceDBusAdaptor session;
35+ QCOMPARE(session.getUserProperty("NOPE", "com.canonical.unity.AccountsService", "demo-edges"), QVariant());
36+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "NOPE"), QVariant());
37+ }
38+
39+ void testGetSetServiceDBusAdaptor()
40+ {
41+ AccountsServiceDBusAdaptor session;
42+ session.setUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges", QVariant(true));
43+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges"), QVariant(true));
44+ session.setUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges", QVariant(false));
45+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges"), QVariant(false));
3646 }
3747
38− void testGetSet()
48+ void testGetSetService()
3949 {
4050 AccountsService session;
41− QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(true));
42− session.setUserProperty("testuser", "demo-edges", QVariant(false));
43− QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(false));
51+ session.setUser("testuser");
52+ session.setDemoEdges(true);
53+ QCOMPARE(session.getDemoEdges(), true);
54+ session.setDemoEdges(false);
55+ QCOMPARE(session.getDemoEdges(), false);
4456 }
4557};
4658
tests/plugins/Unity/Launcher/CMakeLists.txt+2−2
@@ -21,7 +21,7 @@ add_test(NAME launcherbackendtest COMMAND ${testBackendCommand})
2121add_custom_target(launcherbackendtest ${testBackendCommand})
2222add_executable(launcherbackendtestExec
2323 launcherbackendtest.cpp
24− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
24+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
2525 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
2626 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
2727 )
@@ -39,7 +39,7 @@ add_executable(launchermodeltestExec
3939 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launchermodel.cpp
4040 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launcheritem.cpp
4141 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/quicklistmodel.cpp
42− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
42+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
4343 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
4444 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
4545 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h