on xenial help sign in
Fix not unlocking when logind asks us to
11cf308Michael Terry
plugins/Unity/Session/dbusunitysessionservice.cpp+8−3
@@ -247,7 +247,7 @@ DBusUnitySessionService::DBusUnitySessionService()
247 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(PromptLock()));
247 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(PromptLock()));
248 // ... and our Unlocked() signal to the logind's session Unlock() signal
248 // ... and our Unlocked() signal to the logind's session Unlock() signal
249 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
249 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
250− QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
250+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SLOT(doUnlock()));
251 connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
251 connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
252 } else {
252 } else {
253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
@@ -361,9 +361,8 @@ void DBusUnitySessionService::Lock()
361 // time the indicator locks without also asking the display manager to
361 // time the indicator locks without also asking the display manager to
362 // switch sessions on us. And since we are switching screens, we also
362 // switch sessions on us. And since we are switching screens, we also
363 // don't bother respecting the animate request, simply doing a PromptLock.
363 // don't bother respecting the animate request, simply doing a PromptLock.
364− switchToGreeter();
365−
366 PromptLock();
364 PromptLock();
365+ switchToGreeter();
367}
366}
368
367
369void DBusUnitySessionService::switchToGreeter()
368void DBusUnitySessionService::switchToGreeter()
@@ -392,6 +391,12 @@ void DBusUnitySessionService::switchToGreeter()
392 });
391 });
393}
392}
394
393
394+void DBusUnitySessionService::doUnlock()
395+{
396+ Q_EMIT Unlocked();
397+ Q_EMIT unlocked();
398+}
399+
395bool DBusUnitySessionService::IsLocked() const
400bool DBusUnitySessionService::IsLocked() const
396{
401{
397 return !d->isSessionActive;
402 return !d->isSessionActive;
plugins/Unity/Session/dbusunitysessionservice.h+4
@@ -106,6 +106,7 @@ Q_SIGNALS:
106 * Emitted after the session has been unlocked.
106 * Emitted after the session has been unlocked.
107 */
107 */
108 Q_SCRIPTABLE void Unlocked();
108 Q_SCRIPTABLE void Unlocked();
109+ void unlocked();
109
110
110public Q_SLOTS:
111public Q_SLOTS:
111 /**
112 /**
@@ -259,6 +260,9 @@ public Q_SLOTS:
259 */
260 */
260 Q_SCRIPTABLE bool IsLocked() const;
261 Q_SCRIPTABLE bool IsLocked() const;
261
262
263+private Q_SLOTS:
264+ void doUnlock();
265+
262private:
266private:
263 void switchToGreeter();
267 void switchToGreeter();
264};
268};
qml/Greeter/Greeter.qml+4−1
@@ -455,7 +455,10 @@ Showable {
455 Connections {
455 Connections {
456 target: DBusUnitySessionService
456 target: DBusUnitySessionService
457 onLockRequested: root.forceShow()
457 onLockRequested: root.forceShow()
458+ onUnlocked: {
458− onUnlocked: root.forcedUnlock = true
459+ root.forcedUnlock = true;
460+ root.hideNow();
461+ }
459 }
462 }
460
463
461 Binding {
464 Binding {
tests/plugins/Unity/Session/LogindServer.cpp+5
@@ -26,3 +26,8 @@ QDBusObjectPath LogindServer::GetSessionByPID(quint32)
26{
26{
27 return QDBusObjectPath("/logindsession");
27 return QDBusObjectPath("/logindsession");
28}
28}
29+
30+void LogindServer::MockEmitUnlock()
31+{
32+ Q_EMIT Unlock();
33+}
tests/plugins/Unity/Session/LogindServer.h+2
@@ -32,6 +32,8 @@ public:
32public Q_SLOTS:
32public Q_SLOTS:
33 QDBusObjectPath GetSessionByPID(quint32 pid);
33 QDBusObjectPath GetSessionByPID(quint32 pid);
34
34
35+ void MockEmitUnlock(); // only in mock
36+
35Q_SIGNALS:
37Q_SIGNALS:
36 void Lock();
38 void Lock();
37 void Unlock();
39 void Unlock();
tests/plugins/Unity/Session/interfaces.xml+1
@@ -10,6 +10,7 @@
10 <signal name="PrepareForSleep" />
10 <signal name="PrepareForSleep" />
11 </interface>
11 </interface>
12 <interface name="org.freedesktop.login1.Session">
12 <interface name="org.freedesktop.login1.Session">
13+ <method name="MockEmitUnlock" />
13 <signal name="Lock" />
14 <signal name="Lock" />
14 <signal name="Unlock" />
15 <signal name="Unlock" />
15 </interface>
16 </interface>
tests/plugins/Unity/Session/sessionbackendtest.cpp+12
@@ -124,6 +124,18 @@ private Q_SLOTS:
124 QCOMPARE(spy.count(), 1);
124 QCOMPARE(spy.count(), 1);
125 }
125 }
126
126
127+ void testUnlockFromLogind() {
128+ DBusUnitySessionService dbusUnitySessionService;
129+ QCoreApplication::processEvents(); // to let the service register on DBus
130+
131+ QDBusInterface iface("org.freedesktop.login1", "/logindsession", "org.freedesktop.login1.Session");
132+ QVERIFY(iface.isValid());
133+
134+ QSignalSpy spy(&dbusUnitySessionService, SIGNAL(Unlocked()));
135+ QCOMPARE(iface.call("MockEmitUnlock").errorMessage(), QString());
136+ QTRY_COMPARE(spy.count(), 1);
137+ }
138+
127 void testUserName() {
139 void testUserName() {
128 DBusUnitySessionService dbusUnitySessionService;
140 DBusUnitySessionService dbusUnitySessionService;
129 QCoreApplication::processEvents(); // to let the service register on DBus
141 QCoreApplication::processEvents(); // to let the service register on DBus