@@ -64,19 +64,19 @@ public:
6464 QStringLiteral("GetSessionByPID"));
6565 msg << (quint32) getpid();
6666
67− QDBusReply<QDBusObjectPath> reply = QDBusConnection::systemBus().call(msg);
67+ QDBusReply<QDBusObjectPath> reply = QDBusConnection::SM_BUSNAME().call(msg);
6868 if (reply.isValid()) {
6969 logindSessionPath = reply.value().path();
7070
7171 // start watching the Active property
72− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
73− this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
72+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
73+ this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
7474
7575 setupSystemdInhibition();
7676
7777 // re-enable the inhibition upon resume from sleep
78− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
79− this, SLOT(onResuming(bool)));
78+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
79+ this, SLOT(onResuming(bool)));
8080 } else {
8181 qWarning() << "Failed to get logind session path" << reply.error().message();
8282 }
@@ -96,7 +96,7 @@ public:
9696 msg << "Unity8 handles power events"; // why
9797 msg << "block"; // mode
9898
99− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
99+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
100100 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
101101 connect(watcher, &QDBusPendingCallWatcher::finished,
102102 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -114,7 +114,7 @@ public:
114114 bool checkLogin1Call(const QString &method) const
115115 {
116116 QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, method);
117− QDBusReply<QString> reply = QDBusConnection::systemBus().call(msg);
117+ QDBusReply<QString> reply = QDBusConnection::SM_BUSNAME().call(msg);
118118 return reply.isValid() && (reply == QStringLiteral("yes") || reply == QStringLiteral("challenge"));
119119 }
120120
@@ -125,7 +125,7 @@ public:
125125 LOGIN1_IFACE,
126126 method);
127127 msg.setArguments(args);
128− QDBusConnection::systemBus().asyncCall(msg);
128+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
129129 }
130130
131131 void setActive(bool active)
@@ -157,7 +157,7 @@ public:
157157 msg << LOGIN1_SESSION_IFACE;
158158 msg << ACTIVE_KEY;
159159
160− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
160+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
161161 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
162162 connect(watcher, &QDBusPendingCallWatcher::finished,
163163 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -191,7 +191,7 @@ public:
191191 msg << LOGIN1_SESSION_IFACE;
192192 msg << IDLE_SINCE_KEY;
193193
194− QDBusReply<QVariant> reply = QDBusConnection::systemBus().call(msg);
194+ QDBusReply<QVariant> reply = QDBusConnection::SM_BUSNAME().call(msg);
195195 if (reply.isValid()) {
196196 return reply.value().value<quint64>();
197197 } else {
@@ -208,7 +208,7 @@ public:
208208 LOGIN1_SESSION_IFACE,
209209 QStringLiteral("SetIdleHint"));
210210 msg << idle;
211− QDBusConnection::systemBus().asyncCall(msg);
211+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
212212 }
213213
214214private Q_SLOTS:
@@ -243,11 +243,11 @@ DBusUnitySessionService::DBusUnitySessionService()
243243 : UnityDBusObject(QStringLiteral("/com/canonical/Unity/Session"), QStringLiteral("com.canonical.Unity"))
244244{
245245 if (!d->logindSessionPath.isEmpty()) {
246− // connect our Lock() slot to the logind's session Lock() signal
247− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(Lock()));
246+ // connect our PromptLock() slot to the logind's session Lock() signal
247+ 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::systemBus().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";
@@ -332,15 +332,41 @@ QString DBusUnitySessionService::HostName() const
332332
333333void DBusUnitySessionService::PromptLock()
334334{
335+ // Prompt as in quick. No locking animation needed. Usually used by
336+ // indicator-session in combination with a switch to greeter or other
337+ // user session.
335338 Q_EMIT LockRequested();
336339 Q_EMIT lockRequested();
337340}
338341
339342void DBusUnitySessionService::Lock()
340343{
341− // signal u8 to show the lockscreen/greeter
344+ // Normal lock (with animation, as compared to PromptLock above). Usually
345+ // used by indicator-session to lock the session in place.
346+ //
347+ // FIXME: We also -- as a bit of a hack around indicator-session not fully
348+ // supporting a phone profile -- switch to greeter here. The unity7 flow is
349+ // that the user chooses "Lock/Switch" from the indicator, and then can go
350+ // to greeter by selecting "Switch" again from the indicator, which is now
351+ // exposed by the desktop_lockscreen profile. But since in unity8, we try
352+ // to expose most things all the time, we don't use the separate lockscreen
353+ // profile. Instead, we just go directly to the greeter the first time
354+ // a user presses "Lock/Switch". This isn't what this DBus call is
355+ // supposed to do, but we can live with it for now.
356+ //
357+ // Here's a bug about indicator-session growing a converged Touch profile:
358+ // https://launchpad.net/bugs/1557716
359+ //
360+ // We only do this here in the animated-lock call because that's the only
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
363+ // don't bother respecting the animate request, simply doing a PromptLock.
342364 PromptLock();
365+ switchToGreeter();
366+}
343367
368+void DBusUnitySessionService::switchToGreeter()
369+{
344370 // lock the session using the org.freedesktop.DisplayManager system DBUS service
345371 const QString sessionPath = QString::fromLocal8Bit(qgetenv("XDG_SESSION_PATH"));
346372 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.DisplayManager"),
@@ -348,7 +374,7 @@ void DBusUnitySessionService::Lock()
348374 QStringLiteral("org.freedesktop.DisplayManager.Session"),
349375 QStringLiteral("Lock"));
350376
351− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
377+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
352378 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
353379 connect(watcher, &QDBusPendingCallWatcher::finished,
354380 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -365,6 +391,12 @@ void DBusUnitySessionService::Lock()
365391 });
366392}
367393
394+void DBusUnitySessionService::doUnlock()
395+{
396+ Q_EMIT Unlocked();
397+ Q_EMIT unlocked();
398+}
399+
368400bool DBusUnitySessionService::IsLocked() const
369401{
370402 return !d->isSessionActive;
@@ -486,7 +518,7 @@ void DBusGnomeScreensaverWrapper::SetActive(bool lock)
486518
487519void DBusGnomeScreensaverWrapper::Lock()
488520{
489− performAsyncUnityCall(QStringLiteral("Lock"));
521+ performAsyncUnityCall(QStringLiteral("PromptLock"));
490522}
491523
492524quint32 DBusGnomeScreensaverWrapper::GetActiveTime() const
@@ -523,7 +555,7 @@ bool DBusScreensaverWrapper::SetActive(bool lock)
523555
524556void DBusScreensaverWrapper::Lock()
525557{
526− performAsyncUnityCall(QStringLiteral("Lock"));
558+ performAsyncUnityCall(QStringLiteral("PromptLock"));
527559}
528560
529561quint32 DBusScreensaverWrapper::GetActiveTime() const