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
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
import Gio from 'gi://Gio';
|
2010-04-29 17:13:20 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
import {loadInterfaceXML} from './fileUtils.js';
|
2018-09-06 00:55:20 +00:00
|
|
|
|
|
|
|
const PresenceIface = loadInterfaceXML('org.gnome.SessionManager.Presence');
|
2010-04-29 17:13:20 +00:00
|
|
|
|
2023-07-30 12:56:59 +00:00
|
|
|
/** @enum {number} */
|
2023-07-10 09:53:00 +00:00
|
|
|
export const PresenceStatus = {
|
2010-04-29 17:13:20 +00:00
|
|
|
AVAILABLE: 0,
|
|
|
|
INVISIBLE: 1,
|
|
|
|
BUSY: 2,
|
2019-08-20 21:43:54 +00:00
|
|
|
IDLE: 3,
|
2010-04-29 17:13:20 +00:00
|
|
|
};
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
const PresenceProxy = Gio.DBusProxy.makeProxyWrapper(PresenceIface);
|
2023-07-30 12:56:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Function} initCallback
|
|
|
|
* @param {Gio.Cancellable} cancellable
|
|
|
|
* @returns {Gio.DBusProxy}
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function Presence(initCallback, cancellable) {
|
2011-08-16 12:24:39 +00:00
|
|
|
return new PresenceProxy(Gio.DBus.session, 'org.gnome.SessionManager',
|
|
|
|
'/org/gnome/SessionManager/Presence', initCallback, cancellable);
|
2010-04-29 17:13:20 +00:00
|
|
|
}
|
|
|
|
|
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)
|
2018-09-06 00:55:20 +00:00
|
|
|
const InhibitorIface = loadInterfaceXML('org.gnome.SessionManager.Inhibitor');
|
2023-07-10 09:53:00 +00:00
|
|
|
const InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface);
|
2023-07-30 12:56:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} objectPath
|
|
|
|
* @param {Function} initCallback
|
|
|
|
* @param {Gio.Cancellable} cancellable
|
|
|
|
* @returns {Gio.DBusProxy}
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function Inhibitor(objectPath, initCallback, cancellable) {
|
2011-08-16 12:24:39 +00:00
|
|
|
return new InhibitorProxy(Gio.DBus.session, 'org.gnome.SessionManager', objectPath, initCallback, cancellable);
|
2011-01-06 15:30:15 +00:00
|
|
|
}
|
|
|
|
|
2011-03-12 20:34:01 +00:00
|
|
|
// Not the full interface, only the methods we use
|
2018-09-06 00:55:20 +00:00
|
|
|
const SessionManagerIface = loadInterfaceXML('org.gnome.SessionManager');
|
2023-07-10 09:53:00 +00:00
|
|
|
const SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface);
|
2023-07-30 12:56:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Function} initCallback
|
|
|
|
* @param {Gio.Cancellable} cancellable
|
|
|
|
* @returns {Gio.DBusProxy}
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function SessionManager(initCallback, cancellable) {
|
2011-08-16 12:24:39 +00:00
|
|
|
return new SessionManagerProxy(Gio.DBus.session, 'org.gnome.SessionManager', '/org/gnome/SessionManager', initCallback, cancellable);
|
2011-03-12 20:34:01 +00:00
|
|
|
}
|
2020-08-30 16:57:19 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export const InhibitFlags = {
|
2020-08-30 16:57:19 +00:00
|
|
|
LOGOUT: 1 << 0,
|
|
|
|
SWITCH: 1 << 1,
|
|
|
|
SUSPEND: 1 << 2,
|
|
|
|
IDLE: 1 << 3,
|
|
|
|
AUTOMOUNT: 1 << 4,
|
|
|
|
};
|