[Sugar-devel] [PATCH sugar] SugarAdhoc networks: make 'connect' option in Palette available
silbe at activitycentral.com
Mon Jan 16 13:25:19 EST 2012
Excerpts from Simon Schampijer's message of 2012-01-04 13:23:46 +0100:
> The palette got only updated on device state changes so far,
> but is not initialised on startup. The device state is now signaled
> as well on bringup from the manager to the widget.
It took me a while to figure out why the first change (calling
start_listening() later) is needed, as the fix is in MeshBox, but what
fails is the interaction between AdHocManager and SugarAdhocView.
And while your patch has the effect of revealing the connect action, it
really fixes the initialisation. But maybe I'm splitting hairs here.
Anyway, this is my take on it:
=== snip ===
Fix initialisation of ad-hoc network panels (reveals connect action)
SugarAdhocView (which shows an individual ad-hoc network icon in the
Neighbourhood) defaults to an undefined state, not showing any action on
Formerly, AdHocManager didn't propagate the state of the network device
via the 'update-state' signal when hooking to NetworkManager
(AdHocManager.start_listening()), so the palettes didn't get initialised
to a known state. The connect action on ad-hoc icon palettes only got
revealed after the state of the network device changed for some reason
(e.g. connecting to a network).
While SugarAdhocView shouldn't depend on the update-state signal getting
delivered right after instantiation, the NetworkManager client code in
Sugar needs major rework and most of the ad-hoc support should move into
NetworkManager, so we're doing a minimally invasive change instead. The
change is both correct and required in any case (as one of the ad-hoc
networks could have been connected to before the current instance of
Sugar got started).
The ad-hoc network icons (SugarAdhocView instances) now get instantiated
before AdHocManager.start_listening() is called, so they can receive the
'update-state' signal that AdHocManager.start_listening() will now
broadcast after hooking up to NetworkManager.
=== snip ===
Feel free to include as much of it as you consider useful in your commit
Please remember to include your sign-off to indicate acceptance of our
patch submission guidelines, including permission to distribute your
code under the current license of the module your modifying.
> def add_adhoc_networks(self, device):
> if self._adhoc_manager is None:
> self._adhoc_manager = get_adhoc_manager_instance()
> - self._adhoc_manager.start_listening(device)
> + self._adhoc_manager.start_listening(device)
I'd argue that SugarAdhocView is broken because it _relies_ on the
update-state signal getting delivered in order to complete
initialisation. Instead it should initialise itself to a default state
(i.e. being disconnected). If the network device isn't usable, the icons
should be hidden rather than being shown without any action.
But since the NetworkManager client code in Sugar is quite a mess and we
should move the ad-hoc functionality to NetworkManager anyway, your
minimally invasive change is still the way to go. We should just make
sure we know and document what we're doing.
Acked-by: Sascha Silbe <silbe at activitycentral.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 490 bytes
Desc: not available
More information about the Sugar-devel