Merge lp:~mterry/unity8/greeter-wallpaper into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Michael Terry
Approved revision: 279
Merged at revision: 302
Proposed branch: lp:~mterry/unity8/greeter-wallpaper
Merge into: lp:unity8
Diff against target: 727 lines (+361/-55)
17 files modified
Components/EdgeDemo.qml (+4/-4)
Greeter/GreeterContent.qml (+19/-2)
Shell.qml (+2/-0)
plugins/AccountsService/AccountsService.cpp (+104/-0)
plugins/AccountsService/AccountsService.h (+70/-0)
plugins/AccountsService/AccountsServiceDBusAdaptor.cpp (+63/-11)
plugins/AccountsService/AccountsServiceDBusAdaptor.h (+18/-8)
plugins/AccountsService/CMakeLists.txt (+1/-0)
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 (+23/-7)
tests/mocks/AccountsService/AccountsService.h (+22/-3)
tests/mocks/AccountsService/CMakeLists.txt (+2/-0)
tests/plugins/AccountsService/CMakeLists.txt (+1/-0)
tests/plugins/AccountsService/client.cpp (+23/-11)
tests/plugins/Unity/Launcher/CMakeLists.txt (+2/-2)
To merge this branch: bzr merge lp:~mterry/unity8/greeter-wallpaper
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michael Zanetti (community) Approve
Review via email: mp+183018@code.launchpad.net

Commit message

Have the greeter use AccountsService to determine its background.

Description of the change

Have the greeter use AccountsService to determine its background.

See the design: https://wiki.ubuntu.com/Appearance#Phone

Note that the user can have separate backgrounds for the greeter and the session. The session uses gsettings, and the greeter uses AccountsService. This is also what the greeter uses on the desktop (although there, the session makes sure that the two values are in sync rather than allowing them to be different).

Along the way, I cleaned up the AccountsService plugin to be more Qml-like. Bindable properties with change notifications for the properties we care about.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

554 + Q_INVOKABLE void setUser(const QString &user);

Why not make this a property too?

review: Needs Information
Revision history for this message
Michael Terry (mterry) wrote :

No reason. I was just thinking that since I only needed a set, not a get/notify, a method would do. And I don't (yet!) dream in Qml so it didn't feel weird to me. :)

I've made it a property in latest revision.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

518 +void AccountsBindings::setUser(const QString &)
519 +{
520 +}

527 +void AccountsBindings::setDemoEdges(bool)
528 +{
529 +}

Please use Q_UNUSED to get rid of the compiler warnings.

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

> Please use Q_UNUSED to get rid of the compiler warnings.

Done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

tbh I really don't like the naming of the classes...

imho AccountsBindings should still be AccountsService and the current AccountsService should be AccountsServiceDBusAdaptor or something like that.

but maybe its just me... what do you think?

review: Needs Information
Revision history for this message
Michael Terry (mterry) wrote :

Well, note that from Qml, it still is exposed as AccountsService.

But I figured the AccountsService class was more "accurate" to the DBus service. So it should get the name. While the class that bridged the gap between the service and Qml should be called Bindings.

But I don't care much. I'm happy to rename.

Revision history for this message
Michael Terry (mterry) wrote :

