Merge lp:~system76-dev/ubiquity/trunk into lp:ubiquity

Proposed by Jeremy Soller
Status: Merged
Merged at revision: 6540
Proposed branch: lp:~system76-dev/ubiquity/trunk
Merge into: lp:ubiquity
Diff against target: 419 lines (+103/-110)
7 files modified
d-i/manifest (+5/-3)
debian/changelog (+6/-0)
debian/control (+1/-1)
tests/test_wireless.py (+1/-18)
ubiquity/frontend/gtk_components/nmwidgets.py (+83/-77)
ubiquity/frontend/kde_components/nmwidgets.py (+7/-1)
ubiquity/plugins/ubi-wireless.py (+0/-10)
To merge this branch: bzr merge lp:~system76-dev/ubiquity/trunk
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Needs Information
Review via email: mp+319142@code.launchpad.net

Description of the change

- Add WPA-2 enterprise support using libnm-gtk
- Remove password box from GTK installer, using libnm-gtk for any secure connections

This patch to `libnm-gtk` must also be applied: https://bugs.launchpad.net/ubuntu/+source/network-manager-applet/+bug/1667129

To post a comment you must log in.
lp:~system76-dev/ubiquity/trunk updated
6525. By Jeremy Soller

Switch to using libnma

6526. By Jeremy Soller

Fixes for use of libnma

6527. By Jeremy Soller

Change RemoteConnection to SimpleConnection

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Looks fine to me code-wise; now I'll merge and review functionally.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

How did you test this? I've built this in my PPA, and installing it on a live session leads to ubiquity not starting the wireless panel at all (I expected it to still show a list of wireless networks).

review: Needs Information
lp:~system76-dev/ubiquity/trunk updated
6528. By Jeremy Soller

Merge

6529. By Jeremy Soller

Update changelog

Revision history for this message
Jeremy Soller (jackpot51) wrote :

cyphermox, the wireless network page is skipped if you are connected to a wired network.

lp:~system76-dev/ubiquity/trunk updated
6530. By Jeremy Soller

Merge

6531. By Jeremy Soller

Update changelog

6532. By Jeremy Soller

