Merge lp:~mterry/unity8/slim_greeter_select_user into lp:~josharenson/unity8/slim_greeter_real_lightdm

Proposed by Michael Terry
Status: Merged
Approved by: Josh Arenson
Approved revision: 1996
Merged at revision: 1989
Proposed branch: lp:~mterry/unity8/slim_greeter_select_user
Merge into: lp:~josharenson/unity8/slim_greeter_real_lightdm
Diff against target: 456 lines (+142/-71)
17 files modified
data/51-unity8-greeter.conf (+0/-3)
data/unity8-greeter.desktop.in (+1/-1)
data/unity8-greeter.pkla (+44/-0)
debian/unity8-greeter.install (+1/-0)
plugins/LightDM/Greeter.cpp (+6/-0)
plugins/LightDM/Greeter.h (+2/-0)
plugins/Unity/Indicators/indicatorsmanager.cpp (+1/-1)
qml/Greeter/Greeter.qml (+19/-10)
qml/Shell.qml (+8/-3)
qml/Stages/ShimStage.qml (+0/-43)
tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp (+16/-0)
tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h (+5/-0)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp (+8/-1)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h (+1/-0)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h (+1/-0)
tests/qmltests/Greeter/TestView.qml (+2/-0)
tests/qmltests/Greeter/tst_Greeter.qml (+27/-9)
To merge this branch: bzr merge lp:~mterry/unity8/slim_greeter_select_user
Reviewer Review Type Date Requested Status
Josh Arenson Approve
Review via email: mp+296854@code.launchpad.net

Commit message

Support selectUserHint.

Description of the change

Support selectUserHint.

I also stuck some unrelated fixes in here, that we probably want in the base slim greeter branch.

To post a comment you must log in.
1993. By Michael Terry

Add pkla and nerf indicators as much as possible until we have proper app launching

1994. By Michael Terry

Use cmake install locations rather than hardcoding them

Revision history for this message
Josh Arenson (josharenson) wrote :

Please add a test for a non-existent user and see the 1 inline comment

review: Needs Fixing
1995. By Michael Terry

Add more tests for selectUser

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

Added test for non-existent user. (And we agreed to not worry about your inline comment.)

I'm looking at a failure in Greeter::test_promptless right now. It's not because of this branch. But I may squeeze it in, depending on when this gets merged in.

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

Oh, that was easy. Fixed test_promptless.

1996. By Michael Terry

Fix test_promptless

Revision history for this message
Josh Arenson (josharenson) wrote :

