~darkxst/ubuntu/saucy/gnome-shell/upstart_log

« back to all changes in this revision

Viewing changes to .pc/git_logind_check.patch/js/misc/loginManager.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-31 12:01:12 UTC
  • mfrom: (1.1.49) (19.1.36 experimental)
  • Revision ID: package-import@ubuntu.com-20130531120112-ew91khxf051x9i2r
Tags: 3.8.2-1ubuntu1
* Merge with Debian (LP: #1185869, #1185721). Remaining changes:
  - debian/control.in:
    + Build-depend on libsystemd-login-dev & libsystemd-daemon-dev
    + Depend on gdm instead of gdm3
    + Don't recommend gnome-session-fallback
  - debian/patches/40_change-pam-name-to-match-gdm.patch:
  - debian/patches/revert-suspend-break.patch:
    + Disabled, not needed on Ubuntu
  - debian/patches/ubuntu-lightdm-user-switching.patch:
    + Allow user switching when using LightDM. Thanks Gerhard Stein
      for rebasing against gnome-shell 3.8!
  - debian/patches/ubuntu_lock_on_suspend.patch
    + Respect Ubuntu's lock-on-suspend setting.
      Disabled until it can be rewritten.
  - debian/patches/git_relock_screen_after_crash.patch:
    + Add Upstream fix for unlocked session after crash (LP: #1064584)
* Note that the new GNOME Classic mode (which requires installing
  gnome-shell-extensions) won't work until gnome-session 3.8 is
  available in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2
 
 
3
 
const GLib = imports.gi.GLib;
4
 
const Gio = imports.gi.Gio;
5
 
const Lang = imports.lang;
6
 
const Shell = imports.gi.Shell;
7
 
 
8
 
const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager'>
9
 
<method name='PowerOff'>
10
 
    <arg type='b' direction='in'/>
11
 
</method>
12
 
<method name='Reboot'>
13
 
    <arg type='b' direction='in'/>
14
 
</method>
15
 
<method name='CanPowerOff'>
16
 
    <arg type='s' direction='out'/>
17
 
</method>
18
 
<method name='CanReboot'>
19
 
    <arg type='s' direction='out'/>
20
 
</method>
21
 
</interface>;
22
 
 
23
 
const SystemdLoginSessionIface = <interface name='org.freedesktop.login1.Session'>
24
 
<signal name='Lock' />
25
 
<signal name='Unlock' />
26
 
</interface>;
27
 
 
28
 
const SystemdLoginManager = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
29
 
const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
30
 
 
31
 
const ConsoleKitManagerIface = <interface name='org.freedesktop.ConsoleKit.Manager'>
32
 
<method name='CanRestart'>
33
 
    <arg type='b' direction='out'/>
34
 
</method>
35
 
<method name='CanStop'>
36
 
    <arg type='b' direction='out'/>
37
 
</method>
38
 
<method name='Restart' />
39
 
<method name='Stop' />
40
 
<method name='GetCurrentSession'>
41
 
    <arg type='o' direction='out' />
42
 
</method>
43
 
</interface>;
44
 
 
45
 
const ConsoleKitSessionIface = <interface name='org.freedesktop.ConsoleKit.Session'>
46
 
<method name='IsActive'>
47
 
    <arg type='b' direction='out' />
48
 
</method>
49
 
<signal name='ActiveChanged'>
50
 
    <arg type='b' direction='out' />
51
 
</signal>
52
 
<signal name='Lock' />
53
 
<signal name='Unlock' />
54
 
</interface>;
55
 
 
56
 
const ConsoleKitSession = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
57
 
const ConsoleKitManager = Gio.DBusProxy.makeProxyWrapper(ConsoleKitManagerIface);
58
 
 
59
 
function haveSystemd() {
60
 
    return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
61
 
}
62
 
 
63
 
let _loginManager = null;
64
 
 
65
 
/**
66
 
 * LoginManager:
67
 
 * An abstraction over systemd/logind and ConsoleKit.
68
 
 *
69
 
 */
70
 
function getLoginManager() {
71
 
    if (_loginManager == null) {
72
 
        if (haveSystemd())
73
 
            _loginManager = new LoginManagerSystemd();
74
 
        else
75
 
            _loginManager = new LoginManagerConsoleKit();
76
 
    }
77
 
 
78
 
    return _loginManager;
79
 
}
80
 
 
81
 
const LoginManagerSystemd = new Lang.Class({
82
 
    Name: 'LoginManagerSystemd',
83
 
 
84
 
    _init: function() {
85
 
        this._proxy = new SystemdLoginManager(Gio.DBus.system,
86
 
                                              'org.freedesktop.login1',
87
 
                                              '/org/freedesktop/login1');
88
 
    },
89
 
 
90
 
    // Having this function is a bit of a hack since the Systemd and ConsoleKit
91
 
    // session objects have different interfaces - but in both cases there are
92
 
    // Lock/Unlock signals, and that's all we count upon at the moment.
93
 
    getCurrentSessionProxy: function() {
94
 
        if (!this._currentSession) {
95
 
            this._currentSession = new SystemdLoginSession(Gio.DBus.system,
96
 
                                                           'org.freedesktop.login1',
97
 
                                                           '/org/freedesktop/login1/session/' +
98
 
                                                           GLib.getenv('XDG_SESSION_ID'));
99
 
        }
100
 
 
101
 
        return this._currentSession;
102
 
    },
103
 
 
104
 
    get sessionActive() {
105
 
        return Shell.session_is_active_for_systemd();
106
 
    },
107
 
 
108
 
    canPowerOff: function(asyncCallback) {
109
 
        this._proxy.CanPowerOffRemote(function(result, error) {
110
 
            if (error)
111
 
                asyncCallback(false);
112
 
            else
113
 
                asyncCallback(result[0] != 'no');
114
 
        });
115
 
    },
116
 
 
117
 
    canReboot: function(asyncCallback) {
118
 
        this._proxy.CanRebootRemote(function(result, error) {
119
 
            if (error)
120
 
                asyncCallback(false);
121
 
            else
122
 
                asyncCallback(result[0] != 'no');
123
 
        });
124
 
    },
125
 
 
126
 
    powerOff: function() {
127
 
        this._proxy.PowerOffRemote(true);
128
 
    },
129
 
 
130
 
    reboot: function() {
131
 
        this._proxy.RebootRemote(true);
132
 
    }
133
 
});
134
 
 
135
 
const LoginManagerConsoleKit = new Lang.Class({
136
 
    Name: 'LoginManagerConsoleKit',
137
 
 
138
 
    _init: function() {
139
 
        this._proxy = new ConsoleKitManager(Gio.DBus.system,
140
 
                                            'org.freedesktop.ConsoleKit',
141
 
                                            '/org/freedesktop/ConsoleKit/Manager');
142
 
    },
143
 
 
144
 
    // Having this function is a bit of a hack since the Systemd and ConsoleKit
145
 
    // session objects have different interfaces - but in both cases there are
146
 
    // Lock/Unlock signals, and that's all we count upon at the moment.
147
 
    getCurrentSessionProxy: function() {
148
 
        if (!this._currentSession) {
149
 
            let [currentSessionId] = this._proxy.GetCurrentSessionSync();
150
 
            this._currentSession = new ConsoleKitSession(Gio.DBus.system,
151
 
                                                         'org.freedesktop.ConsoleKit',
152
 
                                                         currentSessionId);
153
 
        }
154
 
 
155
 
        return this._currentSession;
156
 
    },
157
 
 
158
 
    get sessionActive() {
159
 
        if (this._sessionActive !== undefined)
160
 
            return this._sessionActive;
161
 
 
162
 
        let session = this.getCurrentSessionProxy();
163
 
        session.connectSignal('ActiveChanged', Lang.bind(this, function(object, senderName, [isActive]) {
164
 
            this._sessionActive = isActive;
165
 
        }));
166
 
        [this._sessionActive] = session.IsActiveSync();
167
 
 
168
 
        return this._sessionActive;
169
 
    },
170
 
 
171
 
    canPowerOff: function(asyncCallback) {
172
 
        this._proxy.CanStopRemote(function(result, error) {
173
 
            if (error)
174
 
                asyncCallback(false);
175
 
            else
176
 
                asyncCallback(result[0]);
177
 
        });
178
 
    },
179
 
 
180
 
    canReboot: function(asyncCallback) {
181
 
        this._proxy.CanRestartRemote(function(result, error) {
182
 
            if (error)
183
 
                asyncCallback(false);
184
 
            else
185
 
                asyncCallback(result[0]);
186
 
        });
187
 
    },
188
 
 
189
 
    powerOff: function() {
190
 
        this._proxy.StopRemote();
191
 
    },
192
 
 
193
 
    reboot: function() {
194
 
        this._proxy.RestartRemote();
195
 
    }
196
 
            
197
 
});