Revert manifest to zesty versions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'd-i/manifest'
2--- d-i/manifest 2017-04-07 14:17:15 +0000
3+++ d-i/manifest 2017-06-22 16:34:36 +0000
4@@ -1,15 +1,15 @@
5 apt-setup 1:0.104ubuntu5
6 base-installer 1.158ubuntu4
7 bterm-unifont 1.4
8-choose-mirror 2.78ubuntu1
9+choose-mirror 2.75ubuntu1
10 clock-setup 0.131ubuntu1
11 console-setup 1.142ubuntu5
12 debian-installer-utils 1.113ubuntu1
13 flash-kernel 3.0~rc.4ubuntu65
14 grub-installer 1.128ubuntu7
15-hw-detect 1.117ubuntu4
16+hw-detect 1.117ubuntu3
17 localechooser 2.65ubuntu4
18-netcfg 1.138ubuntu5
19+netcfg 1.138ubuntu4
20 partconf 1.50
21 partman-auto 134ubuntu6
22 partman-auto-crypto 22ubuntu1
23@@ -24,6 +24,7 @@
24 partman-ext3 86ubuntu1
25 partman-jfs 47
26 partman-lvm 113
27+partman-newworld 34
28 partman-partitioning 114ubuntu2
29 partman-swapfile 1
30 partman-target 98ubuntu1
31@@ -32,3 +33,4 @@
32 preseed 1.71ubuntu4
33 tzsetup 1:0.81ubuntu1
34 user-setup 1.63ubuntu4
35+yaboot-installer 1.1.36ubuntu1
36
37=== modified file 'debian/changelog'
38--- debian/changelog 2017-04-10 02:36:04 +0000
39+++ debian/changelog 2017-06-22 16:34:36 +0000
40@@ -1,3 +1,9 @@
41+ubiquity (17.04.10~system76~1) zesty; urgency=medium
42+
43+ * Fix for crashes when selecting a WPA 2 enterprise network
44+
45+ -- Jeremy Soller <jeremy@system76.com> Fri, 16 Jun 2017 09:55:28 -0600
46+
47 ubiquity (17.04.9) zesty; urgency=medium
48
49 * tests/test_misc.py: Really fix test for the 'ta' keymap: check for
50
51=== modified file 'debian/control'
52--- debian/control 2016-09-26 19:16:34 +0000
53+++ debian/control 2017-06-22 16:34:36 +0000
54@@ -45,7 +45,7 @@
55 Package: ubiquity-frontend-gtk
56 Architecture: amd64 arm64 armhf i386 powerpc ppc64el
57 Pre-Depends: ${misc:Pre-Depends}
58-Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, ubiquity (= ${binary:Version}), python3-dbus, gir1.2-gtk-3.0 (>= 3.20), gir1.2-pango-1.0, gir1.2-soup-2.4, gir1.2-vte-2.91, gir1.2-webkit2-4.0, iso-codes, metacity | marco | xfwm4 | matchbox-window-manager | lubuntu-default-settings | openbox | gnome-shell, gir1.2-xkl-1.0, gir1.2-timezonemap-1.0, python3-gi, python3-cairo, python3-gi-cairo, gir1.2-appindicator3-0.1, busybox-static | busybox
59+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, ubiquity (= ${binary:Version}), python3-dbus, gir1.2-gtk-3.0 (>= 3.20), gir1.2-nma-1.0, gir1.2-pango-1.0, gir1.2-soup-2.4, gir1.2-vte-2.91, gir1.2-webkit2-4.0, iso-codes, metacity | marco | xfwm4 | matchbox-window-manager | lubuntu-default-settings | openbox | gnome-shell, gir1.2-xkl-1.0, gir1.2-timezonemap-1.0, python3-gi, python3-cairo, python3-gi-cairo, gir1.2-appindicator3-0.1, busybox-static | busybox
60 Suggests: gnome-control-center | feh
61 Conflicts: ubuntu-express-frontend-gtk, espresso-frontend-gtk, ubiquity (<< 2.4.3)
62 Replaces: ubuntu-express-frontend-gtk, espresso-frontend-gtk, ubiquity (<< 2.4.3)
63
64=== modified file 'tests/test_wireless.py'
65--- tests/test_wireless.py 2012-07-16 14:29:13 +0000
66+++ tests/test_wireless.py 2017-06-22 16:34:36 +0000
67@@ -4,7 +4,7 @@
68
69 import mock
70
71-from ubiquity import gtkwidgets, nm, plugin_manager
72+from ubiquity import nm, plugin_manager
73
74
75 class WirelessTests(unittest.TestCase):
76@@ -22,20 +22,3 @@
77 self.manager = self.nmwidget.view.wifi_model
78 self.model = self.manager.model
79 self.manager.passphrases_cache = {}
80-
81- @mock.patch('ubiquity.nm.NetworkManager.is_connected')
82- def test_secure_ap_can_enter_password(self, is_connected):
83- is_connected.return_value = False
84- iterator = self.model.append(None, ['/foo', 'Intel', 'Wireless'])
85- iterator_insecure = self.model.append(iterator, ['Insecure', False, 0])
86- iterator_secure = self.model.append(iterator, ['Secure', True, 0])
87- gtkwidgets.refresh()
88- self.assertFalse(self.nmwidget.hbox.get_sensitive())
89- self.nmwidget.view.set_cursor(
90- self.model.get_path(iterator_secure), None, False)
91- gtkwidgets.refresh()
92- self.assertTrue(self.nmwidget.hbox.get_sensitive())
93- self.nmwidget.view.set_cursor(
94- self.model.get_path(iterator_insecure), None, False)
95- gtkwidgets.refresh()
96- self.assertFalse(self.nmwidget.hbox.get_sensitive())
97
98=== modified file 'ubiquity/frontend/gtk_components/nmwidgets.py'
99--- ubiquity/frontend/gtk_components/nmwidgets.py 2016-12-01 14:00:11 +0000
100+++ ubiquity/frontend/gtk_components/nmwidgets.py 2017-06-22 16:34:36 +0000
101@@ -1,11 +1,10 @@
102-import string
103-
104 from dbus.mainloop.glib import DBusGMainLoop
105 DBusGMainLoop(set_as_default=True)
106
107 from gi.repository import Gtk, GObject, GLib
108+from gi.repository import NM, NMA
109
110-from ubiquity.nm import QueuedCaller, NetworkStore, NetworkManager
111+from ubiquity.nm import decode_ssid, QueuedCaller, NetworkStore, NetworkManager
112
113
114 class GLibQueuedCaller(QueuedCaller):
115@@ -92,9 +91,8 @@
116 class NetworkManagerTreeView(Gtk.TreeView):
117 __gtype_name__ = 'NetworkManagerTreeView'
118
119- def __init__(self, password_entry=None, state_changed=None):
120+ def __init__(self, state_changed=None):
121 Gtk.TreeView.__init__(self)
122- self.password_entry = password_entry
123 self.configure_icons()
124 model = GtkNetworkStore()
125 model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
126@@ -102,6 +100,10 @@
127 self.wifi_model = NetworkManager(model,
128 GLibQueuedCaller,
129 state_changed)
130+
131+ self.nm_client = None
132+ self.nm_connection = None
133+
134 self.set_model(model)
135
136 ssid_column = Gtk.TreeViewColumn('')
137@@ -157,17 +159,21 @@
138 self.expand_row(path, False)
139 i = model.iter_next(i)
140
141+ def row_activated(self, unused, path, column):
142+ self.connect_to_selection()
143+
144 def get_state(self):
145 return self.wifi_model.get_state()
146
147 def disconnect_from_ap(self):
148- self.wifi_model.disconnect_from_ap()
149+ if self.nm_connection:
150+ if not self.nm_client:
151+ self.nm_client = NM.Client.new()
152
153- def row_activated(self, unused, path, column):
154- passphrase = None
155- if self.password_entry:
156- passphrase = self.password_entry.get_text()
157- self.connect_to_selection(passphrase)
158+ self.nm_client.deactivate_connection(self.nm_connection)
159+ self.nm_connection = None
160+ else:
161+ self.wifi_model.disconnect_from_ap()
162
163 def configure_icons(self):
164 it = Gtk.IconTheme()
165@@ -220,13 +226,6 @@
166 else:
167 cell.set_property('text', ssid)
168
169- def get_passphrase(self, ssid):
170- try:
171- cached = self.wifi_model.passphrases_cache[ssid]
172- except KeyError:
173- return ''
174- return cached
175-
176 def is_row_an_ap(self):
177 model, iterator = self.get_selection().get_selected()
178 if iterator is None:
179@@ -244,12 +243,72 @@
180 else:
181 return False
182
183- def connect_to_selection(self, passphrase):
184+ def find_ap(self, device, ssid):
185+ for ap in device.get_access_points():
186+ ap_ssid = ap.get_ssid()
187+ if ap_ssid and decode_ssid(ap_ssid.get_data()) == ssid:
188+ return ap
189+ return None
190+
191+ def connect_cb(self, client, result, user_data):
192+ self.nm_connection = client.add_and_activate_connection_finish(result)
193+
194+ def connect_dialog_cb(self, dialog, response):
195+ if response == Gtk.ResponseType.OK:
196+ connection, device, ap = dialog.get_connection()
197+
198+ if not self.nm_client:
199+ self.nm_client = NM.Client.new()
200+
201+ self.nm_client.add_and_activate_connection_async(
202+ connection, device, None, None, self.connect_cb, None
203+ )
204+ dialog.hide()
205+
206+ def connect_to_selection(self):
207 model, iterator = self.get_selection().get_selected()
208- ssid = model[iterator][0]
209+ if iterator is None:
210+ return
211 parent = model.iter_parent(iterator)
212 if parent:
213- self.wifi_model.connect_to_ap(model[parent][0], ssid, passphrase)
214+ try:
215+ devid = model[parent][0]
216+ ssid = model[iterator][0]
217+ if model[iterator][1]:
218+ if not self.nm_client:
219+ self.nm_client = NM.Client.new()
220+
221+ device = self.nm_client.get_device_by_path(devid)
222+ ap = self.find_ap(device, ssid)
223+
224+ connection = NM.SimpleConnection()
225+ connection.add_setting(NM.SettingConnection(
226+ uuid=NM.utils_uuid_generate()
227+ ))
228+ connection.add_setting(NM.SettingWireless(
229+ ssid=ap.get_property("ssid")
230+ ))
231+
232+ dialog = NMA.WifiDialog.new(
233+ self.nm_client,
234+ connection,
235+ device,
236+ ap,
237+ False
238+ )
239+ dialog.connect("response", self.connect_dialog_cb)
240+ dialog.run()
241+ else:
242+ self.wifi_model.connect_to_ap(devid, ssid)
243+ except Exception as e:
244+ dialog = Gtk.MessageDialog(
245+ None, Gtk.DialogFlags.MODAL,
246+ Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
247+ "Failed to connect to wireless network"
248+ )
249+ dialog.format_secondary_text("{}".format(e))
250+ dialog.run()
251+ dialog.hide()
252
253
254 GObject.type_register(NetworkManagerTreeView)
255@@ -262,44 +321,23 @@
256 GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE,
257 (GObject.TYPE_UINT,)),
258 'selection_changed': (
259- GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ()),
260- 'pw_validated': (
261- GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE,
262- (GObject.TYPE_BOOLEAN,))}
263+ GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())}
264
265 def __init__(self):
266 Gtk.Box.__init__(self)
267 self.set_orientation(Gtk.Orientation.VERTICAL)
268 self.set_spacing(12)
269- self.password_entry = Gtk.Entry()
270- self.view = NetworkManagerTreeView(self.password_entry,
271- self.state_changed)
272+ self.view = NetworkManagerTreeView(self.state_changed)
273 scrolled_window = Gtk.ScrolledWindow()
274 scrolled_window.set_policy(
275 Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
276 scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
277 scrolled_window.add(self.view)
278 self.pack_start(scrolled_window, True, True, 0)
279- self.hbox = Gtk.Box(spacing=6)
280- self.pack_start(self.hbox, False, True, 0)
281- self.password_label = Gtk.Label(label='Password:')
282- self.password_entry.set_visibility(False)
283- self.password_entry.connect('activate', self.connect_to_ap)
284- self.password_entry.connect('changed', self.password_entry_changed)
285- self.display_password = Gtk.CheckButton(label='Display password')
286- self.display_password.connect('toggled', self.display_password_toggled)
287- self.hbox.pack_start(self.password_label, False, True, 0)
288- self.hbox.pack_start(self.password_entry, True, True, 0)
289- self.hbox.pack_start(self.display_password, False, True, 0)
290- self.hbox.set_sensitive(False)
291 self.selection = self.view.get_selection()
292 self.selection.connect('changed', self.changed)
293 self.show_all()
294
295- def translate(self, password_label_text, display_password_text):
296- self.password_label.set_label(password_label_text)
297- self.display_password.set_label(display_password_text)
298-
299 def get_state(self):
300 return self.view.get_state()
301
302@@ -315,48 +353,16 @@
303 def state_changed(self, state):
304 self.emit('connection', state)
305
306- def password_is_valid(self):
307- passphrase = self.password_entry.get_text()
308- if len(passphrase) >= 8 and len(passphrase) < 64:
309- return True
310- if len(passphrase) == 64:
311- for c in passphrase:
312- if c not in string.hexdigits:
313- return False
314- return True
315- else:
316- return False
317-
318 def connect_to_ap(self, *args):
319- if self.password_is_valid():
320- passphrase = self.password_entry.get_text()
321- self.view.connect_to_selection(passphrase)
322+ self.view.connect_to_selection()
323
324 def disconnect_from_ap(self):
325 self.view.disconnect_from_ap()
326
327- def password_entry_changed(self, *args):
328- self.emit('pw_validated', self.password_is_valid())
329-
330- def display_password_toggled(self, *args):
331- self.password_entry.set_visibility(self.display_password.get_active())
332-
333 def changed(self, selection):
334 iterator = selection.get_selected()[1]
335 if not iterator:
336 return
337- row = selection.get_tree_view().get_model()[iterator]
338- secure = row[1]
339- ssid = row[0]
340- if secure:
341- self.hbox.set_sensitive(True)
342- passphrase = self.view.get_passphrase(ssid)
343- self.password_entry.set_text(passphrase)
344- self.emit('pw_validated', False)
345- else:
346- self.hbox.set_sensitive(False)
347- self.password_entry.set_text('')
348- self.emit('pw_validated', True)
349 self.emit('selection_changed')
350
351
352
353=== modified file 'ubiquity/frontend/kde_components/nmwidgets.py'
354--- ubiquity/frontend/kde_components/nmwidgets.py 2016-10-06 14:29:28 +0000
355+++ ubiquity/frontend/kde_components/nmwidgets.py 2017-06-22 16:34:36 +0000
356@@ -272,7 +272,13 @@
357
358 def connect_to_selection(self, passphrase):
359 devid, ssid = self._get_selected_row_ids()
360- self.wifi_model.connect_to_ap(devid, ssid, passphrase)
361+ try:
362+ self.wifi_model.connect_to_ap(devid, ssid, passphrase)
363+ except Exception as e:
364+ dialog = QtWidgets.QMessageBox()
365+ dialog.setWindowTitle("Failed to connect to wireless network")
366+ dialog.setText("{}".format(e))
367+ dialog.exec_()
368
369 def get_cached_passphrase(self):
370 index = self.currentIndex()
371
372=== modified file 'ubiquity/plugins/ubi-wireless.py'
373--- ubiquity/plugins/ubi-wireless.py 2016-10-06 03:27:02 +0000
374+++ ubiquity/plugins/ubi-wireless.py 2017-06-22 16:34:36 +0000
375@@ -84,7 +84,6 @@
376 self.nmwidget = builder.get_object('nmwidget')
377 self.nmwidget.connect('connection', self.state_changed)
378 self.nmwidget.connect('selection_changed', self.selection_changed)
379- self.nmwidget.connect('pw_validated', self.pw_validated)
380 self.no_wireless = builder.get_object('no_wireless')
381 self.use_wireless = builder.get_object('use_wireless')
382 self.use_wireless.connect('toggled', self.wireless_toggled)
383@@ -99,10 +98,6 @@
384
385 def plugin_translate(self, lang):
386 get_s = self.controller.get_string
387- label_text = get_s('ubiquity/text/wireless_password_label')
388- display_text = get_s('ubiquity/text/wireless_display_password')
389- self.nmwidget.translate(label_text, display_text)
390-
391 self.connect_text = get_s('ubiquity/text/connect', lang)
392 self.stop_text = get_s('ubiquity/text/stop', lang)
393 frontend = self.controller._wizard
394@@ -141,7 +136,6 @@
395 frontend.connecting_spinner.stop()
396 frontend.connecting_label.hide()
397 frontend.translate_widget(frontend.next)
398- self.nmwidget.hbox.set_sensitive(False)
399 self.next_normal = True
400 self.controller.allow_go_forward(True)
401
402@@ -179,7 +173,6 @@
403 frontend.connecting_spinner.hide()
404 frontend.connecting_spinner.stop()
405 frontend.connecting_label.hide()
406- self.controller.allow_go_forward(True)
407
408 frontend.translate_widget(frontend.back)
409 self.back_normal = True
410@@ -196,9 +189,6 @@
411 frontend.back.set_sensitive(True)
412 self.selection_changed(None)
413
414- def pw_validated(self, unused, validated):
415- self.controller.allow_go_forward(validated)
416-
417
418 class PageKde(WirelessPageBase):
419 plugin_breadcrumb = 'ubiquity/text/breadcrumb_wireless'

Subscribers

People subscribed via source and target branches

to status/vote changes: