diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js
index 00e269b3b..8543edea6 100644
--- a/js/misc/loginManager.js
+++ b/js/misc/loginManager.js
@@ -33,6 +33,10 @@ const SystemdLoginManagerIface =
+
+
+
+
@@ -136,15 +140,23 @@ const LoginManagerSystemd = new Lang.Class({
// Having this function is a bit of a hack since the Systemd and ConsoleKit
// session objects have different interfaces - but in both cases there are
// Lock/Unlock signals, and that's all we count upon at the moment.
- getCurrentSessionProxy: function() {
- if (!this._currentSession) {
- this._currentSession = new SystemdLoginSession(Gio.DBus.system,
- 'org.freedesktop.login1',
- '/org/freedesktop/login1/session/' +
- GLib.getenv('XDG_SESSION_ID'));
+ getCurrentSessionProxy: function(callback) {
+ if (this._currentSession) {
+ callback (this._currentSession);
+ return;
}
- return this._currentSession;
+ this._proxy.GetSessionRemote(GLib.getenv('XDG_SESSION_ID'), Lang.bind(this,
+ function(result, error) {
+ if (error) {
+ logError(error, 'Could not get a proxy for the current session');
+ } else {
+ this._currentSession = new SystemdLoginSession(Gio.DBus.system,
+ 'org.freedesktop.login1',
+ result[0]);
+ callback(this._currentSession);
+ }
+ }));
},
canPowerOff: function(asyncCallback) {
@@ -233,15 +245,23 @@ const LoginManagerConsoleKit = new Lang.Class({
// Having this function is a bit of a hack since the Systemd and ConsoleKit
// session objects have different interfaces - but in both cases there are
// Lock/Unlock signals, and that's all we count upon at the moment.
- getCurrentSessionProxy: function() {
- if (!this._currentSession) {
- let [currentSessionId] = this._proxy.GetCurrentSessionSync();
- this._currentSession = new ConsoleKitSession(Gio.DBus.system,
- 'org.freedesktop.ConsoleKit',
- currentSessionId);
+ getCurrentSessionProxy: function(callback) {
+ if (this._currentSession) {
+ callback (this._currentSession);
+ return;
}
- return this._currentSession;
+ this._proxy.GetCurrentSessionRemote(Lang.bind(this,
+ function(result, error) {
+ if (error) {
+ logError(error, 'Could not get a proxy for the current session');
+ } else {
+ this._currentSession = new ConsoleKitSession(Gio.DBus.system,
+ 'org.freedesktop.ConsoleKit',
+ result[0]);
+ callback(this._currentSession);
+ }
+ }));
},
canPowerOff: function(asyncCallback) {
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 7d9654c16..c9c154343 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -512,9 +512,12 @@ const ScreenShield = new Lang.Class({
Lang.bind(this, this._prepareForSleep));
this._inhibitSuspend();
- this._loginSession = this._loginManager.getCurrentSessionProxy();
- this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
- this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); }));
+ this._loginManager.getCurrentSessionProxy(Lang.bind(this,
+ function(sessionProxy) {
+ this._loginSession = sessionProxy;
+ this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
+ this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); }));
+ }));
this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });