Merge ~jibel/ubiquity:check_site_connectivity into ubiquity:master

Proposed by Jean-Baptiste Lallement
Status: Merged
Approved by: Jean-Baptiste Lallement
Approved revision: 32094f64fbcae7a2da2f4b20e75d16883a0f5581
Merged at revision: 7c8307a4ecc277ba029528640a92641103a388b2
Proposed branch: ~jibel/ubiquity:check_site_connectivity
Merge into: ubiquity:master
Diff against target: 109 lines (+36/-6)
4 files modified
debian/changelog (+11/-0)
ubiquity/frontend/gtk_ui.py (+6/-0)
ubiquity/misc.py (+16/-5)
ubiquity/plugins/ubi-usersetup.py (+3/-1)
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli (community) Approve
Review via email: mp+403733@code.launchpad.net

Commit message

Distinguish site and global connectivity

Make a distinction between local and global connectivity availability.
For example, AD can be enabled with a working site connection but no internet, while package download requires a global connection.

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Tested and works

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 96772f9..caf876e 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,14 @@
6+ubiquity (21.10.2) UNRELEASED; urgency=medium
7+
8+ [ Didier Roche ]
9+ [ Jean-Baptiste Lallement ]
10+ * connectity check: Make a distinction between local and global connection
11+ availability. For example, AD can be enabled with a working site
12+ connection but no internet, while package download requires a global
13+ connection.
14+
15+ -- Jean-Baptiste Lallement <jean-baptiste.lallement@ubuntu.com> Fri, 04 Jun 2021 14:07:25 +0200
16+
17 ubiquity (21.10.1) impish; urgency=medium
18
19 * choose-mirror: hirsute -> impish
20diff --git a/ubiquity/frontend/gtk_ui.py b/ubiquity/frontend/gtk_ui.py
21index 042f56f..ea0840e 100644
22--- a/ubiquity/frontend/gtk_ui.py
23+++ b/ubiquity/frontend/gtk_ui.py
24@@ -574,6 +574,11 @@ class Wizard(BaseFrontend):
25 GLib.source_remove(self.timeout_id)
26 self.timeout_id = GLib.timeout_add(300, self.check_returncode)
27
28+ def set_connectivity_state(self, state):
29+ for p in self.pages:
30+ if hasattr(p.ui, 'plugin_set_connectivity_state'):
31+ p.ui.plugin_set_connectivity_state(state)
32+
33 def set_online_state(self, state):
34 for p in self.pages:
35 if hasattr(p.ui, 'plugin_set_online_state'):
36@@ -1121,6 +1126,7 @@ class Wizard(BaseFrontend):
37 self.allow_go_backward(False)
38
39 misc.add_connection_watch(self.network_change)
40+ misc.add_connection_watch(self.set_connectivity_state, global_only=False)
41
42 def set_window_hints(self, widget):
43 if (self.oem_user_config or
44diff --git a/ubiquity/misc.py b/ubiquity/misc.py
45index e7175cc..49512bb 100644
46--- a/ubiquity/misc.py
47+++ b/ubiquity/misc.py
48@@ -880,6 +880,7 @@ def set_indicator_keymaps(lang):
49
50
51 NM = 'org.freedesktop.NetworkManager'
52+NM_STATE_CONNECTED_SITE = 60
53 NM_STATE_CONNECTED_GLOBAL = 70
54
55
56@@ -895,23 +896,33 @@ def get_prop(obj, iface, prop):
57
58
59 def has_connection():
60+ return connection_state() == NM_STATE_CONNECTED_GLOBAL
61+
62+
63+def connection_state():
64 import dbus
65 bus = dbus.SystemBus()
66 manager = bus.get_object(NM, '/org/freedesktop/NetworkManager')
67- state = get_prop(manager, NM, 'State')
68- return state == NM_STATE_CONNECTED_GLOBAL
69+ return get_prop(manager, NM, 'State')
70
71
72-def add_connection_watch(func):
73+def add_connection_watch(func, global_only=True):
74 import dbus
75
76 def connection_cb(state):
77- func(state == NM_STATE_CONNECTED_GLOBAL)
78+ is_connected = False
79+ if global_only:
80+ if state == NM_STATE_CONNECTED_GLOBAL:
81+ is_connected = True
82+ else:
83+ if state == NM_STATE_CONNECTED_GLOBAL or state == NM_STATE_CONNECTED_SITE:
84+ is_connected = True
85+ func(is_connected)
86
87 bus = dbus.SystemBus()
88 bus.add_signal_receiver(connection_cb, 'StateChanged', NM, NM)
89 try:
90- func(has_connection())
91+ connection_cb(connection_state())
92 except dbus.DBusException:
93 # We can't talk to NM, so no idea. Wild guess: we're connected
94 # using ssh with X forwarding, and are therefore connected. This
95diff --git a/ubiquity/plugins/ubi-usersetup.py b/ubiquity/plugins/ubi-usersetup.py
96index 1eb785c..ee3cc98 100644
97--- a/ubiquity/plugins/ubi-usersetup.py
98+++ b/ubiquity/plugins/ubi-usersetup.py
99@@ -514,7 +514,9 @@ class PageGtk(PageBase):
100
101 self.controller._wizard.set_page_title(self)
102
103- def plugin_set_online_state(self, state):
104+ def plugin_set_connectivity_state(self, state):
105+ # For AD we need network connectivity but it can be local and not
106+ # necessarily internet connectivity
107 if not state:
108 self.login_directory.set_active(False)
109 self.login_directory.set_sensitive(state)

Subscribers

People subscribed via source and target branches