After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 646380 - On/Off switch for "VPN Connections" makes no sense
On/Off switch for "VPN Connections" makes no sense
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: network-indicator
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-03-31 20:29 UTC by Owen Taylor
Modified: 2011-04-08 16:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot of the switch (42.46 KB, image/png)
2011-03-31 20:29 UTC, Owen Taylor
  Details
NetworkMenu: fix VPN connection state (2.27 KB, patch)
2011-03-31 20:46 UTC, Giovanni Campagna
reviewed Details | Review
NetworkMenu: fix VPN connection state (2.29 KB, patch)
2011-04-02 17:19 UTC, Giovanni Campagna
committed Details | Review
network: fix logic bug in checking whether to activate or deactive (1.26 KB, patch)
2011-04-02 19:08 UTC, Owen Taylor
committed Details | Review

Description Owen Taylor 2011-03-31 20:29:47 UTC
Created attachment 184821 [details]
Screenshot of the switch

The On/Off switch on the "VPN Connections" just confuses the heck out of me:

 - It's "On" even if you aren't connected to any VPN
 - Turning it off and then on causes a connection to an arbitrary VPN
 - Turning it off when you're connected doesn't seem to disconnect from a VPN

I'm not sure if this switch is intentional, or just an artifact of code to add it for other sections.
Comment 1 Giovanni Campagna 2011-03-31 20:32:26 UTC
(In reply to comment #0)
> Created an attachment (id=184821) [details]
> Screenshot of the switch
> 
> The On/Off switch on the "VPN Connections" just confuses the heck out of me:
> 
>  - It's "On" even if you aren't connected to any VPN
>  - Turning it off and then on causes a connection to an arbitrary VPN
>  - Turning it off when you're connected doesn't seem to disconnect from a VPN
> 
> I'm not sure if this switch is intentional, or just an artifact of code to add
> it for other sections.

It is both. It is there because code is shared, and it is there because otherwise you cannot disconnect from VPN.
The behavior on activate (that is, from off to on) is the same as other devices: just connect to last used connection (with higher timestamp reported by NM).
Comment 2 Giovanni Campagna 2011-03-31 20:46:19 UTC
Created attachment 184823 [details] [review]
NetworkMenu: fix VPN connection state

It was always reporting true, even if disconnected. At the same time,
add a signal that is emitted when state changes and update the UI
accordingly.
In the future (with another libnm-glib API break) we should use the
NMVPNConnection object to track the connection state, so that we can
show if we're connecting or we need authentication.
Comment 3 Dan Winship 2011-04-01 17:14:20 UTC
Comment on attachment 184823 [details] [review]
NetworkMenu: fix VPN connection state

>             this._device.activate();
>         else
>             this._device.deactivate();
>+
>+        // Immediately reset the switch to false, it will be updated appropriately
>+        // by state-changed signals in devices (but fixes the VPN not being in sync
>+        // if the ActiveConnection object is never seen by libnm-glib)
>+        this._switch.setToggleState(false);

Hm... would it be better to set it false *before* calling this._device.activate(), in case it ends up emitting state-changed before returning from activate()?


But it all seems to work fine for me (both ethernet and VPN). Is there some reason we don't get a "connecting..." status on the VPN item? It seems weird that it continues to show as "Off" while we're connecting.
Comment 4 Owen Taylor 2011-04-01 21:28:13 UTC
(In reply to comment #3)

> But it all seems to work fine for me (both ethernet and VPN). Is there some
> reason we don't get a "connecting..." status on the VPN item? It seems weird
> that it continues to show as "Off" while we're connecting.

Giovanni said above:

 In the future (with another libnm-glib API break) we should use the
 NMVPNConnection object to track the connection state, so that we can
 show if we're connecting or we need authentication.
Comment 5 Owen Taylor 2011-04-01 21:43:49 UTC
Review of attachment 184823 [details] [review]:

In testing, this really makes a big difference - I'm not sure this is fully what we'd want for design long-term but it feels much more functional - it's confusing to have the state where the VPN is off, but it says ON, and the fact that it's off is indicated by the absence of a dot by the VPN connection.

There is a slight inconsistency:

 - For Wireless, if no Wireless connection is active, the switch is on (because wireless is enabled)
 - For VPN, if no VPN connection is active, the switch is off

But I'm not sure anybody would actually notice, and if we made the Wireless switch behave in the same fashion as VPN then you'd have no way to turn it off and keep it from autoconnecting.

Code changes look good to me - in terms of coding patterns, I think Dan is right that it's better to set false first to be agnostic about whether activate/deactivate is sync or async, but it's not going to make a difference here in practice - activate/deactivate get sent pretty much immmediately to D-Bus, and D-Bus outgoing calls don't re-enter.
Comment 6 Giovanni Campagna 2011-04-02 17:19:58 UTC
Created attachment 184954 [details] [review]
NetworkMenu: fix VPN connection state

It was always reporting true, even if disconnected. At the same time,
add a signal that is emitted when state changes and update the UI
accordingly.
In the future (with another libnm-glib API break) we should use the
NMVPNConnection object to track the connection state, so that we can
show if we're connecting or we need authentication.
Comment 7 Giovanni Campagna 2011-04-02 18:41:00 UTC
Attachment 184954 [details] pushed as d1a110d - NetworkMenu: fix VPN connection state
Comment 8 Owen Taylor 2011-04-02 19:08:27 UTC
Created attachment 184965 [details] [review]
network: fix logic bug in checking whether to activate or deactive

Guess Dan and I should have kept our mouth shut about theoretical
ordering considerations :-) ... as committed clicking on the switch
when off didn't actually activate the VPN.

===
A cosmetic change recommended in review of the patch to fix the
VPN Connections switch ended up introducing a logic error that
made the switch not work properly. Fix.
Comment 9 Giovanni Campagna 2011-04-02 19:11:40 UTC
(In reply to comment #8)
> Created an attachment (id=184965) [details] [review]
> network: fix logic bug in checking whether to activate or deactive
> 
> Guess Dan and I should have kept our mouth shut about theoretical
> ordering considerations :-) ... as committed clicking on the switch
> when off didn't actually activate the VPN.
> 
> ===
> A cosmetic change recommended in review of the patch to fix the
> VPN Connections switch ended up introducing a logic error that
> made the switch not work properly. Fix.

Ugh... And I should have checked it before pushing... Anyway good to commit, with RT approval (they'll be very happy of our careful and attentive reviews...)
Comment 10 Owen Taylor 2011-04-03 01:59:52 UTC
Pushed (didn't ask for r-t approval as it's just a correction to a previouly approved change)

Attachment 184965 [details] pushed as 6c3300b - network: fix logic bug in checking whether to activate or deactive
Comment 11 Florian Müllner 2011-04-08 16:40:23 UTC
*** Bug 647194 has been marked as a duplicate of this bug. ***