Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/extensions
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 /extensions
parent5b527f2a1ea28f66694cb2ba5fcb65a9d1dc9255 (diff)
Transmit the color of the ad-hoc network creator
The color is encoded in the essid
Diffstat (limited to 'extensions')
-rw-r--r--extensions/deviceicon/network.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 5016943..0803936 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -215,6 +215,7 @@ class WirelessDeviceView(ToolButton):
self._device_props = None
self._flags = 0
self._name = ''
+ self._mode = network.NM_802_11_MODE_UNKNOWN
self._strength = 0
self._frequency = 0
self._device_state = None
@@ -308,8 +309,12 @@ class WirelessDeviceView(ToolButton):
self._update_properties(properties)
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:
@@ -317,14 +322,21 @@ class WirelessDeviceView(ToolButton):
if 'Frequency' in properties:
self._frequency = properties['Frequency']
- sh = hashlib.sha1()
- data = self._name + hex(self._flags)
- sh.update(data)
- h = hash(sh.digest())
- idx = h % len(xocolor.colors)
-
- self._color = xocolor.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.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.XoColor('%s,%s' %
+ (xocolor.colors[index][0],
+ xocolor.colors[index][1]))
self._update()
def __get_all_ap_props_reply_cb(self, properties):
@@ -399,7 +411,8 @@ class WirelessDeviceView(ToolButton):
def __create_connection_cb(self, palette, data=None):
client = gconf.client_get_default()
nick = client.get_string('/desktop/sugar/user/nick')
- connection_name = _('%s\'s network') % nick
+ color = client.get_string('/desktop/sugar/user/color')
+ connection_name = _('%s\'s network %s') % (nick, color)
connection = network.find_connection(connection_name)
if connection is None: