Ticket #2246: 0001-AP-signal-strength-update-not-seperate-from-state-ch.patch

File 0001-AP-signal-strength-update-not-seperate-from-state-ch.patch, 6.4 KB (added by erikos, 11 years ago)

This separates the state change from the signal strength change

  • src/jarabe/desktop/networkviews.py

    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): 
    159159    def __device_state_changed_cb(self, new_state, old_state, reason):
    160160        self._device_state = new_state
    161161        self._update_state()
     162        self._update_icon()
    162163
    163164    def __update_active_ap(self, ap_path):
    164165        if ap_path in self._access_points:
    class WirelessNetworkView(CanvasPulsingIcon): 
    166167            # strength of that one
    167168            self._active_ap = self._access_points[ap_path]
    168169            self.update_strength()
    169             self._update_state()
    170170        elif self._active_ap is not None:
    171171            # revert to showing state of strongest AP again
    172172            self._active_ap = None
    173173            self.update_strength()
    174             self._update_state()
    175174
    176175    def __wireless_properties_changed_cb(self, properties):
    177176        if 'ActiveAccessPoint' in properties:
    class WirelessNetworkView(CanvasPulsingIcon): 
    191190
    192191    def __get_device_state_reply_cb(self, state):
    193192        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):
    200193        self._update_state()
    201194        self._update_color()
    202195
    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)
    208198
     199    def _update_icon(self):
    209200        if self._mode == network.NM_802_11_MODE_ADHOC and \
    210201                network.is_sugar_adhoc_network(self._name):
    211202            channel = max([1] + [ap.channel for ap in
    212203                                 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:
    214206                icon_name = 'network-adhoc-%s-connected' % channel
    215207            else:
    216208                icon_name = 'network-adhoc-%s' % channel
    class WirelessNetworkView(CanvasPulsingIcon): 
    218210            icon = self._palette.props.icon
    219211            icon.props.icon_name = icon_name
    220212        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:
    226215                icon_name = '%s-connected' % _AP_ICON_NAME
    227216            else:
    228217                icon_name = _AP_ICON_NAME
    class WirelessNetworkView(CanvasPulsingIcon): 
    233222                icon = self._palette.props.icon
    234223                icon.props.icon_name = icon_name
    235224
     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
    236231        if state == network.DEVICE_STATE_PREPARE or \
    237232           state == network.DEVICE_STATE_CONFIG or \
    238233           state == network.DEVICE_STATE_NEED_AUTH or \
    class WirelessNetworkView(CanvasPulsingIcon): 
    243238            self._palette.props.secondary_text = _('Connecting...')
    244239            self.props.pulsing = True
    245240        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()
    246245            if self._disconnect_item:
    247246                self._disconnect_item.show()
    248247            self._connect_item.hide()
    class WirelessNetworkView(CanvasPulsingIcon): 
    262261        else:
    263262            self.props.base_color = self._color
    264263
     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
    265278    def _disconnect_activate_cb(self, item):
    266279        pass
    267280
    class WirelessNetworkView(CanvasPulsingIcon): 
    376389
    377390    def set_filter(self, query):
    378391        self._greyed_out = self._name.lower().find(query) == -1
    379         self._update_state()
     392        self._update_icon()
    380393        self._update_color()
    381394
    382395    def create_keydialog(self, settings, response):
    383396        keydialog.create(self._name, self._flags, self._wpa_flags,
    384397                         self._rsn_flags, self._device_caps, settings, response)
    385398
    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 
    400399    def add_ap(self, ap):
    401400        self._access_points[ap.model.object_path] = ap
    402401        self.update_strength()