Port client side code to GDBus
This continues the series of patches for GDBus porting, affecting all code that accesses remote DBus objects. This includes modemManager, automount, autorun (for the hotplug sniffer), calendar, network (for nm-applet only), power, scripting (for perf monitor interface) https://bugzilla.gnome.org/show_bug.cgi?id=648651
This commit is contained in:
parent
827bf506a7
commit
6547f75b12
@ -1,6 +1,6 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const DBus = imports.dbus;
|
||||
const Gio = imports.gi.Gio;
|
||||
const Lang = imports.lang;
|
||||
const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
@ -8,33 +8,43 @@ const Signals = imports.signals;
|
||||
// The following are not the complete interfaces, just the methods we need
|
||||
// (or may need in the future)
|
||||
|
||||
const ModemGsmNetworkInterface = {
|
||||
name: 'org.freedesktop.ModemManager.Modem.Gsm.Network',
|
||||
methods: [
|
||||
{ name: 'GetRegistrationInfo', inSignature: '', outSignature: 'uss' },
|
||||
{ name: 'GetSignalQuality', inSignature: '', outSignature: 'u' }
|
||||
],
|
||||
properties: [
|
||||
{ name: 'AccessTechnology', signature: 'u', access: 'read' }
|
||||
],
|
||||
signals: [
|
||||
{ name: 'SignalQuality', inSignature: 'u' },
|
||||
{ name: 'RegistrationInfo', inSignature: 'uss' }
|
||||
]
|
||||
};
|
||||
const ModemGsmNetworkProxy = DBus.makeProxyClass(ModemGsmNetworkInterface);
|
||||
const ModemGsmNetworkInterface = <interface name="org.freedesktop.ModemManager.Modem.Gsm.Network">
|
||||
<method name="GetRegistrationInfo">
|
||||
<arg type="u" direction="out" />
|
||||
<arg type="s" direction="out" />
|
||||
<arg type="s" direction="out" />
|
||||
</method>
|
||||
<method name="GetSignalQuality">
|
||||
<arg type="u" direction="out" />
|
||||
</method>
|
||||
<property name="AccessTechnology" type="u" access="read" />
|
||||
<signal name="SignalQuality">
|
||||
<arg type="u" direction="out" />
|
||||
</signal>
|
||||
<signal name="RegistrationInfo">
|
||||
<arg type="u" direction="out" />
|
||||
<arg type="s" direction="out" />
|
||||
<arg type="s" direction="out" />
|
||||
</signal>
|
||||
</interface>;
|
||||
|
||||
const ModemCdmaInterface = {
|
||||
name: 'org.freedesktop.ModemManager.Modem.Cdma',
|
||||
methods: [
|
||||
{ name: 'GetSignalQuality', inSignature: '', outSignature: 'u' },
|
||||
{ name: 'GetServingSystem', inSignature: '', outSignature: 'usu' }
|
||||
],
|
||||
signals: [
|
||||
{ name: 'SignalQuality', inSignature: 'u' }
|
||||
]
|
||||
};
|
||||
const ModemCdmaProxy = DBus.makeProxyClass(ModemCdmaInterface);
|
||||
const ModemGsmNetworkProxy = Gio.DBusProxy.makeProxyWrapper(ModemGsmNetworkInterface);
|
||||
|
||||
const ModemCdmaInterface = <interface name="org.freedesktop.ModemManager.Modem.Cdma">
|
||||
<method name="GetSignalQuality">
|
||||
<arg type="u" direction="out" />
|
||||
</method>
|
||||
<method name="GetServingSystem">
|
||||
<arg type="u" direction="out" />
|
||||
<arg type="s" direction="out" />
|
||||
<arg type="u" direction="out" />
|
||||
</method>
|
||||
<signal name="SignalQuality">
|
||||
<arg type="u" direction="out" />
|
||||
</signal>
|
||||
</interface>;
|
||||
|
||||
const ModemCdmaProxy = Gio.DBusProxy.makeProxyWrapper(ModemCdmaInterface);
|
||||
|
||||
let _providersTable;
|
||||
function _getProvidersTable() {
|
||||
@ -50,17 +60,17 @@ function ModemGsm() {
|
||||
|
||||
ModemGsm.prototype = {
|
||||
_init: function(path) {
|
||||
this._proxy = new ModemGsmNetworkProxy(DBus.system, 'org.freedesktop.ModemManager', path);
|
||||
this._proxy = new ModemGsmNetworkProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
|
||||
|
||||
this.signal_quality = 0;
|
||||
this.operator_name = null;
|
||||
|
||||
// Code is duplicated because the function have different signatures
|
||||
this._proxy.connect('SignalQuality', Lang.bind(this, function(proxy, quality) {
|
||||
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, [quality]) {
|
||||
this.signal_quality = quality;
|
||||
this.emit('notify::signal-quality');
|
||||
}));
|
||||
this._proxy.connect('RegistrationInfo', Lang.bind(this, function(proxy, status, code, name) {
|
||||
this._proxy.connectSignal('RegistrationInfo', Lang.bind(this, function(proxy, sender, [status, code, name]) {
|
||||
this.operator_name = this._findOperatorName(name, code);
|
||||
this.emit('notify::operator-name');
|
||||
}));
|
||||
@ -155,12 +165,12 @@ function ModemCdma() {
|
||||
|
||||
ModemCdma.prototype = {
|
||||
_init: function(path) {
|
||||
this._proxy = new ModemCdmaProxy(DBus.system, 'org.freedesktop.ModemManager', path);
|
||||
this._proxy = new ModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
|
||||
|
||||
this.signal_quality = 0;
|
||||
this.operator_name = null;
|
||||
this._proxy.connect('SignalQuality', Lang.bind(this, function(proxy, quality) {
|
||||
this.signal_quality = quality;
|
||||
this._proxy.connect('SignalQuality', Lang.bind(this, function(proxy, sender, params) {
|
||||
this.signal_quality = params[0];
|
||||
this.emit('notify::signal-quality');
|
||||
|
||||
// receiving this signal means the device got activated
|
||||
|
@ -1,7 +1,6 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const Lang = imports.lang;
|
||||
const DBus = imports.dbus;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Gio = imports.gi.Gio;
|
||||
const Params = imports.misc.params;
|
||||
@ -16,63 +15,54 @@ const SETTING_ENABLE_AUTOMOUNT = 'automount';
|
||||
|
||||
const AUTORUN_EXPIRE_TIMEOUT_SECS = 10;
|
||||
|
||||
const ConsoleKitSessionIface = {
|
||||
name: 'org.freedesktop.ConsoleKit.Session',
|
||||
methods: [{ name: 'IsActive',
|
||||
inSignature: '',
|
||||
outSignature: 'b' }],
|
||||
signals: [{ name: 'ActiveChanged',
|
||||
inSignature: 'b' }]
|
||||
};
|
||||
const ConsoleKitSessionIface = <interface name="org.freedesktop.ConsoleKit.Session">
|
||||
<method name="IsActive">
|
||||
<arg type="b" direction="out" />
|
||||
</method>
|
||||
<signal name="ActiveChanged">
|
||||
<arg type="b" direction="out" />
|
||||
</signal>
|
||||
</interface>;
|
||||
|
||||
const ConsoleKitSessionProxy = DBus.makeProxyClass(ConsoleKitSessionIface);
|
||||
const ConsoleKitSessionProxy = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
|
||||
|
||||
const ConsoleKitManagerIface = {
|
||||
name: 'org.freedesktop.ConsoleKit.Manager',
|
||||
methods: [{ name: 'GetCurrentSession',
|
||||
inSignature: '',
|
||||
outSignature: 'o' }]
|
||||
};
|
||||
const ConsoleKitManagerIface = <interface name="org.freedesktop.ConsoleKit.Manager">
|
||||
<method name="GetCurrentSession">
|
||||
<arg type="o" direction="out" />
|
||||
</method>
|
||||
</interface>;
|
||||
|
||||
const ConsoleKitManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(ConsoleKitManagerIface);
|
||||
|
||||
function ConsoleKitManager() {
|
||||
this._init();
|
||||
};
|
||||
var self = new Gio.DBusProxy({ g_connection: Gio.DBus.system,
|
||||
g_interface_name: ConsoleKitManagerInfo.name,
|
||||
g_interface_info: ConsoleKitManagerInfo,
|
||||
g_name: 'org.freedesktop.ConsoleKit',
|
||||
g_object_path: '/org/freedesktop/ConsoleKit/Manager',
|
||||
g_flags: (Gio.DBusProxyFlags.DO_NOT_AUTO_START |
|
||||
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
|
||||
|
||||
ConsoleKitManager.prototype = {
|
||||
_init: function() {
|
||||
this.sessionActive = true;
|
||||
self.connect('notify::g-name-owner', function() {
|
||||
if (self.g_name_owner) {
|
||||
self.GetCurrentSessionRemote(function([session]) {
|
||||
self._ckSession = new ConsoleKitSessionProxy(Gio.DBus.system, 'org.freedesktop.ConsoleKit', session);
|
||||
|
||||
DBus.system.proxifyObject(this,
|
||||
'org.freedesktop.ConsoleKit',
|
||||
'/org/freedesktop/ConsoleKit/Manager');
|
||||
|
||||
DBus.system.watch_name('org.freedesktop.ConsoleKit',
|
||||
false, // do not launch a name-owner if none exists
|
||||
Lang.bind(this, this._onManagerAppeared),
|
||||
Lang.bind(this, this._onManagerVanished));
|
||||
},
|
||||
|
||||
_onManagerAppeared: function(owner) {
|
||||
this.GetCurrentSessionRemote(Lang.bind(this, this._onCurrentSession));
|
||||
},
|
||||
|
||||
_onManagerVanished: function(oldOwner) {
|
||||
this.sessionActive = true;
|
||||
},
|
||||
|
||||
_onCurrentSession: function(session) {
|
||||
this._ckSession = new ConsoleKitSessionProxy(DBus.system, 'org.freedesktop.ConsoleKit', session);
|
||||
|
||||
this._ckSession.connect
|
||||
('ActiveChanged', Lang.bind(this, function(object, isActive) {
|
||||
this.sessionActive = isActive;
|
||||
}));
|
||||
this._ckSession.IsActiveRemote(Lang.bind(this, function(isActive) {
|
||||
this.sessionActive = isActive;
|
||||
}));
|
||||
self._ckSession.connectSignal('ActiveChanged', function(object, senderName, [isActive]) {
|
||||
self.sessionActive = isActive;
|
||||
});
|
||||
self._ckSession.IsActiveRemote(function([isActive]) {
|
||||
self.sessionActive = isActive;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
self.sessionActive = true;
|
||||
}
|
||||
};
|
||||
DBus.proxifyPrototype(ConsoleKitManager.prototype, ConsoleKitManagerIface);
|
||||
});
|
||||
|
||||
self.init(null);
|
||||
return self;
|
||||
}
|
||||
|
||||
function AutomountManager() {
|
||||
this._init();
|
||||
|
@ -1,7 +1,6 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const Lang = imports.lang;
|
||||
const DBus = imports.dbus;
|
||||
const Gio = imports.gi.Gio;
|
||||
const St = imports.gi.St;
|
||||
|
||||
@ -62,25 +61,19 @@ function startAppForMount(app, mount) {
|
||||
|
||||
/******************************************/
|
||||
|
||||
const HotplugSnifferIface = {
|
||||
name: 'org.gnome.Shell.HotplugSniffer',
|
||||
methods: [{ name: 'SniffURI',
|
||||
inSignature: 's',
|
||||
outSignature: 'as' }]
|
||||
};
|
||||
const HotplugSnifferIface = <interface name="org.gnome.Shell.HotplugSniffer">
|
||||
<method name="SniffURI">
|
||||
<arg type="s" direction="in" />
|
||||
<arg type="as" direction="out" />
|
||||
</method>
|
||||
</interface>;
|
||||
|
||||
const HotplugSniffer = function() {
|
||||
this._init();
|
||||
};
|
||||
|
||||
HotplugSniffer.prototype = {
|
||||
_init: function() {
|
||||
DBus.session.proxifyObject(this,
|
||||
const HotplugSnifferProxy = Gio.DBusProxy.makeProxyWrapper(HotplugSnifferIface);
|
||||
function HotplugSniffer() {
|
||||
return new HotplugSnifferProxy(Gio.DBus.session,
|
||||
'org.gnome.Shell.HotplugSniffer',
|
||||
'/org/gnome/Shell/HotplugSniffer');
|
||||
},
|
||||
};
|
||||
DBus.proxifyPrototype(HotplugSniffer.prototype, HotplugSnifferIface);
|
||||
}
|
||||
|
||||
function ContentTypeDiscoverer(callback) {
|
||||
this._init(callback);
|
||||
@ -114,9 +107,8 @@ ContentTypeDiscoverer.prototype = {
|
||||
let root = mount.get_root();
|
||||
|
||||
let hotplugSniffer = new HotplugSniffer();
|
||||
hotplugSniffer.SniffURIRemote
|
||||
(root.get_uri(), DBus.CALL_FLAG_START,
|
||||
Lang.bind(this, function(contentTypes) {
|
||||
hotplugSniffer.SniffURIRemote(root.get_uri(),
|
||||
Lang.bind(this, function([contentTypes]) {
|
||||
this._emitCallback(mount, contentTypes);
|
||||
}));
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const DBus = imports.dbus;
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gio = imports.gi.Gio;
|
||||
const Lang = imports.lang;
|
||||
@ -195,30 +194,34 @@ EmptyEventSource.prototype = {
|
||||
};
|
||||
Signals.addSignalMethods(EmptyEventSource.prototype);
|
||||
|
||||
const CalendarServerIface = {
|
||||
name: 'org.gnome.Shell.CalendarServer',
|
||||
methods: [{ name: 'GetEvents',
|
||||
inSignature: 'xxb',
|
||||
outSignature: 'a(sssbxxa{sv})' }],
|
||||
signals: [{ name: 'Changed',
|
||||
inSignature: '' }]
|
||||
};
|
||||
const CalendarServerIface = <interface name="org.gnome.Shell.CalendarServer">
|
||||
<method name="GetEvents">
|
||||
<arg type="x" direction="in" />
|
||||
<arg type="x" direction="in" />
|
||||
<arg type="b" direction="in" />
|
||||
<arg type="a(sssbxxa{sv})" direction="out" />
|
||||
</method>
|
||||
<signal name="Changed" />
|
||||
</interface>;
|
||||
|
||||
const CalendarServer = function () {
|
||||
this._init();
|
||||
};
|
||||
const CalendarServerInfo = Gio.DBusInterfaceInfo.new_for_xml(CalendarServerIface);
|
||||
|
||||
CalendarServer.prototype = {
|
||||
_init: function() {
|
||||
DBus.session.proxifyObject(this, 'org.gnome.Shell.CalendarServer', '/org/gnome/Shell/CalendarServer');
|
||||
}
|
||||
};
|
||||
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_AUTO_START |
|
||||
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
|
||||
|
||||
DBus.proxifyPrototype(CalendarServer.prototype, CalendarServerIface);
|
||||
self.init(null);
|
||||
return self;
|
||||
}
|
||||
|
||||
// an implementation that reads data from a session bus service
|
||||
function DBusEventSource(owner) {
|
||||
this._init(owner);
|
||||
function DBusEventSource() {
|
||||
this._init();
|
||||
}
|
||||
|
||||
function _datesEqual(a, b) {
|
||||
@ -241,16 +244,18 @@ function _dateIntervalsOverlap(a0, a1, b0, b1)
|
||||
|
||||
|
||||
DBusEventSource.prototype = {
|
||||
_init: function(owner) {
|
||||
_init: function() {
|
||||
this._resetCache();
|
||||
|
||||
this._dbusProxy = new CalendarServer(owner);
|
||||
this._dbusProxy.connect('Changed', Lang.bind(this, this._onChanged));
|
||||
this._dbusProxy = new CalendarServer();
|
||||
this._dbusProxy.connectSignal('Changed', Lang.bind(this, this._onChanged));
|
||||
|
||||
DBus.session.watch_name('org.gnome.Shell.CalendarServer',
|
||||
false, // do not launch a name-owner if none exists
|
||||
Lang.bind(this, this._onNameAppeared),
|
||||
Lang.bind(this, this._onNameVanished));
|
||||
this._dbusProxy.connect('notify::g-name-owner', Lang.bind(this, function() {
|
||||
if (this._dbusProxy.g_name_owner)
|
||||
this._onNameAppeared();
|
||||
else
|
||||
this._onNameVanished();
|
||||
}));
|
||||
},
|
||||
|
||||
_resetCache: function() {
|
||||
@ -273,7 +278,7 @@ DBusEventSource.prototype = {
|
||||
this._loadEvents(false);
|
||||
},
|
||||
|
||||
_onEventsReceived: function(appointments) {
|
||||
_onEventsReceived: function([appointments]) {
|
||||
let newEvents = [];
|
||||
if (appointments != null) {
|
||||
for (let n = 0; n < appointments.length; n++) {
|
||||
@ -296,9 +301,9 @@ DBusEventSource.prototype = {
|
||||
|
||||
_loadEvents: function(forceReload) {
|
||||
if (this._curRequestBegin && this._curRequestEnd){
|
||||
let callFlags = 0;
|
||||
let callFlags = Gio.DBusCallFlags.NO_AUTO_START;
|
||||
if (forceReload)
|
||||
callFlags |= DBus.CALL_FLAG_START;
|
||||
callFlags = Gio.DBusCallFlags.NONE;
|
||||
this._dbusProxy.GetEventsRemote(this._curRequestBegin.getTime() / 1000,
|
||||
this._curRequestEnd.getTime() / 1000,
|
||||
forceReload,
|
||||
|
@ -1,6 +1,5 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const DBus = imports.dbus;
|
||||
const Gio = imports.gi.Gio;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Meta = imports.gi.Meta;
|
||||
@ -70,24 +69,21 @@ function waitLeisure() {
|
||||
};
|
||||
}
|
||||
|
||||
const PerfHelperIface = {
|
||||
name: 'org.gnome.Shell.PerfHelper',
|
||||
methods: [{ name: 'CreateWindow', inSignature: 'iibb', outSignature: '' },
|
||||
{ name: 'WaitWindows', inSignature: '', outSignature: '' },
|
||||
{ name: 'DestroyWindows', inSignature: '', outSignature: ''}]
|
||||
};
|
||||
const PerfHelperIface = <interface name="org.gnome.Shell.PerfHelper">
|
||||
<method name="CreateWindow">
|
||||
<arg type="i" direction="in" />
|
||||
<arg type="i" direction="in" />
|
||||
<arg type="b" direction="in" />
|
||||
<arg type="b" direction="in" />
|
||||
</method>
|
||||
<method name="WaitWindows" />
|
||||
<method name="DestroyWindows" />
|
||||
</interface>;
|
||||
|
||||
const PerfHelper = function () {
|
||||
this._init();
|
||||
};
|
||||
|
||||
PerfHelper.prototype = {
|
||||
_init: function() {
|
||||
DBus.session.proxifyObject(this, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
|
||||
}
|
||||
};
|
||||
|
||||
DBus.proxifyPrototype(PerfHelper.prototype, PerfHelperIface);
|
||||
var PerfHelperProxy = Gio.DBusProxy.makeProxyWrapper(PerfHelperIface);
|
||||
function PerfHelper() {
|
||||
return new PerfHelperProxy(Gio.DBus.session, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
|
||||
}
|
||||
|
||||
let _perfHelper = null;
|
||||
function _getPerfHelper() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const Gio = imports.gi.Gio;
|
||||
const DBus = imports.dbus;
|
||||
const Lang = imports.lang;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Shell = imports.gi.Shell;
|
||||
@ -40,20 +39,18 @@ const UPDeviceState = {
|
||||
PENDING_DISCHARGE: 6
|
||||
};
|
||||
|
||||
const PowerManagerInterface = {
|
||||
name: 'org.gnome.SettingsDaemon.Power',
|
||||
methods: [
|
||||
{ name: 'GetDevices', inSignature: '', outSignature: 'a(susdut)' },
|
||||
{ name: 'GetPrimaryDevice', inSignature: '', outSignature: '(susdut)' },
|
||||
],
|
||||
signals: [
|
||||
{ name: 'Changed', inSignature: '' },
|
||||
],
|
||||
properties: [
|
||||
{ name: 'Icon', signature: 's', access: 'read' },
|
||||
]
|
||||
};
|
||||
let PowerManagerProxy = DBus.makeProxyClass(PowerManagerInterface);
|
||||
const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power">
|
||||
<method name="GetDevices">
|
||||
<arg type="a(susdut)" direction="out" />
|
||||
</method>
|
||||
<method name="GetPrimaryDevice">
|
||||
<arg type="(susdut)" direction="out" />
|
||||
</method>
|
||||
<signal name="Changed" />
|
||||
<property name="Icon" type="s" access="read" />
|
||||
</interface>;
|
||||
|
||||
const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface);
|
||||
|
||||
function Indicator() {
|
||||
this._init.apply(this, arguments);
|
||||
@ -64,7 +61,7 @@ Indicator.prototype = {
|
||||
|
||||
_init: function() {
|
||||
PanelMenu.SystemStatusButton.prototype._init.call(this, 'battery-missing');
|
||||
this._proxy = new PowerManagerProxy(DBus.session, BUS_NAME, OBJECT_PATH);
|
||||
this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
|
||||
|
||||
this._deviceItems = [ ];
|
||||
this._hasPrimary = false;
|
||||
@ -81,19 +78,19 @@ Indicator.prototype = {
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
this.menu.addSettingsAction(_("Power Settings"), 'gnome-power-panel.desktop');
|
||||
|
||||
this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));
|
||||
this._proxy.connectSignal('Changed', Lang.bind(this, this._devicesChanged));
|
||||
this._devicesChanged();
|
||||
},
|
||||
|
||||
_readPrimaryDevice: function() {
|
||||
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(device, error) {
|
||||
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) {
|
||||
if (error) {
|
||||
this._hasPrimary = false;
|
||||
this._primaryDeviceId = null;
|
||||
this._batteryItem.actor.hide();
|
||||
return;
|
||||
}
|
||||
let [device_id, device_type, icon, percentage, state, seconds] = device;
|
||||
let [[device_id, device_type, icon, percentage, state, seconds]] = result;
|
||||
if (device_type == UPDeviceType.BATTERY) {
|
||||
this._hasPrimary = true;
|
||||
let time = Math.round(seconds / 60);
|
||||
@ -130,7 +127,7 @@ Indicator.prototype = {
|
||||
},
|
||||
|
||||
_readOtherDevices: function() {
|
||||
this._proxy.GetDevicesRemote(Lang.bind(this, function(devices, error) {
|
||||
this._proxy.GetDevicesRemote(Lang.bind(this, function(result, error) {
|
||||
this._deviceItems.forEach(function(i) { i.destroy(); });
|
||||
this._deviceItems = [];
|
||||
|
||||
@ -139,6 +136,7 @@ Indicator.prototype = {
|
||||
}
|
||||
|
||||
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)
|
||||
@ -153,7 +151,7 @@ Indicator.prototype = {
|
||||
},
|
||||
|
||||
_devicesChanged: function() {
|
||||
this._proxy.GetRemote('Icon', Lang.bind(this, function(icon, error) {
|
||||
let icon = this._proxy.Icon;
|
||||
if (icon) {
|
||||
let gicon = Gio.icon_new_for_string(icon);
|
||||
this.setGIcon(gicon);
|
||||
@ -162,7 +160,6 @@ Indicator.prototype = {
|
||||
this.menu.close();
|
||||
this.actor.hide();
|
||||
}
|
||||
}));
|
||||
this._readPrimaryDevice();
|
||||
this._readOtherDevices();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user