loginManager: listen to the correct object path

Use GetSession() to get the valid object path for the current
XDG_SESSION_ID.

https://bugzilla.gnome.org/show_bug.cgi?id=696287
This commit is contained in:
Cosimo Cecchi 2013-03-25 13:25:30 -04:00
parent b878f3fc4a
commit 869e1dc241
2 changed files with 40 additions and 17 deletions

View File

@ -33,6 +33,10 @@ const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager
<arg type='s' direction='in'/> <arg type='s' direction='in'/>
<arg type='h' direction='out'/> <arg type='h' direction='out'/>
</method> </method>
<method name='GetSession'>
<arg type='s' direction='in'/>
<arg type='o' direction='out'/>
</method>
<method name='ListSessions'> <method name='ListSessions'>
<arg name='sessions' type='a(susso)' direction='out'/> <arg name='sessions' type='a(susso)' direction='out'/>
</method> </method>
@ -136,15 +140,23 @@ const LoginManagerSystemd = new Lang.Class({
// Having this function is a bit of a hack since the Systemd and ConsoleKit // 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 // session objects have different interfaces - but in both cases there are
// Lock/Unlock signals, and that's all we count upon at the moment. // Lock/Unlock signals, and that's all we count upon at the moment.
getCurrentSessionProxy: function() { getCurrentSessionProxy: function(callback) {
if (!this._currentSession) { if (this._currentSession) {
this._currentSession = new SystemdLoginSession(Gio.DBus.system, callback (this._currentSession);
'org.freedesktop.login1', return;
'/org/freedesktop/login1/session/' +
GLib.getenv('XDG_SESSION_ID'));
} }
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) { 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 // 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 // session objects have different interfaces - but in both cases there are
// Lock/Unlock signals, and that's all we count upon at the moment. // Lock/Unlock signals, and that's all we count upon at the moment.
getCurrentSessionProxy: function() { getCurrentSessionProxy: function(callback) {
if (!this._currentSession) { if (this._currentSession) {
let [currentSessionId] = this._proxy.GetCurrentSessionSync(); callback (this._currentSession);
this._currentSession = new ConsoleKitSession(Gio.DBus.system, return;
'org.freedesktop.ConsoleKit',
currentSessionId);
} }
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) { canPowerOff: function(asyncCallback) {

View File

@ -512,9 +512,12 @@ const ScreenShield = new Lang.Class({
Lang.bind(this, this._prepareForSleep)); Lang.bind(this, this._prepareForSleep));
this._inhibitSuspend(); this._inhibitSuspend();
this._loginSession = this._loginManager.getCurrentSessionProxy(); 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('Lock', Lang.bind(this, function() { this.lock(false); }));
this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); })); this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); }));
}));
this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA }); this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });