diff --git a/shell/hardware/nmclient.py b/shell/hardware/nmclient.py index f678e0d6..3bcc4332 100644 --- a/shell/hardware/nmclient.py +++ b/shell/hardware/nmclient.py @@ -70,6 +70,14 @@ NM_802_11_CAP_CIPHER_WEP104 = 0x00002000 NM_802_11_CAP_CIPHER_TKIP = 0x00004000 NM_802_11_CAP_CIPHER_CCMP = 0x00008000 +NETWORK_STATE_CONNECTING = 0 +NETWORK_STATE_CONNECTED = 1 +NETWORK_STATE_NOTCONNECTED = 2 + +DEVICE_STATE_ACTIVATING = 0 +DEVICE_STATE_ACTIVATED = 1 +DEVICE_STATE_INACTIVE = 2 + class Network(gobject.GObject): __gsignals__ = { 'init-failed' : (gobject.SIGNAL_RUN_FIRST, @@ -77,6 +85,8 @@ class Network(gobject.GObject): 'strength-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), 'ssid-changed' : (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([])), + 'state-changed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) } @@ -87,6 +97,7 @@ class Network(gobject.GObject): self._mode = None self._strength = 0 self._valid = False + self._state = NETWORK_STATE_NOTCONNECTED obj = sys_bus.get_object(NM_SERVICE, self._op) net = dbus.Interface(obj, NM_IFACE_DEVICES) @@ -121,6 +132,13 @@ class Network(gobject.GObject): def get_ssid(self): return self._ssid + def get_state(self): + return self._state + + def set_state(self, state): + self._state = state + self.emit('state-changed') + def get_op(self): return self._op @@ -138,13 +156,15 @@ class Device(gobject.GObject): __gsignals__ = { 'init-failed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), - 'activated': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ([])), - 'deactivated': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ([])), 'strength-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), + 'strength-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([])), + 'ssid-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([])), + 'state-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([])), 'network-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), @@ -164,8 +184,10 @@ class Device(gobject.GObject): self._link = False self._valid = False self._networks = {} - self._active_net = None self._caps = 0 + self._state = DEVICE_STATE_INACTIVE + self._ssid = None + self._active_network = None obj = sys_bus.get_object(NM_SERVICE, self._op) dev = dbus.Interface(obj, NM_IFACE_DEVICES) @@ -184,15 +206,15 @@ class Device(gobject.GObject): old_strength = self._strength self._strength = props[14] if self._strength != old_strength: - self.emit('strength-changed', self._strength) + self.emit('strength-changed') self._update_networks(props[20], props[19]) self._valid = True if self._active: - self.emit('activated') + self.set_state(DEVICE_STATE_ACTIVATED) else: - self.emit('deactivated') + self.set_state(DEVICE_STATE_INACTIVE) def _update_networks(self, net_ops, active_op): for op in net_ops: @@ -200,7 +222,8 @@ class Device(gobject.GObject): self._networks[op] = net net.connect('init-failed', self._net_init_failed) if op == active_op: - self._active_net = op + self.set_active_network(net) + def _update_error_cb(self, err): logging.debug("Device(%s): failed to update. (%s)" % (self._op, err)) @@ -211,8 +234,6 @@ class Device(gobject.GObject): net_op = net.get_op() if not self._networks.has_key(net_op): return - if net_op == self._active_net: - self._active_net = None del self._networks[net_op] def get_op(self): @@ -221,9 +242,6 @@ class Device(gobject.GObject): def get_networks(self): return self._networks.values() - def get_active_network(self): - return self.get_network(self._active_net) - def get_network(self, op): if self._networks.has_key(op): return self._networks[op] @@ -244,7 +262,7 @@ class Device(gobject.GObject): else: self._strength = 0 - self.emit('strength-changed', self._strength) + self.emit('strength-changed') def network_appeared(self, network): if self._networks.has_key(network): @@ -257,25 +275,51 @@ class Device(gobject.GObject): def network_disappeared(self, network): if not self._networks.has_key(network): return - if network == self._active_net: - self._active_net = None self.emit('network-disappeared', self._networks[network]) del self._networks[network] - def get_active(self): - return self._active + def _active_network_ssid_changed_cb(self, active_network): + self._ssid = active_network.get_ssid() - def set_active(self, active, ssid=None): - self._active = active - if self._type == DEVICE_TYPE_802_11_WIRELESS: - if not ssid: - self._active_net = None - else: - for (op, net) in self._networks.items(): - if net.get_ssid() == ssid: - self._active_net = op + def set_active_network(self, network): + if self._active_network: + self._active_network.disconnect(self._ssid_sid) + + self._active_network = network + + if self._active_network: + self._ssid_sid = network.connect( + 'ssid-changed', self._active_network_ssid_changed_cb) + + def get_state(self): + return self._state + + def set_state(self, state): + self._state = state + + if state == DEVICE_STATE_ACTIVATING: + obj = sys_bus.get_object(NM_SERVICE, self._op) + dev = dbus.Interface(obj, NM_IFACE_DEVICES) + + network = dev.getActiveNetwork() + self.set_active_network(self._networks[network]) + + _device_to_network_state = { + DEVICE_STATE_ACTIVATING : NETWORK_STATE_CONNECTING, + DEVICE_STATE_ACTIVATED : NETWORK_STATE_CONNECTED, + DEVICE_STATE_INACTIVE : NETWORK_STATE_NOTCONNECTED + } + + if self._active_network: + network_state = _device_to_network_state[state] + self._active_network.set_state(network_state) + + self.emit('state-changed') + + def get_ssid(self): + return self._ssid def get_type(self): return self._type @@ -289,14 +333,11 @@ class Device(gobject.GObject): def get_capabilities(self): return self._caps -NM_STATE_UNKNOWN = 0 -NM_STATE_ASLEEP = 1 -NM_STATE_CONNECTING = 2 -NM_STATE_CONNECTED = 3 -NM_STATE_DISCONNECTED = 4 - class NMClient(gobject.GObject): __gsignals__ = { + 'device-added' : (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), 'device-activated' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), @@ -310,9 +351,7 @@ class NMClient(gobject.GObject): self.nminfo = None self._nm_present = False - self._nm_state = NM_STATE_UNKNOWN self._update_timer = 0 - self._active_device = None self._devices = {} try: @@ -321,23 +360,11 @@ class NMClient(gobject.GObject): pass self._setup_dbus() if self._nm_present: - self._get_nm_state() self._get_initial_devices() def get_devices(self): return self._devices.values() - def _get_nm_state(self): - # Grab NM's state - self._nm_obj.state(reply_handler=self._get_state_reply_cb, \ - error_handler=self._get_state_error_cb) - - def _get_state_reply_cb(self, state): - self._nm_state = state - - def _get_state_error_cb(self, err): - logging.debug("Failed to get NetworkManager state! %s" % err) - def _get_initial_devices_reply_cb(self, ops): for op in ops: self._add_device(op) @@ -360,38 +387,26 @@ class NMClient(gobject.GObject): dev = Device(dev_op) self._devices[dev_op] = dev dev.connect('init-failed', self._dev_init_failed_cb) - dev.connect('activated', self._dev_activated_cb) - dev.connect('strength-changed', self._dev_strength_changed_cb) + dev.connect('state-changed', self._dev_state_changed_cb) + + self.emit('device-added', dev) def _remove_device(self, dev_op): if not self._devices.has_key(dev_op): return - if self._active_device == dev_op: - self._active_device = None dev = self._devices[dev_op] - dev.disconnect('activated') + dev.disconnect('state-changed') dev.disconnect('init-failed') - dev.disconnect('strength-changed') del self._devices[dev_op] self.emit('device-removed', dev) - def _dev_activated_cb(self, dev): + def _dev_state_changed_cb(self, dev): op = dev.get_op() if not self._devices.has_key(op): return - if not dev.get_active(): - return - self._active_device = op - - self.emit('device-activated', dev) - - def _dev_strength_changed_cb(self, dev, strength): - op = dev.get_op() - if not self._devices.has_key(op): - return - if not dev.get_active(): - return + if dev.get_state() != DEVICE_STATE_INACTIVE : + self.emit('device-activated', dev) def get_device(self, dev_op): if not self._devices.has_key(dev_op): @@ -400,7 +415,6 @@ class NMClient(gobject.GObject): def _setup_dbus(self): self._sig_handlers = { - 'StateChange': self.state_change_sig_handler, 'DeviceAdded': self.device_added_sig_handler, 'DeviceRemoved': self.device_removed_sig_handler, 'DeviceActivationStage': self.device_activation_stage_sig_handler, @@ -502,24 +516,18 @@ class NMClient(gobject.GObject): def device_activation_stage_sig_handler(self, device, stage): logging.debug('Device Activation Stage "%s" for device %s' % (NM_DEVICE_STAGE_STRINGS[stage], device)) - def state_change_sig_handler(self, state): - self._nm_state = state - def device_activating_sig_handler(self, device): - self._active_device = device + self._devices[device].set_state(DEVICE_STATE_ACTIVATING) def device_now_active_sig_handler(self, device, ssid=None): if not self._devices.has_key(device): return - self._active_device = device - self._devices[device].set_active(True, ssid) + self._devices[device].set_state(DEVICE_STATE_ACTIVATED) def device_no_longer_active_sig_handler(self, device): if not self._devices.has_key(device): return - if self._active_device == device: - self._active_device = None - self._devices[device].set_active(False) + self._devices[device].set_state(DEVICE_STATE_INACTIVE) def name_owner_changed_sig_handler(self, name, old, new): if name != NM_SERVICE: @@ -530,12 +538,9 @@ class NMClient(gobject.GObject): for op in self._devices.keys(): del self._devices[op] self._devices = {} - self._active_device = None - self._nm_state = NM_STATE_UNKNOWN elif (not old and not len(old)) and (new and len(new)): # NM started up self._nm_present = True - self._get_nm_state() self._get_initial_devices() def device_added_sig_handler(self, device): diff --git a/shell/model/MeshModel.py b/shell/model/MeshModel.py index 8fd74b27..c6247a89 100644 --- a/shell/model/MeshModel.py +++ b/shell/model/MeshModel.py @@ -20,47 +20,9 @@ from sugar.graphics.xocolor import XoColor from sugar.presence import PresenceService from sugar.activity import bundleregistry from model.BuddyModel import BuddyModel +from model.accesspointmodel import AccessPointModel from hardware import hardwaremanager -class AccessPointModel(gobject.GObject): - __gproperties__ = { - 'name' : (str, None, None, None, - gobject.PARAM_READABLE), - 'strength' : (int, None, None, 0, 100, 0, - gobject.PARAM_READABLE) - } - - def __init__(self, nm_device, nm_network): - gobject.GObject.__init__(self) - self._nm_network = nm_network - self._nm_device = nm_device - - self._nm_network.connect('strength-changed', - self._strength_changed_cb) - self._nm_network.connect('ssid-changed', - self._essid_changed_cb) - - def _strength_changed_cb(self, nm_network): - self.notify('strength') - - def _essid_changed_cb(self, nm_network): - self.notify('name') - - def get_id(self): - return self._nm_network.get_op() - - def get_nm_device(self): - return self._nm_device - - def get_nm_network(self): - return self._nm_network - - def do_get_property(self, pspec): - if pspec.name == 'strength': - return self._nm_network.get_strength() - elif pspec.name == 'name': - return self._nm_network.get_ssid() - class ActivityModel: def __init__(self, activity, bundle, service): self._service = service @@ -127,7 +89,7 @@ class MeshModel(gobject.GObject): network_manager = hardwaremanager.get_network_manager() for nm_device in network_manager.get_devices(): self._add_network_device(nm_device) - network_manager.connect('device-activated', + network_manager.connect('device-added', self._nm_device_activated_cb) def _nm_device_activated_cb(self, manager, nm_device): diff --git a/shell/model/accesspointmodel.py b/shell/model/accesspointmodel.py new file mode 100644 index 00000000..02899c0c --- /dev/null +++ b/shell/model/accesspointmodel.py @@ -0,0 +1,78 @@ +# Copyright (C) 2006, Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import gobject + +from hardware import nmclient + +STATE_CONNECTING = 0 +STATE_CONNECTED = 1 +STATE_NOTCONNECTED = 2 + +_nm_state_to_state = { + nmclient.NETWORK_STATE_CONNECTED : STATE_CONNECTED, + nmclient.NETWORK_STATE_CONNECTING : STATE_CONNECTING, + nmclient.NETWORK_STATE_NOTCONNECTED : STATE_NOTCONNECTED +} + +class AccessPointModel(gobject.GObject): + __gproperties__ = { + 'name' : (str, None, None, None, + gobject.PARAM_READABLE), + 'strength' : (int, None, None, 0, 100, 0, + gobject.PARAM_READABLE), + 'state' : (int, None, None, STATE_CONNECTING, + STATE_NOTCONNECTED, 0, gobject.PARAM_READABLE) + } + + def __init__(self, nm_device, nm_network): + gobject.GObject.__init__(self) + self._nm_network = nm_network + self._nm_device = nm_device + + self._nm_network.connect('strength-changed', + self._strength_changed_cb) + self._nm_network.connect('ssid-changed', + self._ssid_changed_cb) + self._nm_network.connect('state-changed', + self._state_changed_cb) + + def _strength_changed_cb(self, nm_network): + self.notify('strength') + + def _ssid_changed_cb(self, nm_network): + self.notify('name') + + def _state_changed_cb(self, nm_network): + self.notify('state') + + def get_id(self): + return self._nm_network.get_op() + + def get_nm_device(self): + return self._nm_device + + def get_nm_network(self): + return self._nm_network + + def do_get_property(self, pspec): + if pspec.name == 'strength': + return self._nm_network.get_strength() + elif pspec.name == 'name': + return self._nm_network.get_ssid() + elif pspec.name == 'state': + nm_state = self._nm_device.get_state() + return _nm_state_to_state[nm_state] diff --git a/shell/model/devices/devicesmodel.py b/shell/model/devices/devicesmodel.py index dd535961..92332d20 100644 --- a/shell/model/devices/devicesmodel.py +++ b/shell/model/devices/devicesmodel.py @@ -42,8 +42,9 @@ class DevicesModel(gobject.GObject): def _network_device_removed_cb(self, nm_device): self._remove_network_device(nm_device) - def _network_device_deactivated_cb(self, nm_device): - self._remove_network_device(nm_device) + def _network_device_state_changed_cb(self, nm_device): + if nm_device.get_state == nmclient.DEVICE_STATE_INACTIVE: + self._remove_network_device(nm_device) def _check_network_device(self, nm_device): if not nm_device.is_valid(): @@ -57,8 +58,8 @@ class DevicesModel(gobject.GObject): def _add_network_device(self, nm_device): self.add_device(wirelessnetwork.Device(nm_device)) - nm_device.connect('deactivated', - self._network_device_deactivated_cb) + nm_device.connect('state-changed', + self._network_device_state_changed_cb) def _remove_network_device(self, nm_device): self.remove_device(self._get_network_device(nm_device)) diff --git a/shell/model/devices/wirelessnetwork.py b/shell/model/devices/wirelessnetwork.py index a3648274..50793b5c 100644 --- a/shell/model/devices/wirelessnetwork.py +++ b/shell/model/devices/wirelessnetwork.py @@ -1,13 +1,43 @@ +# +# Copyright (C) 2006, Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + import gobject from model.devices import device +from hardware import nmclient + +STATE_ACTIVATING = 0 +STATE_ACTIVATED = 1 +STATE_INACTIVE = 2 + +_nm_state_to_state = { + nmclient.DEVICE_STATE_ACTIVATING : STATE_ACTIVATING, + nmclient.DEVICE_STATE_ACTIVATED : STATE_ACTIVATED, + nmclient.DEVICE_STATE_INACTIVE : STATE_INACTIVE +} class Device(device.Device): __gproperties__ = { 'name' : (str, None, None, None, gobject.PARAM_READABLE), 'strength' : (int, None, None, 0, 100, 0, - gobject.PARAM_READABLE) + gobject.PARAM_READABLE), + 'state' : (int, None, None, STATE_ACTIVATING, + STATE_INACTIVE, 0, gobject.PARAM_READABLE) } def __init__(self, nm_device): @@ -16,19 +46,28 @@ class Device(device.Device): self._nm_device.connect('strength-changed', self._strength_changed_cb) + self._nm_device.connect('ssid-changed', + self._ssid_changed_cb) + self._nm_device.connect('state-changed', + self._state_changed_cb) - def _strength_changed_cb(self, nm_device, strength): + def _strength_changed_cb(self, nm_device): self.notify('strength') - def _essid_changed_cb(self, nm_device): + def _ssid_changed_cb(self, nm_device): self.notify('name') + def _state_changed_cb(self, nm_device): + self.notify('state') + def do_get_property(self, pspec): if pspec.name == 'strength': return self._nm_device.get_strength() elif pspec.name == 'name': - # FIXME - return None + return self._nm_device.get_ssid() + elif pspec.name == 'state': + nm_state = self._nm_device.get_state() + return _nm_state_to_state[nm_state] def get_type(self): return 'wirelessnetwork' diff --git a/shell/view/devices/wirelessnetwork.py b/shell/view/devices/wirelessnetwork.py index 4a9e3780..9164810c 100644 --- a/shell/view/devices/wirelessnetwork.py +++ b/shell/view/devices/wirelessnetwork.py @@ -1,4 +1,30 @@ +# +# Copyright (C) 2006, Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + from view.devices import deviceview +from model.devices import wirelessnetwork + +_strength_to_icon = { + (0, 20) : 'stock-net-wireless-00', + (21, 40) : 'stock-net-wireless-21-40', + (41, 60) : 'stock-net-wireless-41-60', + (61, 80) : 'stock-net-wireless-61-80', + (81, 100) : 'stock-net-wireless-81-100' +} class DeviceView(deviceview.DeviceView): def __init__(self, model): @@ -7,9 +33,11 @@ class DeviceView(deviceview.DeviceView): model.connect('notify::name', self._name_changed_cb) model.connect('notify::strength', self._strength_changed_cb) + model.connect('notify::state', self._state_changed_cb) self._update_name() self._update_icon() + self._update_state() def _strength_changed_cb(self, model, pspec): self._update_icon() @@ -17,18 +45,25 @@ class DeviceView(deviceview.DeviceView): def _name_changed_cb(self, model, pspec): self._update_name() + def _state_changed_cb(self, model, pspec): + self._update_state() + def _update_name(self): self.props.tooltip = self._model.props.name def _update_icon(self): strength = self._model.props.strength - if strength < 21: - self.props.icon_name = 'theme:stock-net-wireless-00' - elif strength < 41: - self.props.icon_name = 'theme:stock-net-wireless-21-40' - elif strength < 61: - self.props.icon_name = 'theme:stock-net-wireless-41-60' - elif strength < 81: - self.props.icon_name = 'theme:stock-net-wireless-61-80' - else: - self.props.icon_name = 'theme:stock-net-wireless-81-100' + for interval in _strength_to_icon.keys(): + if strength >= interval[0] and strength <= interval[1]: + stock_name = _strength_to_icon[interval] + self.props.icon_name = 'theme:' + stock_name + + def _update_state(self): + # FIXME Change icon colors once we have real icons + state = self._model.props.state + if state == wirelessnetwork.STATE_ACTIVATING: + self.props.background_color = 0xFF0000FF + elif state == wirelessnetwork.STATE_ACTIVATED: + self.props.background_color = 0x00FF00FF + elif state == wirelessnetwork.STATE_INACTIVE: + self.props.background_color = 0x00000000 diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py index 7b5e5da4..2618c805 100644 --- a/shell/view/home/MeshBox.py +++ b/shell/view/home/MeshBox.py @@ -22,9 +22,18 @@ import gobject from sugar.graphics.spreadbox import SpreadBox from sugar.graphics.snowflakebox import SnowflakeBox from sugar.graphics.canvasicon import CanvasIcon +from model import accesspointmodel from hardware import hardwaremanager from view.BuddyIcon import BuddyIcon +_strength_to_icon = { + (0, 20) : 'stock-net-wireless-00', + (21, 40) : 'stock-net-wireless-21-40', + (41, 60) : 'stock-net-wireless-41-60', + (61, 80) : 'stock-net-wireless-61-80', + (81, 100) : 'stock-net-wireless-81-100' +} + class AccessPointView(CanvasIcon): def __init__(self, model): CanvasIcon.__init__(self) @@ -37,6 +46,7 @@ class AccessPointView(CanvasIcon): self._update_icon() self._update_name() + self._update_state() def _strength_changed_cb(self, model, pspec): self._update_icon() @@ -44,6 +54,9 @@ class AccessPointView(CanvasIcon): def _name_changed_cb(self, model, pspec): self._update_name() + def _state_changed_cb(self, model, pspec): + self._update_state() + def _activate_cb(self, icon): network_manager = hardwaremanager.get_network_manager() @@ -57,16 +70,19 @@ class AccessPointView(CanvasIcon): def _update_icon(self): strength = self._model.props.strength - if strength < 21: - self.props.icon_name = 'theme:stock-net-wireless-00' - elif strength < 41: - self.props.icon_name = 'theme:stock-net-wireless-21-40' - elif strength < 61: - self.props.icon_name = 'theme:stock-net-wireless-41-60' - elif strength < 81: - self.props.icon_name = 'theme:stock-net-wireless-61-80' - else: - self.props.icon_name = 'theme:stock-net-wireless-81-100' + for interval in _strength_to_icon.keys(): + if strength >= interval[0] and strength <= interval[1]: + stock_name = _strength_to_icon[interval] + self.props.icon_name = 'theme:' + stock_name + + def _update_state(self): + # FIXME Change icon colors once we have real icons + if self._model.props.state == accesspointmodel.STATE_CONNECTING: + self.props.background_color = 0xFF0000FF + elif self._model.props.state == accesspointmodel.STATE_CONNECTED: + self.props.background_color = 0x00FF00FF + elif self._model.props.state == accesspointmodel.STATE_NOTCONNECTED: + self.props.background_color = 0x00000000 class ActivityView(SnowflakeBox): def __init__(self, shell, menu_shell, model):