2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2010-04-29 17:13:20 +00:00
|
|
|
|
|
|
|
const DBus = imports.dbus;
|
|
|
|
const Lang = imports.lang;
|
2011-01-06 15:30:15 +00:00
|
|
|
const Signals = imports.signals;
|
2010-04-29 17:13:20 +00:00
|
|
|
|
|
|
|
const PresenceIface = {
|
|
|
|
name: 'org.gnome.SessionManager.Presence',
|
|
|
|
methods: [{ name: 'SetStatus',
|
2011-02-26 18:21:10 +00:00
|
|
|
inSignature: 'u',
|
|
|
|
outSignature: '' }],
|
2010-04-29 17:13:20 +00:00
|
|
|
properties: [{ name: 'status',
|
|
|
|
signature: 'u',
|
|
|
|
access: 'readwrite' }],
|
|
|
|
signals: [{ name: 'StatusChanged',
|
|
|
|
inSignature: 'u' }]
|
|
|
|
};
|
|
|
|
|
|
|
|
const PresenceStatus = {
|
|
|
|
AVAILABLE: 0,
|
|
|
|
INVISIBLE: 1,
|
|
|
|
BUSY: 2,
|
|
|
|
IDLE: 3
|
|
|
|
};
|
|
|
|
|
|
|
|
function Presence() {
|
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
|
|
|
Presence.prototype = {
|
|
|
|
_init: function() {
|
|
|
|
DBus.session.proxifyObject(this, 'org.gnome.SessionManager', '/org/gnome/SessionManager/Presence', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
getStatus: function(callback) {
|
|
|
|
this.GetRemote('status', Lang.bind(this,
|
|
|
|
function(status, ex) {
|
|
|
|
if (!ex)
|
|
|
|
callback(this, status);
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
setStatus: function(status) {
|
|
|
|
this.SetStatusRemote(status);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
DBus.proxifyPrototype(Presence.prototype, PresenceIface);
|
2011-01-06 15:30:15 +00:00
|
|
|
|
|
|
|
// Note inhibitors are immutable objects, so they don't
|
|
|
|
// change at runtime (changes always come in the form
|
|
|
|
// of new inhibitors)
|
|
|
|
const InhibitorIface = {
|
|
|
|
name: 'org.gnome.SessionManager.Inhibitor',
|
|
|
|
properties: [{ name: 'app_id',
|
|
|
|
signature: 's',
|
|
|
|
access: 'readonly' },
|
|
|
|
{ name: 'client_id',
|
|
|
|
signature: 's',
|
|
|
|
access: 'readonly' },
|
|
|
|
{ name: 'reason',
|
|
|
|
signature: 's',
|
|
|
|
access: 'readonly' },
|
|
|
|
{ name: 'flags',
|
|
|
|
signature: 'u',
|
|
|
|
access: 'readonly' },
|
|
|
|
{ name: 'toplevel_xid',
|
|
|
|
signature: 'u',
|
|
|
|
access: 'readonly' },
|
|
|
|
{ name: 'cookie',
|
|
|
|
signature: 'u',
|
|
|
|
access: 'readonly' }],
|
|
|
|
};
|
|
|
|
|
|
|
|
function Inhibitor(objectPath) {
|
|
|
|
this._init(objectPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
Inhibitor.prototype = {
|
|
|
|
_init: function(objectPath) {
|
|
|
|
DBus.session.proxifyObject(this,
|
2011-09-30 21:30:47 +00:00
|
|
|
'org.gnome.SessionManager',
|
2011-01-06 15:30:15 +00:00
|
|
|
objectPath);
|
|
|
|
this.isLoaded = false;
|
|
|
|
this._loadingPropertiesCount = InhibitorIface.properties.length;
|
|
|
|
for (let i = 0; i < InhibitorIface.properties.length; i++) {
|
|
|
|
let propertyName = InhibitorIface.properties[i].name;
|
|
|
|
this.GetRemote(propertyName, Lang.bind(this,
|
|
|
|
function(value, exception) {
|
|
|
|
if (exception)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this[propertyName] = value;
|
|
|
|
this._loadingPropertiesCount--;
|
|
|
|
|
|
|
|
if (this._loadingPropertiesCount == 0) {
|
|
|
|
this.isLoaded = true;
|
2011-09-30 21:30:47 +00:00
|
|
|
this.emit('is-loaded');
|
2011-01-06 15:30:15 +00:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
DBus.proxifyPrototype(Inhibitor.prototype, InhibitorIface);
|
|
|
|
Signals.addSignalMethods(Inhibitor.prototype);
|
2011-03-12 20:34:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Not the full interface, only the methods we use
|
|
|
|
const SessionManagerIface = {
|
|
|
|
name: 'org.gnome.SessionManager',
|
|
|
|
methods: [
|
|
|
|
{ name: 'Logout', inSignature: 'u', outSignature: '' },
|
2011-06-03 22:10:55 +00:00
|
|
|
{ name: 'Shutdown', inSignature: '', outSignature: '' },
|
|
|
|
{ name: 'CanShutdown', inSignature: '', outSignature: 'b' }
|
2011-03-12 20:34:01 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
function SessionManager() {
|
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
|
|
|
SessionManager.prototype = {
|
|
|
|
_init: function() {
|
|
|
|
DBus.session.proxifyObject(this, 'org.gnome.SessionManager', '/org/gnome/SessionManager');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
DBus.proxifyPrototype(SessionManager.prototype, SessionManagerIface);
|