diff options
author | Simon Schampijer <simon@schampijer.de> | 2009-08-18 05:59:30 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2009-12-01 17:54:33 (GMT) |
commit | 85de8e45beb078de882e2f0c6c56e99fff5ac3cd (patch) | |
tree | 1b4bb3a422d152b86ece0ba111fcee2e50cb34ff /src | |
parent | 3890cb055e106d4d682a5c32dd1111c35c9b1f9b (diff) |
Transmit the color of the ad-hoc network creator
The color is encoded in the essid
Diffstat (limited to 'src')
-rw-r--r-- | src/jarabe/desktop/meshbox.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py index 5e3658c..db5b71e 100644 --- a/src/jarabe/desktop/meshbox.py +++ b/src/jarabe/desktop/meshbox.py @@ -76,7 +76,7 @@ class AccessPointView(CanvasPulsingIcon): self._flags = 0 self._wpa_flags = 0 self._rsn_flags = 0 - self._mode = 0 + self._mode = network.NM_802_11_MODE_UNKNOWN self._device_caps = 0 self._device_state = None self._connection = None @@ -158,8 +158,12 @@ class AccessPointView(CanvasPulsingIcon): self._update_state() def _update_properties(self, properties): + if 'Mode' in properties: + self._mode = properties['Mode'] + self._color = None if 'Ssid' in properties: self._name = properties['Ssid'] + self._color = None if 'Strength' in properties: self._strength = properties['Strength'] if 'Flags' in properties: @@ -168,17 +172,21 @@ class AccessPointView(CanvasPulsingIcon): self._wpa_flags = properties['WpaFlags'] if 'RsnFlags' in properties: self._rsn_flags = properties['RsnFlags'] - if 'Mode' in properties: - self._mode = properties['Mode'] - - sh = sha.new() - data = self._name + hex(self._flags) - sh.update(data) - h = hash(sh.digest()) - idx = h % len(xocolor.colors) - self._color = XoColor('%s,%s' % (xocolor.colors[idx][0], - xocolor.colors[idx][1])) + if self._color == None: + if self._mode == network.NM_802_11_MODE_ADHOC: + encoded_color = self._name.split("#", 1) + if len(encoded_color) == 2: + self._color = XoColor('#' + encoded_color[1]) + if self._mode == network.NM_802_11_MODE_INFRA: + sh = sha.new() + data = self._name + hex(self._flags) + sh.update(data) + h = hash(sh.digest()) + idx = h % len(xocolor.colors) + + self._color = XoColor('%s,%s' % (xocolor.colors[idx][0], + xocolor.colors[idx][1])) self._update() |