network: Don't pass a list of connections to the devices

Instead, just add them after they're constructed. This allows us to
not have to pass the connections to each device, and prevents issues
with having to enumerate the connections in the middle of construction.

https://bugzilla.gnome.org/show_bug.cgi?id=704670
This commit is contained in:
Jasper St. Pierre 2013-07-17 01:10:42 -04:00
parent fc6a0c1006
commit 39bff8bfbc

View File

@ -117,12 +117,11 @@ const NMDevice = new Lang.Class({
Name: 'NMDevice', Name: 'NMDevice',
Abstract: true, Abstract: true,
_init: function(client, device, connections) { _init: function(client, device) {
this._client = client; this._client = client;
this._setDevice(device); this._setDevice(device);
this._connections = []; this._connections = [];
connections.forEach(Lang.bind(this, this.checkConnection));
this._activeConnection = null; this._activeConnection = null;
this._activeConnectionItem = null; this._activeConnectionItem = null;
@ -463,7 +462,8 @@ const NMDeviceModem = new Lang.Class({
Extends: NMDevice, Extends: NMDevice,
category: NMConnectionCategory.WWAN, category: NMConnectionCategory.WWAN,
_init: function(client, device, connections) { _init: function(client, device) {
this.parent(client, device);
device._description = _("Mobile broadband"); device._description = _("Mobile broadband");
this.mobileDevice = null; this.mobileDevice = null;
@ -497,8 +497,6 @@ const NMDeviceModem = new Lang.Class({
this.emit('icon-changed'); this.emit('icon-changed');
})); }));
} }
this.parent(client, device, connections);
}, },
destroy: function() { destroy: function() {
@ -565,13 +563,11 @@ const NMDeviceModem = new Lang.Class({
const NMDeviceBluetooth = new Lang.Class({ const NMDeviceBluetooth = new Lang.Class({
Name: 'NMDeviceBluetooth', Name: 'NMDeviceBluetooth',
Extends: NMDevice, Extends: NMDevice,
category: NMConnectionCategory.WWAN,
_init: function(client, device, connections) { _init: function(client, device) {
this.parent(client, device);
device._description = _("Bluetooth"); device._description = _("Bluetooth");
this.category = NMConnectionCategory.WWAN;
this.parent(client, device, connections);
}, },
_activateAutomaticConnection: function() { _activateAutomaticConnection: function() {
@ -595,14 +591,13 @@ const NMDeviceBluetooth = new Lang.Class({
const NMDeviceWireless = new Lang.Class({ const NMDeviceWireless = new Lang.Class({
Name: 'NMDeviceWireless', Name: 'NMDeviceWireless',
Extends: NMDevice, Extends: NMDevice,
category: NMConnectionCategory.WIRELESS,
_init: function(client, device, connections) { _init: function(client, device) {
this.category = NMConnectionCategory.WIRELESS; this.parent(client, device);
this._networks = [ ]; this._networks = [ ];
this.parent(client, device, connections);
let accessPoints = device.get_access_points() || [ ]; let accessPoints = device.get_access_points() || [ ];
accessPoints.forEach(Lang.bind(this, function(ap) { accessPoints.forEach(Lang.bind(this, function(ap) {
this._accessPointAdded(this._device, ap); this._accessPointAdded(this._device, ap);
@ -1378,12 +1373,16 @@ const NMApplet = new Lang.Class({
let wrapperClass = this._dtypes[device.get_device_type()]; let wrapperClass = this._dtypes[device.get_device_type()];
if (wrapperClass) { if (wrapperClass) {
let wrapper = new wrapperClass(this._client, device, this._connections); let wrapper = new wrapperClass(this._client, device);
this._addDeviceWrapper(wrapper); this._addDeviceWrapper(wrapper);
this._nmDevices.push(device); this._nmDevices.push(device);
if (!skipSyncDeviceNames) if (!skipSyncDeviceNames)
this._syncDeviceNames(); this._syncDeviceNames();
this._connections.forEach(function(connection) {
wrapper.checkConnection(connection);
});
} }
}, },