~ubuntu-branches/ubuntu/precise/ubiquity/precise-proposed

« back to all changes in this revision

Viewing changes to ubiquity/nm.py

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber, James M. Leddy, Colin Watson, Stéphane Graber, Kent Baxley, Harald Sitter
  • Date: 2012-07-17 17:48:48 UTC
  • Revision ID: package-import@ubuntu.com-20120717174848-i3zgd6w9lkz4ok1a
Tags: 2.10.18
[ James M. Leddy ]
* Only allow a user to proceed on the networking screen if he entered a valid
  password. This prevents a nm dbus exception. (LP: #929092)

[ Colin Watson ]
* Install oem-config-slideshow-ubuntu in a separate pass from
  oem-config-$frontend and ubiquity-frontend-$frontend, since it may be
  missing from images; and only do this for the GTK frontend in any case,
  since other frontends don't currently use the slideshow (LP: #987050).
* Don't try and fail to set up encrypted swap if no swap partitions are
  configured (LP: #989279).

[ Stéphane Graber ]
* Get d-i components from precise-updates. (LP: #992241)
* Automatic update of included source packages: partman-base
  153ubuntu5, partman-target 77ubuntu2.1.

[ Kent Baxley ]
* Add the ability to run simple, custom scripts in ubiquity-dm
  (LP: #1017580).

[ Harald Sitter ]
* Fix bogus attribute access in usersetup plugin leading to crashes with
  the KDE frontend (LP: #1008255)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import subprocess
 
2
import string
2
3
 
3
4
import dbus
4
5
from dbus.mainloop.glib import DBusGMainLoop
392
393
    __gsignals__ = { 'connection' : (GObject.SignalFlags.RUN_FIRST,
393
394
                                     GObject.TYPE_NONE, (GObject.TYPE_UINT,)),
394
395
                     'selection_changed' : (GObject.SignalFlags.RUN_FIRST,
395
 
                                            GObject.TYPE_NONE, ())}
 
396
                                            GObject.TYPE_NONE, ()),
 
397
                     'pw_validated' : (GObject.SignalFlags.RUN_FIRST,
 
398
                                       GObject.TYPE_NONE, (GObject.TYPE_BOOLEAN,))}
396
399
    def __init__(self):
397
400
        Gtk.Box.__init__(self)
398
401
        self.set_orientation(Gtk.Orientation.VERTICAL)
410
413
        self.password_label = Gtk.Label('Password:')
411
414
        self.password_entry.set_visibility(False)
412
415
        self.password_entry.connect('activate', self.connect_to_ap)
 
416
        self.password_entry.connect('changed', self.password_entry_changed)
413
417
        self.display_password = Gtk.CheckButton('Display password')
414
418
        self.display_password.connect('toggled', self.display_password_toggled)
415
419
        self.hbox.pack_start(self.password_label, False, True, 0)
439
443
    def state_changed(self, state):
440
444
        self.emit('connection', state)
441
445
 
 
446
    def password_is_valid(self):
 
447
        passphrase = self.password_entry.get_text()
 
448
        if len(passphrase) >= 8 and \
 
449
           len(passphrase) < 64 :
 
450
            return True
 
451
        if len(passphrase) == 64:
 
452
            for c in passphrase:
 
453
                if not c in string.hexdigits: return False
 
454
            return True
 
455
        else:
 
456
            return False
 
457
 
442
458
    def connect_to_ap(self, *args):
443
 
        passphrase = self.password_entry.get_text()
444
 
        self.view.connect_to_selection(passphrase)
 
459
        if self.password_is_valid():
 
460
            passphrase = self.password_entry.get_text()
 
461
            self.view.connect_to_selection(passphrase)
445
462
 
446
463
    def disconnect_from_ap(self):
447
464
        self.view.disconnect_from_ap()
 
465
        
 
466
    def password_entry_changed(self, *args):
 
467
        self.emit('pw_validated', self.password_is_valid())
448
468
 
449
469
    def display_password_toggled(self, *args):
450
470
        self.password_entry.set_visibility(self.display_password.get_active())
460
480
            self.hbox.set_sensitive(True)
461
481
            passphrase = self.view.get_passphrase(ssid)
462
482
            self.password_entry.set_text(passphrase)
 
483
            self.emit('pw_validated', False)
463
484
        else:
464
485
            self.hbox.set_sensitive(False)
465
486
            self.password_entry.set_text('')
 
487
            self.emit('pw_validated', True)
466
488
        self.emit('selection_changed')
467
489
 
 
490
 
468
491
GObject.type_register(NetworkManagerWidget)
469
492
 
470
493
if __name__ == '__main__':