Renamed!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Re-approving to get a clean run after today's jenkins issues.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

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 18:10:06 +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 18:10:06 +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"
5370
=== modified file 'Shell.qml'
--- Shell.qml 2013-09-04 20:40:11 +0000
+++ Shell.qml 2013-09-05 18:10:06 +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.user = user;
481 LauncherModel.setUser(user);483 LauncherModel.setUser(user);
482 }484 }
483485
484486
=== added file 'plugins/AccountsService/AccountsService.cpp'
--- plugins/AccountsService/AccountsService.cpp 1970-01-01 00:00:00 +0000
+++ plugins/AccountsService/AccountsService.cpp 2013-09-05 18:10:06 +0000
@@ -0,0 +1,104 @@
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 "AccountsService.h"
20#include "AccountsServiceDBusAdaptor.h"
21
22#include <QStringList>
23
24AccountsService::AccountsService(QObject* parent)
25 : QObject(parent),
26 m_service(new AccountsServiceDBusAdaptor(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
35QString AccountsService::getUser()
36{
37 return m_user;
38}
39
40void AccountsService::setUser(const QString &user)
41{
42 m_user = user;
43 Q_EMIT userChanged();
44
45 updateDemoEdges();
46 updateBackgroundFile();
47}
48
49bool AccountsService::getDemoEdges()
50{
51 return m_demoEdges;
52}
53
54void AccountsService::setDemoEdges(bool demoEdges)
55{
56 m_demoEdges = demoEdges;
57 m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
58}
59
60QString AccountsService::getBackgroundFile()
61{
62 return m_backgroundFile;
63}
64
65void 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();
71 }
72}
73
74void AccountsService::updateBackgroundFile()
75{
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();
80 }
81}
82
83void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
84{
85 if (m_user != user) {
86 return;
87 }
88
89 if (interface == "com.canonical.unity.AccountsService") {
90 if (changed.contains("demo-edges")) {
91 updateDemoEdges();
92 }
93 }
94}
95
96void AccountsService::maybeChanged(const QString &user)
97{
98 if (m_user != user) {
99 return;
100 }
101
102 // Standard properties might have changed
103 updateBackgroundFile();
104}
0105
=== added file 'plugins/AccountsService/AccountsService.h'
--- plugins/AccountsService/AccountsService.h 1970-01-01 00:00:00 +0000
+++ plugins/AccountsService/AccountsService.h 2013-09-05 18:10:06 +0000
@@ -0,0 +1,70 @@
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_ACCOUNTSSERVICE_H
20#define UNITY_ACCOUNTSSERVICE_H
21
22#include <QObject>
23#include <QString>
24
25class AccountsServiceDBusAdaptor;
26
27class AccountsService: public QObject
28{
29 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)
41
42public:
43 explicit AccountsService(QObject *parent = 0);
44
45 QString getUser();
46 void setUser(const QString &user);
47 bool getDemoEdges();
48 void setDemoEdges(bool demoEdges);
49 QString getBackgroundFile();
50
51Q_SIGNALS:
52 void userChanged();
53 void demoEdgesChanged();
54 void backgroundFileChanged();
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
64 AccountsServiceDBusAdaptor *m_service;
65 QString m_user;
66 bool m_demoEdges;
67 QString m_backgroundFile;
68};
69
70#endif
071
=== renamed file 'plugins/AccountsService/AccountsService.cpp' => 'plugins/AccountsService/AccountsServiceDBusAdaptor.cpp'
--- plugins/AccountsService/AccountsService.cpp 2013-08-22 14:54:08 +0000
+++ plugins/AccountsService/AccountsServiceDBusAdaptor.cpp 2013-09-05 18:10:06 +0000
@@ -16,13 +16,13 @@
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 "AccountsServiceDBusAdaptor.h"
20#include <QDBusConnection>20#include <QDBusConnection>
21#include <QDBusConnectionInterface>21#include <QDBusConnectionInterface>
22#include <QDBusMessage>22#include <QDBusMessage>
23#include <QDBusVariant>23#include <QDBusVariant>
2424
25AccountsService::AccountsService(QObject* parent)25AccountsServiceDBusAdaptor::AccountsServiceDBusAdaptor(QObject* parent)
26 : QObject(parent),26 : QObject(parent),
27 accounts_manager(NULL),27 accounts_manager(NULL),
28 users()28 users()
@@ -36,11 +36,11 @@
36 connection, this);36 connection, this);
37}37}
3838
39QVariant AccountsService::getUserProperty(const QString &user, const QString &property)39QVariant AccountsServiceDBusAdaptor::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,25 +48,77 @@
48 return QVariant();48 return QVariant();
49}49}
5050
51void AccountsService::setUserProperty(const QString &user, const QString &property, const QVariant &value)51void AccountsServiceDBusAdaptor::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}58}
5959
60QDBusInterface *AccountsService::getUserInterface(const QString &user)60void 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
71void AccountsServiceDBusAdaptor::maybeChangedSlot()
72{
73 Q_EMIT maybeChanged(getUserForPath(message().path()));
74}
75
76QString 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
87QDBusInterface *AccountsServiceDBusAdaptor::getUserInterface(const QString &user)
61{88{
62 auto iface = users.value(user);89 auto iface = users.value(user);
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
=== renamed file 'plugins/AccountsService/AccountsService.h' => 'plugins/AccountsService/AccountsServiceDBusAdaptor.h'
--- plugins/AccountsService/AccountsService.h 2013-08-27 17:29:16 +0000
+++ plugins/AccountsService/AccountsServiceDBusAdaptor.h 2013-09-05 18:10:06 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2012,2013 Canonical, Ltd.2 * Copyright (C) 2013 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -16,26 +16,36 @@
16 * Authors: Michael Terry <michael.terry@canonical.com>16 * Authors: Michael Terry <michael.terry@canonical.com>
17 */17 */
1818
19#ifndef UNITY_ACCOUNTSSERVICE_H19#ifndef UNITY_ACCOUNTSSERVICEDBUSADAPTOR_H
20#define UNITY_ACCOUNTSSERVICE_H20#define UNITY_ACCOUNTSSERVICEDBUSADAPTOR_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 AccountsServiceDBusAdaptor: public QObject, public QDBusContext
28{29{
29 Q_OBJECT30 Q_OBJECT
3031
31public:32public:
32 explicit AccountsService(QObject *parent = 0);33 explicit AccountsServiceDBusAdaptor(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 18:10:06 +0000
@@ -4,6 +4,7 @@
44
5add_library(AccountsService-qml MODULE5add_library(AccountsService-qml MODULE
6 AccountsService.cpp6 AccountsService.cpp
7 AccountsServiceDBusAdaptor.cpp
7 plugin.cpp8 plugin.cpp
8 )9 )
910
1011
=== modified file 'plugins/Unity/Launcher/CMakeLists.txt'
--- plugins/Unity/Launcher/CMakeLists.txt 2013-09-02 08:53:33 +0000
+++ plugins/Unity/Launcher/CMakeLists.txt 2013-09-05 18:10:06 +0000
@@ -17,7 +17,7 @@
17 quicklistmodel.cpp17 quicklistmodel.cpp
18 common/quicklistentry.cpp18 common/quicklistentry.cpp
19 backend/launcherbackend.cpp19 backend/launcherbackend.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp20 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
21 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h21 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
22 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h22 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
23 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h23 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
2424
=== 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 18:10:06 +0000
@@ -18,7 +18,7 @@
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */19 */
2020
21#include "AccountsService.h"21#include "AccountsServiceDBusAdaptor.h"
22#include "launcherbackend.h"22#include "launcherbackend.h"
2323
24#include <QDir>24#include <QDir>
@@ -43,7 +43,7 @@
43 m_accounts(nullptr)43 m_accounts(nullptr)
44{44{
45 if (useStorage) {45 if (useStorage) {
46 m_accounts = new AccountsService(this);46 m_accounts = new AccountsServiceDBusAdaptor(this);
47 }47 }
48 m_user = qgetenv("USER");48 m_user = qgetenv("USER");
49 syncFromAccounts();49 syncFromAccounts();
@@ -214,7 +214,7 @@
214 m_storedApps.clear();214 m_storedApps.clear();
215215
216 if (m_accounts && !m_user.isEmpty()) {216 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");
218 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());218 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
219 defaults = isDefaultsItem(apps);219 defaults = isDefaultsItem(apps);
220 }220 }
@@ -257,7 +257,7 @@
257 items << itemToVariant(appId);257 items << itemToVariant(appId);
258 }258 }
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));
261 }261 }
262}262}
263263
264264
=== modified file 'plugins/Unity/Launcher/backend/launcherbackend.h'
--- plugins/Unity/Launcher/backend/launcherbackend.h 2013-09-02 08:53:33 +0000
+++ plugins/Unity/Launcher/backend/launcherbackend.h 2013-09-05 18:10:06 +0000
@@ -25,7 +25,7 @@
25#include <QSettings>25#include <QSettings>
26#include <QStringList>26#include <QStringList>
2727
28class AccountsService;28class AccountsServiceDBusAdaptor;
2929
30/**30/**
31 * @brief An interface that provides all the data needed by the launcher.31 * @brief An interface that provides all the data needed by the launcher.
@@ -156,7 +156,7 @@
156 QList<QString> m_storedApps;156 QList<QString> m_storedApps;
157 mutable QHash<QString, LauncherBackendItem*> m_itemCache;157 mutable QHash<QString, LauncherBackendItem*> m_itemCache;
158158
159 AccountsService *m_accounts;159 AccountsServiceDBusAdaptor *m_accounts;
160 QString m_user;160 QString m_user;
161};161};
162162
163163
=== modified file 'tests/mocks/AccountsService/AccountsService.cpp'
--- tests/mocks/AccountsService/AccountsService.cpp 2013-08-02 20:03:16 +0000
+++ tests/mocks/AccountsService/AccountsService.cpp 2013-09-05 18:10:06 +0000
@@ -23,11 +23,27 @@
23{23{
24}24}
2525
26QVariant AccountsService::getUserProperty(const QString &, const QString &)26QString AccountsService::getUser()
27{27{
28 return QVariant(false);28 return "testuser";
29}29}
3030
31void AccountsService::setUserProperty(const QString &, const QString &, const QVariant &)31void AccountsService::setUser(const QString &user)
32{32{
33 Q_UNUSED(user)
34}
35
36bool AccountsService::getDemoEdges()
37{
38 return false;
39}
40
41void AccountsService::setDemoEdges(bool demoEdges)
42{
43 Q_UNUSED(demoEdges)
44}
45
46QString AccountsService::getBackgroundFile()
47{
48 return TOP_SRCDIR "/graphics/phone_background.jpg";
33}49}
3450
=== modified file 'tests/mocks/AccountsService/AccountsService.h'
--- tests/mocks/AccountsService/AccountsService.h 2013-08-27 17:34:46 +0000
+++ tests/mocks/AccountsService/AccountsService.h 2013-09-05 18:10:06 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2012,2013 Canonical, Ltd.2 * Copyright (C) 2013 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -27,12 +27,31 @@
27class AccountsService: public QObject27class AccountsService: public QObject
28{28{
29 Q_OBJECT29 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
31public:42public:
32 explicit AccountsService(QObject *parent = 0);43 explicit AccountsService(QObject *parent = 0);
3344
34 Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);45 QString getUser();
35 Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);46 void setUser(const QString &user);
47 bool getDemoEdges();
48 void setDemoEdges(bool demoEdges);
49 QString getBackgroundFile();
50
51Q_SIGNALS:
52 void userChanged();
53 void demoEdgesChanged();
54 void backgroundFileChanged();
36};55};
3756
38#endif57#endif
3958
=== 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 18:10:06 +0000
@@ -1,3 +1,5 @@
1add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
2
1add_library(MockAccountsService-qml MODULE3add_library(MockAccountsService-qml MODULE
2 AccountsService.cpp4 AccountsService.cpp
3 plugin.cpp5 plugin.cpp
46
=== 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 18:10:06 +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/AccountsServiceDBusAdaptor.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 18:10:06 +0000
@@ -18,6 +18,7 @@
18 */18 */
1919
20#include "AccountsService.h"20#include "AccountsService.h"
21#include "AccountsServiceDBusAdaptor.h"
21#include <QSignalSpy>22#include <QSignalSpy>
22#include <QTest>23#include <QTest>
2324
@@ -30,17 +31,28 @@
30 void testInvalids()31 void testInvalids()
31 {32 {
32 // Test various invalid calls33 // Test various invalid calls
33 AccountsService session;34 AccountsServiceDBusAdaptor 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 testGetSetServiceDBusAdaptor()
39 {40 {
40 AccountsService session;41 AccountsServiceDBusAdaptor 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 testGetSetService()
49 {
50 AccountsService session;
51 session.setUser("testuser");
52 session.setDemoEdges(true);
53 QCOMPARE(session.getDemoEdges(), true);
54 session.setDemoEdges(false);
55 QCOMPARE(session.getDemoEdges(), false);
44 }56 }
45};57};
4658
4759
=== modified file 'tests/plugins/Unity/Launcher/CMakeLists.txt'
--- tests/plugins/Unity/Launcher/CMakeLists.txt 2013-09-04 22:30:51 +0000
+++ tests/plugins/Unity/Launcher/CMakeLists.txt 2013-09-05 18:10:06 +0000
@@ -21,7 +21,7 @@
21add_custom_target(launcherbackendtest ${testBackendCommand})21add_custom_target(launcherbackendtest ${testBackendCommand})
22add_executable(launcherbackendtestExec22add_executable(launcherbackendtestExec
23 launcherbackendtest.cpp23 launcherbackendtest.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp24 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
25 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp25 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
26 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp26 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
27 )27 )
@@ -39,7 +39,7 @@
39 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launchermodel.cpp39 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launchermodel.cpp
40 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launcheritem.cpp40 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launcheritem.cpp
41 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/quicklistmodel.cpp41 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/quicklistmodel.cpp
42 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp42 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
43 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp43 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
44 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp44 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
45 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h45 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h

Subscribers

People subscribed via source and target branches