Compare commits
3 Commits
citadel
...
wip/gdbus-
Author | SHA1 | Date | |
---|---|---|---|
|
d2052a885e | ||
|
afcc1b7b52 | ||
|
a6b4d68a1d |
@ -21,7 +21,16 @@ const GnomeShellIface = <interface name="org.gnome.Shell.Extensions">
|
|||||||
</signal>
|
</signal>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
|
const GnomeShellProxy = new Gio.DBusProxyClass({
|
||||||
|
Name: 'GnomeShellProxy',
|
||||||
|
Interface: GnomeShellIface,
|
||||||
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: 'org.gnome.Shell',
|
||||||
|
g_object_path: '/org/gnome/Shell' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function stripPrefix(string, prefix) {
|
function stripPrefix(string, prefix) {
|
||||||
if (string.slice(0, prefix.length) == prefix)
|
if (string.slice(0, prefix.length) == prefix)
|
||||||
@ -191,7 +200,8 @@ const Application = new Lang.Class({
|
|||||||
|
|
||||||
this._extensionPrefsBin.add(label);
|
this._extensionPrefsBin.add(label);
|
||||||
|
|
||||||
this._shellProxy = new GnomeShellProxy(Gio.DBus.session, 'org.gnome.Shell', '/org/gnome/Shell');
|
this._shellProxy = new GnomeShellProxy();
|
||||||
|
this._shellProxy.init(null);
|
||||||
this._shellProxy.connectSignal('ExtensionStatusChanged', Lang.bind(this, function(proxy, senderName, [uuid, state, error]) {
|
this._shellProxy.connectSignal('ExtensionStatusChanged', Lang.bind(this, function(proxy, senderName, [uuid, state, error]) {
|
||||||
if (ExtensionUtils.extensions[uuid] !== undefined)
|
if (ExtensionUtils.extensions[uuid] !== undefined)
|
||||||
this._scanExtensions();
|
this._scanExtensions();
|
||||||
|
@ -11,16 +11,14 @@ const FprintManagerIface = <interface name='net.reactivated.Fprint.Manager'>
|
|||||||
</method>
|
</method>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const FprintManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(FprintManagerIface);
|
const FprintManager = new Gio.DBusProxyClass({
|
||||||
|
Name: 'FprintManager',
|
||||||
|
Interface: FprintManagerIface,
|
||||||
|
|
||||||
function FprintManager() {
|
_init: function() {
|
||||||
var self = new Gio.DBusProxy({ g_connection: Gio.DBus.system,
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
g_interface_name: FprintManagerInfo.name,
|
g_name: 'net.reactivated.Fprint',
|
||||||
g_interface_info: FprintManagerInfo,
|
g_object_path: '/net/reactivated/Fprint/Manager',
|
||||||
g_name: 'net.reactivated.Fprint',
|
g_flags: (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
|
||||||
g_object_path: '/net/reactivated/Fprint/Manager',
|
}
|
||||||
g_flags: (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
|
});
|
||||||
|
|
||||||
self.init(null);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
@ -35,7 +35,13 @@ const PowerMenuButton = new Lang.Class({
|
|||||||
/* Translators: accessible name of the power menu in the login screen */
|
/* Translators: accessible name of the power menu in the login screen */
|
||||||
this.parent('system-shutdown-symbolic', _("Power"));
|
this.parent('system-shutdown-symbolic', _("Power"));
|
||||||
|
|
||||||
this._loginManager = LoginManager.getLoginManager();
|
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
|
||||||
|
this._loginManager = manager;
|
||||||
|
|
||||||
|
this._updateHaveShutdown();
|
||||||
|
this._updateHaveRestart();
|
||||||
|
this._updateHaveSuspend();
|
||||||
|
}));
|
||||||
|
|
||||||
this._settings = new Gio.Settings({ schema: GdmUtil.LOGIN_SCREEN_SCHEMA });
|
this._settings = new Gio.Settings({ schema: GdmUtil.LOGIN_SCREEN_SCHEMA });
|
||||||
this._settings.connect('changed::disable-restart-buttons',
|
this._settings.connect('changed::disable-restart-buttons',
|
||||||
@ -64,6 +70,12 @@ const PowerMenuButton = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateHaveShutdown: function() {
|
_updateHaveShutdown: function() {
|
||||||
|
if (!this._loginManager) {
|
||||||
|
this._haveShutdown = false;
|
||||||
|
this._powerOffItem.actor.visible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._loginManager.canPowerOff(Lang.bind(this, function(result) {
|
this._loginManager.canPowerOff(Lang.bind(this, function(result) {
|
||||||
this._haveShutdown = result;
|
this._haveShutdown = result;
|
||||||
this._powerOffItem.actor.visible = this._haveShutdown;
|
this._powerOffItem.actor.visible = this._haveShutdown;
|
||||||
@ -72,6 +84,12 @@ const PowerMenuButton = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateHaveRestart: function() {
|
_updateHaveRestart: function() {
|
||||||
|
if (!this._loginManager) {
|
||||||
|
this._haveRestart = false;
|
||||||
|
this._restartItem.actor.visible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._loginManager.canReboot(Lang.bind(this, function(result) {
|
this._loginManager.canReboot(Lang.bind(this, function(result) {
|
||||||
this._haveRestart = result;
|
this._haveRestart = result;
|
||||||
this._restartItem.actor.visible = this._haveRestart;
|
this._restartItem.actor.visible = this._haveRestart;
|
||||||
@ -80,6 +98,12 @@ const PowerMenuButton = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateHaveSuspend: function() {
|
_updateHaveSuspend: function() {
|
||||||
|
if (!this._loginManager) {
|
||||||
|
this._haveSuspend = false;
|
||||||
|
this._suspendItem.actor.visible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._loginManager.canSuspend(Lang.bind(this, function(result) {
|
this._loginManager.canSuspend(Lang.bind(this, function(result) {
|
||||||
this._haveSuspend = result;
|
this._haveSuspend = result;
|
||||||
this._suspendItem.actor.visible = this._haveSuspend;
|
this._suspendItem.actor.visible = this._haveSuspend;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
|
const GLib = imports.gi.GLib;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
@ -16,7 +17,16 @@ const ProviderIface = <interface name='org.freedesktop.realmd.Provider'>
|
|||||||
<arg name="realm" type="ao" direction="out"/>
|
<arg name="realm" type="ao" direction="out"/>
|
||||||
</method>
|
</method>
|
||||||
</interface>;
|
</interface>;
|
||||||
const Provider = Gio.DBusProxy.makeProxyWrapper(ProviderIface);
|
const Provider = new Gio.DBusProxyClass({
|
||||||
|
Name: 'RealmdProvider',
|
||||||
|
Interface: ProviderIface,
|
||||||
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.realmd',
|
||||||
|
g_object_path: '/org/freedesktop/realmd' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const ServiceIface = <interface name="org.freedesktop.realmd.Service">
|
const ServiceIface = <interface name="org.freedesktop.realmd.Service">
|
||||||
<method name="Cancel">
|
<method name="Cancel">
|
||||||
@ -31,7 +41,16 @@ const ServiceIface = <interface name="org.freedesktop.realmd.Service">
|
|||||||
<arg name="operation" type="s"/>
|
<arg name="operation" type="s"/>
|
||||||
</signal>
|
</signal>
|
||||||
</interface>;
|
</interface>;
|
||||||
const Service = Gio.DBusProxy.makeProxyWrapper(ServiceIface);
|
const Service = new Gio.DBusProxyClass({
|
||||||
|
Name: 'RealmdService',
|
||||||
|
Interface: ServiceIface,
|
||||||
|
|
||||||
|
_init: function(service) {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.realmd',
|
||||||
|
g_object_path: service });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const RealmIface = <interface name="org.freedesktop.realmd.Realm">
|
const RealmIface = <interface name="org.freedesktop.realmd.Realm">
|
||||||
<property name="Name" type="s" access="read"/>
|
<property name="Name" type="s" access="read"/>
|
||||||
@ -51,16 +70,22 @@ const RealmIface = <interface name="org.freedesktop.realmd.Realm">
|
|||||||
<arg name="options" type="a{sv}" direction="in"/>
|
<arg name="options" type="a{sv}" direction="in"/>
|
||||||
</method>
|
</method>
|
||||||
</interface>;
|
</interface>;
|
||||||
const Realm = Gio.DBusProxy.makeProxyWrapper(RealmIface);
|
const Realm = new Gio.DBusProxyClass({
|
||||||
|
Name: 'RealmdRealm',
|
||||||
|
Interface: RealmIface,
|
||||||
|
|
||||||
|
_init: function(realm) {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.realmd',
|
||||||
|
g_object_path: realm });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const Manager = new Lang.Class({
|
const Manager = new Lang.Class({
|
||||||
Name: 'Manager',
|
Name: 'Manager',
|
||||||
|
|
||||||
_init: function(parentActor) {
|
_init: function(parentActor) {
|
||||||
this._aggregateProvider = Provider(Gio.DBus.system,
|
this._aggregateProvider = new Provider();
|
||||||
'org.freedesktop.realmd',
|
|
||||||
'/org/freedesktop/realmd',
|
|
||||||
Lang.bind(this, this._reloadRealms))
|
|
||||||
this._realms = {};
|
this._realms = {};
|
||||||
|
|
||||||
this._aggregateProvider.connect('g-properties-changed',
|
this._aggregateProvider.connect('g-properties-changed',
|
||||||
@ -68,6 +93,16 @@ const Manager = new Lang.Class({
|
|||||||
if ('Realms' in properties.deep_unpack())
|
if ('Realms' in properties.deep_unpack())
|
||||||
this._reloadRealms();
|
this._reloadRealms();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this._aggregateProvider.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
|
try {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._reloadRealms();
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_reloadRealms: function() {
|
_reloadRealms: function() {
|
||||||
@ -77,10 +112,8 @@ const Manager = new Lang.Class({
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (let i = 0; i < realmPaths.length; i++) {
|
for (let i = 0; i < realmPaths.length; i++) {
|
||||||
let realm = Realm(Gio.DBus.system,
|
let realm = new Realm(realmPaths[i]);
|
||||||
'org.freedesktop.realmd',
|
realm.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, this._onRealmLoaded));
|
||||||
realmPaths[i],
|
|
||||||
Lang.bind(this, this._onRealmLoaded));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -97,9 +130,10 @@ const Manager = new Lang.Class({
|
|||||||
this._updateLoginFormat();
|
this._updateLoginFormat();
|
||||||
},
|
},
|
||||||
|
|
||||||
_onRealmLoaded: function(realm, error) {
|
_onRealmLoaded: function(realm, result) {
|
||||||
if (error)
|
try {
|
||||||
return;
|
realm.init_finish(result);
|
||||||
|
} catch(e) { return; }
|
||||||
|
|
||||||
this._reloadRealm(realm);
|
this._reloadRealm(realm);
|
||||||
|
|
||||||
|
@ -82,6 +82,8 @@ const ShellUserVerifier = new Lang.Class({
|
|||||||
this._settings = new Gio.Settings({ schema: LOGIN_SCREEN_SCHEMA });
|
this._settings = new Gio.Settings({ schema: LOGIN_SCREEN_SCHEMA });
|
||||||
|
|
||||||
this._fprintManager = new Fprint.FprintManager();
|
this._fprintManager = new Fprint.FprintManager();
|
||||||
|
this._fprintManager.init(null);
|
||||||
|
|
||||||
this._realmManager = new Realmd.Manager();
|
this._realmManager = new Realmd.Manager();
|
||||||
|
|
||||||
this._failCounter = 0;
|
this._failCounter = 0;
|
||||||
@ -137,11 +139,14 @@ const ShellUserVerifier = new Lang.Class({
|
|||||||
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY))
|
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable, Lang.bind(this,
|
this._fprintManager.GetDefaultDeviceRemote(this._cancellable, Lang.bind(this, function(manager, result) {
|
||||||
function(device, error) {
|
try {
|
||||||
if (!error && device)
|
let device = manager.GetDefaultDeviceFinish(result);
|
||||||
this._haveFingerprintReader = true;
|
this._haveFingerprintReader = !!device;
|
||||||
}));
|
} catch(e) {
|
||||||
|
this._haveFingerprintReader = false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_reportInitError: function(where, error) {
|
_reportInitError: function(where, error) {
|
||||||
|
@ -21,11 +21,16 @@ const PresenceStatus = {
|
|||||||
IDLE: 3
|
IDLE: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
var PresenceProxy = Gio.DBusProxy.makeProxyWrapper(PresenceIface);
|
const Presence = new Gio.DBusProxyClass({
|
||||||
function Presence(initCallback, cancellable) {
|
Name: 'GnomeSessionPresence',
|
||||||
return new PresenceProxy(Gio.DBus.session, 'org.gnome.SessionManager',
|
Interface: PresenceIface,
|
||||||
'/org/gnome/SessionManager/Presence', initCallback, cancellable);
|
|
||||||
}
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: 'org.gnome.SessionManager',
|
||||||
|
g_object_path: '/org/gnome/SessionManager/Presence' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Note inhibitors are immutable objects, so they don't
|
// Note inhibitors are immutable objects, so they don't
|
||||||
// change at runtime (changes always come in the form
|
// change at runtime (changes always come in the form
|
||||||
@ -39,10 +44,16 @@ const InhibitorIface = <interface name="org.gnome.SessionManager.Inhibitor">
|
|||||||
</method>
|
</method>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
var InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface);
|
const Inhibitor = new Gio.DBusProxyClass({
|
||||||
function Inhibitor(objectPath, initCallback, cancellable) {
|
Name: 'GnomeSessionInhibitor',
|
||||||
return new InhibitorProxy(Gio.DBus.session, 'org.gnome.SessionManager', objectPath, initCallback, cancellable);
|
Interface: InhibitorIface,
|
||||||
}
|
|
||||||
|
_init: function(inhibitor) {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: 'org.gnome.SessionManager',
|
||||||
|
g_object_path: inhibitor });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Not the full interface, only the methods we use
|
// Not the full interface, only the methods we use
|
||||||
const SessionManagerIface = <interface name="org.gnome.SessionManager">
|
const SessionManagerIface = <interface name="org.gnome.SessionManager">
|
||||||
@ -66,7 +77,14 @@ const SessionManagerIface = <interface name="org.gnome.SessionManager">
|
|||||||
</signal>
|
</signal>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
var SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface);
|
const SessionManager = new Gio.DBusProxyClass({
|
||||||
function SessionManager(initCallback, cancellable) {
|
Name: 'GnomeSessionManager',
|
||||||
return new SessionManagerProxy(Gio.DBus.session, 'org.gnome.SessionManager', '/org/gnome/SessionManager', initCallback, cancellable);
|
Interface: SessionManagerIface,
|
||||||
}
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: 'org.gnome.SessionManager',
|
||||||
|
g_object_path: '/org/gnome/SessionManager' });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
|
const GObject = imports.gi.GObject;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
@ -33,8 +34,26 @@ const SystemdLoginSessionIface = <interface name='org.freedesktop.login1.Session
|
|||||||
<signal name='Unlock' />
|
<signal name='Unlock' />
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const SystemdLoginManager = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
|
const SystemdLoginManager = new Gio.DBusProxyClass({
|
||||||
const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
|
Name: 'SystemdLoginManager',
|
||||||
|
Interface: SystemdLoginManagerIface,
|
||||||
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.login1',
|
||||||
|
g_object_path: '/org/freedesktop/login1' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const SystemdLoginSession = new Gio.DBusProxyClass({
|
||||||
|
Name: 'SystemdLoginSession',
|
||||||
|
Interface: SystemdLoginSessionIface,
|
||||||
|
|
||||||
|
_init: function(session) {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.login1',
|
||||||
|
g_object_path: session });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const ConsoleKitManagerIface = <interface name='org.freedesktop.ConsoleKit.Manager'>
|
const ConsoleKitManagerIface = <interface name='org.freedesktop.ConsoleKit.Manager'>
|
||||||
<method name='CanRestart'>
|
<method name='CanRestart'>
|
||||||
@ -61,51 +80,128 @@ const ConsoleKitSessionIface = <interface name='org.freedesktop.ConsoleKit.Sessi
|
|||||||
<signal name='Unlock' />
|
<signal name='Unlock' />
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const ConsoleKitSession = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
|
const ConsoleKitSession = new Gio.DBusProxyClass({
|
||||||
const ConsoleKitManager = Gio.DBusProxy.makeProxyWrapper(ConsoleKitManagerIface);
|
Name: 'ConsoleKitSession',
|
||||||
|
Interface: ConsoleKitSessionIface,
|
||||||
|
|
||||||
|
_init: function(session) {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.ConsoleKit',
|
||||||
|
g_object_path: session });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const ConsoleKitManager = new Gio.DBusProxyClass({
|
||||||
|
Name: 'ConsoleKitManager',
|
||||||
|
Interface: ConsoleKitManagerIface,
|
||||||
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.ConsoleKit',
|
||||||
|
g_object_path: '/org/freedesktop/ConsoleKit/Manager' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function haveSystemd() {
|
function haveSystemd() {
|
||||||
return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
|
return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _loginManager = null;
|
let _loginManager = null;
|
||||||
|
let _pendingAsyncCallbacks = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LoginManager:
|
* LoginManager:
|
||||||
* An abstraction over systemd/logind and ConsoleKit.
|
* An abstraction over systemd/logind and ConsoleKit.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getLoginManager() {
|
function getLoginManager(asyncCallback) {
|
||||||
if (_loginManager == null) {
|
if (_loginManager == null) {
|
||||||
if (haveSystemd())
|
if (_pendingAsyncCallbacks.length == 0) {
|
||||||
_loginManager = new LoginManagerSystemd();
|
let manager;
|
||||||
else
|
|
||||||
_loginManager = new LoginManagerConsoleKit();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _loginManager;
|
if (haveSystemd())
|
||||||
|
manager = new LoginManagerSystemd();
|
||||||
|
else
|
||||||
|
manager = new LoginManagerConsoleKit();
|
||||||
|
|
||||||
|
manager.initAsync(null, function(obj, result) {
|
||||||
|
obj.initFinish(result);
|
||||||
|
|
||||||
|
_loginManager = manager;
|
||||||
|
|
||||||
|
_pendingAsyncCallbacks.forEach(function (f) { f(obj) });
|
||||||
|
_pendingAsyncCallbacks = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
_pendingAsyncCallbacks = [asyncCallback];
|
||||||
|
} else {
|
||||||
|
_pendingAsyncCallbacks.push(asyncCallback);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GLib.idle_add(GLib.PRIORITY_DEFAULT, function() {
|
||||||
|
asyncCallback(_loginManager);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const LoginManagerSystemd = new Lang.Class({
|
const LoginManagerSystemd = new Lang.Class({
|
||||||
Name: 'LoginManagerSystemd',
|
Name: 'LoginManagerSystemd',
|
||||||
|
Extends: GObject.Object,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._proxy = new SystemdLoginManager(Gio.DBus.system,
|
this.parent();
|
||||||
'org.freedesktop.login1',
|
|
||||||
'/org/freedesktop/login1');
|
this._proxy = new SystemdLoginManager();
|
||||||
|
},
|
||||||
|
|
||||||
|
initAsync: function(cancellable, asyncCallback) {
|
||||||
|
let simpleResult = Gio.SimpleAsyncResult.new(this, asyncCallback, null);
|
||||||
|
simpleResult.set_check_cancellable(cancellable);
|
||||||
|
|
||||||
|
this._proxy.init_async(GLib.PRIORITY_DEFAULT, cancellable, Lang.bind(this, function(proxy, result) {
|
||||||
|
try {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
if (cancellable && cancellable.is_cancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._fetchCurrentSession(cancellable, simpleResult);
|
||||||
|
} catch(e if e instanceof GLib.Error) {
|
||||||
|
simpleResult.set_from_error(e);
|
||||||
|
simpleResult.complete();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
initFinish: function(simpleResult) {
|
||||||
|
if (!simpleResult.propagate_error())
|
||||||
|
return simpleResult.get_op_res_gboolean();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
_fetchCurrentSession: function(cancellable, simpleResult) {
|
||||||
|
this._currentSession = new SystemdLoginSession('/org/freedesktop/login1/session/' +
|
||||||
|
GLib.getenv('XDG_SESSION_ID'));
|
||||||
|
|
||||||
|
this._currentSession.init_async(GLib.PRIORITY_DEFAULT, cancellable, Lang.bind(this, function(proxy, result) {
|
||||||
|
try {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
simpleResult.set_op_res_gboolean(true);
|
||||||
|
} catch(e if e instanceof GLib.Error) {
|
||||||
|
simpleResult.set_from_error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
simpleResult.complete();
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
// 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.
|
||||||
|
//
|
||||||
|
// This is only valid after async initialization
|
||||||
getCurrentSessionProxy: function() {
|
getCurrentSessionProxy: function() {
|
||||||
if (!this._currentSession) {
|
|
||||||
this._currentSession = new SystemdLoginSession(Gio.DBus.system,
|
|
||||||
'org.freedesktop.login1',
|
|
||||||
'/org/freedesktop/login1/session/' +
|
|
||||||
GLib.getenv('XDG_SESSION_ID'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._currentSession;
|
return this._currentSession;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -114,66 +210,126 @@ const LoginManagerSystemd = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
canPowerOff: function(asyncCallback) {
|
canPowerOff: function(asyncCallback) {
|
||||||
this._proxy.CanPowerOffRemote(function(result, error) {
|
this._proxy.CanPowerOffRemote(null, function(proxy, result) {
|
||||||
if (error)
|
let val = false;
|
||||||
asyncCallback(false);
|
|
||||||
else
|
try {
|
||||||
asyncCallback(result[0] != 'no');
|
val = proxy.CanPowerOffFinish(result)[0] != 'no';
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
asyncCallback(val);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
canReboot: function(asyncCallback) {
|
canReboot: function(asyncCallback) {
|
||||||
this._proxy.CanRebootRemote(function(result, error) {
|
this._proxy.CanRebootRemote(null, function(proxy, result) {
|
||||||
if (error)
|
let val = false;
|
||||||
asyncCallback(false);
|
|
||||||
else
|
try {
|
||||||
asyncCallback(result[0] != 'no');
|
val = proxy.CanRebootFinish(result)[0] != 'no';
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
asyncCallback(val);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
canSuspend: function(asyncCallback) {
|
canSuspend: function(asyncCallback) {
|
||||||
this._proxy.CanSuspendRemote(function(result, error) {
|
this._proxy.CanSuspendRemote(null, function(proxy, result) {
|
||||||
if (error)
|
let val = false;
|
||||||
asyncCallback(false);
|
|
||||||
else
|
try {
|
||||||
asyncCallback(result[0] != 'no');
|
val = proxy.CanRebootFinish(result)[0] != 'no';
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
asyncCallback(val);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
powerOff: function() {
|
powerOff: function() {
|
||||||
this._proxy.PowerOffRemote(true);
|
this._proxy.PowerOffRemote(true, null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
reboot: function() {
|
reboot: function() {
|
||||||
this._proxy.RebootRemote(true);
|
this._proxy.RebootRemote(true, null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
suspend: function() {
|
suspend: function() {
|
||||||
this._proxy.SuspendRemote(true);
|
this._proxy.SuspendRemote(true, null, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const LoginManagerConsoleKit = new Lang.Class({
|
const LoginManagerConsoleKit = new Lang.Class({
|
||||||
Name: 'LoginManagerConsoleKit',
|
Name: 'LoginManagerConsoleKit',
|
||||||
|
Extends: GObject.Object,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._proxy = new ConsoleKitManager(Gio.DBus.system,
|
this.parent();
|
||||||
'org.freedesktop.ConsoleKit',
|
|
||||||
'/org/freedesktop/ConsoleKit/Manager');
|
this._proxy = new ConsoleKitManager();
|
||||||
this._upClient = new UPowerGlib.Client();
|
this._upClient = new UPowerGlib.Client();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initAsync: function(cancellable, asyncCallback) {
|
||||||
|
let simpleResult = Gio.SimpleAsyncResult.new(this, asyncCallback, null);
|
||||||
|
simpleResult.set_check_cancellable(cancellable);
|
||||||
|
|
||||||
|
this._proxy.init_async(GLib.PRIORITY_DEFAULT, cancellable, Lang.bind(this, function(proxy, result) {
|
||||||
|
try {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
if (cancellable && cancellable.is_cancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._fetchCurrentSession(cancellable, simpleResult);
|
||||||
|
} catch(e if e instanceof GLib.Error) {
|
||||||
|
simpleResult.set_from_error(e);
|
||||||
|
simpleResult.complete();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
initFinish: function(simpleResult) {
|
||||||
|
if (!simpleResult.propagate_error())
|
||||||
|
return simpleResult.get_op_res_gboolean();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
_fetchCurrentSession: function(cancellable, simpleResult) {
|
||||||
|
this._proxy.GetCurrentSessionRemote(cancellable, Lang.bind(this, function(proxy, result) {
|
||||||
|
try {
|
||||||
|
let [currentSessionId] = proxy.GetCurrentSessionFinish(result);
|
||||||
|
|
||||||
|
if (cancellable && cancellable.is_cancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._createSessionProxy(currentSessionId, cancellable, simpleResult);
|
||||||
|
} catch(e if e instanceof GLib.Error) {
|
||||||
|
simpleResult.set_from_error(e);
|
||||||
|
simpleResult.complete();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
_createSessionProxy: function(currentSessionId, cancellable, simpleResult) {
|
||||||
|
this._currentSession = new ConsoleKitSession(currentSessionId);
|
||||||
|
this._currentSession.init_async(GLib.PRIORITY_DEFAULT, cancellable, Lang.bind(this, function(proxy, result) {
|
||||||
|
try {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
simpleResult.set_op_res_gboolean(true);
|
||||||
|
} catch(e if e instanceof GLib.Error) {
|
||||||
|
simpleResult.set_from_error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
simpleResult.complete();
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
// 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() {
|
||||||
if (!this._currentSession) {
|
|
||||||
let [currentSessionId] = this._proxy.GetCurrentSessionSync();
|
|
||||||
this._currentSession = new ConsoleKitSession(Gio.DBus.system,
|
|
||||||
'org.freedesktop.ConsoleKit',
|
|
||||||
currentSessionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._currentSession;
|
return this._currentSession;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -185,26 +341,32 @@ const LoginManagerConsoleKit = new Lang.Class({
|
|||||||
session.connectSignal('ActiveChanged', Lang.bind(this, function(object, senderName, [isActive]) {
|
session.connectSignal('ActiveChanged', Lang.bind(this, function(object, senderName, [isActive]) {
|
||||||
this._sessionActive = isActive;
|
this._sessionActive = isActive;
|
||||||
}));
|
}));
|
||||||
[this._sessionActive] = session.IsActiveSync();
|
[this._sessionActive] = session.IsActiveSync(null);
|
||||||
|
|
||||||
return this._sessionActive;
|
return this._sessionActive;
|
||||||
},
|
},
|
||||||
|
|
||||||
canPowerOff: function(asyncCallback) {
|
canPowerOff: function(asyncCallback) {
|
||||||
this._proxy.CanStopRemote(function(result, error) {
|
this._proxy.CanStopRemote(null, function(proxy, result) {
|
||||||
if (error)
|
let val = false;
|
||||||
asyncCallback(false);
|
|
||||||
else
|
try {
|
||||||
asyncCallback(result[0]);
|
[val] = proxy.CanStopFinish(result);
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
asyncCallback(val);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
canReboot: function(asyncCallback) {
|
canReboot: function(asyncCallback) {
|
||||||
this._proxy.CanRestartRemote(function(result, error) {
|
this._proxy.CanRestartRemote(null, function(proxy, result) {
|
||||||
if (error)
|
let val = false;
|
||||||
asyncCallback(false);
|
|
||||||
else
|
try {
|
||||||
asyncCallback(result[0]);
|
[val] = proxy.CanRestartFinish(result);
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
asyncCallback(val);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -216,11 +378,11 @@ const LoginManagerConsoleKit = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
powerOff: function() {
|
powerOff: function() {
|
||||||
this._proxy.StopRemote();
|
this._proxy.StopRemote(null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
reboot: function() {
|
reboot: function() {
|
||||||
this._proxy.RestartRemote();
|
this._proxy.RestartRemote(null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
suspend: function() {
|
suspend: function() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
|
const GLib = imports.gi.GLib;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
@ -26,7 +27,16 @@ const ModemGsmNetworkInterface = <interface name="org.freedesktop.ModemManager.M
|
|||||||
</signal>
|
</signal>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const ModemGsmNetworkProxy = Gio.DBusProxy.makeProxyWrapper(ModemGsmNetworkInterface);
|
const ModemGsmNetworkProxy = new Gio.DBusProxyClass({
|
||||||
|
Name: 'ModemGsmNetworkProxy',
|
||||||
|
Interface: ModemGsmNetworkInterface,
|
||||||
|
|
||||||
|
_init: function(modem) {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.ModemManager',
|
||||||
|
g_object_path: modem });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const ModemCdmaInterface = <interface name="org.freedesktop.ModemManager.Modem.Cdma">
|
const ModemCdmaInterface = <interface name="org.freedesktop.ModemManager.Modem.Cdma">
|
||||||
<method name="GetSignalQuality">
|
<method name="GetSignalQuality">
|
||||||
@ -40,7 +50,16 @@ const ModemCdmaInterface = <interface name="org.freedesktop.ModemManager.Modem.C
|
|||||||
</signal>
|
</signal>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const ModemCdmaProxy = Gio.DBusProxy.makeProxyWrapper(ModemCdmaInterface);
|
const ModemCdmaProxy = new Gio.DBusProxyClass({
|
||||||
|
Name: 'ModemCdmaProxy',
|
||||||
|
Interface: ModemCdmaInterface,
|
||||||
|
|
||||||
|
_init: function(modem) {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
|
||||||
|
g_name: 'org.freedesktop.ModemManager',
|
||||||
|
g_object_path: modem });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
let _providersTable;
|
let _providersTable;
|
||||||
function _getProvidersTable() {
|
function _getProvidersTable() {
|
||||||
@ -54,11 +73,18 @@ const ModemGsm = new Lang.Class({
|
|||||||
Name: 'ModemGsm',
|
Name: 'ModemGsm',
|
||||||
|
|
||||||
_init: function(path) {
|
_init: function(path) {
|
||||||
this._proxy = new ModemGsmNetworkProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
|
this._proxy = new ModemGsmNetworkProxy(path);
|
||||||
|
this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(obj, result) {
|
||||||
|
obj.init_finish(result);
|
||||||
|
|
||||||
|
this._finishInit();
|
||||||
|
}));
|
||||||
|
|
||||||
this.signal_quality = 0;
|
this.signal_quality = 0;
|
||||||
this.operator_name = null;
|
this.operator_name = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
_finishInit: function() {
|
||||||
// Code is duplicated because the function have different signatures
|
// Code is duplicated because the function have different signatures
|
||||||
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, [quality]) {
|
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, [quality]) {
|
||||||
this.signal_quality = quality;
|
this.signal_quality = quality;
|
||||||
@ -68,24 +94,19 @@ const ModemGsm = new Lang.Class({
|
|||||||
this.operator_name = this._findOperatorName(name, code);
|
this.operator_name = this._findOperatorName(name, code);
|
||||||
this.emit('notify::operator-name');
|
this.emit('notify::operator-name');
|
||||||
}));
|
}));
|
||||||
this._proxy.GetRegistrationInfoRemote(Lang.bind(this, function([result], err) {
|
this._proxy.GetRegistrationInfoRemote(null, Lang.bind(this, function(proxy, result) {
|
||||||
if (err) {
|
let [status, code, name] = proxy.GetRegistrationInfoFinish(result);
|
||||||
log(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let [status, code, name] = result;
|
|
||||||
this.operator_name = this._findOperatorName(name, code);
|
this.operator_name = this._findOperatorName(name, code);
|
||||||
this.emit('notify::operator-name');
|
this.emit('notify::operator-name');
|
||||||
}));
|
}));
|
||||||
this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
|
this._proxy.GetSignalQualityRemote(null, Lang.bind(this, function(proxy, result) {
|
||||||
if (err) {
|
try {
|
||||||
|
[this.signal_quality] = proxy.GetSignalQualityFinish(result);
|
||||||
|
} catch(e) {
|
||||||
// it will return an error if the device is not connected
|
// it will return an error if the device is not connected
|
||||||
this.signal_quality = 0;
|
this.signal_quality = 0;
|
||||||
} else {
|
|
||||||
let [quality] = result;
|
|
||||||
this.signal_quality = quality;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('notify::signal-quality');
|
this.emit('notify::signal-quality');
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@ -157,10 +178,18 @@ const ModemCdma = new Lang.Class({
|
|||||||
Name: 'ModemCdma',
|
Name: 'ModemCdma',
|
||||||
|
|
||||||
_init: function(path) {
|
_init: function(path) {
|
||||||
this._proxy = new ModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
|
this._proxy = new ModemCdmaProxy(path);
|
||||||
|
this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(obj, result) {
|
||||||
|
obj.init_finish(result);
|
||||||
|
|
||||||
|
this._finishInit();
|
||||||
|
}));
|
||||||
|
|
||||||
this.signal_quality = 0;
|
this.signal_quality = 0;
|
||||||
this.operator_name = null;
|
this.operator_name = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
_finishInit: function() {
|
||||||
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, params) {
|
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, params) {
|
||||||
this.signal_quality = params[0];
|
this.signal_quality = params[0];
|
||||||
this.emit('notify::signal-quality');
|
this.emit('notify::signal-quality');
|
||||||
@ -170,30 +199,31 @@ const ModemCdma = new Lang.Class({
|
|||||||
if (this.operator_name == null)
|
if (this.operator_name == null)
|
||||||
this._refreshServingSystem();
|
this._refreshServingSystem();
|
||||||
}));
|
}));
|
||||||
this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
|
this._proxy.GetSignalQualityRemote(null, Lang.bind(this, function(proxy, result) {
|
||||||
if (err) {
|
try {
|
||||||
|
[this.signal_quality] = proxy.GetSignalQualityFinish(result);
|
||||||
|
} catch(e) {
|
||||||
// it will return an error if the device is not connected
|
// it will return an error if the device is not connected
|
||||||
this.signal_quality = 0;
|
this.signal_quality = 0;
|
||||||
} else {
|
|
||||||
let [quality] = result;
|
|
||||||
this.signal_quality = quality;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('notify::signal-quality');
|
this.emit('notify::signal-quality');
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshServingSystem: function() {
|
_refreshServingSystem: function() {
|
||||||
this._proxy.GetServingSystemRemote(Lang.bind(this, function([result], err) {
|
this._proxy.GetServingSystemRemote(null, Lang.bind(this, function(proxy, result) {
|
||||||
if (err) {
|
try {
|
||||||
// it will return an error if the device is not connected
|
let [bandClass, band, name] = proxy.GetServingSystemFinish(result);
|
||||||
this.operator_name = null;
|
|
||||||
} else {
|
|
||||||
let [bandClass, band, id] = result;
|
|
||||||
if (name.length > 0)
|
if (name.length > 0)
|
||||||
this.operator_name = this._findProviderForSid(id);
|
this.operator_name = this._findProviderForSid(name);
|
||||||
else
|
else
|
||||||
this.operator_name = null;
|
this.operator_name = null;
|
||||||
|
} catch(e) {
|
||||||
|
// it will return an error if the device is not connected
|
||||||
|
this.operator_name = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('notify::operator-name');
|
this.emit('notify::operator-name');
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
const Clutter = imports.gi.Clutter;
|
const Clutter = imports.gi.Clutter;
|
||||||
|
const GLib = imports.gi.GLib;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
@ -200,19 +201,17 @@ const CalendarServerIface = <interface name="org.gnome.Shell.CalendarServer">
|
|||||||
<signal name="Changed" />
|
<signal name="Changed" />
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const CalendarServerInfo = Gio.DBusInterfaceInfo.new_for_xml(CalendarServerIface);
|
const CalendarServer = new Gio.DBusProxyClass({
|
||||||
|
Name: 'CalendarServer',
|
||||||
|
Interface: CalendarServerIface,
|
||||||
|
|
||||||
function CalendarServer() {
|
_init: function() {
|
||||||
var self = new Gio.DBusProxy({ g_connection: Gio.DBus.session,
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
g_interface_name: CalendarServerInfo.name,
|
g_name: 'org.gnome.Shell.CalendarServer',
|
||||||
g_interface_info: CalendarServerInfo,
|
g_object_path: '/org/gnome/Shell/CalendarServer',
|
||||||
g_name: 'org.gnome.Shell.CalendarServer',
|
g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
|
||||||
g_object_path: '/org/gnome/Shell/CalendarServer',
|
}
|
||||||
g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
|
});
|
||||||
|
|
||||||
self.init(null);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _datesEqual(a, b) {
|
function _datesEqual(a, b) {
|
||||||
if (a < b)
|
if (a < b)
|
||||||
@ -242,11 +241,15 @@ const DBusEventSource = new Lang.Class({
|
|||||||
this._dbusProxy = new CalendarServer();
|
this._dbusProxy = new CalendarServer();
|
||||||
this._dbusProxy.connectSignal('Changed', Lang.bind(this, this._onChanged));
|
this._dbusProxy.connectSignal('Changed', Lang.bind(this, this._onChanged));
|
||||||
|
|
||||||
this._dbusProxy.connect('notify::g-name-owner', Lang.bind(this, function() {
|
this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
if (this._dbusProxy.g_name_owner)
|
try {
|
||||||
this._onNameAppeared();
|
proxy.init_finish(result);
|
||||||
else
|
} catch(e) {
|
||||||
this._onNameVanished();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._resetCache();
|
||||||
|
this.emit('changed');
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -256,52 +259,52 @@ const DBusEventSource = new Lang.Class({
|
|||||||
this._lastRequestEnd = null;
|
this._lastRequestEnd = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_onNameAppeared: function(owner) {
|
|
||||||
this._resetCache();
|
|
||||||
this._loadEvents(true);
|
|
||||||
},
|
|
||||||
|
|
||||||
_onNameVanished: function(oldOwner) {
|
|
||||||
this._resetCache();
|
|
||||||
this.emit('changed');
|
|
||||||
},
|
|
||||||
|
|
||||||
_onChanged: function() {
|
_onChanged: function() {
|
||||||
this._loadEvents(false);
|
this._loadEvents(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onEventsReceived: function(results, error) {
|
_onEventsReceived: function(proxy, result) {
|
||||||
let newEvents = [];
|
let appointments;
|
||||||
let appointments = results ? results[0] : null;
|
try {
|
||||||
if (appointments != null) {
|
[appointments] = proxy.call_finish(result).deep_unpack();
|
||||||
for (let n = 0; n < appointments.length; n++) {
|
} catch(e if e instanceof GLib.Error) {
|
||||||
let a = appointments[n];
|
// ignore errors coming from DBus
|
||||||
let date = new Date(a[4] * 1000);
|
appointments = [];
|
||||||
let end = new Date(a[5] * 1000);
|
|
||||||
let summary = a[1];
|
|
||||||
let allDay = a[3];
|
|
||||||
let event = new CalendarEvent(date, end, summary, allDay);
|
|
||||||
newEvents.push(event);
|
|
||||||
}
|
|
||||||
newEvents.sort(function(event1, event2) {
|
|
||||||
return event1.date.getTime() - event2.date.getTime();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let newEvents = [];
|
||||||
|
for (let n = 0; n < appointments.length; n++) {
|
||||||
|
let a = appointments[n];
|
||||||
|
let date = new Date(a[4] * 1000);
|
||||||
|
let end = new Date(a[5] * 1000);
|
||||||
|
let summary = a[1];
|
||||||
|
let allDay = a[3];
|
||||||
|
let event = new CalendarEvent(date, end, summary, allDay);
|
||||||
|
newEvents.push(event);
|
||||||
|
}
|
||||||
|
newEvents.sort(function(event1, event2) {
|
||||||
|
return event1.date.getTime() - event2.date.getTime();
|
||||||
|
});
|
||||||
|
|
||||||
this._events = newEvents;
|
this._events = newEvents;
|
||||||
this.emit('changed');
|
this.emit('changed');
|
||||||
},
|
},
|
||||||
|
|
||||||
_loadEvents: function(forceReload) {
|
_loadEvents: function(forceReload) {
|
||||||
if (this._curRequestBegin && this._curRequestEnd){
|
if (this._curRequestBegin && this._curRequestEnd){
|
||||||
|
/* Can't use GetEventsRemote because we need to pass the
|
||||||
|
flags here */
|
||||||
let callFlags = Gio.DBusCallFlags.NO_AUTO_START;
|
let callFlags = Gio.DBusCallFlags.NO_AUTO_START;
|
||||||
if (forceReload)
|
if (forceReload)
|
||||||
callFlags = Gio.DBusCallFlags.NONE;
|
callFlags = Gio.DBusCallFlags.NONE;
|
||||||
this._dbusProxy.GetEventsRemote(this._curRequestBegin.getTime() / 1000,
|
this._dbusProxy.call("GetEvents",
|
||||||
this._curRequestEnd.getTime() / 1000,
|
GLib.Variant.new("(xxb)", [this._curRequestBegin.getTime() / 1000,
|
||||||
forceReload,
|
this._curRequestEnd.getTime() / 1000,
|
||||||
Lang.bind(this, this._onEventsReceived),
|
forceReload]),
|
||||||
callFlags);
|
callFlags,
|
||||||
|
-1,
|
||||||
|
null,
|
||||||
|
Lang.bind(this, this._onEventsReceived));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -394,7 +397,6 @@ const Calendar = new Lang.Class({
|
|||||||
this._eventSourceChangedId = this._eventSource.connect('changed', Lang.bind(this, function() {
|
this._eventSourceChangedId = this._eventSource.connect('changed', Lang.bind(this, function() {
|
||||||
this._update(false);
|
this._update(false);
|
||||||
}));
|
}));
|
||||||
this._update(true);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@ const AutomountManager = new Lang.Class({
|
|||||||
Lang.bind(this, this._InhibitorsChanged));
|
Lang.bind(this, this._InhibitorsChanged));
|
||||||
this._inhibited = false;
|
this._inhibited = false;
|
||||||
|
|
||||||
this._loginManager = LoginManager.getLoginManager();
|
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
|
||||||
|
this._loginManager = manager;
|
||||||
|
}));
|
||||||
this._volumeMonitor = Gio.VolumeMonitor.get();
|
this._volumeMonitor = Gio.VolumeMonitor.get();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ const AutomountManager = new Lang.Class({
|
|||||||
_onDriveConnected: function() {
|
_onDriveConnected: function() {
|
||||||
// if we're not in the current ConsoleKit session,
|
// if we're not in the current ConsoleKit session,
|
||||||
// or screensaver is active, don't play sounds
|
// or screensaver is active, don't play sounds
|
||||||
if (!this._loginManager.sessionActive)
|
if (!this._loginManager || !this._loginManager.sessionActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
global.play_theme_sound(0, 'device-added-media');
|
global.play_theme_sound(0, 'device-added-media');
|
||||||
@ -94,7 +96,7 @@ const AutomountManager = new Lang.Class({
|
|||||||
_onDriveDisconnected: function() {
|
_onDriveDisconnected: function() {
|
||||||
// if we're not in the current ConsoleKit session,
|
// if we're not in the current ConsoleKit session,
|
||||||
// or screensaver is active, don't play sounds
|
// or screensaver is active, don't play sounds
|
||||||
if (!this._loginManager.sessionActive)
|
if (!this._loginManager || !this._loginManager.sessionActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
global.play_theme_sound(0, 'device-removed-media');
|
global.play_theme_sound(0, 'device-removed-media');
|
||||||
@ -103,7 +105,7 @@ const AutomountManager = new Lang.Class({
|
|||||||
_onDriveEjectButton: function(monitor, drive) {
|
_onDriveEjectButton: function(monitor, drive) {
|
||||||
// TODO: this code path is not tested, as the GVfs volume monitor
|
// TODO: this code path is not tested, as the GVfs volume monitor
|
||||||
// doesn't emit this signal just yet.
|
// doesn't emit this signal just yet.
|
||||||
if (!this._loginManager.sessionActive)
|
if (!this._loginManager || !this._loginManager.sessionActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// we force stop/eject in this case, so we don't have to pass a
|
// we force stop/eject in this case, so we don't have to pass a
|
||||||
@ -143,7 +145,7 @@ const AutomountManager = new Lang.Class({
|
|||||||
if (params.checkSession) {
|
if (params.checkSession) {
|
||||||
// if we're not in the current ConsoleKit session,
|
// if we're not in the current ConsoleKit session,
|
||||||
// don't attempt automount
|
// don't attempt automount
|
||||||
if (!this._loginManager.sessionActive)
|
if (!this._loginManager || !this._loginManager.sessionActive)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
|
const GLib = imports.gi.GLib;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
|
||||||
const LoginManager = imports.misc.loginManager;
|
const LoginManager = imports.misc.loginManager;
|
||||||
@ -82,12 +83,16 @@ const HotplugSnifferIface = <interface name="org.gnome.Shell.HotplugSniffer">
|
|||||||
</method>
|
</method>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const HotplugSnifferProxy = Gio.DBusProxy.makeProxyWrapper(HotplugSnifferIface);
|
const HotplugSniffer = new Gio.DBusProxyClass({
|
||||||
function HotplugSniffer() {
|
Name: 'HotplugSnifferProxy',
|
||||||
return new HotplugSnifferProxy(Gio.DBus.session,
|
Interface: HotplugSnifferIface,
|
||||||
'org.gnome.Shell.HotplugSniffer',
|
|
||||||
'/org/gnome/Shell/HotplugSniffer');
|
_init: function() {
|
||||||
}
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: 'org.gnome.Shell.HotplugSniffer',
|
||||||
|
g_object_path: '/org/gnome/Shell/HotplugSniffer' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const ContentTypeDiscoverer = new Lang.Class({
|
const ContentTypeDiscoverer = new Lang.Class({
|
||||||
Name: 'ContentTypeDiscoverer',
|
Name: 'ContentTypeDiscoverer',
|
||||||
@ -127,10 +132,14 @@ const ContentTypeDiscoverer = new Lang.Class({
|
|||||||
let root = mount.get_root();
|
let root = mount.get_root();
|
||||||
|
|
||||||
let hotplugSniffer = new HotplugSniffer();
|
let hotplugSniffer = new HotplugSniffer();
|
||||||
hotplugSniffer.SniffURIRemote(root.get_uri(),
|
hotplugSniffer.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
Lang.bind(this, function([contentTypes]) {
|
proxy.init_finish(result);
|
||||||
this._emitCallback(mount, contentTypes);
|
|
||||||
}));
|
proxy.SniffURIRemote(root.get_uri(), null, Lang.bind(this, function(proxy, result) {
|
||||||
|
let [contentTypes] = proxy.SniffURIFinish(result);
|
||||||
|
this._emitCallback(mount, contentTypes);
|
||||||
|
}));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -162,7 +171,9 @@ const AutorunManager = new Lang.Class({
|
|||||||
Name: 'AutorunManager',
|
Name: 'AutorunManager',
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._loginManager = LoginManager.getLoginManager();
|
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
|
||||||
|
this._loginManager = manager;
|
||||||
|
}));
|
||||||
|
|
||||||
this._volumeMonitor = Gio.VolumeMonitor.get();
|
this._volumeMonitor = Gio.VolumeMonitor.get();
|
||||||
|
|
||||||
@ -215,7 +226,7 @@ const AutorunManager = new Lang.Class({
|
|||||||
_onMountAdded: function(monitor, mount) {
|
_onMountAdded: function(monitor, mount) {
|
||||||
// don't do anything if our session is not the currently
|
// don't do anything if our session is not the currently
|
||||||
// active one
|
// active one
|
||||||
if (!this._loginManager.sessionActive)
|
if (!this._loginManager || !this._loginManager.sessionActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._processMount(mount, true);
|
this._processMount(mount, true);
|
||||||
|
@ -218,6 +218,34 @@ function init() {
|
|||||||
_endSessionDialog = new EndSessionDialog();
|
_endSessionDialog = new EndSessionDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const EndSessionExporter = new Gio.DBusImplementerClass({
|
||||||
|
Name: 'EndSessionExporter',
|
||||||
|
Interface: EndSessionDialogIface,
|
||||||
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent();
|
||||||
|
|
||||||
|
this.export(Gio.DBus.session, '/org/gnome/SessionManager/EndSessionDialog');
|
||||||
|
},
|
||||||
|
|
||||||
|
OpenAsync: function(parameters, invocation) {
|
||||||
|
this.emit('open', parameters, invocation);
|
||||||
|
},
|
||||||
|
|
||||||
|
close: function() {
|
||||||
|
this.emit_signal('Closed');
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel: function() {
|
||||||
|
this.emit_signal('Canceled');
|
||||||
|
},
|
||||||
|
|
||||||
|
confirm: function(type) {
|
||||||
|
this.emit_signal(type);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
Signals.addSignalMethods(EndSessionExporter.prototype);
|
||||||
|
|
||||||
const EndSessionDialog = new Lang.Class({
|
const EndSessionDialog = new Lang.Class({
|
||||||
Name: 'EndSessionDialog',
|
Name: 'EndSessionDialog',
|
||||||
Extends: ModalDialog.ModalDialog,
|
Extends: ModalDialog.ModalDialog,
|
||||||
@ -295,8 +323,8 @@ const EndSessionDialog = new Lang.Class({
|
|||||||
scrollView.hide();
|
scrollView.hide();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(EndSessionDialogIface, this);
|
this._exporter = new EndSessionExporter();
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/SessionManager/EndSessionDialog');
|
this._exporter.connect('open', Lang.bind(this, this._onOpenRequest));
|
||||||
},
|
},
|
||||||
|
|
||||||
_onDestroy: function() {
|
_onDestroy: function() {
|
||||||
@ -387,19 +415,19 @@ const EndSessionDialog = new Lang.Class({
|
|||||||
|
|
||||||
close: function() {
|
close: function() {
|
||||||
this.parent();
|
this.parent();
|
||||||
this._dbusImpl.emit_signal('Closed', null);
|
this._exporter.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
this._stopTimer();
|
this._stopTimer();
|
||||||
this._dbusImpl.emit_signal('Canceled', null);
|
this._exporter.cancel();
|
||||||
this.close(global.get_current_time());
|
this.close(global.get_current_time());
|
||||||
},
|
},
|
||||||
|
|
||||||
_confirm: function(signal) {
|
_confirm: function(signal) {
|
||||||
this._fadeOutDialog();
|
this._fadeOutDialog();
|
||||||
this._stopTimer();
|
this._stopTimer();
|
||||||
this._dbusImpl.emit_signal(signal, null);
|
this._exporter.confirm(signal);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onOpened: function() {
|
_onOpened: function() {
|
||||||
@ -452,7 +480,7 @@ const EndSessionDialog = new Lang.Class({
|
|||||||
this._updateContent();
|
this._updateContent();
|
||||||
},
|
},
|
||||||
|
|
||||||
OpenAsync: function(parameters, invocation) {
|
_onOpenRequest: function(exporter, parameters, invocation) {
|
||||||
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
|
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
|
||||||
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
|
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
|
||||||
this._inhibitors = [];
|
this._inhibitors = [];
|
||||||
@ -466,7 +494,10 @@ const EndSessionDialog = new Lang.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < inhibitorObjectPaths.length; i++) {
|
for (let i = 0; i < inhibitorObjectPaths.length; i++) {
|
||||||
let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i], Lang.bind(this, function(proxy, error) {
|
let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i]);
|
||||||
|
inhibitor.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
this._onInhibitorLoaded(proxy);
|
this._onInhibitorLoaded(proxy);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const Caribou = imports.gi.Caribou;
|
const Caribou = imports.gi.Caribou;
|
||||||
const Clutter = imports.gi.Clutter;
|
const Clutter = imports.gi.Clutter;
|
||||||
const DBus = imports.dbus;
|
|
||||||
const Gdk = imports.gi.Gdk;
|
const Gdk = imports.gi.Gdk;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
@ -191,13 +190,14 @@ const Key = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Keyboard = new Lang.Class({
|
const Keyboard = new Gio.DBusImplementerClass({
|
||||||
// HACK: we can't set Name, because it collides with Name dbus property
|
// HACK: we can't set Name, because it collides with Name dbus property
|
||||||
// Name: 'Keyboard',
|
// Name: 'Keyboard',
|
||||||
|
Interface: CaribouKeyboardIface,
|
||||||
|
|
||||||
_init: function () {
|
_init: function () {
|
||||||
this._impl = Gio.DBusExportedObject.wrapJSObject(CaribouKeyboardIface, this);
|
this.parent();
|
||||||
this._impl.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
|
this.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
|
||||||
|
|
||||||
this.actor = null;
|
this.actor = null;
|
||||||
this._focusInTray = false;
|
this._focusInTray = false;
|
||||||
|
@ -96,14 +96,15 @@ const ZoomRegionIface = <interface name={ZOOM_SERVICE_NAME}>
|
|||||||
// '/org/gnome/Magnifier/ZoomRegion/zoomer1', etc.
|
// '/org/gnome/Magnifier/ZoomRegion/zoomer1', etc.
|
||||||
let _zoomRegionInstanceCount = 0;
|
let _zoomRegionInstanceCount = 0;
|
||||||
|
|
||||||
const ShellMagnifier = new Lang.Class({
|
const ShellMagnifier = new Gio.DBusImplementerClass({
|
||||||
Name: 'ShellMagnifier',
|
Name: 'ShellMagnifier',
|
||||||
|
Interface: MagnifierIface,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._zoomers = {};
|
this.parent();
|
||||||
|
this.export(Gio.DBus.session, MAG_SERVICE_PATH);
|
||||||
|
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(MagnifierIface, this);
|
this._zoomers = {};
|
||||||
this._dbusImpl.export(Gio.DBus.session, MAG_SERVICE_PATH);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,14 +333,15 @@ const ShellMagnifier = new Lang.Class({
|
|||||||
* @zoomerObjectPath: String that is the path to a DBus ZoomRegion.
|
* @zoomerObjectPath: String that is the path to a DBus ZoomRegion.
|
||||||
* @zoomRegion: The actual zoom region associated with the object path.
|
* @zoomRegion: The actual zoom region associated with the object path.
|
||||||
*/
|
*/
|
||||||
const ShellMagnifierZoomRegion = new Lang.Class({
|
const ShellMagnifierZoomRegion = new Gio.DBusImplementerClass({
|
||||||
Name: 'ShellMagnifierZoomRegion',
|
Name: 'ShellMagnifierZoomRegion',
|
||||||
|
Interface: ZoomRegionIface,
|
||||||
|
|
||||||
_init: function(zoomerObjectPath, zoomRegion) {
|
_init: function(zoomerObjectPath, zoomRegion) {
|
||||||
this._zoomRegion = zoomRegion;
|
this.parent();
|
||||||
|
this.export(Gio.DBus.session, zoomerObjectPath);
|
||||||
|
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ZoomRegionIface, this);
|
this._zoomRegion = zoomRegion;
|
||||||
this._dbusImpl.export(Gio.DBus.session, zoomerObjectPath);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -417,6 +419,6 @@ const ShellMagnifierZoomRegion = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
this._dbusImpl.unexport();
|
this.unexport();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1365,13 +1365,16 @@ const MessageTray = new Lang.Class({
|
|||||||
Name: 'MessageTray',
|
Name: 'MessageTray',
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) {
|
this._presence = new GnomeSession.Presence();
|
||||||
|
this._presence.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
this._onStatusChanged(proxy.status);
|
this._onStatusChanged(proxy.status);
|
||||||
|
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
|
||||||
|
this._onStatusChanged(status);
|
||||||
|
}));
|
||||||
}));
|
}));
|
||||||
this._busy = false;
|
this._busy = false;
|
||||||
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
|
|
||||||
this._onStatusChanged(status);
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.actor = new St.Widget({ name: 'message-tray',
|
this.actor = new St.Widget({ name: 'message-tray',
|
||||||
reactive: true,
|
reactive: true,
|
||||||
|
@ -25,10 +25,19 @@ const BusIface = <interface name="org.freedesktop.DBus">
|
|||||||
</method>
|
</method>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
var BusProxy = Gio.DBusProxy.makeProxyWrapper(BusIface);
|
const Bus = new Gio.DBusProxyClass({
|
||||||
function Bus() {
|
Name: 'SessionBusProxy',
|
||||||
return new BusProxy(Gio.DBus.session, 'org.freedesktop.DBus', '/org/freedesktop/DBus');
|
Interface: BusIface,
|
||||||
}
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: 'org.freedesktop.DBus',
|
||||||
|
g_object_path: '/org/freedesktop/DBus',
|
||||||
|
g_flags: (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES |
|
||||||
|
Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS |
|
||||||
|
Gio.DBusProxyFlags.DO_NOT_AUTO_START) });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const NotificationDaemonIface = <interface name="org.freedesktop.Notifications">
|
const NotificationDaemonIface = <interface name="org.freedesktop.Notifications">
|
||||||
<method name="Notify">
|
<method name="Notify">
|
||||||
@ -103,17 +112,20 @@ const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
|
|||||||
'ibus-ui-gtk': 'keyboard'
|
'ibus-ui-gtk': 'keyboard'
|
||||||
};
|
};
|
||||||
|
|
||||||
const NotificationDaemon = new Lang.Class({
|
const NotificationDaemon = new Gio.DBusImplementerClass({
|
||||||
Name: 'NotificationDaemon',
|
Name: 'NotificationDaemon',
|
||||||
|
Interface: NotificationDaemonIface,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(NotificationDaemonIface, this);
|
this.parent();
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/Notifications');
|
this.export(Gio.DBus.session, '/org/freedesktop/Notifications');
|
||||||
|
|
||||||
this._sources = [];
|
this._sources = [];
|
||||||
this._senderToPid = {};
|
this._senderToPid = {};
|
||||||
this._notifications = {};
|
this._notifications = {};
|
||||||
this._busProxy = new Bus();
|
this._busProxy = new Bus();
|
||||||
|
// This is synchronous but fast because of the flags we use.
|
||||||
|
this._busProxy.init(null);
|
||||||
|
|
||||||
this._trayManager = new Shell.TrayManager();
|
this._trayManager = new Shell.TrayManager();
|
||||||
this._trayIconAddedId = this._trayManager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded));
|
this._trayIconAddedId = this._trayManager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded));
|
||||||
@ -316,18 +328,20 @@ const NotificationDaemon = new Lang.Class({
|
|||||||
return invocation.return_value(GLib.Variant.new('(u)', [id]));;
|
return invocation.return_value(GLib.Variant.new('(u)', [id]));;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._busProxy.GetConnectionUnixProcessIDRemote(sender, Lang.bind(this, function (result, excp) {
|
this._busProxy.GetConnectionUnixProcessIDRemote(sender, null, Lang.bind(this, function (proxy, result) {
|
||||||
// The app may have updated or removed the notification
|
// The app may have updated or removed the notification
|
||||||
ndata = this._notifications[id];
|
ndata = this._notifications[id];
|
||||||
if (!ndata)
|
if (!ndata)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (excp) {
|
let pid;
|
||||||
|
try {
|
||||||
|
[pid] = proxy.GetConnectionUnixProcessIDFinish(result);
|
||||||
|
} catch(excp) {
|
||||||
logError(excp, 'Call to GetConnectionUnixProcessID failed');
|
logError(excp, 'Call to GetConnectionUnixProcessID failed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let [pid] = result;
|
|
||||||
source = this._getSource(appName, pid, ndata, sender, null);
|
source = this._getSource(appName, pid, ndata, sender, null);
|
||||||
|
|
||||||
// We only store sender-pid entries for persistent sources.
|
// We only store sender-pid entries for persistent sources.
|
||||||
@ -487,13 +501,11 @@ const NotificationDaemon = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_emitNotificationClosed: function(id, reason) {
|
_emitNotificationClosed: function(id, reason) {
|
||||||
this._dbusImpl.emit_signal('NotificationClosed',
|
this.emit_signal('NotificationClosed', id, reason);
|
||||||
GLib.Variant.new('(uu)', [id, reason]));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_emitActionInvoked: function(id, action) {
|
_emitActionInvoked: function(id, action) {
|
||||||
this._dbusImpl.emit_signal('ActionInvoked',
|
this.emit_signal('ActionInvoked', id, action);
|
||||||
GLib.Variant.new('(us)', [id, action]));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_onTrayIconAdded: function(o, icon) {
|
_onTrayIconAdded: function(o, icon) {
|
||||||
|
@ -29,8 +29,15 @@ const SearchProviderIface = <interface name="org.gnome.Shell.SearchProvider">
|
|||||||
</method>
|
</method>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
var SearchProviderProxy = Gio.DBusProxy.makeProxyWrapper(SearchProviderIface);
|
var SearchProviderProxy = new Gio.DBusProxyClass({
|
||||||
|
Name: 'SearchProviderProxy',
|
||||||
|
Interface: SearchProviderIface,
|
||||||
|
|
||||||
|
_init: function(params) {
|
||||||
|
params.g_bus_type = Gio.BusType.SESSION;
|
||||||
|
this.parent(params);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function loadRemoteSearchProviders(addProviderCallback) {
|
function loadRemoteSearchProviders(addProviderCallback) {
|
||||||
let dataDirs = GLib.get_system_data_dirs();
|
let dataDirs = GLib.get_system_data_dirs();
|
||||||
@ -90,13 +97,22 @@ function loadRemoteSearchProvidersFromDir(dir, loadedProviders, addProviderCallb
|
|||||||
icon,
|
icon,
|
||||||
busName,
|
busName,
|
||||||
objectPath);
|
objectPath);
|
||||||
|
remoteProvider.initAsync(null, function(obj, result) {
|
||||||
|
try {
|
||||||
|
remoteProvider.initFinish(result);
|
||||||
|
} catch(e) {
|
||||||
|
log('Failed to add search provider "%s": %s'.format(title, e.toString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addProviderCallback(remoteProvider);
|
||||||
|
});
|
||||||
|
|
||||||
loadedProviders[objectPath] = remoteProvider;
|
loadedProviders[objectPath] = remoteProvider;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
log('Failed to add search provider "%s": %s'.format(title, e.toString()));
|
log('Failed to add search provider "%s": %s'.format(title, e.toString()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
addProviderCallback(remoteProvider);
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -107,13 +123,41 @@ const RemoteSearchProvider = new Lang.Class({
|
|||||||
Extends: Search.SearchProvider,
|
Extends: Search.SearchProvider,
|
||||||
|
|
||||||
_init: function(title, icon, dbusName, dbusPath) {
|
_init: function(title, icon, dbusName, dbusPath) {
|
||||||
this._proxy = new SearchProviderProxy(Gio.DBus.session,
|
|
||||||
dbusName, dbusPath);
|
|
||||||
|
|
||||||
this.parent(title.toUpperCase());
|
this.parent(title.toUpperCase());
|
||||||
|
|
||||||
|
this._proxy = new SearchProviderProxy({ g_name: dbusName,
|
||||||
|
g_object_path: dbusPath });
|
||||||
this._cancellable = new Gio.Cancellable();
|
this._cancellable = new Gio.Cancellable();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initAsync: function(cancellable, asyncCallback) {
|
||||||
|
// Can't pass "this" as source object, because RemoteSearchProvider
|
||||||
|
// is not a GObject.Object (and in gjs you can't inherit from a JS
|
||||||
|
// type that in turn inherits from GObject)
|
||||||
|
|
||||||
|
let simpleResult = Gio.SimpleAsyncResult.new(null, asyncCallback, null);
|
||||||
|
simpleResult.set_check_cancellable(cancellable);
|
||||||
|
|
||||||
|
this._proxy.init_async(GLib.PRIORITY_DEFAULT, cancellable, Lang.bind(this, function(proxy, result) {
|
||||||
|
try {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
simpleResult.set_op_res_gboolean(true);
|
||||||
|
} catch(e if e instanceof GLib.Error) {
|
||||||
|
simpleResult.set_from_error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
simpleResult.complete();
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
initFinish: function(simpleResult) {
|
||||||
|
if (!simpleResult.propagate_error())
|
||||||
|
return simpleResult.get_op_res_gboolean();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
createIcon: function(size, meta) {
|
createIcon: function(size, meta) {
|
||||||
if (meta['gicon']) {
|
if (meta['gicon']) {
|
||||||
return new St.Icon({ gicon: Gio.icon_new_for_string(meta['gicon']),
|
return new St.Icon({ gicon: Gio.icon_new_for_string(meta['gicon']),
|
||||||
@ -131,10 +175,17 @@ const RemoteSearchProvider = new Lang.Class({
|
|||||||
icon_size: size });
|
icon_size: size });
|
||||||
},
|
},
|
||||||
|
|
||||||
_getResultsFinished: function(results, error) {
|
_getResultsFinished: function(proxy, result) {
|
||||||
if (error)
|
try {
|
||||||
return;
|
// We rely on a small implementation detail of the
|
||||||
this.searchSystem.pushResults(this, results[0]);
|
// GDBus bindings here: all *Finish are equal
|
||||||
|
|
||||||
|
let [results] = proxy.GetInitialResultSetFinish(result);
|
||||||
|
this.searchSystem.pushResults(this, results);
|
||||||
|
} catch(e) {
|
||||||
|
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
|
||||||
|
log('Received error from search provider %s: %s'.format(this.title, String(e)));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialResultSet: function(terms) {
|
getInitialResultSet: function(terms) {
|
||||||
@ -142,8 +193,8 @@ const RemoteSearchProvider = new Lang.Class({
|
|||||||
this._cancellable.reset();
|
this._cancellable.reset();
|
||||||
try {
|
try {
|
||||||
this._proxy.GetInitialResultSetRemote(terms,
|
this._proxy.GetInitialResultSetRemote(terms,
|
||||||
Lang.bind(this, this._getResultsFinished),
|
this._cancellable,
|
||||||
this._cancellable);
|
Lang.bind(this, this._getResultsFinished));
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
log('Error calling GetInitialResultSet for provider %s: %s'.format( this.title, e.toString()));
|
log('Error calling GetInitialResultSet for provider %s: %s'.format( this.title, e.toString()));
|
||||||
this.searchSystem.pushResults(this, []);
|
this.searchSystem.pushResults(this, []);
|
||||||
@ -155,30 +206,30 @@ const RemoteSearchProvider = new Lang.Class({
|
|||||||
this._cancellable.reset();
|
this._cancellable.reset();
|
||||||
try {
|
try {
|
||||||
this._proxy.GetSubsearchResultSetRemote(previousResults, newTerms,
|
this._proxy.GetSubsearchResultSetRemote(previousResults, newTerms,
|
||||||
Lang.bind(this, this._getResultsFinished),
|
this._cancellable,
|
||||||
this._cancellable);
|
Lang.bind(this, this._getResultsFinished))
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
log('Error calling GetSubsearchResultSet for provider %s: %s'.format(this.title, e.toString()));
|
log('Error calling GetSubsearchResultSet for provider %s: %s'.format(this.title, e.toString()));
|
||||||
this.searchSystem.pushResults(this, []);
|
this.searchSystem.pushResults(this, []);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_getResultMetasFinished: function(results, error, callback) {
|
_getResultMetasFinished: function(proxy, result, callback) {
|
||||||
if (error) {
|
try {
|
||||||
|
let [metas] = results.GetResultMetasFinish(result);
|
||||||
|
let resultMetas = [];
|
||||||
|
for (let i = 0; i < metas.length; i++) {
|
||||||
|
for (let prop in metas[i])
|
||||||
|
metas[i][prop] = metas[i][prop].deep_unpack();
|
||||||
|
resultMetas.push({ id: metas[i]['id'],
|
||||||
|
name: metas[i]['name'],
|
||||||
|
createIcon: Lang.bind(this,
|
||||||
|
this.createIcon, metas[i]) });
|
||||||
|
}
|
||||||
|
callback(resultMetas);
|
||||||
|
} catch(e) {
|
||||||
callback([]);
|
callback([]);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let metas = results[0];
|
|
||||||
let resultMetas = [];
|
|
||||||
for (let i = 0; i < metas.length; i++) {
|
|
||||||
for (let prop in metas[i])
|
|
||||||
metas[i][prop] = metas[i][prop].deep_unpack();
|
|
||||||
resultMetas.push({ id: metas[i]['id'],
|
|
||||||
name: metas[i]['name'],
|
|
||||||
createIcon: Lang.bind(this,
|
|
||||||
this.createIcon, metas[i]) });
|
|
||||||
}
|
|
||||||
callback(resultMetas);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getResultMetas: function(ids, callback) {
|
getResultMetas: function(ids, callback) {
|
||||||
@ -186,8 +237,8 @@ const RemoteSearchProvider = new Lang.Class({
|
|||||||
this._cancellable.reset();
|
this._cancellable.reset();
|
||||||
try {
|
try {
|
||||||
this._proxy.GetResultMetasRemote(ids,
|
this._proxy.GetResultMetasRemote(ids,
|
||||||
Lang.bind(this, this._getResultMetasFinished, callback),
|
this._cancellable,
|
||||||
this._cancellable);
|
Lang.bind(this, this._getResultMetasFinished, callback));
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
log('Error calling GetResultMetas for provider %s: %s'.format(this.title, e.toString()));
|
log('Error calling GetResultMetas for provider %s: %s'.format(this.title, e.toString()));
|
||||||
callback([]);
|
callback([]);
|
||||||
@ -195,7 +246,7 @@ const RemoteSearchProvider = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(id) {
|
activateResult: function(id) {
|
||||||
this._proxy.ActivateResultRemote(id);
|
this._proxy.ActivateResultRemote(id, null, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -418,10 +418,11 @@ const ScreenShield = new Lang.Class({
|
|||||||
|
|
||||||
this._screenSaverDBus = new ShellDBus.ScreenSaverDBus(this);
|
this._screenSaverDBus = new ShellDBus.ScreenSaverDBus(this);
|
||||||
|
|
||||||
this._loginManager = LoginManager.getLoginManager();
|
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
|
||||||
this._loginSession = this._loginManager.getCurrentSessionProxy();
|
this._loginSession = manager.getCurrentSessionProxy();
|
||||||
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.unlock(); }));
|
this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.unlock(); }));
|
||||||
|
}));
|
||||||
|
|
||||||
this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });
|
this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });
|
||||||
|
|
||||||
@ -875,6 +876,7 @@ const ScreenShieldFallback = new Lang.Class({
|
|||||||
g_flags: (Gio.DBusProxyFlags.DO_NOT_AUTO_START |
|
g_flags: (Gio.DBusProxyFlags.DO_NOT_AUTO_START |
|
||||||
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES),
|
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES),
|
||||||
});
|
});
|
||||||
|
// This is synchronous but it is the fallback case.
|
||||||
this._proxy.init(null);
|
this._proxy.init(null);
|
||||||
|
|
||||||
this._proxy.connect('g-signal', Lang.bind(this, this._onSignal));
|
this._proxy.connect('g-signal', Lang.bind(this, this._onSignal));
|
||||||
|
@ -80,15 +80,23 @@ const PerfHelperIface = <interface name="org.gnome.Shell.PerfHelper">
|
|||||||
<method name="DestroyWindows" />
|
<method name="DestroyWindows" />
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
var PerfHelperProxy = Gio.DBusProxy.makeProxyWrapper(PerfHelperIface);
|
const PerfHelper = new Gio.DBusProxyClass({
|
||||||
function PerfHelper() {
|
Name: 'PerfHelperProxy',
|
||||||
return new PerfHelperProxy(Gio.DBus.session, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
|
Interface: PerfHelperIface,
|
||||||
}
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: 'org.gnome.Shell.PerfHelper',
|
||||||
|
g_object_path: '/org/gnome/Shell/PerfHelper' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let _perfHelper = null;
|
let _perfHelper = null;
|
||||||
function _getPerfHelper() {
|
function _getPerfHelper() {
|
||||||
if (_perfHelper == null)
|
if (_perfHelper == null) {
|
||||||
_perfHelper = new PerfHelper();
|
_perfHelper = new PerfHelper();
|
||||||
|
_perfHelper.init(null);
|
||||||
|
}
|
||||||
|
|
||||||
return _perfHelper;
|
return _perfHelper;
|
||||||
}
|
}
|
||||||
@ -111,7 +119,8 @@ function createTestWindow(width, height, alpha, maximized) {
|
|||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = _getPerfHelper();
|
||||||
|
|
||||||
perfHelper.CreateWindowRemote(width, height, alpha, maximized,
|
perfHelper.CreateWindowRemote(width, height, alpha, maximized,
|
||||||
function(result, excp) {
|
null,
|
||||||
|
function(proxy, result) {
|
||||||
if (cb)
|
if (cb)
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
@ -131,7 +140,7 @@ function waitTestWindows() {
|
|||||||
let cb;
|
let cb;
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = _getPerfHelper();
|
||||||
|
|
||||||
perfHelper.WaitWindowsRemote(function(result, excp) {
|
perfHelper.WaitWindowsRemote(null, function(proxy, result) {
|
||||||
if (cb)
|
if (cb)
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
@ -154,7 +163,7 @@ function destroyTestWindows() {
|
|||||||
let cb;
|
let cb;
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = _getPerfHelper();
|
||||||
|
|
||||||
perfHelper.DestroyWindowsRemote(function(result, excp) {
|
perfHelper.DestroyWindowsRemote(null, function(proxy, result) {
|
||||||
if (cb)
|
if (cb)
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
|
const GObject = imports.gi.GObject;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
@ -75,6 +76,8 @@ const SearchProvider = new Lang.Class({
|
|||||||
Name: 'SearchProvider',
|
Name: 'SearchProvider',
|
||||||
|
|
||||||
_init: function(title) {
|
_init: function(title) {
|
||||||
|
this.parent();
|
||||||
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.searchSystem = null;
|
this.searchSystem = null;
|
||||||
},
|
},
|
||||||
|
@ -67,14 +67,16 @@ const ScreenSaverIface = <interface name="org.gnome.ScreenSaver">
|
|||||||
</signal>
|
</signal>
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const GnomeShell = new Lang.Class({
|
const GnomeShell = new Gio.DBusImplementerClass({
|
||||||
Name: 'GnomeShellDBus',
|
Name: 'GnomeShellDBus',
|
||||||
|
Interface: GnomeShellIface,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
|
this.parent();
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
|
||||||
|
|
||||||
this._extensionsSerivce = new GnomeShellExtensions();
|
this.export(Gio.DBus.session, '/org/gnome/Shell');
|
||||||
|
|
||||||
|
this._extensionsService = new GnomeShellExtensions();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,12 +238,14 @@ const GnomeShellExtensionsIface = <interface name="org.gnome.Shell.Extensions">
|
|||||||
<property name="ShellVersion" type="s" access="read" />
|
<property name="ShellVersion" type="s" access="read" />
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const GnomeShellExtensions = new Lang.Class({
|
const GnomeShellExtensions = new Gio.DBusImplementerClass({
|
||||||
Name: 'GnomeShellExtensionsDBus',
|
Name: 'GnomeShellExtensionsDBus',
|
||||||
|
Interface: GnomeShellExtensionsIface,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
|
this.parent();
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
|
||||||
|
this.export(Gio.DBus.session, '/org/gnome/Shell');
|
||||||
ExtensionSystem.connect('extension-state-changed',
|
ExtensionSystem.connect('extension-state-changed',
|
||||||
Lang.bind(this, this._extensionStateChanged));
|
Lang.bind(this, this._extensionStateChanged));
|
||||||
},
|
},
|
||||||
@ -335,25 +339,23 @@ const GnomeShellExtensions = new Lang.Class({
|
|||||||
ShellVersion: Config.PACKAGE_VERSION,
|
ShellVersion: Config.PACKAGE_VERSION,
|
||||||
|
|
||||||
_extensionStateChanged: function(_, newState) {
|
_extensionStateChanged: function(_, newState) {
|
||||||
this._dbusImpl.emit_signal('ExtensionStatusChanged',
|
this.emit_signal('ExtensionStatusChanged', newState.uuid, newState.state, newState.error);
|
||||||
GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const ScreenSaverDBus = new Lang.Class({
|
const ScreenSaverDBus = new Gio.DBusImplementerClass({
|
||||||
Name: 'ScreenSaverDBus',
|
Name: 'ScreenSaverDBus',
|
||||||
|
Interface: ScreenSaverIface,
|
||||||
|
|
||||||
_init: function(screenShield) {
|
_init: function(screenShield) {
|
||||||
this.parent();
|
this.parent();
|
||||||
|
|
||||||
this._screenShield = screenShield;
|
this._screenShield = screenShield;
|
||||||
screenShield.connect('lock-status-changed', Lang.bind(this, function(shield) {
|
screenShield.connect('lock-status-changed', Lang.bind(this, function(shield) {
|
||||||
this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.locked]));
|
this.emit_signal('ActiveChanged', shield.locked);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
|
this.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
|
|
||||||
|
|
||||||
Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -554,14 +554,16 @@ const ShellMountOperationType = {
|
|||||||
SHOW_PROCESSES: 3
|
SHOW_PROCESSES: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
const GnomeShellMountOpHandler = new Lang.Class({
|
const GnomeShellMountOpHandler = new Gio.DBusImplementerClass({
|
||||||
Name: 'GnomeShellMountOpHandler',
|
Name: 'GnomeShellMountOpHandler',
|
||||||
|
Interface: GnomeShellMountOpIface,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellMountOpIface, this);
|
this.parent();
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
|
|
||||||
Gio.bus_own_name_on_connection(Gio.DBus.session, 'org.gtk.MountOperationHandler',
|
this.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
|
||||||
Gio.BusNameOwnerFlags.REPLACE, null, null);
|
Gio.DBus.session.own_name('org.gtk.MountOperationHandler',
|
||||||
|
Gio.BusNameOwnerFlags.REPLACE, null, null);
|
||||||
|
|
||||||
this._dialog = null;
|
this._dialog = null;
|
||||||
this._volumeMonitor = Gio.VolumeMonitor.get();
|
this._volumeMonitor = Gio.VolumeMonitor.get();
|
||||||
|
@ -1629,7 +1629,44 @@ const NMApplet = new Lang.Class({
|
|||||||
this.secondaryIcon = this.addIcon(new Gio.ThemedIcon({ name: 'network-vpn-symbolic' }));
|
this.secondaryIcon = this.addIcon(new Gio.ThemedIcon({ name: 'network-vpn-symbolic' }));
|
||||||
this.secondaryIcon.hide();
|
this.secondaryIcon.hide();
|
||||||
|
|
||||||
this._client = NMClient.Client.new();
|
// Device types
|
||||||
|
this._dtypes = { };
|
||||||
|
this._dtypes[NetworkManager.DeviceType.ETHERNET] = NMDeviceWired;
|
||||||
|
this._dtypes[NetworkManager.DeviceType.WIFI] = NMDeviceWireless;
|
||||||
|
this._dtypes[NetworkManager.DeviceType.MODEM] = NMDeviceModem;
|
||||||
|
this._dtypes[NetworkManager.DeviceType.BT] = NMDeviceBluetooth;
|
||||||
|
// TODO: WiMax support
|
||||||
|
|
||||||
|
// Connection types
|
||||||
|
this._ctypes = { };
|
||||||
|
this._ctypes[NetworkManager.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS;
|
||||||
|
this._ctypes[NetworkManager.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED;
|
||||||
|
this._ctypes[NetworkManager.SETTING_PPPOE_SETTING_NAME] = NMConnectionCategory.WIRED;
|
||||||
|
this._ctypes[NetworkManager.SETTING_PPP_SETTING_NAME] = NMConnectionCategory.WIRED;
|
||||||
|
this._ctypes[NetworkManager.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN;
|
||||||
|
this._ctypes[NetworkManager.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN;
|
||||||
|
this._ctypes[NetworkManager.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN;
|
||||||
|
this._ctypes[NetworkManager.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN;
|
||||||
|
|
||||||
|
NMClient.Client.new_async(null, Lang.bind(this, this._clientGot));
|
||||||
|
NMClient.RemoteSettings.new_async(null, null, Lang.bind(this, this._remoteSettingsGot));
|
||||||
|
},
|
||||||
|
|
||||||
|
_clientGot: function(obj, result) {
|
||||||
|
this._client = NMClient.Client.new_finish(result);
|
||||||
|
|
||||||
|
this._tryLateInit();
|
||||||
|
},
|
||||||
|
|
||||||
|
_remoteSettingsGot: function(obj, result) {
|
||||||
|
this._settings = NMClient.RemoteSettings.new_finish(result);
|
||||||
|
|
||||||
|
this._tryLateInit();
|
||||||
|
},
|
||||||
|
|
||||||
|
_tryLateInit: function() {
|
||||||
|
if (!this._client || !this._settings)
|
||||||
|
return;
|
||||||
|
|
||||||
this._statusSection = new PopupMenu.PopupMenuSection();
|
this._statusSection = new PopupMenu.PopupMenuSection();
|
||||||
this._statusItem = new PopupMenu.PopupMenuItem('', { reactive: false });
|
this._statusItem = new PopupMenu.PopupMenuItem('', { reactive: false });
|
||||||
@ -1690,44 +1727,17 @@ const NMApplet = new Lang.Class({
|
|||||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||||
this.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
|
this.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
|
||||||
|
|
||||||
// Device types
|
this._readConnections();
|
||||||
this._dtypes = { };
|
this._readDevices();
|
||||||
this._dtypes[NetworkManager.DeviceType.ETHERNET] = NMDeviceWired;
|
this._syncNMState();
|
||||||
this._dtypes[NetworkManager.DeviceType.WIFI] = NMDeviceWireless;
|
|
||||||
this._dtypes[NetworkManager.DeviceType.MODEM] = NMDeviceModem;
|
|
||||||
this._dtypes[NetworkManager.DeviceType.BT] = NMDeviceBluetooth;
|
|
||||||
// TODO: WiMax support
|
|
||||||
|
|
||||||
// Connection types
|
this._client.connect('notify::manager-running', Lang.bind(this, this._syncNMState));
|
||||||
this._ctypes = { };
|
this._client.connect('notify::networking-enabled', Lang.bind(this, this._syncNMState));
|
||||||
this._ctypes[NetworkManager.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS;
|
this._client.connect('notify::state', Lang.bind(this, this._syncNMState));
|
||||||
this._ctypes[NetworkManager.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED;
|
this._client.connect('notify::active-connections', Lang.bind(this, this._updateIcon));
|
||||||
this._ctypes[NetworkManager.SETTING_PPPOE_SETTING_NAME] = NMConnectionCategory.WIRED;
|
this._client.connect('device-added', Lang.bind(this, this._deviceAdded));
|
||||||
this._ctypes[NetworkManager.SETTING_PPP_SETTING_NAME] = NMConnectionCategory.WIRED;
|
this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved));
|
||||||
this._ctypes[NetworkManager.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN;
|
this._settings.connect('new-connection', Lang.bind(this, this._newConnection));
|
||||||
this._ctypes[NetworkManager.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN;
|
|
||||||
this._ctypes[NetworkManager.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN;
|
|
||||||
this._ctypes[NetworkManager.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN;
|
|
||||||
|
|
||||||
this._settings = NMClient.RemoteSettings.new(null);
|
|
||||||
this._connectionsReadId = this._settings.connect('connections-read', Lang.bind(this, function() {
|
|
||||||
this._readConnections();
|
|
||||||
this._readDevices();
|
|
||||||
this._syncNMState();
|
|
||||||
|
|
||||||
// Connect to signals late so that early signals don't find in inconsistent state
|
|
||||||
// and connect only once (this signal handler can be called again if NetworkManager goes up and down)
|
|
||||||
if (!this._inited) {
|
|
||||||
this._inited = true;
|
|
||||||
this._client.connect('notify::manager-running', Lang.bind(this, this._syncNMState));
|
|
||||||
this._client.connect('notify::networking-enabled', Lang.bind(this, this._syncNMState));
|
|
||||||
this._client.connect('notify::state', Lang.bind(this, this._syncNMState));
|
|
||||||
this._client.connect('notify::active-connections', Lang.bind(this, this._updateIcon));
|
|
||||||
this._client.connect('device-added', Lang.bind(this, this._deviceAdded));
|
|
||||||
this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved));
|
|
||||||
this._settings.connect('new-connection', Lang.bind(this, this._newConnection));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_ensureSource: function() {
|
_ensureSource: function() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
|
const GLib = imports.gi.GLib;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
|
||||||
@ -45,7 +46,16 @@ const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power">
|
|||||||
<property name="Icon" type="s" access="read" />
|
<property name="Icon" type="s" access="read" />
|
||||||
</interface>;
|
</interface>;
|
||||||
|
|
||||||
const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface);
|
const PowerManagerProxy = new Gio.DBusProxyClass({
|
||||||
|
Name: 'PowerManagerProxy',
|
||||||
|
Interface: PowerManagerInterface,
|
||||||
|
|
||||||
|
_init: function() {
|
||||||
|
this.parent({ g_bus_type: Gio.BusType.SESSION,
|
||||||
|
g_name: BUS_NAME,
|
||||||
|
g_object_path: OBJECT_PATH });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const Indicator = new Lang.Class({
|
const Indicator = new Lang.Class({
|
||||||
Name: 'PowerIndicator',
|
Name: 'PowerIndicator',
|
||||||
@ -54,7 +64,7 @@ const Indicator = new Lang.Class({
|
|||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent('battery-missing-symbolic', _("Battery"));
|
this.parent('battery-missing-symbolic', _("Battery"));
|
||||||
|
|
||||||
this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
|
this._proxy = new PowerManagerProxy();
|
||||||
|
|
||||||
this._deviceItems = [ ];
|
this._deviceItems = [ ];
|
||||||
this._hasPrimary = false;
|
this._hasPrimary = false;
|
||||||
@ -73,18 +83,26 @@ const Indicator = new Lang.Class({
|
|||||||
|
|
||||||
this._proxy.connect('g-properties-changed',
|
this._proxy.connect('g-properties-changed',
|
||||||
Lang.bind(this, this._devicesChanged));
|
Lang.bind(this, this._devicesChanged));
|
||||||
this._devicesChanged();
|
this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
this._devicesChanged();
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_readPrimaryDevice: function() {
|
_readPrimaryDevice: function() {
|
||||||
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) {
|
this._proxy.GetPrimaryDeviceRemote(null, Lang.bind(this, function(proxy, result) {
|
||||||
if (error) {
|
let device_id, device_type, icon, percentage, state, seconds;
|
||||||
|
try {
|
||||||
|
[[device_id, device_type, icon, percentage, state, seconds]] =
|
||||||
|
proxy.GetPrimaryDeviceFinish(result);
|
||||||
|
} catch(e) {
|
||||||
this._hasPrimary = false;
|
this._hasPrimary = false;
|
||||||
this._primaryDeviceId = null;
|
this._primaryDeviceId = null;
|
||||||
this._batteryItem.actor.hide();
|
this._batteryItem.actor.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let [[device_id, device_type, icon, percentage, state, seconds]] = result;
|
|
||||||
if (device_type == UPDeviceType.BATTERY) {
|
if (device_type == UPDeviceType.BATTERY) {
|
||||||
this._hasPrimary = true;
|
this._hasPrimary = true;
|
||||||
let time = Math.round(seconds / 60);
|
let time = Math.round(seconds / 60);
|
||||||
@ -121,16 +139,18 @@ const Indicator = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_readOtherDevices: function() {
|
_readOtherDevices: function() {
|
||||||
this._proxy.GetDevicesRemote(Lang.bind(this, function(result, error) {
|
this._proxy.GetDevicesRemote(null, Lang.bind(this, function(proxy, result) {
|
||||||
this._deviceItems.forEach(function(i) { i.destroy(); });
|
this._deviceItems.forEach(function(i) { i.destroy(); });
|
||||||
this._deviceItems = [];
|
this._deviceItems = [];
|
||||||
|
|
||||||
if (error) {
|
let devices;
|
||||||
|
try {
|
||||||
|
[devices] = proxy.GetDevicesFinish(result);
|
||||||
|
} catch(e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let position = 0;
|
let position = 0;
|
||||||
let [devices] = result;
|
|
||||||
for (let i = 0; i < devices.length; i++) {
|
for (let i = 0; i < devices.length; i++) {
|
||||||
let [device_id, device_type] = devices[i];
|
let [device_id, device_type] = devices[i];
|
||||||
if (device_type == UPDeviceType.AC_POWER || device_id == this._primaryDeviceId)
|
if (device_type == UPDeviceType.AC_POWER || device_id == this._primaryDeviceId)
|
||||||
|
@ -195,8 +195,12 @@ const IMStatusChooserItem = new Lang.Class({
|
|||||||
Lang.bind(this, this._changeIMStatus));
|
Lang.bind(this, this._changeIMStatus));
|
||||||
|
|
||||||
this._presence = new GnomeSession.Presence();
|
this._presence = new GnomeSession.Presence();
|
||||||
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
|
this._presence.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(obj, result) {
|
||||||
this._sessionStatusChanged(status);
|
obj.init_finish(result);
|
||||||
|
|
||||||
|
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
|
||||||
|
this._sessionStatusChanged(status);
|
||||||
|
}));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._sessionPresenceRestored = false;
|
this._sessionPresenceRestored = false;
|
||||||
@ -480,14 +484,33 @@ const UserMenuButton = new Lang.Class({
|
|||||||
this._userManager = AccountsService.UserManager.get_default();
|
this._userManager = AccountsService.UserManager.get_default();
|
||||||
|
|
||||||
this._user = this._userManager.get_user(GLib.get_user_name());
|
this._user = this._userManager.get_user(GLib.get_user_name());
|
||||||
|
|
||||||
this._presence = new GnomeSession.Presence();
|
this._presence = new GnomeSession.Presence();
|
||||||
this._session = new GnomeSession.SessionManager();
|
this._presence.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
this._updateSwitch(this._presence.status);
|
||||||
|
this._presence.connectSignal('StatusChanged', Lang.bind(this, function (proxy, senderName, [status]) {
|
||||||
|
this._updateSwitch(status);
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
|
||||||
|
let session = new GnomeSession.SessionManager();
|
||||||
|
session.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
|
||||||
|
// This should never fail.
|
||||||
|
proxy.init_finish(result);
|
||||||
|
|
||||||
|
this._session = proxy;
|
||||||
|
this._updateHaveShutdown();
|
||||||
|
}));
|
||||||
this._haveShutdown = true;
|
this._haveShutdown = true;
|
||||||
this._haveSuspend = true;
|
this._haveSuspend = true;
|
||||||
|
|
||||||
this._accountMgr = Tp.AccountManager.dup();
|
this._accountMgr = Tp.AccountManager.dup();
|
||||||
|
|
||||||
this._loginManager = LoginManager.getLoginManager();
|
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
|
||||||
|
this._loginManager = manager;
|
||||||
|
}));
|
||||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
|
|
||||||
this._iconBox = new St.Bin();
|
this._iconBox = new St.Bin();
|
||||||
@ -533,11 +556,6 @@ const UserMenuButton = new Lang.Class({
|
|||||||
|
|
||||||
this._createSubMenu();
|
this._createSubMenu();
|
||||||
|
|
||||||
this._updateSwitch(this._presence.status);
|
|
||||||
this._presence.connectSignal('StatusChanged', Lang.bind(this, function (proxy, senderName, [status]) {
|
|
||||||
this._updateSwitch(status);
|
|
||||||
}));
|
|
||||||
|
|
||||||
this._userManager.connect('notify::is-loaded',
|
this._userManager.connect('notify::is-loaded',
|
||||||
Lang.bind(this, this._updateMultiUser));
|
Lang.bind(this, this._updateMultiUser));
|
||||||
this._userManager.connect('notify::has-multiple-users',
|
this._userManager.connect('notify::has-multiple-users',
|
||||||
@ -637,17 +655,29 @@ const UserMenuButton = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateHaveShutdown: function() {
|
_updateHaveShutdown: function() {
|
||||||
this._session.CanShutdownRemote(Lang.bind(this,
|
if (!this._session) {
|
||||||
function(result, error) {
|
this._haveShutdown = false;
|
||||||
if (!error) {
|
return;
|
||||||
this._haveShutdown = result[0];
|
}
|
||||||
this._updateInstallUpdates();
|
|
||||||
this._updateSuspendOrPowerOff();
|
this._session.CanShutdownRemote(null, Lang.bind(this, function(proxy, result) {
|
||||||
}
|
try {
|
||||||
}));
|
[this._haveShutdown] = proxy.CanShutdownFinish(result);
|
||||||
|
} catch(e) {
|
||||||
|
this._haveShutdown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._updateInstallUpdates();
|
||||||
|
this._updateSuspendOrPowerOff();
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateHaveSuspend: function() {
|
_updateHaveSuspend: function() {
|
||||||
|
if (!this._loginManager) {
|
||||||
|
this._haveSuspend = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._loginManager.canSuspend(Lang.bind(this,
|
this._loginManager.canSuspend(Lang.bind(this,
|
||||||
function(result) {
|
function(result) {
|
||||||
this._haveSuspend = result;
|
this._haveSuspend = result;
|
||||||
@ -837,14 +867,17 @@ const UserMenuButton = new Lang.Class({
|
|||||||
|
|
||||||
_onQuitSessionActivate: function() {
|
_onQuitSessionActivate: function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
this._session.LogoutRemote(0);
|
|
||||||
|
if (this._session)
|
||||||
|
this._session.LogoutRemote(0, null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onInstallUpdatesActivate: function() {
|
_onInstallUpdatesActivate: function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
Util.spawn(['pkexec', '/usr/libexec/pk-trigger-offline-update']);
|
Util.spawn(['pkexec', '/usr/libexec/pk-trigger-offline-update']);
|
||||||
|
|
||||||
this._session.RebootRemote();
|
if (this._haveShutdown)
|
||||||
|
this._session.RebootRemote(null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onSuspendOrPowerOffActivate: function() {
|
_onSuspendOrPowerOffActivate: function() {
|
||||||
@ -852,8 +885,8 @@ const UserMenuButton = new Lang.Class({
|
|||||||
|
|
||||||
if (this._haveShutdown &&
|
if (this._haveShutdown &&
|
||||||
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
|
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
|
||||||
this._session.ShutdownRemote();
|
this._session.ShutdownRemote(null, null);
|
||||||
} else {
|
} else if (this._haveSuspend) {
|
||||||
if (this._screenSaverSettings.get_boolean(LOCK_ENABLED_KEY)) {
|
if (this._screenSaverSettings.get_boolean(LOCK_ENABLED_KEY)) {
|
||||||
let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
|
let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
|
||||||
Main.screenShield.disconnect(tmpId);
|
Main.screenShield.disconnect(tmpId);
|
||||||
|
Loading…
Reference in New Issue
Block a user