[gnome-shell/wip/message-tray-menu: 103/109] network: Use accessPointAdded to add initial access points
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/message-tray-menu: 103/109] network: Use accessPointAdded to add initial access points
- Date: Thu, 9 May 2013 15:45:00 +0000 (UTC)
commit 8aaf7cffd6a1e479196666f4f436948f1057f4fc
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Apr 29 12:28:02 2013 -0400
network: Use accessPointAdded to add initial access points
This is technically a smidge slower due to the constant bisect insert,
but since this should only happen when we make a Wi-Fi dialog, it's
insignificant.
js/ui/status/network.js | 64 +++--------------------------------------------
1 files changed, 4 insertions(+), 60 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index b07c09c..fe9f56c 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -64,13 +64,6 @@ function signalToIcon(value) {
return 'none';
}
-// shared between NMNetworkMenuItem and NMDeviceWireless
-function sortAccessPoints(accessPoints) {
- return accessPoints.sort(function (one, two) {
- return two.strength - one.strength;
- });
-}
-
function ssidToLabel(ssid) {
let label = NetworkManager.utils_ssid_to_utf8(ssid);
if (!label)
@@ -661,61 +654,14 @@ const NMDeviceWireless = new Lang.Class({
_init: function(client, device, connections) {
this.category = NMConnectionCategory.WIRELESS;
-
this._networks = [ ];
- // breaking the layers with this, but cannot call
- // this.connectionValid until I have a device
- this.device = device;
+ this.parent(client, device, connections);
- let validConnections = connections.filter(Lang.bind(this, function(connection) {
- return this.connectionValid(connection);
- }));
let accessPoints = device.get_access_points() || [ ];
- for (let i = 0; i < accessPoints.length; i++) {
- // Access points are grouped by network
- let ap = accessPoints[i];
-
- if (ap.get_ssid() == null) {
- // hidden access point cannot be added, we need to know
- // the SSID and security details to connect
- // nevertheless, the access point can acquire a SSID when
- // NetworkManager connects to it (via nmcli or the control-center)
- ap._notifySsidId = ap.connect('notify::ssid', Lang.bind(this, this._notifySsidCb));
- continue;
- }
-
- let pos = this._findNetwork(ap);
- let network;
- if (pos != -1) {
- network = this._networks[pos];
- network.accessPoints.push(ap);
- } else {
- network = { ssid: ap.get_ssid(),
- mode: ap.mode,
- security: this._getApSecurityType(ap),
- connections: [ ],
- item: null,
- accessPoints: [ ap ]
- };
- network.ssidText = ssidToLabel(network.ssid);
- this._networks.push(network);
- }
- ap._updateId = ap.connect('notify::strength', Lang.bind(this, this._onApStrengthChanged));
-
- // Check if some connection is valid for this AP
- for (let j = 0; j < validConnections.length; j++) {
- let connection = validConnections[j];
- if (ap.connection_valid(connection) &&
- network.connections.indexOf(connection) == -1) {
- network.connections.push(connection);
- }
- }
- }
-
- // Sort APs within each network by strength
- for (let i = 0; i < this._networks.length; i++)
- sortAccessPoints(this._networks[i].accessPoints);
+ accessPoints.forEach(Lang.bind(this, function(ap) {
+ this._accessPointAdded(this.device, ap);
+ }));
this._activeApChanged();
this._networks.sort(this._networkSortFunction);
@@ -723,8 +669,6 @@ const NMDeviceWireless = new Lang.Class({
this._apChangedId = device.connect('notify::active-access-point', Lang.bind(this,
this._activeApChanged));
this._apAddedId = device.connect('access-point-added', Lang.bind(this, this._accessPointAdded));
this._apRemovedId = device.connect('access-point-removed', Lang.bind(this,
this._accessPointRemoved));
-
- this.parent(client, device, validConnections);
},
destroy: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]