Compare commits

...

3 Commits

Author SHA1 Message Date
Giovanni Campagna
d2052a885e NetworkMenu: use async initialization for libnm-glib objects
NMClient recently got more heavyweight, with a property holding supported
connections. As fully initializing a NMObject is a recursive operation
and requires multiple DBus calls, switch to async initalization for NMClient
and NMRemoteSettings.

https://bugzilla.gnome.org/show_bug.cgi?id=683288
2012-11-02 14:11:10 +01:00
Giovanni Campagna
afcc1b7b52 Try to do more async initialization
Synchronous calls in the main loop are a performance killer, especially
at login.
2012-11-02 14:11:10 +01:00
Giovanni Campagna
a6b4d68a1d Port to GDBus 2
The GDBus bindings in gjs have been updated to leverage metaclasses
and gobject inheritance, which should result in cleaner and more
maintainable code.
2012-11-02 14:11:10 +01:00
25 changed files with 849 additions and 373 deletions

View File

@ -21,7 +21,16 @@ const GnomeShellIface = <interface name="org.gnome.Shell.Extensions">
</signal>
</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) {
if (string.slice(0, prefix.length) == prefix)
@ -191,7 +200,8 @@ const Application = new Lang.Class({
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]) {
if (ExtensionUtils.extensions[uuid] !== undefined)
this._scanExtensions();

View File

@ -11,16 +11,14 @@ const FprintManagerIface = <interface name='net.reactivated.Fprint.Manager'>
</method>
</interface>;
const FprintManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(FprintManagerIface);
const FprintManager = new Gio.DBusProxyClass({
Name: 'FprintManager',
Interface: FprintManagerIface,
function FprintManager() {
var self = new Gio.DBusProxy({ g_connection: Gio.DBus.system,
g_interface_name: FprintManagerInfo.name,
g_interface_info: FprintManagerInfo,
g_name: 'net.reactivated.Fprint',
g_object_path: '/net/reactivated/Fprint/Manager',
g_flags: (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
self.init(null);
return self;
}
_init: function() {
this.parent({ g_bus_type: Gio.BusType.SYSTEM,
g_name: 'net.reactivated.Fprint',
g_object_path: '/net/reactivated/Fprint/Manager',
g_flags: (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
}
});

View File

@ -35,7 +35,13 @@ const PowerMenuButton = new Lang.Class({
/* Translators: accessible name of the power menu in the login screen */
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.connect('changed::disable-restart-buttons',
@ -64,6 +70,12 @@ const PowerMenuButton = new Lang.Class({
},
_updateHaveShutdown: function() {
if (!this._loginManager) {
this._haveShutdown = false;
this._powerOffItem.actor.visible = false;
return;
}
this._loginManager.canPowerOff(Lang.bind(this, function(result) {
this._haveShutdown = result;
this._powerOffItem.actor.visible = this._haveShutdown;
@ -72,6 +84,12 @@ const PowerMenuButton = new Lang.Class({
},
_updateHaveRestart: function() {
if (!this._loginManager) {
this._haveRestart = false;
this._restartItem.actor.visible = false;
return;
}
this._loginManager.canReboot(Lang.bind(this, function(result) {
this._haveRestart = result;
this._restartItem.actor.visible = this._haveRestart;
@ -80,6 +98,12 @@ const PowerMenuButton = new Lang.Class({
},
_updateHaveSuspend: function() {
if (!this._loginManager) {
this._haveSuspend = false;
this._suspendItem.actor.visible = false;
return;
}
this._loginManager.canSuspend(Lang.bind(this, function(result) {
this._haveSuspend = result;
this._suspendItem.actor.visible = this._haveSuspend;

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
@ -16,7 +17,16 @@ const ProviderIface = <interface name='org.freedesktop.realmd.Provider'>
<arg name="realm" type="ao" direction="out"/>
</method>
</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">
<method name="Cancel">
@ -31,7 +41,16 @@ const ServiceIface = <interface name="org.freedesktop.realmd.Service">
<arg name="operation" type="s"/>
</signal>
</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">
<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"/>
</method>
</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({
Name: 'Manager',
_init: function(parentActor) {
this._aggregateProvider = Provider(Gio.DBus.system,
'org.freedesktop.realmd',
'/org/freedesktop/realmd',
Lang.bind(this, this._reloadRealms))
this._aggregateProvider = new Provider();
this._realms = {};
this._aggregateProvider.connect('g-properties-changed',
@ -68,6 +93,16 @@ const Manager = new Lang.Class({
if ('Realms' in properties.deep_unpack())
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() {
@ -77,10 +112,8 @@ const Manager = new Lang.Class({
return;
for (let i = 0; i < realmPaths.length; i++) {
let realm = Realm(Gio.DBus.system,
'org.freedesktop.realmd',
realmPaths[i],
Lang.bind(this, this._onRealmLoaded));
let realm = new Realm(realmPaths[i]);
realm.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, this._onRealmLoaded));
}
},
@ -97,9 +130,10 @@ const Manager = new Lang.Class({
this._updateLoginFormat();
},
_onRealmLoaded: function(realm, error) {
if (error)
return;
_onRealmLoaded: function(realm, result) {
try {
realm.init_finish(result);
} catch(e) { return; }
this._reloadRealm(realm);

View File

@ -82,6 +82,8 @@ const ShellUserVerifier = new Lang.Class({
this._settings = new Gio.Settings({ schema: LOGIN_SCREEN_SCHEMA });
this._fprintManager = new Fprint.FprintManager();
this._fprintManager.init(null);
this._realmManager = new Realmd.Manager();
this._failCounter = 0;
@ -137,11 +139,14 @@ const ShellUserVerifier = new Lang.Class({
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY))
return;
this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable, Lang.bind(this,
function(device, error) {
if (!error && device)
this._haveFingerprintReader = true;
}));
this._fprintManager.GetDefaultDeviceRemote(this._cancellable, Lang.bind(this, function(manager, result) {
try {
let device = manager.GetDefaultDeviceFinish(result);
this._haveFingerprintReader = !!device;
} catch(e) {
this._haveFingerprintReader = false;
}
}));
},
_reportInitError: function(where, error) {

View File

@ -21,11 +21,16 @@ const PresenceStatus = {
IDLE: 3
};
var PresenceProxy = Gio.DBusProxy.makeProxyWrapper(PresenceIface);
function Presence(initCallback, cancellable) {
return new PresenceProxy(Gio.DBus.session, 'org.gnome.SessionManager',
'/org/gnome/SessionManager/Presence', initCallback, cancellable);
}
const Presence = new Gio.DBusProxyClass({
Name: 'GnomeSessionPresence',
Interface: PresenceIface,
_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
// change at runtime (changes always come in the form
@ -39,10 +44,16 @@ const InhibitorIface = <interface name="org.gnome.SessionManager.Inhibitor">
</method>
</interface>;
var InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface);
function Inhibitor(objectPath, initCallback, cancellable) {
return new InhibitorProxy(Gio.DBus.session, 'org.gnome.SessionManager', objectPath, initCallback, cancellable);
}
const Inhibitor = new Gio.DBusProxyClass({
Name: 'GnomeSessionInhibitor',
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
const SessionManagerIface = <interface name="org.gnome.SessionManager">
@ -66,7 +77,14 @@ const SessionManagerIface = <interface name="org.gnome.SessionManager">
</signal>
</interface>;
var SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface);
function SessionManager(initCallback, cancellable) {
return new SessionManagerProxy(Gio.DBus.session, 'org.gnome.SessionManager', '/org/gnome/SessionManager', initCallback, cancellable);
}
const SessionManager = new Gio.DBusProxyClass({
Name: 'GnomeSessionManager',
Interface: SessionManagerIface,
_init: function() {
this.parent({ g_bus_type: Gio.BusType.SESSION,
g_name: 'org.gnome.SessionManager',
g_object_path: '/org/gnome/SessionManager' });
},
});

View File

@ -2,6 +2,7 @@
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Shell = imports.gi.Shell;
@ -33,8 +34,26 @@ const SystemdLoginSessionIface = <interface name='org.freedesktop.login1.Session
<signal name='Unlock' />
</interface>;
const SystemdLoginManager = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
const SystemdLoginManager = new Gio.DBusProxyClass({
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'>
<method name='CanRestart'>
@ -61,51 +80,128 @@ const ConsoleKitSessionIface = <interface name='org.freedesktop.ConsoleKit.Sessi
<signal name='Unlock' />
</interface>;
const ConsoleKitSession = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
const ConsoleKitManager = Gio.DBusProxy.makeProxyWrapper(ConsoleKitManagerIface);
const ConsoleKitSession = new Gio.DBusProxyClass({
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() {
return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
}
let _loginManager = null;
let _pendingAsyncCallbacks = [];
/**
* LoginManager:
* An abstraction over systemd/logind and ConsoleKit.
*
*/
function getLoginManager() {
function getLoginManager(asyncCallback) {
if (_loginManager == null) {
if (haveSystemd())
_loginManager = new LoginManagerSystemd();
else
_loginManager = new LoginManagerConsoleKit();
}
if (_pendingAsyncCallbacks.length == 0) {
let manager;
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({
Name: 'LoginManagerSystemd',
Extends: GObject.Object,
_init: function() {
this._proxy = new SystemdLoginManager(Gio.DBus.system,
'org.freedesktop.login1',
'/org/freedesktop/login1');
this.parent();
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
// session objects have different interfaces - but in both cases there are
// Lock/Unlock signals, and that's all we count upon at the moment.
//
// This is only valid after async initialization
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;
},
@ -114,66 +210,126 @@ const LoginManagerSystemd = new Lang.Class({
},
canPowerOff: function(asyncCallback) {
this._proxy.CanPowerOffRemote(function(result, error) {
if (error)
asyncCallback(false);
else
asyncCallback(result[0] != 'no');
this._proxy.CanPowerOffRemote(null, function(proxy, result) {
let val = false;
try {
val = proxy.CanPowerOffFinish(result)[0] != 'no';
} catch(e) { }
asyncCallback(val);
});
},
canReboot: function(asyncCallback) {
this._proxy.CanRebootRemote(function(result, error) {
if (error)
asyncCallback(false);
else
asyncCallback(result[0] != 'no');
this._proxy.CanRebootRemote(null, function(proxy, result) {
let val = false;
try {
val = proxy.CanRebootFinish(result)[0] != 'no';
} catch(e) { }
asyncCallback(val);
});
},
canSuspend: function(asyncCallback) {
this._proxy.CanSuspendRemote(function(result, error) {
if (error)
asyncCallback(false);
else
asyncCallback(result[0] != 'no');
this._proxy.CanSuspendRemote(null, function(proxy, result) {
let val = false;
try {
val = proxy.CanRebootFinish(result)[0] != 'no';
} catch(e) { }
asyncCallback(val);
});
},
powerOff: function() {
this._proxy.PowerOffRemote(true);
this._proxy.PowerOffRemote(true, null, null);
},
reboot: function() {
this._proxy.RebootRemote(true);
this._proxy.RebootRemote(true, null, null);
},
suspend: function() {
this._proxy.SuspendRemote(true);
this._proxy.SuspendRemote(true, null, null);
}
});
const LoginManagerConsoleKit = new Lang.Class({
Name: 'LoginManagerConsoleKit',
Extends: GObject.Object,
_init: function() {
this._proxy = new ConsoleKitManager(Gio.DBus.system,
'org.freedesktop.ConsoleKit',
'/org/freedesktop/ConsoleKit/Manager');
this.parent();
this._proxy = new ConsoleKitManager();
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
// session objects have different interfaces - but in both cases there are
// Lock/Unlock signals, and that's all we count upon at the moment.
getCurrentSessionProxy: function() {
if (!this._currentSession) {
let [currentSessionId] = this._proxy.GetCurrentSessionSync();
this._currentSession = new ConsoleKitSession(Gio.DBus.system,
'org.freedesktop.ConsoleKit',
currentSessionId);
}
return this._currentSession;
},
@ -185,26 +341,32 @@ const LoginManagerConsoleKit = new Lang.Class({
session.connectSignal('ActiveChanged', Lang.bind(this, function(object, senderName, [isActive]) {
this._sessionActive = isActive;
}));
[this._sessionActive] = session.IsActiveSync();
[this._sessionActive] = session.IsActiveSync(null);
return this._sessionActive;
},
canPowerOff: function(asyncCallback) {
this._proxy.CanStopRemote(function(result, error) {
if (error)
asyncCallback(false);
else
asyncCallback(result[0]);
this._proxy.CanStopRemote(null, function(proxy, result) {
let val = false;
try {
[val] = proxy.CanStopFinish(result);
} catch(e) { }
asyncCallback(val);
});
},
canReboot: function(asyncCallback) {
this._proxy.CanRestartRemote(function(result, error) {
if (error)
asyncCallback(false);
else
asyncCallback(result[0]);
this._proxy.CanRestartRemote(null, function(proxy, result) {
let val = false;
try {
[val] = proxy.CanRestartFinish(result);
} catch(e) { }
asyncCallback(val);
});
},
@ -216,11 +378,11 @@ const LoginManagerConsoleKit = new Lang.Class({
},
powerOff: function() {
this._proxy.StopRemote();
this._proxy.StopRemote(null, null);
},
reboot: function() {
this._proxy.RestartRemote();
this._proxy.RestartRemote(null, null);
},
suspend: function() {

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
@ -26,7 +27,16 @@ const ModemGsmNetworkInterface = <interface name="org.freedesktop.ModemManager.M
</signal>
</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">
<method name="GetSignalQuality">
@ -40,7 +50,16 @@ const ModemCdmaInterface = <interface name="org.freedesktop.ModemManager.Modem.C
</signal>
</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;
function _getProvidersTable() {
@ -54,11 +73,18 @@ const ModemGsm = new Lang.Class({
Name: 'ModemGsm',
_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.operator_name = null;
},
_finishInit: function() {
// Code is duplicated because the function have different signatures
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, [quality]) {
this.signal_quality = quality;
@ -68,24 +94,19 @@ const ModemGsm = new Lang.Class({
this.operator_name = this._findOperatorName(name, code);
this.emit('notify::operator-name');
}));
this._proxy.GetRegistrationInfoRemote(Lang.bind(this, function([result], err) {
if (err) {
log(err);
return;
}
let [status, code, name] = result;
this._proxy.GetRegistrationInfoRemote(null, Lang.bind(this, function(proxy, result) {
let [status, code, name] = proxy.GetRegistrationInfoFinish(result);
this.operator_name = this._findOperatorName(name, code);
this.emit('notify::operator-name');
}));
this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
if (err) {
this._proxy.GetSignalQualityRemote(null, Lang.bind(this, function(proxy, result) {
try {
[this.signal_quality] = proxy.GetSignalQualityFinish(result);
} catch(e) {
// it will return an error if the device is not connected
this.signal_quality = 0;
} else {
let [quality] = result;
this.signal_quality = quality;
}
this.emit('notify::signal-quality');
}));
},
@ -157,10 +178,18 @@ const ModemCdma = new Lang.Class({
Name: 'ModemCdma',
_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.operator_name = null;
},
_finishInit: function() {
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, params) {
this.signal_quality = params[0];
this.emit('notify::signal-quality');
@ -170,30 +199,31 @@ const ModemCdma = new Lang.Class({
if (this.operator_name == null)
this._refreshServingSystem();
}));
this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
if (err) {
this._proxy.GetSignalQualityRemote(null, Lang.bind(this, function(proxy, result) {
try {
[this.signal_quality] = proxy.GetSignalQualityFinish(result);
} catch(e) {
// it will return an error if the device is not connected
this.signal_quality = 0;
} else {
let [quality] = result;
this.signal_quality = quality;
}
this.emit('notify::signal-quality');
}));
},
_refreshServingSystem: function() {
this._proxy.GetServingSystemRemote(Lang.bind(this, function([result], err) {
if (err) {
// it will return an error if the device is not connected
this.operator_name = null;
} else {
let [bandClass, band, id] = result;
this._proxy.GetServingSystemRemote(null, Lang.bind(this, function(proxy, result) {
try {
let [bandClass, band, name] = proxy.GetServingSystemFinish(result);
if (name.length > 0)
this.operator_name = this._findProviderForSid(id);
this.operator_name = this._findProviderForSid(name);
else
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');
}));
},

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const St = imports.gi.St;
@ -200,19 +201,17 @@ const CalendarServerIface = <interface name="org.gnome.Shell.CalendarServer">
<signal name="Changed" />
</interface>;
const CalendarServerInfo = Gio.DBusInterfaceInfo.new_for_xml(CalendarServerIface);
const CalendarServer = new Gio.DBusProxyClass({
Name: 'CalendarServer',
Interface: CalendarServerIface,
function CalendarServer() {
var self = new Gio.DBusProxy({ g_connection: Gio.DBus.session,
g_interface_name: CalendarServerInfo.name,
g_interface_info: CalendarServerInfo,
g_name: 'org.gnome.Shell.CalendarServer',
g_object_path: '/org/gnome/Shell/CalendarServer',
g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
self.init(null);
return self;
}
_init: function() {
this.parent({ g_bus_type: Gio.BusType.SESSION,
g_name: 'org.gnome.Shell.CalendarServer',
g_object_path: '/org/gnome/Shell/CalendarServer',
g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
}
});
function _datesEqual(a, b) {
if (a < b)
@ -242,11 +241,15 @@ const DBusEventSource = new Lang.Class({
this._dbusProxy = new CalendarServer();
this._dbusProxy.connectSignal('Changed', Lang.bind(this, this._onChanged));
this._dbusProxy.connect('notify::g-name-owner', Lang.bind(this, function() {
if (this._dbusProxy.g_name_owner)
this._onNameAppeared();
else
this._onNameVanished();
this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
try {
proxy.init_finish(result);
} catch(e) {
return;
}
this._resetCache();
this.emit('changed');
}));
},
@ -256,52 +259,52 @@ const DBusEventSource = new Lang.Class({
this._lastRequestEnd = null;
},
_onNameAppeared: function(owner) {
this._resetCache();
this._loadEvents(true);
},
_onNameVanished: function(oldOwner) {
this._resetCache();
this.emit('changed');
},
_onChanged: function() {
this._loadEvents(false);
},
_onEventsReceived: function(results, error) {
let newEvents = [];
let appointments = results ? results[0] : null;
if (appointments != null) {
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();
});
_onEventsReceived: function(proxy, result) {
let appointments;
try {
[appointments] = proxy.call_finish(result).deep_unpack();
} catch(e if e instanceof GLib.Error) {
// ignore errors coming from DBus
appointments = [];
}
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.emit('changed');
},
_loadEvents: function(forceReload) {
if (this._curRequestBegin && this._curRequestEnd){
/* Can't use GetEventsRemote because we need to pass the
flags here */
let callFlags = Gio.DBusCallFlags.NO_AUTO_START;
if (forceReload)
callFlags = Gio.DBusCallFlags.NONE;
this._dbusProxy.GetEventsRemote(this._curRequestBegin.getTime() / 1000,
this._curRequestEnd.getTime() / 1000,
forceReload,
Lang.bind(this, this._onEventsReceived),
callFlags);
callFlags = Gio.DBusCallFlags.NONE;
this._dbusProxy.call("GetEvents",
GLib.Variant.new("(xxb)", [this._curRequestBegin.getTime() / 1000,
this._curRequestEnd.getTime() / 1000,
forceReload]),
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._update(false);
}));
this._update(true);
}
},

View File

@ -33,7 +33,9 @@ const AutomountManager = new Lang.Class({
Lang.bind(this, this._InhibitorsChanged));
this._inhibited = false;
this._loginManager = LoginManager.getLoginManager();
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
this._loginManager = manager;
}));
this._volumeMonitor = Gio.VolumeMonitor.get();
},
@ -85,7 +87,7 @@ const AutomountManager = new Lang.Class({
_onDriveConnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
if (!this._loginManager.sessionActive)
if (!this._loginManager || !this._loginManager.sessionActive)
return;
global.play_theme_sound(0, 'device-added-media');
@ -94,7 +96,7 @@ const AutomountManager = new Lang.Class({
_onDriveDisconnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
if (!this._loginManager.sessionActive)
if (!this._loginManager || !this._loginManager.sessionActive)
return;
global.play_theme_sound(0, 'device-removed-media');
@ -103,7 +105,7 @@ const AutomountManager = new Lang.Class({
_onDriveEjectButton: function(monitor, drive) {
// TODO: this code path is not tested, as the GVfs volume monitor
// doesn't emit this signal just yet.
if (!this._loginManager.sessionActive)
if (!this._loginManager || !this._loginManager.sessionActive)
return;
// 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 we're not in the current ConsoleKit session,
// don't attempt automount
if (!this._loginManager.sessionActive)
if (!this._loginManager || !this._loginManager.sessionActive)
return;
}

View File

@ -2,6 +2,7 @@
const Lang = imports.lang;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const St = imports.gi.St;
const LoginManager = imports.misc.loginManager;
@ -82,12 +83,16 @@ const HotplugSnifferIface = <interface name="org.gnome.Shell.HotplugSniffer">
</method>
</interface>;
const HotplugSnifferProxy = Gio.DBusProxy.makeProxyWrapper(HotplugSnifferIface);
function HotplugSniffer() {
return new HotplugSnifferProxy(Gio.DBus.session,
'org.gnome.Shell.HotplugSniffer',
'/org/gnome/Shell/HotplugSniffer');
}
const HotplugSniffer = new Gio.DBusProxyClass({
Name: 'HotplugSnifferProxy',
Interface: HotplugSnifferIface,
_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({
Name: 'ContentTypeDiscoverer',
@ -127,10 +132,14 @@ const ContentTypeDiscoverer = new Lang.Class({
let root = mount.get_root();
let hotplugSniffer = new HotplugSniffer();
hotplugSniffer.SniffURIRemote(root.get_uri(),
Lang.bind(this, function([contentTypes]) {
this._emitCallback(mount, contentTypes);
}));
hotplugSniffer.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
proxy.init_finish(result);
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',
_init: function() {
this._loginManager = LoginManager.getLoginManager();
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
this._loginManager = manager;
}));
this._volumeMonitor = Gio.VolumeMonitor.get();
@ -215,7 +226,7 @@ const AutorunManager = new Lang.Class({
_onMountAdded: function(monitor, mount) {
// don't do anything if our session is not the currently
// active one
if (!this._loginManager.sessionActive)
if (!this._loginManager || !this._loginManager.sessionActive)
return;
this._processMount(mount, true);

View File

@ -218,6 +218,34 @@ function init() {
_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({
Name: 'EndSessionDialog',
Extends: ModalDialog.ModalDialog,
@ -295,8 +323,8 @@ const EndSessionDialog = new Lang.Class({
scrollView.hide();
}));
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(EndSessionDialogIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/SessionManager/EndSessionDialog');
this._exporter = new EndSessionExporter();
this._exporter.connect('open', Lang.bind(this, this._onOpenRequest));
},
_onDestroy: function() {
@ -387,19 +415,19 @@ const EndSessionDialog = new Lang.Class({
close: function() {
this.parent();
this._dbusImpl.emit_signal('Closed', null);
this._exporter.close();
},
cancel: function() {
this._stopTimer();
this._dbusImpl.emit_signal('Canceled', null);
this._exporter.cancel();
this.close(global.get_current_time());
},
_confirm: function(signal) {
this._fadeOutDialog();
this._stopTimer();
this._dbusImpl.emit_signal(signal, null);
this._exporter.confirm(signal);
},
_onOpened: function() {
@ -452,7 +480,7 @@ const EndSessionDialog = new Lang.Class({
this._updateContent();
},
OpenAsync: function(parameters, invocation) {
_onOpenRequest: function(exporter, parameters, invocation) {
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
this._inhibitors = [];
@ -466,7 +494,10 @@ const EndSessionDialog = new Lang.Class({
}
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);
}));

View File

@ -2,7 +2,6 @@
const Caribou = imports.gi.Caribou;
const Clutter = imports.gi.Clutter;
const DBus = imports.dbus;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
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
// Name: 'Keyboard',
Interface: CaribouKeyboardIface,
_init: function () {
this._impl = Gio.DBusExportedObject.wrapJSObject(CaribouKeyboardIface, this);
this._impl.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
this.parent();
this.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
this.actor = null;
this._focusInTray = false;

View File

@ -96,14 +96,15 @@ const ZoomRegionIface = <interface name={ZOOM_SERVICE_NAME}>
// '/org/gnome/Magnifier/ZoomRegion/zoomer1', etc.
let _zoomRegionInstanceCount = 0;
const ShellMagnifier = new Lang.Class({
const ShellMagnifier = new Gio.DBusImplementerClass({
Name: 'ShellMagnifier',
Interface: MagnifierIface,
_init: function() {
this._zoomers = {};
this.parent();
this.export(Gio.DBus.session, MAG_SERVICE_PATH);
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(MagnifierIface, this);
this._dbusImpl.export(Gio.DBus.session, MAG_SERVICE_PATH);
this._zoomers = {};
},
/**
@ -332,14 +333,15 @@ const ShellMagnifier = new Lang.Class({
* @zoomerObjectPath: String that is the path to a DBus ZoomRegion.
* @zoomRegion: The actual zoom region associated with the object path.
*/
const ShellMagnifierZoomRegion = new Lang.Class({
const ShellMagnifierZoomRegion = new Gio.DBusImplementerClass({
Name: 'ShellMagnifierZoomRegion',
Interface: ZoomRegionIface,
_init: function(zoomerObjectPath, zoomRegion) {
this._zoomRegion = zoomRegion;
this.parent();
this.export(Gio.DBus.session, zoomerObjectPath);
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ZoomRegionIface, this);
this._dbusImpl.export(Gio.DBus.session, zoomerObjectPath);
this._zoomRegion = zoomRegion;
},
/**
@ -417,6 +419,6 @@ const ShellMagnifierZoomRegion = new Lang.Class({
},
destroy: function() {
this._dbusImpl.unexport();
this.unexport();
}
});

View File

@ -1365,13 +1365,16 @@ const MessageTray = new Lang.Class({
Name: 'MessageTray',
_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._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
this._onStatusChanged(status);
}));
}));
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',
reactive: true,

View File

@ -25,10 +25,19 @@ const BusIface = <interface name="org.freedesktop.DBus">
</method>
</interface>;
var BusProxy = Gio.DBusProxy.makeProxyWrapper(BusIface);
function Bus() {
return new BusProxy(Gio.DBus.session, 'org.freedesktop.DBus', '/org/freedesktop/DBus');
}
const Bus = new Gio.DBusProxyClass({
Name: 'SessionBusProxy',
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">
<method name="Notify">
@ -103,17 +112,20 @@ const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
'ibus-ui-gtk': 'keyboard'
};
const NotificationDaemon = new Lang.Class({
const NotificationDaemon = new Gio.DBusImplementerClass({
Name: 'NotificationDaemon',
Interface: NotificationDaemonIface,
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(NotificationDaemonIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/Notifications');
this.parent();
this.export(Gio.DBus.session, '/org/freedesktop/Notifications');
this._sources = [];
this._senderToPid = {};
this._notifications = {};
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._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]));;
}
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
ndata = this._notifications[id];
if (!ndata)
return;
if (excp) {
let pid;
try {
[pid] = proxy.GetConnectionUnixProcessIDFinish(result);
} catch(excp) {
logError(excp, 'Call to GetConnectionUnixProcessID failed');
return;
}
let [pid] = result;
source = this._getSource(appName, pid, ndata, sender, null);
// We only store sender-pid entries for persistent sources.
@ -487,13 +501,11 @@ const NotificationDaemon = new Lang.Class({
},
_emitNotificationClosed: function(id, reason) {
this._dbusImpl.emit_signal('NotificationClosed',
GLib.Variant.new('(uu)', [id, reason]));
this.emit_signal('NotificationClosed', id, reason);
},
_emitActionInvoked: function(id, action) {
this._dbusImpl.emit_signal('ActionInvoked',
GLib.Variant.new('(us)', [id, action]));
this.emit_signal('ActionInvoked', id, action);
},
_onTrayIconAdded: function(o, icon) {

View File

@ -29,8 +29,15 @@ const SearchProviderIface = <interface name="org.gnome.Shell.SearchProvider">
</method>
</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) {
let dataDirs = GLib.get_system_data_dirs();
@ -90,13 +97,22 @@ function loadRemoteSearchProvidersFromDir(dir, loadedProviders, addProviderCallb
icon,
busName,
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;
} catch(e) {
log('Failed to add search provider "%s": %s'.format(title, e.toString()));
continue;
}
addProviderCallback(remoteProvider);
}
}));
@ -107,13 +123,41 @@ const RemoteSearchProvider = new Lang.Class({
Extends: Search.SearchProvider,
_init: function(title, icon, dbusName, dbusPath) {
this._proxy = new SearchProviderProxy(Gio.DBus.session,
dbusName, dbusPath);
this.parent(title.toUpperCase());
this._proxy = new SearchProviderProxy({ g_name: dbusName,
g_object_path: dbusPath });
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) {
if (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 });
},
_getResultsFinished: function(results, error) {
if (error)
return;
this.searchSystem.pushResults(this, results[0]);
_getResultsFinished: function(proxy, result) {
try {
// We rely on a small implementation detail of the
// 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) {
@ -142,8 +193,8 @@ const RemoteSearchProvider = new Lang.Class({
this._cancellable.reset();
try {
this._proxy.GetInitialResultSetRemote(terms,
Lang.bind(this, this._getResultsFinished),
this._cancellable);
this._cancellable,
Lang.bind(this, this._getResultsFinished));
} catch(e) {
log('Error calling GetInitialResultSet for provider %s: %s'.format( this.title, e.toString()));
this.searchSystem.pushResults(this, []);
@ -155,30 +206,30 @@ const RemoteSearchProvider = new Lang.Class({
this._cancellable.reset();
try {
this._proxy.GetSubsearchResultSetRemote(previousResults, newTerms,
Lang.bind(this, this._getResultsFinished),
this._cancellable);
this._cancellable,
Lang.bind(this, this._getResultsFinished))
} catch(e) {
log('Error calling GetSubsearchResultSet for provider %s: %s'.format(this.title, e.toString()));
this.searchSystem.pushResults(this, []);
}
},
_getResultMetasFinished: function(results, error, callback) {
if (error) {
_getResultMetasFinished: function(proxy, result, callback) {
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([]);
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) {
@ -186,8 +237,8 @@ const RemoteSearchProvider = new Lang.Class({
this._cancellable.reset();
try {
this._proxy.GetResultMetasRemote(ids,
Lang.bind(this, this._getResultMetasFinished, callback),
this._cancellable);
this._cancellable,
Lang.bind(this, this._getResultMetasFinished, callback));
} catch(e) {
log('Error calling GetResultMetas for provider %s: %s'.format(this.title, e.toString()));
callback([]);
@ -195,7 +246,7 @@ const RemoteSearchProvider = new Lang.Class({
},
activateResult: function(id) {
this._proxy.ActivateResultRemote(id);
this._proxy.ActivateResultRemote(id, null, null);
}
});

View File

@ -418,10 +418,11 @@ const ScreenShield = new Lang.Class({
this._screenSaverDBus = new ShellDBus.ScreenSaverDBus(this);
this._loginManager = LoginManager.getLoginManager();
this._loginSession = this._loginManager.getCurrentSessionProxy();
this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.unlock(); }));
LoginManager.getLoginManager(Lang.bind(this, function(manager) {
this._loginSession = manager.getCurrentSessionProxy();
this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.unlock(); }));
}));
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 |
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES),
});
// This is synchronous but it is the fallback case.
this._proxy.init(null);
this._proxy.connect('g-signal', Lang.bind(this, this._onSignal));

View File

@ -80,15 +80,23 @@ const PerfHelperIface = <interface name="org.gnome.Shell.PerfHelper">
<method name="DestroyWindows" />
</interface>;
var PerfHelperProxy = Gio.DBusProxy.makeProxyWrapper(PerfHelperIface);
function PerfHelper() {
return new PerfHelperProxy(Gio.DBus.session, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
}
const PerfHelper = new Gio.DBusProxyClass({
Name: 'PerfHelperProxy',
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;
function _getPerfHelper() {
if (_perfHelper == null)
if (_perfHelper == null) {
_perfHelper = new PerfHelper();
_perfHelper.init(null);
}
return _perfHelper;
}
@ -111,7 +119,8 @@ function createTestWindow(width, height, alpha, maximized) {
let perfHelper = _getPerfHelper();
perfHelper.CreateWindowRemote(width, height, alpha, maximized,
function(result, excp) {
null,
function(proxy, result) {
if (cb)
cb();
});
@ -131,7 +140,7 @@ function waitTestWindows() {
let cb;
let perfHelper = _getPerfHelper();
perfHelper.WaitWindowsRemote(function(result, excp) {
perfHelper.WaitWindowsRemote(null, function(proxy, result) {
if (cb)
cb();
});
@ -154,7 +163,7 @@ function destroyTestWindows() {
let cb;
let perfHelper = _getPerfHelper();
perfHelper.DestroyWindowsRemote(function(result, excp) {
perfHelper.DestroyWindowsRemote(null, function(proxy, result) {
if (cb)
cb();
});

View File

@ -2,6 +2,7 @@
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Lang = imports.lang;
const Signals = imports.signals;
const Shell = imports.gi.Shell;
@ -75,6 +76,8 @@ const SearchProvider = new Lang.Class({
Name: 'SearchProvider',
_init: function(title) {
this.parent();
this.title = title;
this.searchSystem = null;
},

View File

@ -67,14 +67,16 @@ const ScreenSaverIface = <interface name="org.gnome.ScreenSaver">
</signal>
</interface>;
const GnomeShell = new Lang.Class({
const GnomeShell = new Gio.DBusImplementerClass({
Name: 'GnomeShellDBus',
Interface: GnomeShellIface,
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
this.parent();
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" />
</interface>;
const GnomeShellExtensions = new Lang.Class({
const GnomeShellExtensions = new Gio.DBusImplementerClass({
Name: 'GnomeShellExtensionsDBus',
Interface: GnomeShellExtensionsIface,
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
this.parent();
this.export(Gio.DBus.session, '/org/gnome/Shell');
ExtensionSystem.connect('extension-state-changed',
Lang.bind(this, this._extensionStateChanged));
},
@ -335,25 +339,23 @@ const GnomeShellExtensions = new Lang.Class({
ShellVersion: Config.PACKAGE_VERSION,
_extensionStateChanged: function(_, newState) {
this._dbusImpl.emit_signal('ExtensionStatusChanged',
GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
this.emit_signal('ExtensionStatusChanged', newState.uuid, newState.state, newState.error);
}
});
const ScreenSaverDBus = new Lang.Class({
const ScreenSaverDBus = new Gio.DBusImplementerClass({
Name: 'ScreenSaverDBus',
Interface: ScreenSaverIface,
_init: function(screenShield) {
this.parent();
this._screenShield = screenShield;
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._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
this.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
},

View File

@ -554,14 +554,16 @@ const ShellMountOperationType = {
SHOW_PROCESSES: 3
};
const GnomeShellMountOpHandler = new Lang.Class({
const GnomeShellMountOpHandler = new Gio.DBusImplementerClass({
Name: 'GnomeShellMountOpHandler',
Interface: GnomeShellMountOpIface,
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellMountOpIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
Gio.bus_own_name_on_connection(Gio.DBus.session, 'org.gtk.MountOperationHandler',
Gio.BusNameOwnerFlags.REPLACE, null, null);
this.parent();
this.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
Gio.DBus.session.own_name('org.gtk.MountOperationHandler',
Gio.BusNameOwnerFlags.REPLACE, null, null);
this._dialog = null;
this._volumeMonitor = Gio.VolumeMonitor.get();

View File

@ -1629,7 +1629,44 @@ const NMApplet = new Lang.Class({
this.secondaryIcon = this.addIcon(new Gio.ThemedIcon({ name: 'network-vpn-symbolic' }));
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._statusItem = new PopupMenu.PopupMenuItem('', { reactive: false });
@ -1690,44 +1727,17 @@ const NMApplet = new Lang.Class({
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
// 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
this._readConnections();
this._readDevices();
this._syncNMState();
// 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;
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));
}
}));
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() {

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const St = imports.gi.St;
@ -45,7 +46,16 @@ const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power">
<property name="Icon" type="s" access="read" />
</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({
Name: 'PowerIndicator',
@ -54,7 +64,7 @@ const Indicator = new Lang.Class({
_init: function() {
this.parent('battery-missing-symbolic', _("Battery"));
this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
this._proxy = new PowerManagerProxy();
this._deviceItems = [ ];
this._hasPrimary = false;
@ -73,18 +83,26 @@ const Indicator = new Lang.Class({
this._proxy.connect('g-properties-changed',
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() {
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) {
if (error) {
this._proxy.GetPrimaryDeviceRemote(null, Lang.bind(this, function(proxy, result) {
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._primaryDeviceId = null;
this._batteryItem.actor.hide();
return;
}
let [[device_id, device_type, icon, percentage, state, seconds]] = result;
if (device_type == UPDeviceType.BATTERY) {
this._hasPrimary = true;
let time = Math.round(seconds / 60);
@ -121,16 +139,18 @@ const Indicator = new Lang.Class({
},
_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 = [];
if (error) {
let devices;
try {
[devices] = proxy.GetDevicesFinish(result);
} catch(e) {
return;
}
let position = 0;
let [devices] = result;
for (let i = 0; i < devices.length; i++) {
let [device_id, device_type] = devices[i];
if (device_type == UPDeviceType.AC_POWER || device_id == this._primaryDeviceId)

View File

@ -195,8 +195,12 @@ const IMStatusChooserItem = new Lang.Class({
Lang.bind(this, this._changeIMStatus));
this._presence = new GnomeSession.Presence();
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
this._sessionStatusChanged(status);
this._presence.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(obj, result) {
obj.init_finish(result);
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
this._sessionStatusChanged(status);
}));
}));
this._sessionPresenceRestored = false;
@ -480,14 +484,33 @@ const UserMenuButton = new Lang.Class({
this._userManager = AccountsService.UserManager.get_default();
this._user = this._userManager.get_user(GLib.get_user_name());
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._haveSuspend = true;
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._iconBox = new St.Bin();
@ -533,11 +556,6 @@ const UserMenuButton = new Lang.Class({
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',
Lang.bind(this, this._updateMultiUser));
this._userManager.connect('notify::has-multiple-users',
@ -637,17 +655,29 @@ const UserMenuButton = new Lang.Class({
},
_updateHaveShutdown: function() {
this._session.CanShutdownRemote(Lang.bind(this,
function(result, error) {
if (!error) {
this._haveShutdown = result[0];
this._updateInstallUpdates();
this._updateSuspendOrPowerOff();
}
}));
if (!this._session) {
this._haveShutdown = false;
return;
}
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() {
if (!this._loginManager) {
this._haveSuspend = false;
return;
}
this._loginManager.canSuspend(Lang.bind(this,
function(result) {
this._haveSuspend = result;
@ -837,14 +867,17 @@ const UserMenuButton = new Lang.Class({
_onQuitSessionActivate: function() {
Main.overview.hide();
this._session.LogoutRemote(0);
if (this._session)
this._session.LogoutRemote(0, null, null);
},
_onInstallUpdatesActivate: function() {
Main.overview.hide();
Util.spawn(['pkexec', '/usr/libexec/pk-trigger-offline-update']);
this._session.RebootRemote();
if (this._haveShutdown)
this._session.RebootRemote(null, null);
},
_onSuspendOrPowerOffActivate: function() {
@ -852,8 +885,8 @@ const UserMenuButton = new Lang.Class({
if (this._haveShutdown &&
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
this._session.ShutdownRemote();
} else {
this._session.ShutdownRemote(null, null);
} else if (this._haveSuspend) {
if (this._screenSaverSettings.get_boolean(LOCK_ENABLED_KEY)) {
let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
Main.screenShield.disconnect(tmpId);