Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2009-08-18 05:59:30 (GMT)
committer Simon Schampijer <simon@schampijer.de>2009-08-18 05:59:30 (GMT)
commit7363fc1f72ee74d2da534eb16de608634e1b7398 (patch)
tree1ddea3680ba08a2861e3c1db170d864b3ecad97d /src
parent5b527f2a1ea28f66694cb2ba5fcb65a9d1dc9255 (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.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index de1f18d..c37bba1 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,18 +172,22 @@ 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 = hashlib.sha1()
- 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:
+ sha_hash = hashlib.sha1()
+ data = self._name + hex(self._flags)
+ sha_hash.update(data)
+ digest = hash(sha_hash.digest())
+ index = digest % len(xocolor.colors)
+
+ self._color = XoColor('%s,%s' %
+ (xocolor.colors[index][0],
+ xocolor.colors[index][1]))
self._update()
def __get_active_ap_reply_cb(self, ap):