on xenial help sign in
Fix not unlocking when logind asks us to
commit11cf30831c384e552e6125ea8b875fe53fbaf572 authorMichael Terry <michael.terry@canonical.com> dateWed 22 Jun 2016, 09:38 (10 years ago) parent1dbcfc3
7 files changed+36−4
plugins/Unity/Session/dbusunitysessionservice.cpp+8−3 plugins/Unity/Session/dbusunitysessionservice.h+4 qml/Greeter/Greeter.qml+4−1 tests/plugins/Unity/Session/LogindServer.cpp+5 tests/plugins/Unity/Session/LogindServer.h+2 tests/plugins/Unity/Session/interfaces.xml+1 tests/plugins/Unity/Session/sessionbackendtest.cpp+12
plugins/Unity/Session/dbusunitysessionservice.cpp+8−3
@@ -247,7 +247,7 @@ DBusUnitySessionService::DBusUnitySessionService()
247247 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(PromptLock()));
248248 // ... and our Unlocked() signal to the logind's session Unlock() signal
249249 // (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()));
251251 connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
252252 } else {
253253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
@@ -361,9 +361,8 @@ void DBusUnitySessionService::Lock()
361361 // time the indicator locks without also asking the display manager to
362362 // switch sessions on us. And since we are switching screens, we also
363363 // don't bother respecting the animate request, simply doing a PromptLock.
364− switchToGreeter();
365−
366364 PromptLock();
365+ switchToGreeter();
367366}
368367
369368void DBusUnitySessionService::switchToGreeter()
@@ -392,6 +391,12 @@ void DBusUnitySessionService::switchToGreeter()
392391 });
393392}
394393
394+void DBusUnitySessionService::doUnlock()
395+{
396+ Q_EMIT Unlocked();
397+ Q_EMIT unlocked();
398+}
399+
395400bool DBusUnitySessionService::IsLocked() const
396401{
397402 return !d->isSessionActive;
plugins/Unity/Session/dbusunitysessionservice.h+4
@@ -106,6 +106,7 @@ Q_SIGNALS:
106106 * Emitted after the session has been unlocked.
107107 */
108108 Q_SCRIPTABLE void Unlocked();
109+ void unlocked();
109110
110111public Q_SLOTS:
111112 /**
@@ -259,6 +260,9 @@ public Q_SLOTS:
259260 */
260261 Q_SCRIPTABLE bool IsLocked() const;
261262
263+private Q_SLOTS:
264+ void doUnlock();
265+
262266private:
263267 void switchToGreeter();
264268};
qml/Greeter/Greeter.qml+4−1
@@ -455,7 +455,10 @@ Showable {
455455 Connections {
456456 target: DBusUnitySessionService
457457 onLockRequested: root.forceShow()
458− onUnlocked: root.forcedUnlock = true
458+ onUnlocked: {
459+ root.forcedUnlock = true;
460+ root.hideNow();
461+ }
459462 }
460463
461464 Binding {
tests/plugins/Unity/Session/LogindServer.cpp+5
@@ -26,3 +26,8 @@ QDBusObjectPath LogindServer::GetSessionByPID(quint32)
2626{
2727 return QDBusObjectPath("/logindsession");
2828}
29+
30+void LogindServer::MockEmitUnlock()
31+{
32+ Q_EMIT Unlock();
33+}
tests/plugins/Unity/Session/LogindServer.h+2
@@ -32,6 +32,8 @@ public:
3232public Q_SLOTS:
3333 QDBusObjectPath GetSessionByPID(quint32 pid);
3434
35+ void MockEmitUnlock(); // only in mock
36+
3537Q_SIGNALS:
3638 void Lock();
3739 void Unlock();
tests/plugins/Unity/Session/interfaces.xml+1
@@ -10,6 +10,7 @@
1010 <signal name="PrepareForSleep" />
1111 </interface>
1212 <interface name="org.freedesktop.login1.Session">
13+ <method name="MockEmitUnlock" />
1314 <signal name="Lock" />
1415 <signal name="Unlock" />
1516 </interface>
tests/plugins/Unity/Session/sessionbackendtest.cpp+12
@@ -124,6 +124,18 @@ private Q_SLOTS:
124124 QCOMPARE(spy.count(), 1);
125125 }
126126
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+
127139 void testUserName() {
128140 DBusUnitySessionService dbusUnitySessionService;
129141 QCoreApplication::processEvents(); // to let the service register on DBus