Looks good to me, now that my internet is fast enough to clone and test locally.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/51-unity8-greeter.conf'
2--- data/51-unity8-greeter.conf 2016-06-07 16:20:53 +0000
3+++ data/51-unity8-greeter.conf 2016-06-09 21:56:24 +0000
4@@ -1,5 +1,2 @@
5 [Seat:*]
6 greeter-session=unity8-greeter
7-
8-# When unity8 can be run under mir on the desktop, change this to unity.
9-type=unity
10
11=== modified file 'data/unity8-greeter.desktop.in'
12--- data/unity8-greeter.desktop.in 2016-01-22 15:41:14 +0000
13+++ data/unity8-greeter.desktop.in 2016-06-09 21:56:24 +0000
14@@ -2,6 +2,6 @@
15 Type=Application
16 Name=Unity 8 Greeter
17 Comment=The converged Unity shell's Greeter
18-Exec=/usr/bin/unity8-greeter-wrapper /usr/bin/unity8 --mode=greeter
19+Exec=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity8-greeter-wrapper @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity8 --mode=greeter
20 X-LightDM-Session-Type=mir
21 X-Ubuntu-Touch=true
22
23=== added file 'data/unity8-greeter.pkla'
24--- data/unity8-greeter.pkla 1970-01-01 00:00:00 +0000
25+++ data/unity8-greeter.pkla 2016-06-09 21:56:24 +0000
26@@ -0,0 +1,44 @@
27+# DO NOT EDIT THIS FILE, it will be overwritten on update
28+# Place your local configurations under /etc/polkit-1/localauthority/
29+
30+[Disable Controlling of Network Devices]
31+Identity=unix-user:lightdm
32+Action=org.freedesktop.NetworkManager.enable-disable-network;org.freedesktop.NetworkManager.enable-disable-wifi;org.freedesktop.NetworkManager.enable-disable-wwan;org.freedesktop.NetworkManager.enable-disable-wimax;
33+ResultActive=no
34+ResultInactive=no
35+ResultsAny=no
36+
37+[Disable Sleep and Wake]
38+Identity=unix-user:lightdm
39+Action=org.freedesktop.NetworkManager.sleep-wake
40+ResultActive=no
41+ResultInactive=no
42+ResultsAny=no
43+
44+[Disable WiFi Sharing]
45+Identity=unix-user:lightdm
46+Action=org.freedesktop.NetworkManager.wifi.share.protected;org.freedesktop.NetworkManager.wifi.share.open
47+ResultActive=no
48+ResultInactive=no
49+ResultsAny=no
50+
51+[Disable Settings Modifications]
52+Identity=unix-user:lightdm
53+Action=org.freedesktop.NetworkManager.settings.modify.own;org.freedesktop.NetworkManager.settings.modify.system;org.freedesktop.NetworkManager.settings.modify.hostname
54+ResultActive=no
55+ResultInactive=no
56+ResultsAny=no
57+
58+[Disable User Connections]
59+Identity=unix-user:lightdm
60+Action=org.freedesktop.NetworkManager.use-user-connections
61+ResultActive=no
62+ResultInactive=no
63+ResultsAny=no
64+
65+[Enable Controlling of Network Connections]
66+Identity=unix-user:lightdm
67+Action=org.freedesktop.NetworkManager.network-control
68+ResultActive=yes
69+ResultInactive=no
70+ResultsAny=no
71
72=== modified file 'debian/unity8-greeter.install'
73--- debian/unity8-greeter.install 2016-01-22 15:24:02 +0000
74+++ debian/unity8-greeter.install 2016-06-09 21:56:24 +0000
75@@ -1,4 +1,5 @@
76 data/unity8-greeter-wrapper usr/bin/
77 data/unity8-greeter-init.conf usr/share/upstart/sessions/
78+data/unity8-greeter.pkla /var/lib/polkit-1/localauthority/10-vendor.d/
79 usr/share/lightdm/greeters/unity8-greeter.desktop
80 usr/share/lightdm/lightdm.conf.d/51-unity8-greeter.conf
81
82=== modified file 'plugins/LightDM/Greeter.cpp'
83--- plugins/LightDM/Greeter.cpp 2015-10-01 23:54:24 +0000
84+++ plugins/LightDM/Greeter.cpp 2016-06-09 21:56:24 +0000
85@@ -78,6 +78,12 @@
86 return d->promptless;
87 }
88
89+QString Greeter::selectUser() const
90+{
91+ Q_D(const Greeter);
92+ return d->m_greeter->selectUserHint();
93+}
94+
95 void Greeter::authenticate(const QString &username)
96 {
97 Q_D(Greeter);
98
99=== modified file 'plugins/LightDM/Greeter.h'
100--- plugins/LightDM/Greeter.h 2015-09-11 13:38:45 +0000
101+++ plugins/LightDM/Greeter.h 2016-06-09 21:56:24 +0000
102@@ -38,6 +38,7 @@
103 Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
104 Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
105 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
106+ Q_PROPERTY(QString selectUser READ selectUser CONSTANT)
107
108 public:
109 explicit Greeter(QObject* parent=0);
110@@ -46,6 +47,7 @@
111 bool isAuthenticated() const;
112 QString authenticationUser() const;
113 bool promptless() const;
114+ QString selectUser() const;
115
116 public Q_SLOTS:
117 void authenticate(const QString &username=QString());
118
119=== modified file 'plugins/Unity/Indicators/indicatorsmanager.cpp'
120--- plugins/Unity/Indicators/indicatorsmanager.cpp 2016-03-29 03:47:39 +0000
121+++ plugins/Unity/Indicators/indicatorsmanager.cpp 2016-06-09 21:56:24 +0000
122@@ -291,7 +291,7 @@
123 // The rest of the indicators respect their default profile (which is "phone", even on desktop PCs)
124 if ((new_indicator->identifier() == QStringLiteral("indicator-session"))
125 || (new_indicator->identifier() == QStringLiteral("indicator-power") && m_platform.isPC())) {
126- new_indicator->setProfile(QStringLiteral("desktop"));
127+ new_indicator->setProfile(m_profile.replace(QStringLiteral("phone"), QStringLiteral("desktop")));
128 } else {
129 new_indicator->setProfile(m_profile);
130 }
131
132=== modified file 'qml/Greeter/Greeter.qml'
133--- qml/Greeter/Greeter.qml 2016-05-02 18:43:06 +0000
134+++ qml/Greeter/Greeter.qml 2016-06-09 21:56:24 +0000
135@@ -114,7 +114,8 @@
136 id: d
137
138 readonly property bool multiUser: LightDMService.users.count > 1
139- property int currentIndex
140+ readonly property int selectUserIndex: d.getUserIndex(LightDMService.greeter.selectUser)
141+ property int currentIndex: Math.max(selectUserIndex, 0)
142 property bool waiting
143
144 // We want 'launcherOffset' to animate down to zero. But not to animate
145@@ -131,7 +132,23 @@
146 UbuntuNumberAnimation {}
147 }
148
149+ function getUserIndex(username) {
150+ if (username === "")
151+ return -1;
152+
153+ // Find index for requested user, if it exists
154+ for (var i = 0; i < LightDMService.users.count; i++) {
155+ if (username === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
156+ return i;
157+ }
158+ }
159+
160+ return -1;
161+ }
162+
163 function selectUser(uid, reset) {
164+ if (uid < 0)
165+ return;
166 d.waiting = true;
167 if (reset) {
168 loader.item.reset();
169@@ -440,15 +457,7 @@
170 }
171 }
172
173- onRequestAuthenticationUser: {
174- // Find index for requested user, if it exists
175- for (var i = 0; i < LightDMService.users.count; i++) {
176- if (user === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
177- d.selectUser(i, true);
178- return;
179- }
180- }
181- }
182+ onRequestAuthenticationUser: d.selectUser(d.getUserIndex(user), true)
183 }
184
185 Connections {
186
187=== modified file 'qml/Shell.qml'
188--- qml/Shell.qml 2016-06-07 16:10:36 +0000
189+++ qml/Shell.qml 2016-06-09 21:56:24 +0000
190@@ -259,8 +259,8 @@
191 ? "phone"
192 : shell.usageScenario
193 readonly property string qmlComponent: {
194- if(shell.mode === "greeter") {
195- return "Stages/ShimStage.qml"
196+ if (shell.mode === "greeter") {
197+ return "Stages/AbstractStage.qml"
198 } else if (applicationsDisplayLoader.usageScenario === "phone") {
199 return "Stages/PhoneStage.qml";
200 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
201@@ -531,7 +531,12 @@
202
203 indicatorsModel: Indicators.IndicatorsModel {
204 // tablet and phone both use the same profile
205- profile: "phone"
206+ // FIXME: use just "phone" for greeter too, but first fix
207+ // greeter app launching to either load the app inside the
208+ // greeter or tell the session to load the app. This will
209+ // involve taking the url-dispatcher dbus name and using
210+ // SessionBroadcast to tell the session.
211+ profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
212 Component.onCompleted: load();
213 }
214 }
215
216=== removed file 'qml/Stages/ShimStage.qml'
217--- qml/Stages/ShimStage.qml 2016-04-14 13:28:11 +0000
218+++ qml/Stages/ShimStage.qml 1970-01-01 00:00:00 +0000
219@@ -1,43 +0,0 @@
220-/*
221- * Copyright (C) 2015 Canonical, Ltd.
222- *
223- * This program is free software; you can redistribute it and/or modify
224- * it under the terms of the GNU General Public License as published by
225- * the Free Software Foundation; version 3.
226- *
227- * This program is distributed in the hope that it will be useful,
228- * but WITHOUT ANY WARRANTY; without even the implied warranty of
229- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
230- * GNU General Public License for more details.
231- *
232- * You should have received a copy of the GNU General Public License
233- * along with this program. If not, see <http://www.gnu.org/licenses/>.
234- */
235-
236-import QtQuick 2.4
237-import Ubuntu.Components 1.3
238-
239-AbstractStage {
240- id: shimStage
241-
242- anchors.fill: parent
243-
244- Text {
245- id: greeterModeText
246-
247- anchors.horizontalCenter: parent.horizontalCenter
248- anchors.top: parent.top
249- anchors.topMargin: units.gu(10)
250- font.bold: true
251- horizontalAlignment: Text.AlignHCenter
252- text: "Shell is in \"greeter\" mode"
253- }
254-
255- Text {
256- anchors.centerIn: parent
257- color: UbuntuColors.orange
258- font.pointSize: units.gu(8)
259- horizontalAlignment: Text.AlignHCenter
260- text: "Shim \nStage"
261- }
262-}
263
264=== modified file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp'
265--- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 2015-09-25 13:01:00 +0000
266+++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 2016-06-09 21:56:24 +0000
267@@ -33,3 +33,19 @@
268 Q_EMIT mockModeChanged(mockMode);
269 }
270 }
271+
272+QString MockGreeter::selectUserHint() const
273+{
274+ Q_D(const Greeter);
275+ return d->m_greeter->selectUserHint();
276+}
277+
278+void MockGreeter::setSelectUserHint(const QString &selectUserHint)
279+{
280+ Q_D(Greeter);
281+
282+ if (d->m_greeter->selectUserHint() != selectUserHint) {
283+ d->m_greeter->setSelectUserHint(selectUserHint);
284+ Q_EMIT selectUserHintChanged();
285+ }
286+}
287
288=== modified file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h'
289--- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 2015-09-25 13:01:00 +0000
290+++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 2016-06-09 21:56:24 +0000
291@@ -25,13 +25,18 @@
292 Q_OBJECT
293
294 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
295+ Q_PROPERTY(QString selectUser READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged)
296
297 public:
298 QString mockMode() const;
299 void setMockMode(QString mockMode);
300
301+ QString selectUserHint() const;
302+ void setSelectUserHint(const QString &selectUserHint);
303+
304 Q_SIGNALS:
305 void mockModeChanged(QString mode);
306+ void selectUserHintChanged();
307 };
308
309 #endif // MOCK_UNITY_GREETER_H
310
311=== modified file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp'
312--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp 2015-08-19 14:24:07 +0000
313+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp 2016-06-09 21:56:24 +0000
314@@ -76,7 +76,14 @@
315
316 QString Greeter::selectUserHint() const
317 {
318- return "";
319+ Q_D(const Greeter);
320+ return d->selectUserHint;
321+}
322+
323+void Greeter::setSelectUserHint(const QString &selectUserHint)
324+{
325+ Q_D(Greeter);
326+ d->selectUserHint = selectUserHint;
327 }
328
329 bool Greeter::selectGuestHint() const
330
331=== modified file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h'
332--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h 2015-02-20 15:30:19 +0000
333+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h 2016-06-09 21:56:24 +0000
334@@ -70,6 +70,7 @@
335 bool lockHint () const;
336 bool hasGuestAccountHint() const;
337 QString selectUserHint() const;
338+ void setSelectUserHint(const QString &selectUserHint); // only in mock
339 bool selectGuestHint() const;
340 QString autologinUserHint() const;
341 bool autologinGuestHint() const;
342
343=== modified file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h'
344--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 2016-05-26 13:15:35 +0000
345+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 2016-06-09 21:56:24 +0000
346@@ -34,6 +34,7 @@
347 bool authenticated;
348 QString authenticationUser;
349 bool twoFactorDone;
350+ QString selectUserHint;
351
352 QString mockMode;
353
354
355=== modified file 'tests/qmltests/Greeter/TestView.qml'
356--- tests/qmltests/Greeter/TestView.qml 2015-07-15 15:07:19 +0000
357+++ tests/qmltests/Greeter/TestView.qml 2016-06-09 21:56:24 +0000
358@@ -33,6 +33,7 @@
359 property var infographicModel
360 readonly property bool fullyShown: _fullyShown
361 readonly property bool required: _required
362+ readonly property bool animating: false
363
364 property bool _fullyShown: true
365 property bool _required: true
366@@ -41,6 +42,7 @@
367 signal responded(string response)
368 signal tease()
369 signal emergencyCall()
370+ signal promptlessLogin()
371
372 signal _showMessageCalled(string html)
373 signal _showPromptCalled(string text, bool isSecret, bool isDefaultPrompt)
374
375=== modified file 'tests/qmltests/Greeter/tst_Greeter.qml'
376--- tests/qmltests/Greeter/tst_Greeter.qml 2016-06-07 16:10:36 +0000
377+++ tests/qmltests/Greeter/tst_Greeter.qml 2016-06-09 21:56:24 +0000
378@@ -139,7 +139,9 @@
379
380 function init() {
381 greeterSettings.lockedOutTime = 0;
382- resetLoader();
383+ LightDM.Greeter.selectUser = "";
384+ greeter.failedLoginsDelayAttempts = 7;
385+ greeter.failedLoginsDelayMinutes = 5;
386 teaseSpy.clear();
387 sessionStartedSpy.clear();
388 activeChangedSpy.clear();
389@@ -151,11 +153,7 @@
390 viewAuthenticationFailedSpy.clear();
391 viewResetSpy.clear();
392 viewTryToUnlockSpy.clear();
393- tryCompare(greeter, "waiting", false);
394- view = findChild(greeter, "testView");
395- verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
396- greeter.failedLoginsDelayAttempts = 7;
397- greeter.failedLoginsDelayMinutes = 5;
398+ resetLoader();
399 }
400
401 function resetLoader() {
402@@ -167,6 +165,8 @@
403 loader.active = true;
404 tryCompare(loader, "status", Loader.Ready);
405 removeTimeConstraintsFromSwipeAreas(loader.item);
406+ tryCompare(greeter, "waiting", false);
407+ view = findChild(greeter, "testView");
408 }
409
410 function getIndexOf(name) {
411@@ -191,6 +191,7 @@
412 compare(view.currentIndex, i);
413 compare(AccountsService.user, name);
414 compare(LightDM.Greeter.authenticationUser, name);
415+ return i;
416 }
417
418 function verifyLoggedIn() {
419@@ -229,11 +230,9 @@
420
421 function test_promptless() {
422 selectUser("no-password");
423- tryCompare(viewAuthenticationSucceededSpy, "count", 1);
424- compare(sessionStartedSpy.count, 1);
425+ tryCompare(view, "locked", false);
426 compare(viewShowPromptSpy.count, 0);
427 compare(viewHideSpy.count, 0);
428- compare(view.locked, false);
429 }
430
431 function test_twoFactorPass() {
432@@ -553,5 +552,24 @@
433 compare(viewResetSpy.count, 1);
434 tryCompare(viewShowPromptSpy, "count", 1);
435 }
436+
437+ function test_selectUserHint() {
438+ LightDM.Greeter.selectUser = "info-prompt";
439+ resetLoader();
440+ var i = verifySelected("info-prompt");
441+ verify(i != 0); // sanity-check that info-prompt isn't default 0 answer
442+ }
443+
444+ function test_selectUserHintUnset() {
445+ LightDM.Greeter.selectUser = "";
446+ resetLoader();
447+ verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
448+ }
449+
450+ function test_selectUserHintInvalid() {
451+ LightDM.Greeter.selectUser = "not-a-real-user";
452+ resetLoader();
453+ verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
454+ }
455 }
456 }

Subscribers

People subscribed via source and target branches

to all changes: