Merge lp:~jm-leddy/ubiquity/lp929092 into lp:ubiquity

Proposed by James M. Leddy
Status: Merged
Merged at revision: 5523
Proposed branch: lp:~jm-leddy/ubiquity/lp929092
Merge into: lp:ubiquity
Diff against target: 100 lines (+30/-3)
2 files modified
ubiquity/nm.py (+26/-3)
ubiquity/plugins/ubi-wireless.py (+4/-0)
To merge this branch: bzr merge lp:~jm-leddy/ubiquity/lp929092
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+112211@code.launchpad.net

Description of the change

Only allow a user to proceed on the networking screen if he entered a valid password. This
prevents a nm dbus exception.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubiquity/nm.py'
2--- ubiquity/nm.py 2012-06-05 15:06:48 +0000
3+++ ubiquity/nm.py 2012-06-26 20:29:19 +0000
4@@ -1,4 +1,5 @@
5 import subprocess
6+import string
7
8 import dbus
9 from dbus.mainloop.glib import DBusGMainLoop
10@@ -391,7 +392,9 @@
11 __gsignals__ = { 'connection' : (GObject.SignalFlags.RUN_FIRST,
12 GObject.TYPE_NONE, (GObject.TYPE_UINT,)),
13 'selection_changed' : (GObject.SignalFlags.RUN_FIRST,
14- GObject.TYPE_NONE, ())}
15+ GObject.TYPE_NONE, ()),
16+ 'pw_validated' : (GObject.SignalFlags.RUN_FIRST,
17+ GObject.TYPE_NONE, (GObject.TYPE_BOOLEAN,))}
18 def __init__(self):
19 Gtk.Box.__init__(self)
20 self.set_orientation(Gtk.Orientation.VERTICAL)
21@@ -409,6 +412,7 @@
22 self.password_label = Gtk.Label('Password:')
23 self.password_entry.set_visibility(False)
24 self.password_entry.connect('activate', self.connect_to_ap)
25+ self.password_entry.connect('changed', self.password_entry_changed)
26 self.display_password = Gtk.CheckButton('Display password')
27 self.display_password.connect('toggled', self.display_password_toggled)
28 self.hbox.pack_start(self.password_label, False, True, 0)
29@@ -438,12 +442,28 @@
30 def state_changed(self, state):
31 self.emit('connection', state)
32
33+ def password_is_valid(self):
34+ passphrase = self.password_entry.get_text()
35+ if len(passphrase) >= 8 and \
36+ len(passphrase) < 64 :
37+ return True
38+ if len(passphrase) == 64:
39+ for c in passphrase:
40+ if not c in string.hexdigits: return False
41+ return True
42+ else:
43+ return False
44+
45 def connect_to_ap(self, *args):
46- passphrase = self.password_entry.get_text()
47- self.view.connect_to_selection(passphrase)
48+ if self.password_is_valid():
49+ passphrase = self.password_entry.get_text()
50+ self.view.connect_to_selection(passphrase)
51
52 def disconnect_from_ap(self):
53 self.view.disconnect_from_ap()
54+
55+ def password_entry_changed(self, *args):
56+ self.emit('pw_validated', self.password_is_valid())
57
58 def display_password_toggled(self, *args):
59 self.password_entry.set_visibility(self.display_password.get_active())
60@@ -459,11 +479,14 @@
61 self.hbox.set_sensitive(True)
62 passphrase = self.view.get_passphrase(ssid)
63 self.password_entry.set_text(passphrase)
64+ self.emit('pw_validated', False)
65 else:
66 self.hbox.set_sensitive(False)
67 self.password_entry.set_text('')
68+ self.emit('pw_validated', True)
69 self.emit('selection_changed')
70
71+
72 GObject.type_register(NetworkManagerWidget)
73
74 if __name__ == '__main__':
75
76=== modified file 'ubiquity/plugins/ubi-wireless.py'
77--- ubiquity/plugins/ubi-wireless.py 2012-02-04 02:53:32 +0000
78+++ ubiquity/plugins/ubi-wireless.py 2012-06-26 20:29:19 +0000
79@@ -51,6 +51,7 @@
80 self.nmwidget = builder.get_object('nmwidget')
81 self.nmwidget.connect('connection', self.state_changed)
82 self.nmwidget.connect('selection_changed', self.selection_changed)
83+ self.nmwidget.connect('pw_validated', self.pw_validated)
84 self.use_wireless = builder.get_object('use_wireless')
85 self.use_wireless.connect('toggled', self.wireless_toggled)
86 self.plugin_widgets = self.page
87@@ -104,6 +105,7 @@
88 frontend.connecting_spinner.stop()
89 frontend.connecting_label.hide()
90 frontend.translate_widget(frontend.next)
91+ self.nmwidget.hbox.set_sensitive(False)
92 self.next_normal = True
93 self.controller.allow_go_forward(True)
94
95@@ -166,3 +168,5 @@
96 frontend.back.set_sensitive(True)
97 self.selection_changed(None)
98
99+ def pw_validated(self, unused, validated):
100+ self.controller.allow_go_forward(validated)

Subscribers

People subscribed via source and target branches

to status/vote changes: