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
1=== modified file 'Components/EdgeDemo.qml'
2--- Components/EdgeDemo.qml 2013-09-03 14:09:28 +0000
3+++ Components/EdgeDemo.qml 2013-09-05 17:32:14 +0000
4@@ -44,13 +44,13 @@
5
6 function hideEdgeDemoInShell() {
7 var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);
8- AccountsService.setUserProperty(user, "demo-edges", false);
9+ AccountsService.demoEdges = false;
10 d.showEdgeDemo = false;
11 stopDemo();
12 }
13
14 function hideEdgeDemoInGreeter() {
15- // TODO: AccountsService.setUserProperty("lightdm", "demo-edges", false);
16+ // TODO: AccountsService.demoEdges = false as lightdm user
17 d.showEdgeDemoInGreeter = false;
18 }
19
20@@ -80,7 +80,7 @@
21 property QtObject leftEdgeDemo
22 property QtObject finalEdgeDemo
23 property bool showEdgeDemo: false
24- property bool showEdgeDemoInGreeter: d.showEdgeDemo // TODO: AccountsService.getUserProperty("lightdm", "demo-edges")
25+ property bool showEdgeDemoInGreeter: d.showEdgeDemo // TODO: AccountsService.demoEdges as lightdm user
26
27 onShowEdgeDemoInGreeterChanged: {
28 if (!d.overlay && d.showEdgeDemoInGreeter) {
29@@ -126,7 +126,7 @@
30
31 onSelected: {
32 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole)
33- d.showEdgeDemo = AccountsService.getUserProperty(user, "demo-edges")
34+ d.showEdgeDemo = AccountsService.demoEdges
35 }
36 }
37
38
39=== modified file 'Greeter/GreeterContent.qml'
40--- Greeter/GreeterContent.qml 2013-08-28 20:50:37 +0000
41+++ Greeter/GreeterContent.qml 2013-09-05 17:32:14 +0000
42@@ -15,6 +15,7 @@
43 */
44
45 import QtQuick 2.0
46+import AccountsService 0.1
47 import Ubuntu.Components 0.1
48 import LightDM 0.1 as LightDM
49 import "../Components"
50@@ -39,14 +40,30 @@
51 color: "black"
52 }
53
54+ property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : shell.defaultBackground
55+ onBackgroundValueChanged: wallpaper.source = backgroundValue
56+
57 CrossFadeImage {
58 id: wallpaper
59-
60- source: shell.background
61 anchors.fill: parent
62 fadeInFirst: false
63 }
64
65+ // See Shell.qml's backgroundSettings treatment for why we need a separate
66+ // Image, but it boils down to avoiding binding loop detection.
67+ Image {
68+ source: wallpaper.source
69+ height: 0
70+ width: 0
71+ sourceSize.height: 0
72+ sourceSize.width: 0
73+ onStatusChanged: {
74+ if (status == Image.Error && source != shell.defaultBackground) {
75+ wallpaper.source = shell.defaultBackground
76+ }
77+ }
78+ }
79+
80 Rectangle {
81 anchors.fill: parent
82 color: "black"
83@@ -117,18 +134,23 @@
84
85 Infographics {
86 id: infographics
87+ objectName: "infographics"
88 height: narrowMode ? parent.height : 0.75 * parent.height
89 model: greeterContentLoader.infographicModel
90
91- Component.onCompleted: infographics.updateUsername(greeterContentLoader.currentIndex)
92+ property string selectedUser
93+ property string infographicUser: AccountsService.statsWelcomeScreen ? selectedUser : ""
94+ onInfographicUserChanged: updateUsername()
95+
96+ Component.onCompleted: selectedUser = greeterContentLoader.model.data(greeterContentLoader.currentIndex, LightDM.UserRoles.NameRole)
97
98 Connections {
99 target: root
100- onSelected: infographics.updateUsername(uid)
101+ onSelected: infographics.selectedUser = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
102 }
103
104- function updateUsername(uid) {
105- greeterContentLoader.infographicModel.username = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
106+ function updateUsername() {
107+ greeterContentLoader.infographicModel.username = infographicUser;
108 greeterContentLoader.infographicModel.readyForDataChangeSlot();
109 }
110
111
112=== modified file 'Greeter/Infographics.qml'
113--- Greeter/Infographics.qml 2013-09-03 14:39:25 +0000
114+++ Greeter/Infographics.qml 2013-09-05 17:32:14 +0000
115@@ -29,13 +29,20 @@
116 Connections {
117 target: model
118
119+ property bool appeared: false
120+
121+ onDataAboutToAppear: {
122+ // Don't 'hide' on first appearance, since there is no content yet
123+ if (appeared) startHideAnimation() // hide "no data" label
124+ appeared = true
125+ }
126 onDataAppeared: startShowAnimation()
127
128 onDataAboutToChange: startHideAnimation()
129-
130 onDataChanged: startShowAnimation()
131
132 onDataAboutToDisappear: startHideAnimation()
133+ onDataDisappeared: startShowAnimation() // show "no data" label
134 }
135
136 function startShowAnimation() {
137
138=== modified file 'Shell.qml'
139--- Shell.qml 2013-09-04 20:40:11 +0000
140+++ Shell.qml 2013-09-05 17:32:14 +0000
141@@ -15,6 +15,7 @@
142 */
143
144 import QtQuick 2.0
145+import AccountsService 0.1
146 import GSettings 1.0
147 import Ubuntu.Application 0.1
148 import Ubuntu.Components 0.1
149@@ -478,6 +479,7 @@
150 onSelected: {
151 // Update launcher items for new user
152 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
153+ AccountsService.setUser(user);
154 LauncherModel.setUser(user);
155 }
156
157
158=== added file 'plugins/AccountsService/AccountsBindings.cpp'
159--- plugins/AccountsService/AccountsBindings.cpp 1970-01-01 00:00:00 +0000
160+++ plugins/AccountsService/AccountsBindings.cpp 2013-09-05 17:32:14 +0000
161@@ -0,0 +1,116 @@
162+/*
163+ * Copyright (C) 2013 Canonical, Ltd.
164+ *
165+ * This program is free software; you can redistribute it and/or modify
166+ * it under the terms of the GNU General Public License as published by
167+ * the Free Software Foundation; version 3.
168+ *
169+ * This program is distributed in the hope that it will be useful,
170+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
171+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
172+ * GNU General Public License for more details.
173+ *
174+ * You should have received a copy of the GNU General Public License
175+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
176+ *
177+ * Author: Michael Terry <michael.terry@canonical.com>
178+ */
179+
180+#include "AccountsBindings.h"
181+#include "AccountsService.h"
182+
183+#include <QStringList>
184+
185+AccountsBindings::AccountsBindings(QObject* parent)
186+ : QObject(parent),
187+ m_service(new AccountsService(this)),
188+ m_user(qgetenv("USER"))
189+{
190+ connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
191+ this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
192+ connect(m_service, SIGNAL(maybeChanged(const QString &)),
193+ this, SLOT(maybeChanged(const QString &)));
194+}
195+
196+void AccountsBindings::setUser(const QString &user)
197+{
198+ m_user = user;
199+ updateDemoEdges();
200+ updateBackgroundFile();
201+ updateStatsWelcomeScreen();
202+}
203+
204+bool AccountsBindings::getDemoEdges()
205+{
206+ return m_demoEdges;
207+}
208+
209+void AccountsBindings::setDemoEdges(bool demoEdges)
210+{
211+ m_demoEdges = demoEdges;
212+ m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
213+}
214+
215+QString AccountsBindings::getBackgroundFile()
216+{
217+ return m_backgroundFile;
218+}
219+
220+bool AccountsBindings::getStatsWelcomeScreen()
221+{
222+ return m_statsWelcomeScreen;
223+}
224+
225+void AccountsBindings::updateDemoEdges()
226+{
227+ auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
228+ if (m_demoEdges != demoEdges) {
229+ m_demoEdges = demoEdges;
230+ Q_EMIT demoEdgesChanged();
231+ }
232+}
233+
234+void AccountsBindings::updateBackgroundFile()
235+{
236+ auto backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
237+ if (m_backgroundFile != backgroundFile) {
238+ m_backgroundFile = backgroundFile;
239+ Q_EMIT backgroundFileChanged();
240+ }
241+}
242+
243+void AccountsBindings::updateStatsWelcomeScreen()
244+{
245+ auto statsWelcomeScreen = m_service->getUserProperty(m_user, "com.ubuntu.touch.AccountsService.SecurityPrivacy", "StatsWelcomeScreen").toBool();
246+ if (m_statsWelcomeScreen != statsWelcomeScreen) {
247+ m_statsWelcomeScreen = statsWelcomeScreen;
248+ Q_EMIT statsWelcomeScreenChanged();
249+ }
250+}
251+
252+void AccountsBindings::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
253+{
254+ if (m_user != user) {
255+ return;
256+ }
257+
258+ if (interface == "com.canonical.unity.AccountsService") {
259+ if (changed.contains("demo-edges")) {
260+ updateDemoEdges();
261+ }
262+ } else if (interface == "com.ubuntu.touch.AccountsService.SecurityPrivacy") {
263+ if (changed.contains("StatsWelcomeScreen")) {
264+ updateStatsWelcomeScreen();
265+ }
266+ }
267+}
268+
269+void AccountsBindings::maybeChanged(const QString &user)
270+{
271+ if (m_user != user) {
272+ return;
273+ }
274+
275+ // Standard properties might have changed
276+ updateBackgroundFile();
277+}
278
279=== added file 'plugins/AccountsService/AccountsBindings.h'
280--- plugins/AccountsService/AccountsBindings.h 1970-01-01 00:00:00 +0000
281+++ plugins/AccountsService/AccountsBindings.h 2013-09-05 17:32:14 +0000
282@@ -0,0 +1,72 @@
283+/*
284+ * Copyright (C) 2012,2013 Canonical, Ltd.
285+ *
286+ * This program is free software; you can redistribute it and/or modify
287+ * it under the terms of the GNU General Public License as published by
288+ * the Free Software Foundation; version 3.
289+ *
290+ * This program is distributed in the hope that it will be useful,
291+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
292+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
293+ * GNU General Public License for more details.
294+ *
295+ * You should have received a copy of the GNU General Public License
296+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
297+ *
298+ * Authors: Michael Terry <michael.terry@canonical.com>
299+ */
300+
301+#ifndef UNITY_ACCOUNTSBINDINGS_H
302+#define UNITY_ACCOUNTSBINDINGS_H
303+
304+#include <QObject>
305+#include <QString>
306+
307+class AccountsService;
308+
309+class AccountsBindings: public QObject
310+{
311+ Q_OBJECT
312+ Q_PROPERTY (bool demoEdges
313+ READ getDemoEdges
314+ WRITE setDemoEdges
315+ NOTIFY demoEdgesChanged)
316+ Q_PROPERTY (QString backgroundFile
317+ READ getBackgroundFile
318+ NOTIFY backgroundFileChanged)
319+ Q_PROPERTY (bool statsWelcomeScreen
320+ READ getStatsWelcomeScreen
321+ NOTIFY statsWelcomeScreenChanged)
322+
323+public:
324+ explicit AccountsBindings(QObject *parent = 0);
325+
326+ Q_INVOKABLE void setUser(const QString &user);
327+
328+ bool getDemoEdges();
329+ void setDemoEdges(bool demoEdges);
330+ QString getBackgroundFile();
331+ bool getStatsWelcomeScreen();
332+
333+Q_SIGNALS:
334+ void demoEdgesChanged();
335+ void backgroundFileChanged();
336+ void statsWelcomeScreenChanged();
337+
338+private Q_SLOTS:
339+ void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
340+ void maybeChanged(const QString &user);
341+
342+private:
343+ void updateDemoEdges();
344+ void updateBackgroundFile();
345+ void updateStatsWelcomeScreen();
346+
347+ AccountsService *m_service;
348+ QString m_user;
349+ bool m_demoEdges;
350+ QString m_backgroundFile;
351+ bool m_statsWelcomeScreen;
352+};
353+
354+#endif
355
356=== modified file 'plugins/AccountsService/AccountsService.cpp'
357--- plugins/AccountsService/AccountsService.cpp 2013-08-22 14:54:08 +0000
358+++ plugins/AccountsService/AccountsService.cpp 2013-09-05 17:32:14 +0000
359@@ -36,11 +36,11 @@
360 connection, this);
361 }
362
363-QVariant AccountsService::getUserProperty(const QString &user, const QString &property)
364+QVariant AccountsService::getUserProperty(const QString &user, const QString &interface, const QString &property)
365 {
366 auto iface = getUserInterface(user);
367 if (iface != nullptr && iface->isValid()) {
368- auto answer = iface->call("Get", "com.canonical.unity.AccountsService", property);
369+ auto answer = iface->call("Get", interface, property);
370 if (answer.type() == QDBusMessage::ReplyMessage) {
371 return answer.arguments()[0].value<QDBusVariant>().variant();
372 }
373@@ -48,13 +48,40 @@
374 return QVariant();
375 }
376
377-void AccountsService::setUserProperty(const QString &user, const QString &property, const QVariant &value)
378+void AccountsService::setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value)
379 {
380 auto iface = getUserInterface(user);
381 if (iface != nullptr && iface->isValid()) {
382 // The value needs to be carefully wrapped
383- iface->call("Set", "com.canonical.unity.AccountsService", property, QVariant::fromValue(QDBusVariant(value)));
384- }
385+ iface->call("Set", interface, property, QVariant::fromValue(QDBusVariant(value)));
386+ }
387+}
388+
389+void AccountsService::propertiesChangedSlot(const QString &interface, const QVariantMap &changed, const QStringList &invalid)
390+{
391+ // Merge changed and invalidated together
392+ QStringList combined;
393+ combined << invalid;
394+ combined << changed.keys();
395+ combined.removeDuplicates();
396+
397+ Q_EMIT propertiesChanged(getUserForPath(message().path()), interface, combined);
398+}
399+
400+void AccountsService::maybeChangedSlot()
401+{
402+ Q_EMIT maybeChanged(getUserForPath(message().path()));
403+}
404+
405+QString AccountsService::getUserForPath(const QString &path)
406+{
407+ QMap<QString, QDBusInterface *>::const_iterator i;
408+ for (i = users.constBegin(); i != users.constEnd(); ++i) {
409+ if (i.value()->path() == path) {
410+ return i.key();
411+ }
412+ }
413+ return QString();
414 }
415
416 QDBusInterface *AccountsService::getUserInterface(const QString &user)
417@@ -63,10 +90,35 @@
418 if (iface == nullptr && accounts_manager->isValid()) {
419 auto answer = accounts_manager->call("FindUserByName", user);
420 if (answer.type() == QDBusMessage::ReplyMessage) {
421+ auto path = answer.arguments()[0].value<QDBusObjectPath>().path();
422+
423 iface = new QDBusInterface("org.freedesktop.Accounts",
424- answer.arguments()[0].value<QDBusObjectPath>().path(),
425+ path,
426 "org.freedesktop.DBus.Properties",
427 accounts_manager->connection(), this);
428+
429+ // With its own pre-defined properties, AccountsService is oddly
430+ // close-lipped. It won't send out proper DBus.Properties notices,
431+ // but it does have one catch-all Changed() signal. So let's
432+ // listen to that.
433+ iface->connection().connect(
434+ iface->service(),
435+ path,
436+ "org.freedesktop.Accounts.User",
437+ "Changed",
438+ this,
439+ SLOT(maybeChangedSlot()));
440+
441+ // But custom properties do send out the right notifications, so
442+ // let's still listen there.
443+ iface->connection().connect(
444+ iface->service(),
445+ path,
446+ "org.freedesktop.DBus.Properties",
447+ "PropertiesChanged",
448+ this,
449+ SLOT(propertiesChangedSlot(QString, QVariantMap, QStringList)));
450+
451 users.insert(user, iface);
452 }
453 }
454
455=== modified file 'plugins/AccountsService/AccountsService.h'
456--- plugins/AccountsService/AccountsService.h 2013-08-27 17:29:16 +0000
457+++ plugins/AccountsService/AccountsService.h 2013-09-05 17:32:14 +0000
458@@ -19,23 +19,33 @@
459 #ifndef UNITY_ACCOUNTSSERVICE_H
460 #define UNITY_ACCOUNTSSERVICE_H
461
462+#include <QDBusContext>
463 #include <QDBusInterface>
464 #include <QMap>
465 #include <QObject>
466 #include <QString>
467
468-class AccountsService: public QObject
469+class AccountsService: public QObject, public QDBusContext
470 {
471 Q_OBJECT
472
473 public:
474 explicit AccountsService(QObject *parent = 0);
475
476- Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);
477- Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);
478+ Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &interface, const QString &property);
479+ Q_INVOKABLE void setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value);
480+
481+Q_SIGNALS:
482+ void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
483+ void maybeChanged(const QString &user); // Standard properties might have changed
484+
485+private Q_SLOTS:
486+ void propertiesChangedSlot(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
487+ void maybeChangedSlot();
488
489 private:
490 QDBusInterface *getUserInterface(const QString &user);
491+ QString getUserForPath(const QString &path);
492
493 QDBusInterface *accounts_manager;
494 QMap<QString, QDBusInterface *> users;
495
496=== modified file 'plugins/AccountsService/CMakeLists.txt'
497--- plugins/AccountsService/CMakeLists.txt 2013-08-22 20:16:41 +0000
498+++ plugins/AccountsService/CMakeLists.txt 2013-09-05 17:32:14 +0000
499@@ -3,6 +3,7 @@
500 add_definitions(-DSM_BUSNAME=systemBus)
501
502 add_library(AccountsService-qml MODULE
503+ AccountsBindings.cpp
504 AccountsService.cpp
505 plugin.cpp
506 )
507
508=== modified file 'plugins/AccountsService/plugin.cpp'
509--- plugins/AccountsService/plugin.cpp 2013-08-25 21:00:47 +0000
510+++ plugins/AccountsService/plugin.cpp 2013-09-05 17:32:14 +0000
511@@ -17,7 +17,7 @@
512 */
513
514 #include "plugin.h"
515-#include "AccountsService.h"
516+#include "AccountsBindings.h"
517
518 #include <QDBusMetaType>
519 #include <QtQml>
520@@ -26,12 +26,12 @@
521 {
522 Q_UNUSED(engine)
523 Q_UNUSED(scriptEngine)
524- return new AccountsService();
525+ return new AccountsBindings();
526 }
527
528 void AccountsServicePlugin::registerTypes(const char *uri)
529 {
530 Q_ASSERT(uri == QLatin1String("AccountsService"));
531 qDBusRegisterMetaType<QList<QVariantMap>>();
532- qmlRegisterSingletonType<AccountsService>(uri, 0, 1, "AccountsService", service_provider);
533+ qmlRegisterSingletonType<AccountsBindings>(uri, 0, 1, "AccountsService", service_provider);
534 }
535
536=== modified file 'plugins/Unity/Launcher/backend/launcherbackend.cpp'
537--- plugins/Unity/Launcher/backend/launcherbackend.cpp 2013-09-05 16:01:00 +0000
538+++ plugins/Unity/Launcher/backend/launcherbackend.cpp 2013-09-05 17:32:14 +0000
539@@ -213,8 +213,13 @@
540
541 m_storedApps.clear();
542
543+<<<<<<< TREE
544 if (m_accounts && !m_user.isEmpty()) {
545 QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
546+=======
547+ if (m_user != "" && m_accounts != nullptr) {
548+ auto variant = m_accounts->getUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items");
549+>>>>>>> MERGE-SOURCE
550 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
551 defaults = isDefaultsItem(apps);
552 }
553@@ -257,7 +262,7 @@
554 items << itemToVariant(appId);
555 }
556
557- m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
558+ m_accounts->setUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items", QVariant::fromValue(items));
559 }
560 }
561
562
563=== renamed file 'tests/mocks/AccountsService/AccountsService.cpp' => 'tests/mocks/AccountsService/AccountsBindings.cpp'
564--- tests/mocks/AccountsService/AccountsService.cpp 2013-08-02 20:03:16 +0000
565+++ tests/mocks/AccountsService/AccountsBindings.cpp 2013-09-05 17:32:14 +0000
566@@ -16,18 +16,39 @@
567 * Author: Michael Terry <michael.terry@canonical.com>
568 */
569
570-#include "AccountsService.h"
571-
572-AccountsService::AccountsService(QObject* parent)
573- : QObject(parent)
574-{
575-}
576-
577-QVariant AccountsService::getUserProperty(const QString &, const QString &)
578-{
579- return QVariant(false);
580-}
581-
582-void AccountsService::setUserProperty(const QString &, const QString &, const QVariant &)
583-{
584+#include "AccountsBindings.h"
585+
586+AccountsBindings::AccountsBindings(QObject* parent)
587+ : QObject(parent),
588+ m_statsWelcomeScreen(true)
589+{
590+}
591+
592+void AccountsBindings::setUser(const QString &)
593+{
594+}
595+
596+bool AccountsBindings::getDemoEdges()
597+{
598+ return false;
599+}
600+
601+void AccountsBindings::setDemoEdges(bool)
602+{
603+}
604+
605+QString AccountsBindings::getBackgroundFile()
606+{
607+ return TOP_SRCDIR "/graphics/phone_background.jpg";
608+}
609+
610+bool AccountsBindings::getStatsWelcomeScreen()
611+{
612+ return m_statsWelcomeScreen;
613+}
614+
615+void AccountsBindings::setStatsWelcomeScreen(bool statsWelcomeScreen)
616+{
617+ m_statsWelcomeScreen = statsWelcomeScreen;
618+ statsWelcomeScreenChanged();
619 }
620
621=== renamed file 'tests/mocks/AccountsService/AccountsService.h' => 'tests/mocks/AccountsService/AccountsBindings.h'
622--- tests/mocks/AccountsService/AccountsService.h 2013-08-27 17:34:46 +0000
623+++ tests/mocks/AccountsService/AccountsBindings.h 2013-09-05 17:32:14 +0000
624@@ -17,22 +17,46 @@
625 * Michael Terry <michael.terry@canonical.com>
626 */
627
628-#ifndef UNITY_MOCK_ACCOUNTSSERVICE_H
629-#define UNITY_MOCK_ACCOUNTSSERVICE_H
630+#ifndef UNITY_MOCK_ACCOUNTSBINDINGS_H
631+#define UNITY_MOCK_ACCOUNTSBINDINGS_H
632
633 #include <QObject>
634 #include <QString>
635 #include <QVariant>
636
637-class AccountsService: public QObject
638+class AccountsBindings: public QObject
639 {
640 Q_OBJECT
641+ Q_PROPERTY (bool demoEdges
642+ READ getDemoEdges
643+ WRITE setDemoEdges
644+ NOTIFY demoEdgesChanged)
645+ Q_PROPERTY (QString backgroundFile
646+ READ getBackgroundFile
647+ NOTIFY backgroundFileChanged)
648+ Q_PROPERTY (bool statsWelcomeScreen
649+ READ getStatsWelcomeScreen
650+ WRITE setStatsWelcomeScreen // addition for testing
651+ NOTIFY statsWelcomeScreenChanged)
652
653 public:
654- explicit AccountsService(QObject *parent = 0);
655-
656- Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);
657- Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);
658+ explicit AccountsBindings(QObject *parent = 0);
659+
660+ Q_INVOKABLE void setUser(const QString &user);
661+
662+ bool getDemoEdges();
663+ void setDemoEdges(bool demoEdges);
664+ QString getBackgroundFile();
665+ bool getStatsWelcomeScreen();
666+ void setStatsWelcomeScreen(bool statsWelcomeScreen);
667+
668+Q_SIGNALS:
669+ void demoEdgesChanged();
670+ void backgroundFileChanged();
671+ void statsWelcomeScreenChanged();
672+
673+private:
674+ bool m_statsWelcomeScreen;
675 };
676
677 #endif
678
679=== modified file 'tests/mocks/AccountsService/CMakeLists.txt'
680--- tests/mocks/AccountsService/CMakeLists.txt 2013-07-30 23:22:48 +0000
681+++ tests/mocks/AccountsService/CMakeLists.txt 2013-09-05 17:32:14 +0000
682@@ -1,5 +1,7 @@
683+add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
684+
685 add_library(MockAccountsService-qml MODULE
686- AccountsService.cpp
687+ AccountsBindings.cpp
688 plugin.cpp
689 )
690
691
692=== modified file 'tests/mocks/AccountsService/plugin.cpp'
693--- tests/mocks/AccountsService/plugin.cpp 2013-08-27 17:34:46 +0000
694+++ tests/mocks/AccountsService/plugin.cpp 2013-09-05 17:32:14 +0000
695@@ -18,7 +18,7 @@
696 */
697
698 #include "plugin.h"
699-#include "AccountsService.h"
700+#include "AccountsBindings.h"
701
702 #include <QtQml>
703
704@@ -26,11 +26,11 @@
705 {
706 Q_UNUSED(engine)
707 Q_UNUSED(scriptEngine)
708- return new AccountsService();
709+ return new AccountsBindings();
710 }
711
712 void AccountsServicePlugin::registerTypes(const char *uri)
713 {
714 Q_ASSERT(uri == QLatin1String("AccountsService"));
715- qmlRegisterSingletonType<AccountsService>(uri, 0, 1, "AccountsService", service_provider);
716+ qmlRegisterSingletonType<AccountsBindings>(uri, 0, 1, "AccountsService", service_provider);
717 }
718
719=== modified file 'tests/mocks/libusermetrics/UserMetrics.cpp'
720--- tests/mocks/libusermetrics/UserMetrics.cpp 2013-06-14 19:35:25 +0000
721+++ tests/mocks/libusermetrics/UserMetrics.cpp 2013-09-05 17:32:14 +0000
722@@ -407,7 +407,11 @@
723
724 QString UserMetrics::label() const
725 {
726- return d_ptr->m_label;
727+ if (d_ptr->m_label.isEmpty()) {
728+ return "No data";
729+ } else {
730+ return d_ptr->m_label;
731+ }
732 }
733
734 QString UserMetrics::username() const
735
736=== modified file 'tests/plugins/AccountsService/CMakeLists.txt'
737--- tests/plugins/AccountsService/CMakeLists.txt 2013-08-13 23:35:31 +0000
738+++ tests/plugins/AccountsService/CMakeLists.txt 2013-09-05 17:32:14 +0000
739@@ -25,6 +25,7 @@
740
741 add_executable(test-accountsservice
742 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
743+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsBindings.cpp
744 client.cpp
745 )
746 qt5_use_modules(test-accountsservice Core DBus Test)
747
748=== modified file 'tests/plugins/AccountsService/client.cpp'
749--- tests/plugins/AccountsService/client.cpp 2013-08-22 14:54:08 +0000
750+++ tests/plugins/AccountsService/client.cpp 2013-09-05 17:32:14 +0000
751@@ -17,6 +17,7 @@
752 * Authored by: Michael Terry <michael.terry@canonical.com>
753 */
754
755+#include "AccountsBindings.h"
756 #include "AccountsService.h"
757 #include <QSignalSpy>
758 #include <QTest>
759@@ -31,16 +32,27 @@
760 {
761 // Test various invalid calls
762 AccountsService session;
763- QCOMPARE(session.getUserProperty("NOPE", "demo-edges"), QVariant());
764- QCOMPARE(session.getUserProperty("testuser", "NOPE"), QVariant());
765+ QCOMPARE(session.getUserProperty("NOPE", "com.canonical.unity.AccountsService", "demo-edges"), QVariant());
766+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "NOPE"), QVariant());
767 }
768
769- void testGetSet()
770+ void testGetSetService()
771 {
772 AccountsService session;
773- QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(true));
774- session.setUserProperty("testuser", "demo-edges", QVariant(false));
775- QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(false));
776+ session.setUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges", QVariant(true));
777+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges"), QVariant(true));
778+ session.setUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges", QVariant(false));
779+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges"), QVariant(false));
780+ }
781+
782+ void testGetSetBindings()
783+ {
784+ AccountsBindings bindings;
785+ bindings.setUser("testuser");
786+ bindings.setDemoEdges(true);
787+ QCOMPARE(bindings.getDemoEdges(), true);
788+ bindings.setDemoEdges(false);
789+ QCOMPARE(bindings.getDemoEdges(), false);
790 }
791 };
792
793
794=== modified file 'tests/qmltests/Greeter/tst_Infographics.qml'
795--- tests/qmltests/Greeter/tst_Infographics.qml 2013-06-05 22:03:08 +0000
796+++ tests/qmltests/Greeter/tst_Infographics.qml 2013-09-05 17:32:14 +0000
797@@ -64,15 +64,15 @@
798
799 function test_set_username_data() {
800 return [
801- { username: "has-password" },
802- { username: "no-password" },
803- { username: "empty-name" }
804+ { username: "has-password", label: "<b>19</b> minutes talk time" },
805+ { username: "two-factor", label: "No data" },
806+ { username: "", label: "No data" },
807 ]
808 }
809
810 function test_set_username(data) {
811 infographicModel.username = data.username
812- tryCompare(label, "text", "<b>19</b> minutes talk time")
813+ tryCompare(label, "text", data.label)
814 }
815 }
816
817
818=== modified file 'tests/qmltests/Greeter/tst_Phone.qml'
819--- tests/qmltests/Greeter/tst_Phone.qml 2013-06-28 16:39:22 +0000
820+++ tests/qmltests/Greeter/tst_Phone.qml 2013-09-05 17:32:14 +0000
821@@ -21,6 +21,7 @@
822 import Ubuntu.Components 0.1
823 import LightDM 0.1 as LightDM
824 import Unity.Test 0.1 as UT
825+import AccountsService 0.1
826
827 Item {
828 width: units.gu(60)
829@@ -51,6 +52,10 @@
830 name: "Greeter"
831 when: windowShown
832
833+ function cleanup() {
834+ AccountsService.statsWelcomeScreen = true
835+ }
836+
837 function test_properties() {
838 compare(greeter.multiUser, false)
839 compare(greeter.narrowMode, true)
840@@ -102,5 +107,15 @@
841 // Wait until we're back to 0
842 tryCompareFunction(function() { return greeter.x;}, 0);
843 }
844+
845+ function test_statsWelcomeScreen() {
846+ // Test logic in greeter that turns statsWelcomeScreen setting into infographic changes
847+ compare(AccountsService.statsWelcomeScreen, true)
848+ tryCompare(LightDM.Infographic, "username", "single")
849+ AccountsService.statsWelcomeScreen = false
850+ tryCompare(LightDM.Infographic, "username", "")
851+ AccountsService.statsWelcomeScreen = true
852+ tryCompare(LightDM.Infographic, "username", "single")
853+ }
854 }
855 }

Subscribers

People subscribed via source and target branches