From 96c3df2b4dab87194974c943cea17bb1dbd2510d Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd@laptop.org>
Date: Fri, 4 Dec 2009 16:24:09 +0000
Subject: [PATCH 1/2] Revert "Transmit the color of the ad-hoc network creator"
This reverts commit 7363fc1f72ee74d2da534eb16de608634e1b7398.
This uses up too much of the 32-character SSID, limiting the user's
name that appears in the network name to just 6 characters.
Conflicts:
src/jarabe/desktop/meshbox.py
---
extensions/deviceicon/network.py | 31 +++++++++----------------------
src/jarabe/desktop/meshbox.py | 21 ++++++++-------------
2 files changed, 17 insertions(+), 35 deletions(-)
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index dd1a70c..75bc467 100644
a
|
b
|
class WirelessDeviceView(ToolButton): |
215 | 215 | self._device_props = None |
216 | 216 | self._flags = 0 |
217 | 217 | self._name = '' |
218 | | self._mode = network.NM_802_11_MODE_UNKNOWN |
219 | 218 | self._strength = 0 |
220 | 219 | self._frequency = 0 |
221 | 220 | self._device_state = None |
… |
… |
class WirelessDeviceView(ToolButton): |
309 | 308 | self._update_properties(properties) |
310 | 309 | |
311 | 310 | def _update_properties(self, properties): |
312 | | if 'Mode' in properties: |
313 | | self._mode = properties['Mode'] |
314 | | self._color = None |
315 | 311 | if 'Ssid' in properties: |
316 | 312 | self._name = properties['Ssid'] |
317 | | self._color = None |
318 | 313 | if 'Strength' in properties: |
319 | 314 | self._strength = properties['Strength'] |
320 | 315 | if 'Flags' in properties: |
… |
… |
class WirelessDeviceView(ToolButton): |
322 | 317 | if 'Frequency' in properties: |
323 | 318 | self._frequency = properties['Frequency'] |
324 | 319 | |
325 | | if self._color == None: |
326 | | if self._mode == network.NM_802_11_MODE_ADHOC: |
327 | | encoded_color = self._name.split("#", 1) |
328 | | if len(encoded_color) == 2: |
329 | | self._color = xocolor.XoColor('#' + encoded_color[1]) |
330 | | if self._mode == network.NM_802_11_MODE_INFRA: |
331 | | sha_hash = hashlib.sha1() |
332 | | data = self._name + hex(self._flags) |
333 | | sha_hash.update(data) |
334 | | digest = hash(sha_hash.digest()) |
335 | | index = digest % len(xocolor.colors) |
336 | | |
337 | | self._color = xocolor.XoColor('%s,%s' % |
338 | | (xocolor.colors[index][0], |
339 | | xocolor.colors[index][1])) |
| 320 | sh = hashlib.sha1() |
| 321 | data = self._name + hex(self._flags) |
| 322 | sh.update(data) |
| 323 | h = hash(sh.digest()) |
| 324 | idx = h % len(xocolor.colors) |
| 325 | |
| 326 | self._color = xocolor.XoColor('%s,%s' % (xocolor.colors[idx][0], |
| 327 | xocolor.colors[idx][1])) |
340 | 328 | self._update() |
341 | 329 | |
342 | 330 | def __get_all_ap_props_reply_cb(self, properties): |
… |
… |
class WirelessDeviceView(ToolButton): |
411 | 399 | def __create_connection_cb(self, palette, data=None): |
412 | 400 | client = gconf.client_get_default() |
413 | 401 | nick = client.get_string('/desktop/sugar/user/nick') |
414 | | color = client.get_string('/desktop/sugar/user/color') |
415 | | connection_name = _('%s\'s network %s') % (nick, color) |
| 402 | connection_name = _('%s\'s network') % nick |
416 | 403 | |
417 | 404 | connection = network.find_connection(connection_name) |
418 | 405 | if connection is None: |
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 9fee736..6493bef 100644
a
|
b
|
class WirelessNetworkView(CanvasPulsingIcon): |
85 | 85 | self._connection = None |
86 | 86 | self._color = None |
87 | 87 | |
88 | | if self._mode == network.NM_802_11_MODE_ADHOC: |
89 | | encoded_color = self._name.split("#", 1) |
90 | | if len(encoded_color) == 2: |
91 | | self._color = xocolor.XoColor('#' + encoded_color[1]) |
92 | | if self._mode == network.NM_802_11_MODE_INFRA: |
93 | | sha_hash = hashlib.sha1() |
94 | | data = self._name + hex(self._flags) |
95 | | sha_hash.update(data) |
96 | | digest = hash(sha_hash.digest()) |
97 | | index = digest % len(xocolor.colors) |
98 | | |
99 | | self._color = xocolor.XoColor('%s,%s' % |
100 | | (xocolor.colors[index][0], |
101 | | xocolor.colors[index][1])) |
| 88 | sha_hash = hashlib.sha1() |
| 89 | data = self._name + hex(self._flags) |
| 90 | sha_hash.update(data) |
| 91 | digest = hash(sha_hash.digest()) |
| 92 | index = digest % len(xocolor.colors) |
| 93 | |
| 94 | self._color = xocolor.XoColor('%s,%s' % |
| 95 | (xocolor.colors[index][0], |
| 96 | xocolor.colors[index][1])) |
102 | 97 | |
103 | 98 | self.connect('button-release-event', self.__button_release_event_cb) |
104 | 99 | |