From 90019362eaba824a8977241aece203c75805675d Mon Sep 17 00:00:00 2001
From: Simon Schampijer <simon@schampijer.de>
Date: Thu, 26 Aug 2010 17:53:12 +0200
Subject: [PATCH] AP: signal strength update not seperate from state change
---
src/jarabe/desktop/networkviews.py | 67 +++++++++++++++++------------------
1 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py
index 121c817..48d8747 100644
a
|
b
|
class WirelessNetworkView(CanvasPulsingIcon): |
159 | 159 | def __device_state_changed_cb(self, new_state, old_state, reason): |
160 | 160 | self._device_state = new_state |
161 | 161 | self._update_state() |
| 162 | self._update_icon() |
162 | 163 | |
163 | 164 | def __update_active_ap(self, ap_path): |
164 | 165 | if ap_path in self._access_points: |
… |
… |
class WirelessNetworkView(CanvasPulsingIcon): |
166 | 167 | # strength of that one |
167 | 168 | self._active_ap = self._access_points[ap_path] |
168 | 169 | self.update_strength() |
169 | | self._update_state() |
170 | 170 | elif self._active_ap is not None: |
171 | 171 | # revert to showing state of strongest AP again |
172 | 172 | self._active_ap = None |
173 | 173 | self.update_strength() |
174 | | self._update_state() |
175 | 174 | |
176 | 175 | def __wireless_properties_changed_cb(self, properties): |
177 | 176 | if 'ActiveAccessPoint' in properties: |
… |
… |
class WirelessNetworkView(CanvasPulsingIcon): |
191 | 190 | |
192 | 191 | def __get_device_state_reply_cb(self, state): |
193 | 192 | self._device_state = state |
194 | | self._update() |
195 | | |
196 | | def __get_device_state_error_cb(self, err): |
197 | | logging.error('Error getting the device state: %s', err) |
198 | | |
199 | | def _update(self): |
200 | 193 | self._update_state() |
201 | 194 | self._update_color() |
202 | 195 | |
203 | | def _update_state(self): |
204 | | if self._active_ap is not None: |
205 | | state = self._device_state |
206 | | else: |
207 | | state = network.DEVICE_STATE_UNKNOWN |
| 196 | def __get_device_state_error_cb(self, err): |
| 197 | logging.error('Error getting the device state: %s', err) |
208 | 198 | |
| 199 | def _update_icon(self): |
209 | 200 | if self._mode == network.NM_802_11_MODE_ADHOC and \ |
210 | 201 | network.is_sugar_adhoc_network(self._name): |
211 | 202 | channel = max([1] + [ap.channel for ap in |
212 | 203 | self._access_points.values()]) |
213 | | if state == network.DEVICE_STATE_ACTIVATED: |
| 204 | if self._device_state == network.DEVICE_STATE_ACTIVATED and \ |
| 205 | self._active_ap is not None: |
214 | 206 | icon_name = 'network-adhoc-%s-connected' % channel |
215 | 207 | else: |
216 | 208 | icon_name = 'network-adhoc-%s' % channel |
… |
… |
class WirelessNetworkView(CanvasPulsingIcon): |
218 | 210 | icon = self._palette.props.icon |
219 | 211 | icon.props.icon_name = icon_name |
220 | 212 | else: |
221 | | if state == network.DEVICE_STATE_ACTIVATED: |
222 | | connection = network.find_connection_by_ssid(self._name) |
223 | | if connection is not None: |
224 | | if self._mode == network.NM_802_11_MODE_INFRA: |
225 | | connection.set_connected() |
| 213 | if self._device_state == network.DEVICE_STATE_ACTIVATED and \ |
| 214 | self._active_ap is not None: |
226 | 215 | icon_name = '%s-connected' % _AP_ICON_NAME |
227 | 216 | else: |
228 | 217 | icon_name = _AP_ICON_NAME |
… |
… |
class WirelessNetworkView(CanvasPulsingIcon): |
233 | 222 | icon = self._palette.props.icon |
234 | 223 | icon.props.icon_name = icon_name |
235 | 224 | |
| 225 | def _update_state(self): |
| 226 | if self._active_ap is not None: |
| 227 | state = self._device_state |
| 228 | else: |
| 229 | state = network.DEVICE_STATE_UNKNOWN |
| 230 | |
236 | 231 | if state == network.DEVICE_STATE_PREPARE or \ |
237 | 232 | state == network.DEVICE_STATE_CONFIG or \ |
238 | 233 | state == network.DEVICE_STATE_NEED_AUTH or \ |
… |
… |
class WirelessNetworkView(CanvasPulsingIcon): |
243 | 238 | self._palette.props.secondary_text = _('Connecting...') |
244 | 239 | self.props.pulsing = True |
245 | 240 | elif state == network.DEVICE_STATE_ACTIVATED: |
| 241 | connection = network.find_connection_by_ssid(self._name) |
| 242 | if connection is not None: |
| 243 | if self._mode == network.NM_802_11_MODE_INFRA: |
| 244 | connection.set_connected() |
246 | 245 | if self._disconnect_item: |
247 | 246 | self._disconnect_item.show() |
248 | 247 | self._connect_item.hide() |
… |
… |
class WirelessNetworkView(CanvasPulsingIcon): |
262 | 261 | else: |
263 | 262 | self.props.base_color = self._color |
264 | 263 | |
| 264 | def update_strength(self): |
| 265 | if self._active_ap is not None: |
| 266 | # display strength of AP that we are connected to |
| 267 | new_strength = self._active_ap.strength |
| 268 | else: |
| 269 | # display the strength of the strongest AP that makes up this |
| 270 | # network, also considering that there may be no APs |
| 271 | new_strength = max([0] + [ap.strength for ap in |
| 272 | self._access_points.values()]) |
| 273 | |
| 274 | if new_strength != self._strength: |
| 275 | self._strength = new_strength |
| 276 | self._update_icon() |
| 277 | |
265 | 278 | def _disconnect_activate_cb(self, item): |
266 | 279 | pass |
267 | 280 | |
… |
… |
class WirelessNetworkView(CanvasPulsingIcon): |
376 | 389 | |
377 | 390 | def set_filter(self, query): |
378 | 391 | self._greyed_out = self._name.lower().find(query) == -1 |
379 | | self._update_state() |
| 392 | self._update_icon() |
380 | 393 | self._update_color() |
381 | 394 | |
382 | 395 | def create_keydialog(self, settings, response): |
383 | 396 | keydialog.create(self._name, self._flags, self._wpa_flags, |
384 | 397 | self._rsn_flags, self._device_caps, settings, response) |
385 | 398 | |
386 | | def update_strength(self): |
387 | | if self._active_ap is not None: |
388 | | # display strength of AP that we are connected to |
389 | | new_strength = self._active_ap.strength |
390 | | else: |
391 | | # display the strength of the strongest AP that makes up this |
392 | | # network, also considering that there may be no APs |
393 | | new_strength = max([0] + [ap.strength for ap in |
394 | | self._access_points.values()]) |
395 | | |
396 | | if new_strength != self._strength: |
397 | | self._strength = new_strength |
398 | | self._update_state() |
399 | | |
400 | 399 | def add_ap(self, ap): |
401 | 400 | self._access_points[ap.model.object_path] = ap |
402 | 401 | self.update_strength() |