Merge lp:~mterry/unity8/statsWelcomeScreen into lp:unity8

Proposed by Michael Terry
Status: Superseded
Proposed branch: lp:~mterry/unity8/statsWelcomeScreen
Merge into: lp:unity8
Diff against target: 855 lines (+426/-60) (has conflicts)
20 files modified
Components/EdgeDemo.qml (+4/-4)
Greeter/GreeterContent.qml (+28/-6)
Greeter/Infographics.qml (+8/-1)
Shell.qml (+2/-0)
plugins/AccountsService/AccountsBindings.cpp (+116/-0)
plugins/AccountsService/AccountsBindings.h (+72/-0)
plugins/AccountsService/AccountsService.cpp (+58/-6)
plugins/AccountsService/AccountsService.h (+13/-3)
plugins/AccountsService/CMakeLists.txt (+1/-0)
plugins/AccountsService/plugin.cpp (+3/-3)
plugins/Unity/Launcher/backend/launcherbackend.cpp (+6/-1)
tests/mocks/AccountsService/AccountsBindings.cpp (+35/-14)
tests/mocks/AccountsService/AccountsBindings.h (+31/-7)
tests/mocks/AccountsService/CMakeLists.txt (+3/-1)
tests/mocks/AccountsService/plugin.cpp (+3/-3)
tests/mocks/libusermetrics/UserMetrics.cpp (+5/-1)
tests/plugins/AccountsService/CMakeLists.txt (+1/-0)
tests/plugins/AccountsService/client.cpp (+18/-6)
tests/qmltests/Greeter/tst_Infographics.qml (+4/-4)
tests/qmltests/Greeter/tst_Phone.qml (+15/-0)
Text conflict in plugins/Unity/Launcher/backend/launcherbackend.cpp
To merge this branch: bzr merge lp:~mterry/unity8/statsWelcomeScreen
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+184152@code.launchpad.net

This proposal has been superseded by a proposal from 2013-09-05.

Commit message

Listen to the system setting StatsWelcomeScreen, which tells us whether to show user-specific infographic data in the greeter.

Description of the change

Listen to the system setting StatsWelcomeScreen, which tells us whether to show user-specific infographic data in the greeter.

In addition to the main attraction, I fixed a bug with animations when switching between data and no-data in the infographic (the change in Infographic.qml). And I added a tiny test for the new feature.

Support for StatsWelcomeScreen is part of bug 1207857, and the option can be seen in the Privacy section of the system settings. Note that toggling that value, as of this writing, doesn't actually work due to a policykit issue. But to manually change the setting, these dbus commands can be used:

To turn stats off:
dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User32011 org.freedesktop.DBus.Properties.Set string:com.ubuntu.touch.AccountsService.SecurityPrivacy string:StatsWelcomeScreen variant:boolean:false

To turn back on again:
dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User32011 org.freedesktop.DBus.Properties.Set string:com.ubuntu.touch.AccountsService.SecurityPrivacy string:StatsWelcomeScreen variant:boolean:true

To post a comment you must log in.
lp:~mterry/unity8/statsWelcomeScreen updated
276. By Michael Terry

Merge from wallpaper branch

277. By Michael Terry

Merge from trunk

278. By Michael Terry

Merge from trunk

279. By Michael Terry

Merge from trunk

280. By Michael Terry

Make function naming match unity8 style

281. By Michael Terry

Don't use auto

282. By Michael Terry

Merge from trunk

283. By Michael Terry

Merge from trunk

284. By Michael Terry

Prevent overlapping animations

285. By Michael Terry

Merge from trunk

286. By Michael Terry

Don't crash if we only ever set an empty username in our mock libusermetrics

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Components/EdgeDemo.qml'
--- Components/EdgeDemo.qml 2013-09-03 14:09:28 +0000
+++ Components/EdgeDemo.qml 2013-09-05 17:32:14 +0000
@@ -44,13 +44,13 @@
4444
45 function hideEdgeDemoInShell() {45 function hideEdgeDemoInShell() {
46 var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);46 var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);
47 AccountsService.setUserProperty(user, "demo-edges", false);47 AccountsService.demoEdges = false;
48 d.showEdgeDemo = false;48 d.showEdgeDemo = false;
49 stopDemo();49 stopDemo();
50 }50 }
5151
52 function hideEdgeDemoInGreeter() {52 function hideEdgeDemoInGreeter() {
53 // TODO: AccountsService.setUserProperty("lightdm", "demo-edges", false);53 // TODO: AccountsService.demoEdges = false as lightdm user
54 d.showEdgeDemoInGreeter = false;54 d.showEdgeDemoInGreeter = false;
55 }55 }
5656
@@ -80,7 +80,7 @@
80 property QtObject leftEdgeDemo80 property QtObject leftEdgeDemo
81 property QtObject finalEdgeDemo81 property QtObject finalEdgeDemo
82 property bool showEdgeDemo: false82 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
85 onShowEdgeDemoInGreeterChanged: {85 onShowEdgeDemoInGreeterChanged: {
86 if (!d.overlay && d.showEdgeDemoInGreeter) {86 if (!d.overlay && d.showEdgeDemoInGreeter) {
@@ -126,7 +126,7 @@
126126
127 onSelected: {127 onSelected: {
128 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole)128 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole)
129 d.showEdgeDemo = AccountsService.getUserProperty(user, "demo-edges")129 d.showEdgeDemo = AccountsService.demoEdges
130 }130 }
131 }131 }
132132
133133
=== modified file 'Greeter/GreeterContent.qml'
--- Greeter/GreeterContent.qml 2013-08-28 20:50:37 +0000
+++ Greeter/GreeterContent.qml 2013-09-05 17:32:14 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18import AccountsService 0.1
18import Ubuntu.Components 0.119import Ubuntu.Components 0.1
19import LightDM 0.1 as LightDM20import LightDM 0.1 as LightDM
20import "../Components"21import "../Components"
@@ -39,14 +40,30 @@
39 color: "black"40 color: "black"
40 }41 }
4142
43 property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : shell.defaultBackground
44 onBackgroundValueChanged: wallpaper.source = backgroundValue
45
42 CrossFadeImage {46 CrossFadeImage {
43 id: wallpaper47 id: wallpaper
44
45 source: shell.background
46 anchors.fill: parent48 anchors.fill: parent
47 fadeInFirst: false49 fadeInFirst: false
48 }50 }
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
50 Rectangle {67 Rectangle {
51 anchors.fill: parent68 anchors.fill: parent
52 color: "black"69 color: "black"
@@ -117,18 +134,23 @@
117134
118 Infographics {135 Infographics {
119 id: infographics136 id: infographics
137 objectName: "infographics"
120 height: narrowMode ? parent.height : 0.75 * parent.height138 height: narrowMode ? parent.height : 0.75 * parent.height
121 model: greeterContentLoader.infographicModel139 model: greeterContentLoader.infographicModel
122140
123 Component.onCompleted: infographics.updateUsername(greeterContentLoader.currentIndex)141 property string selectedUser
142 property string infographicUser: AccountsService.statsWelcomeScreen ? selectedUser : ""
143 onInfographicUserChanged: updateUsername()
144
145 Component.onCompleted: selectedUser = greeterContentLoader.model.data(greeterContentLoader.currentIndex, LightDM.UserRoles.NameRole)
124146
125 Connections {147 Connections {
126 target: root148 target: root
127 onSelected: infographics.updateUsername(uid)149 onSelected: infographics.selectedUser = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
128 }150 }
129151
130 function updateUsername(uid) {152 function updateUsername() {
131 greeterContentLoader.infographicModel.username = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)153 greeterContentLoader.infographicModel.username = infographicUser;
132 greeterContentLoader.infographicModel.readyForDataChangeSlot();154 greeterContentLoader.infographicModel.readyForDataChangeSlot();
133 }155 }
134156
135157
=== modified file 'Greeter/Infographics.qml'
--- Greeter/Infographics.qml 2013-09-03 14:39:25 +0000
+++ Greeter/Infographics.qml 2013-09-05 17:32:14 +0000
@@ -29,13 +29,20 @@
29 Connections {29 Connections {
30 target: model30 target: model
3131
32 property bool appeared: false
33
34 onDataAboutToAppear: {
35 // Don't 'hide' on first appearance, since there is no content yet
36 if (appeared) startHideAnimation() // hide "no data" label
37 appeared = true
38 }
32 onDataAppeared: startShowAnimation()39 onDataAppeared: startShowAnimation()
3340
34 onDataAboutToChange: startHideAnimation()41 onDataAboutToChange: startHideAnimation()
35
36 onDataChanged: startShowAnimation()42 onDataChanged: startShowAnimation()
3743
38 onDataAboutToDisappear: startHideAnimation()44 onDataAboutToDisappear: startHideAnimation()
45 onDataDisappeared: startShowAnimation() // show "no data" label
39 }46 }
4047
41 function startShowAnimation() {48 function startShowAnimation() {
4249
=== modified file 'Shell.qml'
--- Shell.qml 2013-09-04 20:40:11 +0000
+++ Shell.qml 2013-09-05 17:32:14 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18import AccountsService 0.1
18import GSettings 1.019import GSettings 1.0
19import Ubuntu.Application 0.120import Ubuntu.Application 0.1
20import Ubuntu.Components 0.121import Ubuntu.Components 0.1
@@ -478,6 +479,7 @@
478 onSelected: {479 onSelected: {
479 // Update launcher items for new user480 // Update launcher items for new user
480 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);481 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
482 AccountsService.setUser(user);
481 LauncherModel.setUser(user);483 LauncherModel.setUser(user);
482 }484 }
483485
484486
=== added file 'plugins/AccountsService/AccountsBindings.cpp'
--- plugins/AccountsService/AccountsBindings.cpp 1970-01-01 00:00:00 +0000
+++ plugins/AccountsService/AccountsBindings.cpp 2013-09-05 17:32:14 +0000
@@ -0,0 +1,116 @@
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 "AccountsBindings.h"
20#include "AccountsService.h"
21
22#include <QStringList>
23
24AccountsBindings::AccountsBindings(QObject* parent)
25 : QObject(parent),
26 m_service(new AccountsService(this)),
27 m_user(qgetenv("USER"))
28{
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 &)));
33}
34
35void AccountsBindings::setUser(const QString &user)
36{
37 m_user = user;
38 updateDemoEdges();
39 updateBackgroundFile();
40 updateStatsWelcomeScreen();
41}
42
43bool AccountsBindings::getDemoEdges()
44{
45 return m_demoEdges;
46}
47
48void AccountsBindings::setDemoEdges(bool demoEdges)
49{
50 m_demoEdges = demoEdges;
51 m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
52}
53
54QString AccountsBindings::getBackgroundFile()
55{
56 return m_backgroundFile;
57}
58
59bool AccountsBindings::getStatsWelcomeScreen()
60{
61 return m_statsWelcomeScreen;
62}
63
64void AccountsBindings::updateDemoEdges()
65{
66 auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
67 if (m_demoEdges != demoEdges) {
68 m_demoEdges = demoEdges;
69 Q_EMIT demoEdgesChanged();
70 }
71}
72
73void AccountsBindings::updateBackgroundFile()
74{
75 auto backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
76 if (m_backgroundFile != backgroundFile) {
77 m_backgroundFile = backgroundFile;
78 Q_EMIT backgroundFileChanged();
79 }
80}
81
82void AccountsBindings::updateStatsWelcomeScreen()
83{
84 auto statsWelcomeScreen = m_service->getUserProperty(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen").toBool();
85 if (m_statsWelcomeScreen != statsWelcomeScreen) {
86 m_statsWelcomeScreen = statsWelcomeScreen;
87 Q_EMIT statsWelcomeScreenChanged();
88 }
89}
90
91void AccountsBindings::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
92{
93 if (m_user != user) {
94 return;
95 }
96
97 if (interface == "com.canonical.unity.AccountsService") {
98 if (changed.contains("demo-edges")) {
99 updateDemoEdges();
100 }
101 } else if (interface == "com.ubuntu.touch.AccountsService.SecurityPrivacy") {
102 if (changed.contains("StatsWelcomeScreen")) {
103 updateStatsWelcomeScreen();
104 }
105 }
106}
107
108void AccountsBindings::maybeChanged(const QString &user)
109{
110 if (m_user != user) {
111 return;
112 }
113
114 // Standard properties might have changed
115 updateBackgroundFile();
116}
0117
=== added file 'plugins/AccountsService/AccountsBindings.h'
--- plugins/AccountsService/AccountsBindings.h 1970-01-01 00:00:00 +0000
+++ plugins/AccountsService/AccountsBindings.h 2013-09-05 17:32:14 +0000
@@ -0,0 +1,72 @@
1/*
2 * Copyright (C) 2012,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_ACCOUNTSBINDINGS_H
20#define UNITY_ACCOUNTSBINDINGS_H
21
22#include <QObject>
23#include <QString>
24
25class AccountsService;
26
27class AccountsBindings: public QObject
28{
29 Q_OBJECT
30 Q_PROPERTY (bool demoEdges
31 READ getDemoEdges
32 WRITE setDemoEdges
33 NOTIFY demoEdgesChanged)
34 Q_PROPERTY (QString backgroundFile
35 READ getBackgroundFile
36 NOTIFY backgroundFileChanged)
37 Q_PROPERTY (bool statsWelcomeScreen
38 READ getStatsWelcomeScreen
39 NOTIFY statsWelcomeScreenChanged)
40
41public:
42 explicit AccountsBindings(QObject *parent = 0);
43
44 Q_INVOKABLE void setUser(const QString &user);
45
46 bool getDemoEdges();
47 void setDemoEdges(bool demoEdges);
48 QString getBackgroundFile();
49 bool getStatsWelcomeScreen();
50
51Q_SIGNALS:
52 void demoEdgesChanged();
53 void backgroundFileChanged();
54 void statsWelcomeScreenChanged();
55
56private Q_SLOTS:
57 void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
58 void maybeChanged(const QString &user);
59
60private:
61 void updateDemoEdges();
62 void updateBackgroundFile();
63 void updateStatsWelcomeScreen();
64
65 AccountsService *m_service;
66 QString m_user;
67 bool m_demoEdges;
68 QString m_backgroundFile;
69 bool m_statsWelcomeScreen;
70};
71
72#endif
073
=== modified file 'plugins/AccountsService/AccountsService.cpp'
--- plugins/AccountsService/AccountsService.cpp 2013-08-22 14:54:08 +0000
+++ plugins/AccountsService/AccountsService.cpp 2013-09-05 17:32:14 +0000
@@ -36,11 +36,11 @@
36 connection, this);36 connection, this);
37}37}
3838
39QVariant AccountsService::getUserProperty(const QString &user, const QString &property)39QVariant AccountsService::getUserProperty(const QString &user, const QString &interface, const QString &property)
40{40{
41 auto iface = getUserInterface(user);41 auto iface = getUserInterface(user);
42 if (iface != nullptr && iface->isValid()) {42 if (iface != nullptr && iface->isValid()) {
43 auto answer = iface->call("Get", "com.canonical.unity.AccountsService", property);43 auto answer = iface->call("Get", interface, property);
44 if (answer.type() == QDBusMessage::ReplyMessage) {44 if (answer.type() == QDBusMessage::ReplyMessage) {
45 return answer.arguments()[0].value<QDBusVariant>().variant();45 return answer.arguments()[0].value<QDBusVariant>().variant();
46 }46 }
@@ -48,13 +48,40 @@
48 return QVariant();48 return QVariant();
49}49}
5050
51void AccountsService::setUserProperty(const QString &user, const QString &property, const QVariant &value)51void AccountsService::setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value)
52{52{
53 auto iface = getUserInterface(user);53 auto iface = getUserInterface(user);
54 if (iface != nullptr && iface->isValid()) {54 if (iface != nullptr && iface->isValid()) {
55 // The value needs to be carefully wrapped55 // The value needs to be carefully wrapped
56 iface->call("Set", "com.canonical.unity.AccountsService", property, QVariant::fromValue(QDBusVariant(value)));56 iface->call("Set", interface, property, QVariant::fromValue(QDBusVariant(value)));
57 }57 }
58}
59
60void AccountsService::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
71void AccountsService::maybeChangedSlot()
72{
73 Q_EMIT maybeChanged(getUserForPath(message().path()));
74}
75
76QString AccountsService::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();
58}85}
5986
60QDBusInterface *AccountsService::getUserInterface(const QString &user)87QDBusInterface *AccountsService::getUserInterface(const QString &user)
@@ -63,10 +90,35 @@
63 if (iface == nullptr && accounts_manager->isValid()) {90 if (iface == nullptr && accounts_manager->isValid()) {
64 auto answer = accounts_manager->call("FindUserByName", user);91 auto answer = accounts_manager->call("FindUserByName", user);
65 if (answer.type() == QDBusMessage::ReplyMessage) {92 if (answer.type() == QDBusMessage::ReplyMessage) {
93 auto path = answer.arguments()[0].value<QDBusObjectPath>().path();
94
66 iface = new QDBusInterface("org.freedesktop.Accounts",95 iface = new QDBusInterface("org.freedesktop.Accounts",
67 answer.arguments()[0].value<QDBusObjectPath>().path(),96 path,
68 "org.freedesktop.DBus.Properties",97 "org.freedesktop.DBus.Properties",
69 accounts_manager->connection(), this);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
70 users.insert(user, iface);122 users.insert(user, iface);
71 }123 }
72 }124 }
73125
=== modified file 'plugins/AccountsService/AccountsService.h'
--- plugins/AccountsService/AccountsService.h 2013-08-27 17:29:16 +0000
+++ plugins/AccountsService/AccountsService.h 2013-09-05 17:32:14 +0000
@@ -19,23 +19,33 @@
19#ifndef UNITY_ACCOUNTSSERVICE_H19#ifndef UNITY_ACCOUNTSSERVICE_H
20#define UNITY_ACCOUNTSSERVICE_H20#define UNITY_ACCOUNTSSERVICE_H
2121
22#include <QDBusContext>
22#include <QDBusInterface>23#include <QDBusInterface>
23#include <QMap>24#include <QMap>
24#include <QObject>25#include <QObject>
25#include <QString>26#include <QString>
2627
27class AccountsService: public QObject28class AccountsService: public QObject, public QDBusContext
28{29{
29 Q_OBJECT30 Q_OBJECT
3031
31public:32public:
32 explicit AccountsService(QObject *parent = 0);33 explicit AccountsService(QObject *parent = 0);
3334
34 Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);35 Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &interface, const QString &property);
35 Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);36 Q_INVOKABLE void setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value);
37
38Q_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
42private Q_SLOTS:
43 void propertiesChangedSlot(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
44 void maybeChangedSlot();
3645
37private:46private:
38 QDBusInterface *getUserInterface(const QString &user);47 QDBusInterface *getUserInterface(const QString &user);
48 QString getUserForPath(const QString &path);
3949
40 QDBusInterface *accounts_manager;50 QDBusInterface *accounts_manager;
41 QMap<QString, QDBusInterface *> users;51 QMap<QString, QDBusInterface *> users;
4252
=== modified file 'plugins/AccountsService/CMakeLists.txt'
--- plugins/AccountsService/CMakeLists.txt 2013-08-22 20:16:41 +0000
+++ plugins/AccountsService/CMakeLists.txt 2013-09-05 17:32:14 +0000
@@ -3,6 +3,7 @@
3add_definitions(-DSM_BUSNAME=systemBus)3add_definitions(-DSM_BUSNAME=systemBus)
44
5add_library(AccountsService-qml MODULE5add_library(AccountsService-qml MODULE
6 AccountsBindings.cpp
6 AccountsService.cpp7 AccountsService.cpp
7 plugin.cpp8 plugin.cpp
8 )9 )
910
=== modified file 'plugins/AccountsService/plugin.cpp'
--- plugins/AccountsService/plugin.cpp 2013-08-25 21:00:47 +0000
+++ plugins/AccountsService/plugin.cpp 2013-09-05 17:32:14 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "plugin.h"19#include "plugin.h"
20#include "AccountsService.h"20#include "AccountsBindings.h"
2121
22#include <QDBusMetaType>22#include <QDBusMetaType>
23#include <QtQml>23#include <QtQml>
@@ -26,12 +26,12 @@
26{26{
27 Q_UNUSED(engine)27 Q_UNUSED(engine)
28 Q_UNUSED(scriptEngine)28 Q_UNUSED(scriptEngine)
29 return new AccountsService();29 return new AccountsBindings();
30}30}
3131
32void AccountsServicePlugin::registerTypes(const char *uri)32void AccountsServicePlugin::registerTypes(const char *uri)
33{33{
34 Q_ASSERT(uri == QLatin1String("AccountsService"));34 Q_ASSERT(uri == QLatin1String("AccountsService"));
35 qDBusRegisterMetaType<QList<QVariantMap>>();35 qDBusRegisterMetaType<QList<QVariantMap>>();
36 qmlRegisterSingletonType<AccountsService>(uri, 0, 1, "AccountsService", service_provider);36 qmlRegisterSingletonType<AccountsBindings>(uri, 0, 1, "AccountsService", service_provider);
37}37}
3838
=== modified file 'plugins/Unity/Launcher/backend/launcherbackend.cpp'
--- plugins/Unity/Launcher/backend/launcherbackend.cpp 2013-09-05 16:01:00 +0000
+++ plugins/Unity/Launcher/backend/launcherbackend.cpp 2013-09-05 17:32:14 +0000
@@ -213,8 +213,13 @@
213213
214 m_storedApps.clear();214 m_storedApps.clear();
215215
216<<<<<<< TREE
216 if (m_accounts && !m_user.isEmpty()) {217 if (m_accounts && !m_user.isEmpty()) {
217 QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");218 QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
219=======
220 if (m_user != "" && m_accounts != nullptr) {
221 auto variant = m_accounts->getUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items");
222>>>>>>> MERGE-SOURCE
218 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());223 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
219 defaults = isDefaultsItem(apps);224 defaults = isDefaultsItem(apps);
220 }225 }
@@ -257,7 +262,7 @@
257 items << itemToVariant(appId);262 items << itemToVariant(appId);
258 }263 }
259264
260 m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));265 m_accounts->setUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items", QVariant::fromValue(items));
261 }266 }
262}267}
263268
264269
=== renamed file 'tests/mocks/AccountsService/AccountsService.cpp' => 'tests/mocks/AccountsService/AccountsBindings.cpp'
--- tests/mocks/AccountsService/AccountsService.cpp 2013-08-02 20:03:16 +0000
+++ tests/mocks/AccountsService/AccountsBindings.cpp 2013-09-05 17:32:14 +0000
@@ -16,18 +16,39 @@
16 * Author: Michael Terry <michael.terry@canonical.com>16 * Author: Michael Terry <michael.terry@canonical.com>
17 */17 */
1818
19#include "AccountsService.h"19#include "AccountsBindings.h"
2020
21AccountsService::AccountsService(QObject* parent)21AccountsBindings::AccountsBindings(QObject* parent)
22 : QObject(parent)22 : QObject(parent),
23{23 m_statsWelcomeScreen(true)
24}24{
2525}
26QVariant AccountsService::getUserProperty(const QString &, const QString &)26
27{27void AccountsBindings::setUser(const QString &)
28 return QVariant(false);28{
29}29}
3030
31void AccountsService::setUserProperty(const QString &, const QString &, const QVariant &)31bool AccountsBindings::getDemoEdges()
32{32{
33 return false;
34}
35
36void AccountsBindings::setDemoEdges(bool)
37{
38}
39
40QString AccountsBindings::getBackgroundFile()
41{
42 return TOP_SRCDIR "/graphics/phone_background.jpg";
43}
44
45bool AccountsBindings::getStatsWelcomeScreen()
46{
47 return m_statsWelcomeScreen;
48}
49
50void AccountsBindings::setStatsWelcomeScreen(bool statsWelcomeScreen)
51{
52 m_statsWelcomeScreen = statsWelcomeScreen;
53 statsWelcomeScreenChanged();
33}54}
3455
=== renamed file 'tests/mocks/AccountsService/AccountsService.h' => 'tests/mocks/AccountsService/AccountsBindings.h'
--- tests/mocks/AccountsService/AccountsService.h 2013-08-27 17:34:46 +0000
+++ tests/mocks/AccountsService/AccountsBindings.h 2013-09-05 17:32:14 +0000
@@ -17,22 +17,46 @@
17 * Michael Terry <michael.terry@canonical.com>17 * Michael Terry <michael.terry@canonical.com>
18 */18 */
1919
20#ifndef UNITY_MOCK_ACCOUNTSSERVICE_H20#ifndef UNITY_MOCK_ACCOUNTSBINDINGS_H
21#define UNITY_MOCK_ACCOUNTSSERVICE_H21#define UNITY_MOCK_ACCOUNTSBINDINGS_H
2222
23#include <QObject>23#include <QObject>
24#include <QString>24#include <QString>
25#include <QVariant>25#include <QVariant>
2626
27class AccountsService: public QObject27class AccountsBindings: public QObject
28{28{
29 Q_OBJECT29 Q_OBJECT
30 Q_PROPERTY (bool demoEdges
31 READ getDemoEdges
32 WRITE setDemoEdges
33 NOTIFY demoEdgesChanged)
34 Q_PROPERTY (QString backgroundFile
35 READ getBackgroundFile
36 NOTIFY backgroundFileChanged)
37 Q_PROPERTY (bool statsWelcomeScreen
38 READ getStatsWelcomeScreen
39 WRITE setStatsWelcomeScreen // addition for testing
40 NOTIFY statsWelcomeScreenChanged)
3041
31public:42public:
32 explicit AccountsService(QObject *parent = 0);43 explicit AccountsBindings(QObject *parent = 0);
3344
34 Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);45 Q_INVOKABLE void setUser(const QString &user);
35 Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);46
47 bool getDemoEdges();
48 void setDemoEdges(bool demoEdges);
49 QString getBackgroundFile();
50 bool getStatsWelcomeScreen();
51 void setStatsWelcomeScreen(bool statsWelcomeScreen);
52
53Q_SIGNALS:
54 void demoEdgesChanged();
55 void backgroundFileChanged();
56 void statsWelcomeScreenChanged();
57
58private:
59 bool m_statsWelcomeScreen;
36};60};
3761
38#endif62#endif
3963
=== modified file 'tests/mocks/AccountsService/CMakeLists.txt'
--- tests/mocks/AccountsService/CMakeLists.txt 2013-07-30 23:22:48 +0000
+++ tests/mocks/AccountsService/CMakeLists.txt 2013-09-05 17:32:14 +0000
@@ -1,5 +1,7 @@
1add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
2
1add_library(MockAccountsService-qml MODULE3add_library(MockAccountsService-qml MODULE
2 AccountsService.cpp4 AccountsBindings.cpp
3 plugin.cpp5 plugin.cpp
4 )6 )
57
68
=== modified file 'tests/mocks/AccountsService/plugin.cpp'
--- tests/mocks/AccountsService/plugin.cpp 2013-08-27 17:34:46 +0000
+++ tests/mocks/AccountsService/plugin.cpp 2013-09-05 17:32:14 +0000
@@ -18,7 +18,7 @@
18 */18 */
1919
20#include "plugin.h"20#include "plugin.h"
21#include "AccountsService.h"21#include "AccountsBindings.h"
2222
23#include <QtQml>23#include <QtQml>
2424
@@ -26,11 +26,11 @@
26{26{
27 Q_UNUSED(engine)27 Q_UNUSED(engine)
28 Q_UNUSED(scriptEngine)28 Q_UNUSED(scriptEngine)
29 return new AccountsService();29 return new AccountsBindings();
30}30}
3131
32void AccountsServicePlugin::registerTypes(const char *uri)32void AccountsServicePlugin::registerTypes(const char *uri)
33{33{
34 Q_ASSERT(uri == QLatin1String("AccountsService"));34 Q_ASSERT(uri == QLatin1String("AccountsService"));
35 qmlRegisterSingletonType<AccountsService>(uri, 0, 1, "AccountsService", service_provider);35 qmlRegisterSingletonType<AccountsBindings>(uri, 0, 1, "AccountsService", service_provider);
36}36}
3737
=== modified file 'tests/mocks/libusermetrics/UserMetrics.cpp'
--- tests/mocks/libusermetrics/UserMetrics.cpp 2013-06-14 19:35:25 +0000
+++ tests/mocks/libusermetrics/UserMetrics.cpp 2013-09-05 17:32:14 +0000
@@ -407,7 +407,11 @@
407407
408QString UserMetrics::label() const408QString UserMetrics::label() const
409{409{
410 return d_ptr->m_label;410 if (d_ptr->m_label.isEmpty()) {
411 return "No data";
412 } else {
413 return d_ptr->m_label;
414 }
411}415}
412416
413QString UserMetrics::username() const417QString UserMetrics::username() const
414418
=== modified file 'tests/plugins/AccountsService/CMakeLists.txt'
--- tests/plugins/AccountsService/CMakeLists.txt 2013-08-13 23:35:31 +0000
+++ tests/plugins/AccountsService/CMakeLists.txt 2013-09-05 17:32:14 +0000
@@ -25,6 +25,7 @@
2525
26add_executable(test-accountsservice26add_executable(test-accountsservice
27 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp27 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
28 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsBindings.cpp
28 client.cpp29 client.cpp
29 )30 )
30qt5_use_modules(test-accountsservice Core DBus Test)31qt5_use_modules(test-accountsservice Core DBus Test)
3132
=== modified file 'tests/plugins/AccountsService/client.cpp'
--- tests/plugins/AccountsService/client.cpp 2013-08-22 14:54:08 +0000
+++ tests/plugins/AccountsService/client.cpp 2013-09-05 17:32:14 +0000
@@ -17,6 +17,7 @@
17 * Authored by: Michael Terry <michael.terry@canonical.com>17 * Authored by: Michael Terry <michael.terry@canonical.com>
18 */18 */
1919
20#include "AccountsBindings.h"
20#include "AccountsService.h"21#include "AccountsService.h"
21#include <QSignalSpy>22#include <QSignalSpy>
22#include <QTest>23#include <QTest>
@@ -31,16 +32,27 @@
31 {32 {
32 // Test various invalid calls33 // Test various invalid calls
33 AccountsService session;34 AccountsService session;
34 QCOMPARE(session.getUserProperty("NOPE", "demo-edges"), QVariant());35 QCOMPARE(session.getUserProperty("NOPE", "com.canonical.unity.AccountsService", "demo-edges"), QVariant());
35 QCOMPARE(session.getUserProperty("testuser", "NOPE"), QVariant());36 QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "NOPE"), QVariant());
36 }37 }
3738
38 void testGetSet()39 void testGetSetService()
39 {40 {
40 AccountsService session;41 AccountsService session;
41 QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(true));42 session.setUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges", QVariant(true));
42 session.setUserProperty("testuser", "demo-edges", QVariant(false));43 QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges"), QVariant(true));
43 QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(false));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));
46 }
47
48 void testGetSetBindings()
49 {
50 AccountsBindings bindings;
51 bindings.setUser("testuser");
52 bindings.setDemoEdges(true);
53 QCOMPARE(bindings.getDemoEdges(), true);
54 bindings.setDemoEdges(false);
55 QCOMPARE(bindings.getDemoEdges(), false);
44 }56 }
45};57};
4658
4759
=== modified file 'tests/qmltests/Greeter/tst_Infographics.qml'
--- tests/qmltests/Greeter/tst_Infographics.qml 2013-06-05 22:03:08 +0000
+++ tests/qmltests/Greeter/tst_Infographics.qml 2013-09-05 17:32:14 +0000
@@ -64,15 +64,15 @@
6464
65 function test_set_username_data() {65 function test_set_username_data() {
66 return [66 return [
67 { username: "has-password" },67 { username: "has-password", label: "<b>19</b> minutes talk time" },
68 { username: "no-password" },68 { username: "two-factor", label: "No data" },
69 { username: "empty-name" }69 { username: "", label: "No data" },
70 ]70 ]
71 }71 }
7272
73 function test_set_username(data) {73 function test_set_username(data) {
74 infographicModel.username = data.username74 infographicModel.username = data.username
75 tryCompare(label, "text", "<b>19</b> minutes talk time")75 tryCompare(label, "text", data.label)
76 }76 }
77 }77 }
7878
7979
=== modified file 'tests/qmltests/Greeter/tst_Phone.qml'
--- tests/qmltests/Greeter/tst_Phone.qml 2013-06-28 16:39:22 +0000
+++ tests/qmltests/Greeter/tst_Phone.qml 2013-09-05 17:32:14 +0000
@@ -21,6 +21,7 @@
21import Ubuntu.Components 0.121import Ubuntu.Components 0.1
22import LightDM 0.1 as LightDM22import LightDM 0.1 as LightDM
23import Unity.Test 0.1 as UT23import Unity.Test 0.1 as UT
24import AccountsService 0.1
2425
25Item {26Item {
26 width: units.gu(60)27 width: units.gu(60)
@@ -51,6 +52,10 @@
51 name: "Greeter"52 name: "Greeter"
52 when: windowShown53 when: windowShown
5354
55 function cleanup() {
56 AccountsService.statsWelcomeScreen = true
57 }
58
54 function test_properties() {59 function test_properties() {
55 compare(greeter.multiUser, false)60 compare(greeter.multiUser, false)
56 compare(greeter.narrowMode, true)61 compare(greeter.narrowMode, true)
@@ -102,5 +107,15 @@
102 // Wait until we're back to 0107 // Wait until we're back to 0
103 tryCompareFunction(function() { return greeter.x;}, 0);108 tryCompareFunction(function() { return greeter.x;}, 0);
104 }109 }
110
111 function test_statsWelcomeScreen() {
112 // Test logic in greeter that turns statsWelcomeScreen setting into infographic changes
113 compare(AccountsService.statsWelcomeScreen, true)
114 tryCompare(LightDM.Infographic, "username", "single")
115 AccountsService.statsWelcomeScreen = false
116 tryCompare(LightDM.Infographic, "username", "")
117 AccountsService.statsWelcomeScreen = true
118 tryCompare(LightDM.Infographic, "username", "single")
119 }
105 }120 }
106}121}

Subscribers

People subscribed via source and target branches