@@ -64,19 +64,19 @@ public:
64 QStringLiteral("GetSessionByPID"));
64 QStringLiteral("GetSessionByPID"));
65 msg << (quint32) getpid();
65 msg << (quint32) getpid();
67− QDBusReply<QDBusObjectPath> reply = QDBusConnection::systemBus().call(msg);
67+ QDBusReply<QDBusObjectPath> reply = QDBusConnection::SM_BUSNAME().call(msg);
68 if (reply.isValid()) {
68 if (reply.isValid()) {
69 logindSessionPath = reply.value().path();
69 logindSessionPath = reply.value().path();
71 // start watching the Active property
71 // start watching the Active property
72− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
72+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
73− this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
73+ this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
75 setupSystemdInhibition();
75 setupSystemdInhibition();
77 // re-enable the inhibition upon resume from sleep
77 // re-enable the inhibition upon resume from sleep
78− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
78+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
79− this, SLOT(onResuming(bool)));
79+ this, SLOT(onResuming(bool)));
81 qWarning() << "Failed to get logind session path" << reply.error().message();
81 qWarning() << "Failed to get logind session path" << reply.error().message();
@@ -96,7 +96,7 @@ public:
96 msg << "Unity8 handles power events"; // why
96 msg << "Unity8 handles power events"; // why
97 msg << "block"; // mode
97 msg << "block"; // mode
99− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
99+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
100 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
100 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
101 connect(watcher, &QDBusPendingCallWatcher::finished,
101 connect(watcher, &QDBusPendingCallWatcher::finished,
102 this, [this](QDBusPendingCallWatcher* watcher) {
102 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -114,7 +114,7 @@ public:
114 bool checkLogin1Call(const QString &method) const
114 bool checkLogin1Call(const QString &method) const
116 QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, method);
116 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);
118 return reply.isValid() && (reply == QStringLiteral("yes") || reply == QStringLiteral("challenge"));
118 return reply.isValid() && (reply == QStringLiteral("yes") || reply == QStringLiteral("challenge"));
@@ -125,7 +125,7 @@ public:
125 LOGIN1_IFACE,
125 LOGIN1_IFACE,
127 msg.setArguments(args);
127 msg.setArguments(args);
128− QDBusConnection::systemBus().asyncCall(msg);
128+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
131 void setActive(bool active)
131 void setActive(bool active)
@@ -157,7 +157,7 @@ public:
157 msg << LOGIN1_SESSION_IFACE;
157 msg << LOGIN1_SESSION_IFACE;
158 msg << ACTIVE_KEY;
158 msg << ACTIVE_KEY;
160− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
160+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
161 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
161 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
162 connect(watcher, &QDBusPendingCallWatcher::finished,
162 connect(watcher, &QDBusPendingCallWatcher::finished,
163 this, [this](QDBusPendingCallWatcher* watcher) {
163 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -191,7 +191,7 @@ public:
191 msg << LOGIN1_SESSION_IFACE;
191 msg << LOGIN1_SESSION_IFACE;
192 msg << IDLE_SINCE_KEY;
192 msg << IDLE_SINCE_KEY;
194− QDBusReply<QVariant> reply = QDBusConnection::systemBus().call(msg);
194+ QDBusReply<QVariant> reply = QDBusConnection::SM_BUSNAME().call(msg);
195 if (reply.isValid()) {
195 if (reply.isValid()) {
196 return reply.value().value<quint64>();
196 return reply.value().value<quint64>();
@@ -208,7 +208,7 @@ public:
208 LOGIN1_SESSION_IFACE,
208 LOGIN1_SESSION_IFACE,
209 QStringLiteral("SetIdleHint"));
209 QStringLiteral("SetIdleHint"));
210 msg << idle;
210 msg << idle;
211− QDBusConnection::systemBus().asyncCall(msg);
211+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
214private Q_SLOTS:
214private Q_SLOTS:
@@ -243,11 +243,11 @@ DBusUnitySessionService::DBusUnitySessionService()
243 : UnityDBusObject(QStringLiteral("/com/canonical/Unity/Session"), QStringLiteral("com.canonical.Unity"))
243 : UnityDBusObject(QStringLiteral("/com/canonical/Unity/Session"), QStringLiteral("com.canonical.Unity"))
245 if (!d->logindSessionPath.isEmpty()) {
245 if (!d->logindSessionPath.isEmpty()) {
246− // connect our Lock() slot to the logind's session Lock() signal
246+ // connect our PromptLock() slot to the logind's session Lock() signal
247− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(Lock()));
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::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()));
251 connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
251 connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
@@ -332,15 +332,41 @@ QString DBusUnitySessionService::HostName() const
333void DBusUnitySessionService::PromptLock()
333void DBusUnitySessionService::PromptLock()
335+ // Prompt as in quick. No locking animation needed. Usually used by
336+ // indicator-session in combination with a switch to greeter or other
335 Q_EMIT LockRequested();
338 Q_EMIT LockRequested();
336 Q_EMIT lockRequested();
339 Q_EMIT lockRequested();
339void DBusUnitySessionService::Lock()
342void DBusUnitySessionService::Lock()
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.
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.
357+ // Here's a bug about indicator-session growing a converged Touch profile:
358+ // https://launchpad.net/bugs/1557716
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.
342 PromptLock();
364 PromptLock();
368+void DBusUnitySessionService::switchToGreeter()
344 // lock the session using the org.freedesktop.DisplayManager system DBUS service
370 // lock the session using the org.freedesktop.DisplayManager system DBUS service
345 const QString sessionPath = QString::fromLocal8Bit(qgetenv("XDG_SESSION_PATH"));
371 const QString sessionPath = QString::fromLocal8Bit(qgetenv("XDG_SESSION_PATH"));
346 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.DisplayManager"),
372 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.DisplayManager"),
@@ -348,7 +374,7 @@ void DBusUnitySessionService::Lock()
348 QStringLiteral("org.freedesktop.DisplayManager.Session"),
374 QStringLiteral("org.freedesktop.DisplayManager.Session"),
349 QStringLiteral("Lock"));
375 QStringLiteral("Lock"));
351− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
377+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
352 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
378 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
353 connect(watcher, &QDBusPendingCallWatcher::finished,
379 connect(watcher, &QDBusPendingCallWatcher::finished,
354 this, [this](QDBusPendingCallWatcher* watcher) {
380 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -365,6 +391,12 @@ void DBusUnitySessionService::Lock()
394+void DBusUnitySessionService::doUnlock()
368bool DBusUnitySessionService::IsLocked() const
400bool DBusUnitySessionService::IsLocked() const
370 return !d->isSessionActive;
402 return !d->isSessionActive;
@@ -486,7 +518,7 @@ void DBusGnomeScreensaverWrapper::SetActive(bool lock)
487void DBusGnomeScreensaverWrapper::Lock()
519void DBusGnomeScreensaverWrapper::Lock()
489− performAsyncUnityCall(QStringLiteral("Lock"));
521+ performAsyncUnityCall(QStringLiteral("PromptLock"));
492quint32 DBusGnomeScreensaverWrapper::GetActiveTime() const
524quint32 DBusGnomeScreensaverWrapper::GetActiveTime() const
@@ -523,7 +555,7 @@ bool DBusScreensaverWrapper::SetActive(bool lock)
524void DBusScreensaverWrapper::Lock()
556void DBusScreensaverWrapper::Lock()
526− performAsyncUnityCall(QStringLiteral("Lock"));
558+ performAsyncUnityCall(QStringLiteral("PromptLock"));
529quint32 DBusScreensaverWrapper::GetActiveTime() const
561quint32 DBusScreensaverWrapper::GetActiveTime() const