[gnome-shell] loginManager: listen to the correct object path



commit 869e1dc2416e8a9805fadc5caae4dc44cddb46f7
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 25 13:25:30 2013 -0400

    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

 js/misc/loginManager.js |   48 +++++++++++++++++++++++++++++++++-------------
 js/ui/screenShield.js   |    9 +++++--
 2 files changed, 40 insertions(+), 17 deletions(-)
---
diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js
index 00e269b..8543ede 100644
--- a/js/misc/loginManager.js
+++ b/js/misc/loginManager.js
@@ -33,6 +33,10 @@ const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager
     <arg type='s' direction='in'/>
     <arg type='h' direction='out'/>
 </method>
+<method name='GetSession'>
+    <arg type='s' direction='in'/>
+    <arg type='o' direction='out'/>
+</method>
 <method name='ListSessions'>
     <arg name='sessions' type='a(susso)' direction='out'/>
 </method>
@@ -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 7d9654c..c9c1543 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 });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]