[Sugar-devel] [PATCH 3/4] fix AP association failure after removing encryption #1674
James Cameron
quozl at laptop.org
Wed Apr 21 21:11:11 EDT 2010
Mesh box already segregates access points with the same SSID, but
clicking on them treats them all the same. This leads to failure to
associate with an AP after encryption has been removed, and the
favourite badge icon appears on the wrong icon.
This patch changes the naming of the network connections settings to
use the encryption type as well as the SSID, so that actions against
AP icons in the mesh box are more consistent. The name now has a
security type appended.
Now, when an AP changes from open to encrypted, the connection is
lost, the icon for the open AP loses the highlight, a new icon appears
for the newly scanned encrypted AP, and if it is clicked a key dialog
occurs and the connection succeeds. (Prior to this patch, a discard
network history action was required).
Now, when an AP changes from encrypted to open, the connection is
lost, the icon for the open AP loses the highlight, and a new icon
appears for the newly scanned open AP. (At this point also
NetworkManager emits a spurious GetSecrets method, which if it occurs
can be cancelled by the user). If the new icon is clicked, connection
succeeds. (Prior to this patch, clicking the new icon would retry a
connection to the now missing encrypted AP, and a discard network
history action was required).
Now, when an encrypted AP changes passphrase, the connection is lost,
the icon for the AP does not lose the highlight, and there is no user
indication of connection loss. If the icon is clicked again,
connection is retried, and a new key dialog issued for the new key.
References:
http://dev.laptop.org/ticket/9977
http://bugs.sugarlabs.org/ticket/1674
---
extensions/deviceicon/network.py | 10 ++++----
src/jarabe/desktop/meshbox.py | 39 +++++++++++++++++++++++++++++++------
2 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index f790c91..3d77215 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -398,11 +398,6 @@ class WirelessDeviceView(ToolButton):
self._icon.props.base_color = self._color
def __deactivate_connection_cb(self, palette, data=None):
- connection = network.find_connection(self._name)
- if connection:
- if self._mode == network.NM_802_11_MODE_INFRA:
- connection.set_disconnected()
-
if self._active_ap_op is not None:
obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
netmgr = dbus.Interface(obj, _NM_IFACE)
@@ -413,8 +408,13 @@ class WirelessDeviceView(ToolButton):
for conn_o in active_connections_o:
obj = self._bus.get_object(_NM_IFACE, conn_o)
props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
+ path = props.Get(_NM_ACTIVE_CONN_IFACE, 'Connection')
ap_op = props.Get(_NM_ACTIVE_CONN_IFACE, 'SpecificObject')
if ap_op == self._active_ap_op:
+ if self._mode == network.NM_802_11_MODE_INFRA:
+ conn = network.find_connection_by_path(path)
+ if conn is not None:
+ conn.set_disconnected()
netmgr.DeactivateConnection(conn_o)
break
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 81363ac..54b3720 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -211,7 +211,7 @@ class WirelessNetworkView(CanvasPulsingIcon):
state = network.DEVICE_STATE_UNKNOWN
if state == network.DEVICE_STATE_ACTIVATED:
- connection = network.find_connection(self._name)
+ connection = network.find_connection(self._get_settings_name())
if connection:
if self._mode == network.NM_802_11_MODE_INFRA:
connection.set_connected()
@@ -256,7 +256,7 @@ class WirelessNetworkView(CanvasPulsingIcon):
self.props.base_color = self._color
def _update_badge(self):
- if network.find_connection(self._name) is not None:
+ if network.find_connection(self._get_settings_name()) is not None:
self.props.badge_name = "emblem-favorite"
self._palette_icon.props.badge_name = "emblem-favorite"
elif self._flags == network.NM_802_11_AP_FLAGS_PRIVACY:
@@ -267,7 +267,7 @@ class WirelessNetworkView(CanvasPulsingIcon):
self._palette_icon.props.badge_name = None
def _disconnect_activate_cb(self, item):
- connection = network.find_connection(self._name)
+ connection = network.find_connection(self._get_settings_name())
if connection:
if self._mode == network.NM_802_11_MODE_INFRA:
connection.set_disconnected()
@@ -353,6 +353,29 @@ class WirelessNetworkView(CanvasPulsingIcon):
wireless_security.group = group
return wireless_security
+ def _get_settings_name_security(self):
+ if not (self._flags & network.NM_802_11_AP_FLAGS_PRIVACY) and \
+ (self._wpa_flags == network.NM_802_11_AP_SEC_NONE) and \
+ (self._rsn_flags == network.NM_802_11_AP_SEC_NONE):
+ return 'open'
+
+ if (self._flags & network.NM_802_11_AP_FLAGS_PRIVACY) and \
+ (self._wpa_flags == network.NM_802_11_AP_SEC_NONE) and \
+ (self._rsn_flags == network.NM_802_11_AP_SEC_NONE):
+ return 'wep'
+
+ if (self._rsn_flags & network.NM_802_11_AP_SEC_KEY_MGMT_PSK) and \
+ (self._device_caps & network.NM_802_11_DEVICE_CAP_RSN):
+ return 'wpa psk rsn'
+
+ if (self._wpa_flags & network.NM_802_11_AP_SEC_KEY_MGMT_PSK) and \
+ (self._device_caps & network.NM_802_11_DEVICE_CAP_WPA):
+ return 'wpa psk'
+
+ def _get_settings_name(self):
+ """ internal name for this network connection settings """
+ return 'Auto ' + self._name + ' ' + self._get_settings_name_security()
+
def __connect_activate_cb(self, icon):
self._connect()
@@ -360,10 +383,12 @@ class WirelessNetworkView(CanvasPulsingIcon):
self._connect()
def _connect(self):
- connection = network.find_connection(self._name)
+ name = self._get_settings_name()
+ connection = network.find_connection(name)
+
if connection is None:
- settings = Settings()
- settings.connection.id = 'Auto ' + self._name
+ settings = Settings()
+ settings.connection.id = name
settings.connection.uuid = unique_id()
settings.connection.type = '802-11-wireless'
settings.wireless.ssid = self._name
@@ -382,7 +407,7 @@ class WirelessNetworkView(CanvasPulsingIcon):
if wireless_security is not None:
settings.wireless.security = '802-11-wireless-security'
- connection = network.add_connection(self._name, settings)
+ connection = network.add_connection(name, settings)
obj = self._bus.get_object(_NM_SERVICE, _NM_PATH)
netmgr = dbus.Interface(obj, _NM_IFACE)
--
1.7.0
--
James Cameron
http://quozl.linux.org.au/
More information about the Sugar-devel
mailing list