network: Make the device field private
With getIndicatorIcon() replacing the main use of the .device field, we can make this a private API. https://bugzilla.gnome.org/show_bug.cgi?id=701954
This commit is contained in:
parent
6ef2d4a4cc
commit
465c77ddcf
@ -290,34 +290,34 @@ const NMDevice = new Lang.Class({
|
|||||||
|
|
||||||
_setDevice: function(device) {
|
_setDevice: function(device) {
|
||||||
if (device) {
|
if (device) {
|
||||||
this.device = device;
|
this._device = device;
|
||||||
this.device._delegate = this;
|
this._device._delegate = this;
|
||||||
this._stateChangedId = this.device.connect('state-changed', Lang.bind(this, this._deviceStateChanged));
|
this._stateChangedId = this._device.connect('state-changed', Lang.bind(this, this._deviceStateChanged));
|
||||||
this._activeConnectionChangedId = this.device.connect('notify::active-connection', Lang.bind(this, this._activeConnectionChanged));
|
this._activeConnectionChangedId = this._device.connect('notify::active-connection', Lang.bind(this, this._activeConnectionChanged));
|
||||||
} else if (this.device) {
|
} else if (this._device) {
|
||||||
this.device._delegate = null;
|
this._device._delegate = null;
|
||||||
|
|
||||||
if (this._stateChangedId) {
|
if (this._stateChangedId) {
|
||||||
// Need to go through GObject.Object.prototype because
|
// Need to go through GObject.Object.prototype because
|
||||||
// nm_device_disconnect conflicts with g_signal_disconnect
|
// nm_device_disconnect conflicts with g_signal_disconnect
|
||||||
GObject.Object.prototype.disconnect.call(this.device, this._stateChangedId);
|
GObject.Object.prototype.disconnect.call(this._device, this._stateChangedId);
|
||||||
this._stateChangedId = 0;
|
this._stateChangedId = 0;
|
||||||
}
|
}
|
||||||
if (this._activeConnectionChangedId) {
|
if (this._activeConnectionChangedId) {
|
||||||
GObject.Object.prototype.disconnect.call(this.device, this._activeConnectionChangedId);
|
GObject.Object.prototype.disconnect.call(this._device, this._activeConnectionChangedId);
|
||||||
this._stateChangedId = 0;
|
this._stateChangedId = 0;
|
||||||
}
|
}
|
||||||
if (this._firmwareChangedId) {
|
if (this._firmwareChangedId) {
|
||||||
GObject.Object.prototype.disconnect.call(this.device, this._firmwareChangedId);
|
GObject.Object.prototype.disconnect.call(this._device, this._firmwareChangedId);
|
||||||
this._firmwareChangedId = 0;
|
this._firmwareChangedId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.device = null;
|
this._device = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
this.device.disconnect(null);
|
this._device.disconnect(null);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ const NMDevice = new Lang.Class({
|
|||||||
// Otherwise, if no connection is currently configured,
|
// Otherwise, if no connection is currently configured,
|
||||||
// try automatic configuration (or summon the config dialog)
|
// try automatic configuration (or summon the config dialog)
|
||||||
if (this._connections.length == 1) {
|
if (this._connections.length == 1) {
|
||||||
this._client.activate_connection(this._connections[0].connection, this.device || null, null, null);
|
this._client.activate_connection(this._connections[0].connection, this._device || null, null, null);
|
||||||
return true;
|
return true;
|
||||||
} else if (this._connections.length == 0) {
|
} else if (this._connections.length == 0) {
|
||||||
return this._activateAutomaticConnection();
|
return this._activateAutomaticConnection();
|
||||||
@ -341,16 +341,16 @@ const NMDevice = new Lang.Class({
|
|||||||
|
|
||||||
_activateAutomaticConnection: function() {
|
_activateAutomaticConnection: function() {
|
||||||
let connection = new NetworkManager.Connection();
|
let connection = new NetworkManager.Connection();
|
||||||
this._client.add_and_activate_connection(connection, this.device, null, null);
|
this._client.add_and_activate_connection(connection, this._device, null, null);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
get connected() {
|
get connected() {
|
||||||
return this.device && this.device.state == NetworkManager.DeviceState.ACTIVATED;
|
return this._device && this._device.state == NetworkManager.DeviceState.ACTIVATED;
|
||||||
},
|
},
|
||||||
|
|
||||||
_activeConnectionChanged: function() {
|
_activeConnectionChanged: function() {
|
||||||
let activeConnection = this.device.active_connection;
|
let activeConnection = this._device.active_connection;
|
||||||
|
|
||||||
if (activeConnection == this._activeConnection)
|
if (activeConnection == this._activeConnection)
|
||||||
// nothing to do
|
// nothing to do
|
||||||
@ -368,7 +368,7 @@ const NMDevice = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
connectionValid: function(connection) {
|
connectionValid: function(connection) {
|
||||||
return this.device.connection_valid(connection);
|
return this._device.connection_valid(connection);
|
||||||
},
|
},
|
||||||
|
|
||||||
setEnabled: function(enabled) {
|
setEnabled: function(enabled) {
|
||||||
@ -377,10 +377,10 @@ const NMDevice = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getStatusLabel: function() {
|
getStatusLabel: function() {
|
||||||
if (!this.device)
|
if (!this._device)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
switch(this.device.state) {
|
switch(this._device.state) {
|
||||||
case NetworkManager.DeviceState.DISCONNECTED:
|
case NetworkManager.DeviceState.DISCONNECTED:
|
||||||
case NetworkManager.DeviceState.ACTIVATED:
|
case NetworkManager.DeviceState.ACTIVATED:
|
||||||
return null;
|
return null;
|
||||||
@ -404,8 +404,8 @@ const NMDevice = new Lang.Class({
|
|||||||
// firmware missing), that are exposed by different properties (whose state may
|
// firmware missing), that are exposed by different properties (whose state may
|
||||||
// or may not updated when we receive state-changed).
|
// or may not updated when we receive state-changed).
|
||||||
if (!this._firmwareChangedId)
|
if (!this._firmwareChangedId)
|
||||||
this._firmwareChangedId = this.device.connect('notify::firmware-missing', Lang.bind(this, this._substateChanged));
|
this._firmwareChangedId = this._device.connect('notify::firmware-missing', Lang.bind(this, this._substateChanged));
|
||||||
if (this.device.firmware_missing) {
|
if (this._device.firmware_missing) {
|
||||||
/* Translators: this is for devices that require some kind of firmware or kernel
|
/* Translators: this is for devices that require some kind of firmware or kernel
|
||||||
module, which is missing */
|
module, which is missing */
|
||||||
return _("firmware missing");
|
return _("firmware missing");
|
||||||
@ -416,14 +416,14 @@ const NMDevice = new Lang.Class({
|
|||||||
case NetworkManager.DeviceState.FAILED:
|
case NetworkManager.DeviceState.FAILED:
|
||||||
return _("connection failed");
|
return _("connection failed");
|
||||||
default:
|
default:
|
||||||
log('Device state invalid, is %d'.format(this.device.state));
|
log('Device state invalid, is %d'.format(this._device.state));
|
||||||
return 'invalid';
|
return 'invalid';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
syncDescription: function() {
|
syncDescription: function() {
|
||||||
if (this.device && this.device._description)
|
if (this._device && this._device._description)
|
||||||
this.statusItem.label.text = this.device._description;
|
this.statusItem.label.text = this._device._description;
|
||||||
},
|
},
|
||||||
|
|
||||||
_queueCreateSection: function() {
|
_queueCreateSection: function() {
|
||||||
@ -444,7 +444,7 @@ const NMDevice = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_shouldShowConnectionList: function() {
|
_shouldShowConnectionList: function() {
|
||||||
return (this.device.state >= NetworkManager.DeviceState.DISCONNECTED);
|
return (this._device.state >= NetworkManager.DeviceState.DISCONNECTED);
|
||||||
},
|
},
|
||||||
|
|
||||||
_createSection: function() {
|
_createSection: function() {
|
||||||
@ -482,7 +482,7 @@ const NMDevice = new Lang.Class({
|
|||||||
let item = new PopupMenu.PopupMenuItem(obj.name);
|
let item = new PopupMenu.PopupMenuItem(obj.name);
|
||||||
|
|
||||||
item.connect('activate', Lang.bind(this, function() {
|
item.connect('activate', Lang.bind(this, function() {
|
||||||
this._client.activate_connection(connection, this.device, null, null);
|
this._client.activate_connection(connection, this._device, null, null);
|
||||||
}));
|
}));
|
||||||
return item;
|
return item;
|
||||||
},
|
},
|
||||||
@ -523,7 +523,7 @@ const NMDevice = new Lang.Class({
|
|||||||
|
|
||||||
_updateStatusItem: function() {
|
_updateStatusItem: function() {
|
||||||
if (this._firmwareChangedId) {
|
if (this._firmwareChangedId) {
|
||||||
GObject.Object.prototype.disconnect.call(this.device, this._firmwareChangedId);
|
GObject.Object.prototype.disconnect.call(this._device, this._firmwareChangedId);
|
||||||
this._firmwareChangedId = 0;
|
this._firmwareChangedId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ const NMDeviceWired = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getIndicatorIcon: function() {
|
getIndicatorIcon: function() {
|
||||||
if (this.device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
if (this._device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
||||||
return 'network-wired-acquiring-symbolic';
|
return 'network-wired-acquiring-symbolic';
|
||||||
else
|
else
|
||||||
return 'network-wired-symbolic';
|
return 'network-wired-symbolic';
|
||||||
@ -638,7 +638,7 @@ const NMDeviceModem = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
get connected() {
|
get connected() {
|
||||||
return this._enabled && this.device.state == NetworkManager.DeviceState.ACTIVATED;
|
return this._enabled && this._device.state == NetworkManager.DeviceState.ACTIVATED;
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
@ -685,12 +685,12 @@ const NMDeviceModem = new Lang.Class({
|
|||||||
// Mobile wizard is too complex for the shell UI and
|
// Mobile wizard is too complex for the shell UI and
|
||||||
// is handled by the network panel
|
// is handled by the network panel
|
||||||
Util.spawn(['gnome-control-center', 'network',
|
Util.spawn(['gnome-control-center', 'network',
|
||||||
'connect-3g', this.device.get_path()]);
|
'connect-3g', this._device.get_path()]);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
getIndicatorIcon: function() {
|
getIndicatorIcon: function() {
|
||||||
if (this.device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
if (this._device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
||||||
return 'network-cellular-acquiring-symbolic';
|
return 'network-cellular-acquiring-symbolic';
|
||||||
|
|
||||||
if (!this.mobileDevice) {
|
if (!this.mobileDevice) {
|
||||||
@ -725,7 +725,7 @@ const NMDeviceBluetooth = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getIndicatorIcon: function() {
|
getIndicatorIcon: function() {
|
||||||
if (this.device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
if (this._device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
||||||
return 'network-wired-acquiring-symbolic';
|
return 'network-wired-acquiring-symbolic';
|
||||||
else
|
else
|
||||||
return 'network-wired-symbolic';
|
return 'network-wired-symbolic';
|
||||||
@ -746,7 +746,7 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
|
|
||||||
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);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._activeApChanged();
|
this._activeApChanged();
|
||||||
@ -760,17 +760,17 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
destroy: function() {
|
destroy: function() {
|
||||||
if (this._apChangedId) {
|
if (this._apChangedId) {
|
||||||
// see above for this HACK
|
// see above for this HACK
|
||||||
GObject.Object.prototype.disconnect.call(this.device, this._apChangedId);
|
GObject.Object.prototype.disconnect.call(this._device, this._apChangedId);
|
||||||
this._apChangedId = 0;
|
this._apChangedId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._apAddedId) {
|
if (this._apAddedId) {
|
||||||
GObject.Object.prototype.disconnect.call(this.device, this._apAddedId);
|
GObject.Object.prototype.disconnect.call(this._device, this._apAddedId);
|
||||||
this._apAddedId = 0;
|
this._apAddedId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._apRemovedId) {
|
if (this._apRemovedId) {
|
||||||
GObject.Object.prototype.disconnect.call(this.device, this._apRemovedId);
|
GObject.Object.prototype.disconnect.call(this._device, this._apRemovedId);
|
||||||
this._apRemovedId = 0;
|
this._apRemovedId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -798,14 +798,14 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
if (accessPoint.get_ssid() != null) {
|
if (accessPoint.get_ssid() != null) {
|
||||||
accessPoint.disconnect(accessPoint._notifySsidId);
|
accessPoint.disconnect(accessPoint._notifySsidId);
|
||||||
accessPoint._notifySsidId = 0;
|
accessPoint._notifySsidId = 0;
|
||||||
this._accessPointAdded(this.device, accessPoint);
|
this._accessPointAdded(this._device, accessPoint);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_activeApChanged: function() {
|
_activeApChanged: function() {
|
||||||
this._activeNetwork = null;
|
this._activeNetwork = null;
|
||||||
|
|
||||||
let activeAp = this.device.active_access_point;
|
let activeAp = this._device.active_access_point;
|
||||||
|
|
||||||
if (activeAp) {
|
if (activeAp) {
|
||||||
let res = this._findExistingNetwork(activeAp);
|
let res = this._findExistingNetwork(activeAp);
|
||||||
@ -1138,7 +1138,7 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
else
|
else
|
||||||
title = _("Connected (private)");
|
title = _("Connected (private)");
|
||||||
|
|
||||||
this._activeConnectionItem = new NMNetworkMenuItem(this.device.active_access_point);
|
this._activeConnectionItem = new NMNetworkMenuItem(this._device.active_access_point);
|
||||||
this._activeConnectionItem.setSensitive(false);
|
this._activeConnectionItem.setSensitive(false);
|
||||||
this._activeConnectionItem.setOrnament(PopupMenu.Ornament.DOT);
|
this._activeConnectionItem.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
},
|
},
|
||||||
@ -1157,7 +1157,7 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
let accessPoints = network.accessPoints;
|
let accessPoints = network.accessPoints;
|
||||||
for (let i = 0; i < accessPoints.length; i++) {
|
for (let i = 0; i < accessPoints.length; i++) {
|
||||||
if (accessPoints[i].connection_valid(connection)) {
|
if (accessPoints[i].connection_valid(connection)) {
|
||||||
this._client.activate_connection(connection, this.device, accessPoints[i].dbus_path, null);
|
this._client.activate_connection(connection, this._device, accessPoints[i].dbus_path, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1170,10 +1170,10 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
// 802.1x-enabled APs require further configuration, so they're
|
// 802.1x-enabled APs require further configuration, so they're
|
||||||
// handled in gnome-control-center
|
// handled in gnome-control-center
|
||||||
Util.spawn(['gnome-control-center', 'network', 'connect-8021x-wifi',
|
Util.spawn(['gnome-control-center', 'network', 'connect-8021x-wifi',
|
||||||
this.device.get_path(), accessPoints[0].dbus_path]);
|
this._device.get_path(), accessPoints[0].dbus_path]);
|
||||||
} else {
|
} else {
|
||||||
let connection = new NetworkManager.Connection();
|
let connection = new NetworkManager.Connection();
|
||||||
this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null)
|
this._client.add_and_activate_connection(connection, this._device, accessPoints[0].dbus_path, null)
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -1215,7 +1215,7 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateAccessPoint: function() {
|
_updateAccessPoint: function() {
|
||||||
let ap = this.device.active_access_point;
|
let ap = this._device.active_access_point;
|
||||||
if (this._activeAccessPoint == ap)
|
if (this._activeAccessPoint == ap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1239,12 +1239,12 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getIndicatorIcon: function() {
|
getIndicatorIcon: function() {
|
||||||
if (this.device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
if (this._device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
||||||
return 'network-wireless-acquiring-symbolic';
|
return 'network-wireless-acquiring-symbolic';
|
||||||
|
|
||||||
let ap = this.device.active_access_point;
|
let ap = this._device.active_access_point;
|
||||||
if (!ap) {
|
if (!ap) {
|
||||||
if (this.device.mode != NM80211Mode.ADHOC)
|
if (this._device.mode != NM80211Mode.ADHOC)
|
||||||
log('An active wireless connection, in infrastructure mode, involves no access point?');
|
log('An active wireless connection, in infrastructure mode, involves no access point?');
|
||||||
|
|
||||||
return 'network-wireless-connected-symbolic';
|
return 'network-wireless-connected-symbolic';
|
||||||
@ -1273,7 +1273,7 @@ const NMDeviceVirtual = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
addConnection: function(connection) {
|
addConnection: function(connection) {
|
||||||
if (!this.device && !this.hasConnections())
|
if (!this._device && !this.hasConnections())
|
||||||
this.statusItem.label.text = NMGtk.utils_get_connection_device_name(connection);
|
this.statusItem.label.text = NMGtk.utils_get_connection_device_name(connection);
|
||||||
|
|
||||||
this.parent(connection);
|
this.parent(connection);
|
||||||
@ -1292,7 +1292,7 @@ const NMDeviceVirtual = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeDevice: function(device) {
|
removeDevice: function(device) {
|
||||||
if (device == this.device) {
|
if (device == this._device) {
|
||||||
this._setDevice(null);
|
this._setDevice(null);
|
||||||
this._updateStatusItem();
|
this._updateStatusItem();
|
||||||
this.emit('state-changed');
|
this.emit('state-changed');
|
||||||
@ -1304,7 +1304,7 @@ const NMDeviceVirtual = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getIndicatorIcon: function() {
|
getIndicatorIcon: function() {
|
||||||
if (this.device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
if (this._device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
||||||
return 'network-wired-acquiring-symbolic';
|
return 'network-wired-acquiring-symbolic';
|
||||||
else
|
else
|
||||||
return 'network-wired-connected-symbolic';
|
return 'network-wired-connected-symbolic';
|
||||||
|
Loading…
Reference in New Issue
Block a user