Merge lp:~mterry/unity8/is-active into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Michael Zanetti
Approved revision: 979
Merged at revision: 1047
Proposed branch: lp:~mterry/unity8/is-active
Merge into: lp:unity8
Diff against target: 335 lines (+180/-1)
10 files modified
plugins/LightDM/CMakeLists.txt (+1/-0)
plugins/LightDM/DBusGreeter.cpp (+60/-0)
plugins/LightDM/DBusGreeter.h (+54/-0)
plugins/LightDM/Greeter.cpp (+17/-0)
plugins/LightDM/Greeter.h (+4/-0)
plugins/LightDM/plugin.cpp (+3/-0)
qml/Shell.qml (+6/-0)
tests/mocks/LightDM/CMakeLists.txt (+1/-0)
tests/plugins/LightDM/CMakeLists.txt (+1/-1)
tests/plugins/LightDM/dbus.cpp (+33/-0)
To merge this branch: bzr merge lp:~mterry/unity8/is-active
Reviewer Review Type Date Requested Status
Seth Arnold (community) Approve
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+223653@code.launchpad.net

Commit message

Expose a new greeter DBus property, IsActive, which tells apps and indicators when the integrated-greeter screen is active. Useful for switching UI modes when the screen is locked.

Description of the change

Expose a new greeter DBus property, IsActive, which tells apps and indicators when the integrated-greeter screen is active. Useful for switching UI modes when the screen is locked.

This property is not relevant when using a split greeter. But for an integrated greeter, it is useful. Both indicators and dialer-app will likely use this property to determine what UI mode to use. (reduced information for indicators, emergency dialer mode for dialer-app)

I also took this opportunity to run the greeter dbus test under xvfb.

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 - No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
 - Yes

 * Did you make sure that your branch does not contain spurious tags?
 - Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-
unity team to this MP?
 - NA

 * If you changed the UI, has there been a design review?
 - NA

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 Terry (mterry) wrote :

Hmm, I expect I'll want to let the session write true to this property to lock the screen (but throw an error if the session tries to set false). Will do a bit more work on it.

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

Ugh, upon immediate reflection, that change isn't needed yet. I don't want to block progress on that feature.

lp:~mterry/unity8/is-active updated
977. By Michael Terry

Merge from trunk

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 :

Checklist missing

========
I tried:

$ qdbus com.canonical.UnityGreeter

Error: org.freedesktop.DBus.Error.NoReply
Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

It seems like this in trunk too... Can you explain why its not working?

(also note that the other dbus interfaces are com.canonical.Unity.Something. Just the greeter one differs in naming.

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

Checklist added.

As for the UnityGreeter vs Unity.Greeter, two reasons. One reason is that the greeter being part of the Unity project itself is new. Before, it was just a greeter designed to look like Unity, so it seemed inappropriate to glom it into the Unity namespace. We felt it was its own entity.

But a much more important reason nowadays is that this is an historical interface, and we need to match what the desktop greeter has been doing for ages.

Finally, as for your qdbus error, running "qdbus com.canonical.UnityGreeter" works for me...:
/
/com
/com/canonical
/list
/org

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

I can confirm running "qdbus com.canonical.UnityGreeter" works.

I also tested the value of IsActive and it seems to behave correctly.

lp:~mterry/unity8/is-active updated
978. By Michael Terry

Merge from trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~mterry/unity8/is-active updated
979. By Michael Terry

Merge from trunk

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: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?

yes.

 * Did CI run pass? If not, please explain why.

yes.

review: Approve
Revision history for this message
Seth Arnold (seth-arnold) wrote :

Looks good to me, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/LightDM/CMakeLists.txt'
2--- plugins/LightDM/CMakeLists.txt 2014-06-11 15:36:51 +0000
3+++ plugins/LightDM/CMakeLists.txt 2014-07-11 15:40:06 +0000
4@@ -15,6 +15,7 @@
5
6 set(QMLPLUGIN_SRC
7 ../Utils/qsortfilterproxymodelqml.cpp # FIXME evaluate a more generic approach for using other plugins
8+ DBusGreeter.cpp
9 DBusGreeterList.cpp
10 Greeter.cpp
11 plugin.cpp
12
13=== added file 'plugins/LightDM/DBusGreeter.cpp'
14--- plugins/LightDM/DBusGreeter.cpp 1970-01-01 00:00:00 +0000
15+++ plugins/LightDM/DBusGreeter.cpp 2014-07-11 15:40:06 +0000
16@@ -0,0 +1,60 @@
17+/*
18+ * Copyright (C) 2014 Canonical, Ltd.
19+ *
20+ * This program is free software; you can redistribute it and/or modify
21+ * it under the terms of the GNU General Public License as published by
22+ * the Free Software Foundation; version 3.
23+ *
24+ * This program is distributed in the hope that it will be useful,
25+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+ * GNU General Public License for more details.
28+ *
29+ * You should have received a copy of the GNU General Public License
30+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
31+ */
32+
33+#include "DBusGreeter.h"
34+#include "Greeter.h"
35+
36+#include <QDBusMessage>
37+#include <QStringList>
38+
39+DBusGreeter::DBusGreeter(Greeter *greeter, const QDBusConnection &connection, const QString &path)
40+ : QObject(greeter),
41+ m_greeter(greeter),
42+ m_connection(connection),
43+ m_path(path)
44+{
45+ connect(m_greeter, SIGNAL(isActiveChanged()), this, SLOT(isActiveChangedHandler()));
46+}
47+
48+bool DBusGreeter::isActive() const
49+{
50+ return m_greeter->isActive();
51+}
52+
53+void DBusGreeter::isActiveChangedHandler()
54+{
55+ notifyPropertyChanged("IsActive", isActive());
56+ Q_EMIT isActiveChanged();
57+}
58+
59+// Manually emit a PropertiesChanged signal over DBus, because QtDBus
60+// doesn't do it for us on Q_PROPERTIES, oddly enough.
61+void DBusGreeter::notifyPropertyChanged(const QString& propertyName, const QVariant &value)
62+{
63+ QDBusMessage message;
64+ QVariantMap changedProps;
65+
66+ changedProps.insert(propertyName, value);
67+
68+ message = QDBusMessage::createSignal(m_path,
69+ "org.freedesktop.DBus.Properties",
70+ "PropertiesChanged");
71+ message << "com.canonical.UnityGreeter";
72+ message << changedProps;
73+ message << QStringList();
74+
75+ m_connection.send(message);
76+}
77
78=== added file 'plugins/LightDM/DBusGreeter.h'
79--- plugins/LightDM/DBusGreeter.h 1970-01-01 00:00:00 +0000
80+++ plugins/LightDM/DBusGreeter.h 2014-07-11 15:40:06 +0000
81@@ -0,0 +1,54 @@
82+/*
83+ * Copyright (C) 2014 Canonical, Ltd.
84+ *
85+ * This program is free software; you can redistribute it and/or modify
86+ * it under the terms of the GNU General Public License as published by
87+ * the Free Software Foundation; version 3.
88+ *
89+ * This program is distributed in the hope that it will be useful,
90+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
91+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92+ * GNU General Public License for more details.
93+ *
94+ * You should have received a copy of the GNU General Public License
95+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
96+ */
97+
98+#ifndef UNITY_DBUSGREETER_H
99+#define UNITY_DBUSGREETER_H
100+
101+#include <QDBusConnection>
102+#include <QObject>
103+
104+class Greeter;
105+class QDBusInterface;
106+
107+/** This is an internal class used to talk with the indicators.
108+ */
109+
110+class DBusGreeter : public QObject
111+{
112+ Q_OBJECT
113+ Q_CLASSINFO("D-Bus Interface", "com.canonical.UnityGreeter")
114+
115+ Q_PROPERTY(bool IsActive READ isActive NOTIFY isActiveChanged) // since 14.10
116+
117+public:
118+ explicit DBusGreeter(Greeter *greeter, const QDBusConnection &connection, const QString &path);
119+
120+ bool isActive() const;
121+
122+Q_SIGNALS:
123+ void isActiveChanged();
124+
125+private Q_SLOTS:
126+ void isActiveChangedHandler();
127+ void notifyPropertyChanged(const QString &propertyName, const QVariant &value);
128+
129+private:
130+ Greeter *m_greeter;
131+ QDBusConnection m_connection;
132+ QString m_path;
133+};
134+
135+#endif
136
137=== modified file 'plugins/LightDM/Greeter.cpp'
138--- plugins/LightDM/Greeter.cpp 2014-06-11 15:36:51 +0000
139+++ plugins/LightDM/Greeter.cpp 2014-07-11 15:40:06 +0000
140@@ -25,6 +25,7 @@
141 explicit GreeterPrivate(Greeter *parent);
142
143 QLightDM::Greeter *m_greeter;
144+ bool m_active;
145 bool wasPrompted;
146 bool promptless;
147
148@@ -38,6 +39,7 @@
149
150 GreeterPrivate::GreeterPrivate(Greeter* parent)
151 : m_greeter(new QLightDM::Greeter(parent)),
152+ m_active(false),
153 wasPrompted(false),
154 promptless(false),
155 q_ptr(parent)
156@@ -60,6 +62,21 @@
157 d->m_greeter->connectSync();
158 }
159
160+bool Greeter::isActive() const
161+{
162+ Q_D(const Greeter);
163+ return d->m_active;
164+}
165+
166+void Greeter::setIsActive(bool active)
167+{
168+ Q_D(Greeter);
169+ if (d->m_active != active) {
170+ d->m_active = active;
171+ Q_EMIT isActiveChanged();
172+ }
173+}
174+
175 bool Greeter::isAuthenticated() const
176 {
177 Q_D(const Greeter);
178
179=== modified file 'plugins/LightDM/Greeter.h'
180--- plugins/LightDM/Greeter.h 2014-06-11 15:36:51 +0000
181+++ plugins/LightDM/Greeter.h 2014-07-11 15:40:06 +0000
182@@ -34,6 +34,7 @@
183 {
184 Q_OBJECT
185
186+ Q_PROPERTY(bool active READ isActive WRITE setIsActive NOTIFY isActiveChanged)
187 Q_PROPERTY(bool authenticated READ isAuthenticated)
188 Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
189 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
190@@ -41,6 +42,7 @@
191 public:
192 explicit Greeter(QObject* parent=0);
193
194+ bool isActive() const;
195 bool isAuthenticated() const;
196 QString authenticationUser() const;
197 bool promptless() const;
198@@ -49,12 +51,14 @@
199 void authenticate(const QString &username=QString());
200 void respond(const QString &response);
201 bool startSessionSync(const QString &session=QString());
202+ void setIsActive(bool isActive);
203
204 Q_SIGNALS:
205 void showMessage(const QString &text, bool isError);
206 void showPrompt(const QString &text, bool isSecret);
207 void authenticationComplete();
208 void authenticationUserChanged(const QString &user);
209+ void isActiveChanged();
210 void promptlessChanged();
211
212 // This signal is emitted by external agents like indicators, and the UI
213
214=== modified file 'plugins/LightDM/plugin.cpp'
215--- plugins/LightDM/plugin.cpp 2014-06-11 15:36:51 +0000
216+++ plugins/LightDM/plugin.cpp 2014-07-11 15:40:06 +0000
217@@ -18,6 +18,7 @@
218 */
219
220 #include "plugin.h"
221+#include "DBusGreeter.h"
222 #include "DBusGreeterList.h"
223 #include "Greeter.h"
224 #include "UsersModel.h"
225@@ -39,6 +40,8 @@
226
227 Greeter *greeter = new Greeter();
228 QDBusConnection connection = QDBusConnection::sessionBus();
229+ DBusGreeter *root = new DBusGreeter(greeter, connection, "/");
230+ connection.registerObject("/", root, QDBusConnection::ExportScriptableContents);
231 DBusGreeterList *list = new DBusGreeterList(greeter, connection, GREETER_LIST_DBUS_PATH);
232 connection.registerObject(GREETER_LIST_DBUS_PATH, list, QDBusConnection::ExportScriptableContents);
233 connection.registerService(GREETER_DBUS_SERVICE);
234
235=== modified file 'qml/Shell.qml'
236--- qml/Shell.qml 2014-07-09 19:44:14 +0000
237+++ qml/Shell.qml 2014-07-11 15:40:06 +0000
238@@ -373,6 +373,12 @@
239 }
240 }
241
242+ Binding {
243+ target: LightDM.Greeter
244+ property: "active"
245+ value: greeter.shown || lockscreen.shown
246+ }
247+
248 Rectangle {
249 anchors.fill: parent
250 color: "black"
251
252=== modified file 'tests/mocks/LightDM/CMakeLists.txt'
253--- tests/mocks/LightDM/CMakeLists.txt 2014-06-11 15:36:51 +0000
254+++ tests/mocks/LightDM/CMakeLists.txt 2014-07-11 15:40:06 +0000
255@@ -18,6 +18,7 @@
256 )
257
258 set(QMLPLUGIN_SRC
259+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeter.cpp
260 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp
261 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
262 ${CMAKE_SOURCE_DIR}/plugins/LightDM/plugin.cpp
263
264=== modified file 'tests/plugins/LightDM/CMakeLists.txt'
265--- tests/plugins/LightDM/CMakeLists.txt 2014-06-11 15:36:51 +0000
266+++ tests/plugins/LightDM/CMakeLists.txt 2014-07-11 15:40:06 +0000
267@@ -19,7 +19,7 @@
268
269 add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
270
271-add_custom_target(testLightDMDBus dbus-launch env QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full ${CMAKE_CURRENT_BINARY_DIR}/test-lightdm-dbus)
272+add_custom_target(testLightDMDBus xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum dbus-launch env QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full ${CMAKE_CURRENT_BINARY_DIR}/test-lightdm-dbus)
273 add_dependencies(testLightDMDBus test-lightdm-dbus)
274
275 add_dependencies(qmluitests testLightDMDBus)
276
277=== modified file 'tests/plugins/LightDM/dbus.cpp'
278--- tests/plugins/LightDM/dbus.cpp 2013-12-03 16:55:03 +0000
279+++ tests/plugins/LightDM/dbus.cpp 2014-07-11 15:40:06 +0000
280@@ -40,6 +40,13 @@
281 // to watch.
282 QDBusConnection::sessionBus().connect(
283 "com.canonical.UnityGreeter",
284+ "/",
285+ "org.freedesktop.DBus.Properties",
286+ "PropertiesChanged",
287+ this,
288+ SIGNAL(PropertiesChangedRelay(const QString&, const QVariantMap&, const QStringList&)));
289+ QDBusConnection::sessionBus().connect(
290+ "com.canonical.UnityGreeter",
291 "/list",
292 "org.freedesktop.DBus.Properties",
293 "PropertiesChanged",
294@@ -57,6 +64,12 @@
295 view->show();
296 QTest::qWaitForWindowExposed(view);
297
298+ dbusMain = new QDBusInterface("com.canonical.UnityGreeter",
299+ "/",
300+ "com.canonical.UnityGreeter",
301+ QDBusConnection::sessionBus(), view);
302+ QVERIFY(dbusMain->isValid());
303+
304 dbusList = new QDBusInterface("com.canonical.UnityGreeter",
305 "/list",
306 "com.canonical.UnityGreeter.List",
307@@ -155,9 +168,29 @@
308 QVERIFY(arguments.at(1).toMap()["EntryIsLocked"] == false);
309 }
310
311+ void testIsActive()
312+ {
313+ QVERIFY(!greeter->isActive());
314+ QVERIFY(!dbusMain->property("IsActive").toBool());
315+
316+ QSignalSpy spy(this, SIGNAL(PropertiesChangedRelay(QString, QVariantMap, QStringList)));
317+ greeter->setIsActive(true);
318+ spy.wait();
319+
320+ QVERIFY(greeter->isActive());
321+ QVERIFY(dbusMain->property("IsActive").toBool());
322+
323+ QCOMPARE(spy.count(), 1);
324+ QList<QVariant> arguments = spy.takeFirst();
325+ QCOMPARE(arguments.at(0).toString(), QString("com.canonical.UnityGreeter"));
326+ QVERIFY(arguments.at(1).toMap().contains("IsActive"));
327+ QVERIFY(arguments.at(1).toMap()["IsActive"].toBool());
328+ }
329+
330 private:
331 QQuickView *view;
332 Greeter *greeter;
333+ QDBusInterface *dbusMain;
334 QDBusInterface *dbusList;
335 };
336

Subscribers

People subscribed via source and target branches