[gnome-shell] network: ignore unrecognized/irrelevant devices/connections



commit 1c927868d812fa3127c32402248b558dcb507ced
Author: Dan Winship <danw gnome org>
Date:   Tue Aug 21 10:55:40 2012 -0400

    network: ignore unrecognized/irrelevant devices/connections
    
    Don't log a warning if an unrecognized device type is seen.
    
    Don't show slave connections in the menu. (Eg, don't show the
    individual wired connections making up a bond, since they can't be
    used individually.)
    
    Make the icon only reflect the status of connections that are visible
    in the menu. (ie, don't show the "connecting" icon when an
    unrecognized connection type is connecting, and don't show a
    "connected" status if the only active connections are of unrecognized
    types.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682364

 js/ui/status/network.js |   44 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 82dbbcf..cb1991c 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1832,8 +1832,7 @@ const NMApplet = new Lang.Class({
             devices.push(wrapper);
 
             this._syncSectionTitle(wrapper.category);
-        } else
-            log('Invalid network device type, is ' + device.get_device_type());
+        }
     },
 
     _deviceRemoved: function(client, device) {
@@ -1852,9 +1851,32 @@ const NMApplet = new Lang.Class({
         this._syncSectionTitle(wrapper.category)
     },
 
+    _getSupportedActiveConnections: function() {
+        let activeConnections = this._client.get_active_connections() || [ ];
+        let supportedConnections = [];
+
+        for (let i = 0; i < activeConnections.length; i++) {
+            let devices = activeConnections[i].get_devices();
+            if (!devices || !devices[0])
+                continue;
+            // Ignore connections via unrecognized device types
+            if (!this._dtypes[devices[0].device_type])
+                continue;
+
+            // Ignore slave connections
+            let connectionPath = activeConnections[i].connection;
+            let connection = this._settings.get_connection_by_path(connectionPath)
+            if (this._ignoreConnection(connection))
+                continue;
+
+            supportedConnections.push(activeConnections[i]);
+        }
+        return supportedConnections;
+    },
+
     _syncActiveConnections: function() {
         let closedConnections = [ ];
-        let newActiveConnections = this._client.get_active_connections() || [ ];
+        let newActiveConnections = this._getSupportedActiveConnections();
         for (let i = 0; i < this._activeConnections.length; i++) {
             let a = this._activeConnections[i];
             if (newActiveConnections.indexOf(a) == -1) // connection is removed
@@ -1958,10 +1980,24 @@ const NMApplet = new Lang.Class({
         this._updateIcon();
     },
 
+    _ignoreConnection: function(connection) {
+        let setting = connection.get_setting_connection();
+        if (!setting)
+            return true;
+
+        // Ignore slave connections
+        if (setting.get_master())
+            return true;
+
+        return false;
+    },
+
     _readConnections: function() {
         let connections = this._settings.list_connections();
         for (let i = 0; i < connections.length; i++) {
             let connection = connections[i];
+            if (this._ignoreConnection(connection))
+                continue;
             if (connection._updatedId) {
                 // connection was already seen (for example because NetworkManager was restarted)
                 continue;
@@ -1975,6 +2011,8 @@ const NMApplet = new Lang.Class({
     },
 
     _newConnection: function(settings, connection) {
+        if (this._ignoreConnection(connection))
+            return;
         if (connection._updatedId) {
             // connection was already seen
             return;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]