From 4153bee65d2541b99d4e41aaaf2fd6b2b71b2cc3 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 19 Nov 2012 23:15:36 +0900 Subject: disable "next" button during validation and wait for user to click it. Closes #973 --- src/leap/gui/firstrun/providerinfo.py | 48 +++++++++++++++++++++++----- src/leap/gui/firstrun/providersetup.py | 19 ++++++----- src/leap/gui/firstrun/register.py | 1 + src/leap/gui/firstrun/regvalidation.py | 58 ++++++++++++++++++++-------------- src/leap/gui/firstrun/wizard.py | 3 ++ src/leap/gui/progress.py | 28 ++++++++++++++++ 6 files changed, 117 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/leap/gui/firstrun/providerinfo.py b/src/leap/gui/firstrun/providerinfo.py index e642fcd0..8a3243fc 100644 --- a/src/leap/gui/firstrun/providerinfo.py +++ b/src/leap/gui/firstrun/providerinfo.py @@ -32,6 +32,7 @@ class ProviderInfoPage(ValidationPage): QtGui.QPixmap(APP_LOGO)) self.prev_page = "providerselection" + self.infoWidget = None #self.current_page = "providerinfo" def create_info_panel(self): @@ -62,6 +63,8 @@ class ProviderInfoPage(ValidationPage): # add refs to self to allow for # updates. + # Watch out! Have to get rid of these references! + # this should be better handled with signals !! self.displayName = displayName self.description = description self.enrollment_policy = enrollment_policy @@ -93,8 +96,11 @@ class ProviderInfoPage(ValidationPage): """ executes actual checks in a separate thread """ + finish = lambda: update_signal.emit("end_sentinel", 100) + def pause_and_finish(): - update_signal.emit("end_sentinel", 100) + # only for local debug + finish() pause_for_user() wizard = self.wizard() @@ -164,13 +170,13 @@ class ProviderInfoPage(ValidationPage): #self.did_cert_check = True #self.completeChanged.emit() #return False - pause_and_finish() + finish() return False except baseexceptions.LeapException as exc: wizard.set_validation_error( prevpage, exc.usermessage) - pause_and_finish() + finish() return False ################################## @@ -190,19 +196,20 @@ class ProviderInfoPage(ValidationPage): wizard.set_validation_error( prevpage, "Could not get info from provider.") - pause_and_finish() + finish() return False except requests.exceptions.ConnectionError: wizard.set_validation_error( prevpage, "Could not download provider info " "(refused conn.).") - pause_and_finish() + finish() return False # XXX catch more errors... # We're done! - pause_and_finish() + self.set_done() + finish() def _do_validation(self): """ @@ -214,8 +221,7 @@ class ProviderInfoPage(ValidationPage): errors = self.wizard().get_validation_error(prevpage) if not errors: - self.progress.hide() - self.stepsTableWidget.hide() + self.hide_progress() self.create_info_panel() self.show_provider_info() @@ -228,3 +234,29 @@ class ProviderInfoPage(ValidationPage): wizard = self.wizard() next_ = "providersetupvalidation" return wizard.get_page_index(next_) + + #def isComplete(self): + #return self.is_done() + + def initializePage(self): + logger.error('INITIALIZE PAGE --------------') + logger.error('**') + logger.error('**') + super(ProviderInfoPage, self).initializePage() + self.show_progress() + self.set_undone() + self.completeChanged.emit() + + def cleanupPage(self): + logger.error('CLEANUP PAGE --------------') + + del self.wizard().providerconfig + + if self.infoWidget: + QtCore.QObjectCleanupHandler().add( + self.infoWidget) + + # refactor this into some kind of destructor + del self.displayName + del self.description + del self.enrollment_policy diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py index 3fb9a19b..5b50db87 100644 --- a/src/leap/gui/firstrun/providersetup.py +++ b/src/leap/gui/firstrun/providersetup.py @@ -78,12 +78,12 @@ class ProviderSetupValidationPage(ValidationPage): "Authentication error: %s" % exc.message) return False - pause_for_user() + #pause_for_user() ####################################### update_signal.emit('Fetching CA certificate', 30) - pause_for_user() + #pause_for_user() if pconfig: ca_cert_uri = pconfig.get('ca_cert_uri').geturl() @@ -100,7 +100,7 @@ class ProviderSetupValidationPage(ValidationPage): pCertChecker.download_ca_cert( uri=ca_cert_uri, verify=False) - pause_for_user() + #pause_for_user() update_signal.emit('Checking CA fingerprint', 66) #ca_cert_fingerprint = pconfig.get('ca_cert_fingerprint', None) @@ -133,11 +133,13 @@ class ProviderSetupValidationPage(ValidationPage): # XXX update validationMsg # should catch exception #return False - pause_for_user() + + #pause_for_user() #ca_cert_path = checker.ca_cert_path + self.set_done() update_signal.emit('end_sentinel', 100) - pause_for_user() + #pause_for_user() def _do_validation(self): """ @@ -153,10 +155,11 @@ class ProviderSetupValidationPage(ValidationPage): wizard.set_validation_error( prevpage, first_error) - self.go_back() + # XXX don't go back, signal error + #self.go_back() else: - logger.debug('going next') - self.go_next() + logger.debug('should be going next, wait on user') + #self.go_next() def nextId(self): wizard = self.wizard() diff --git a/src/leap/gui/firstrun/register.py b/src/leap/gui/firstrun/register.py index b46dd4cd..e1a8149c 100644 --- a/src/leap/gui/firstrun/register.py +++ b/src/leap/gui/firstrun/register.py @@ -59,6 +59,7 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn): self.registerField('userName*', self.userNameLineEdit) self.registerField('userPassword*', self.userPasswordLineEdit) + self.registerField('userPassword2*', self.userPassword2LineEdit) # XXX missing password confirmation # XXX validator! diff --git a/src/leap/gui/firstrun/regvalidation.py b/src/leap/gui/firstrun/regvalidation.py index dbe30d3c..6db2bf6e 100644 --- a/src/leap/gui/firstrun/regvalidation.py +++ b/src/leap/gui/firstrun/regvalidation.py @@ -29,16 +29,10 @@ class RegisterUserValidationPage(ValidationPage): def __init__(self, parent=None): super(RegisterUserValidationPage, self).__init__(parent) - is_signup = self.field("is_signup") - self.is_signup = is_signup - if is_signup: - title = "User Creation" - subtitle = "Registering account with provider." - else: - title = "Connecting..." - # XXX uh... really? - subtitle = "Checking connection with provider." + title = "Connecting..." + # XXX uh... really? + subtitle = "Checking connection with provider." self.setTitle(title) self.setSubTitle(subtitle) @@ -67,7 +61,7 @@ class RegisterUserValidationPage(ValidationPage): # Set Credentials. # username and password are in different fields # if they were stored in log_in or sign_up pages. - is_signup = self.is_signup + is_signup = self.field("is_signup") unamek_base = 'userName' passwk_base = 'userPassword' @@ -85,6 +79,7 @@ class RegisterUserValidationPage(ValidationPage): ########################################### # only if from signup + # MOVE TO SIGNUP PAGE... if is_signup: signup = auth.LeapSRPRegister( schema="https", @@ -97,6 +92,8 @@ class RegisterUserValidationPage(ValidationPage): # 1) register user ################################################## # only if from signup. + # XXX MOVE THIS STEP TO SIGNUP-IN-PLACE VALIDATION + # WIDGET.......................................... if is_signup: @@ -113,7 +110,7 @@ class RegisterUserValidationPage(ValidationPage): self.set_error( step, "Error connecting to provider (timeout)") - pause_for_user() + #pause_for_user() return False except requests.exceptions.ConnectionError as exc: @@ -123,9 +120,9 @@ class RegisterUserValidationPage(ValidationPage): "Error connecting to provider " "(connection error)") # XXX we should signal a BAD step - pause_for_user() + #pause_for_user() update_signal.emit("connection error!", 50) - pause_for_user() + #pause_for_user() return False # XXX check for != OK instead??? @@ -147,10 +144,10 @@ class RegisterUserValidationPage(ValidationPage): self.set_error( step, 'Username not available.') - pause_for_user() + #pause_for_user() return False - pause_for_user() + #pause_for_user() ################################################## # 2) fetching eip service config @@ -168,9 +165,9 @@ class RegisterUserValidationPage(ValidationPage): self.set_error( step, 'Could not download eip config.') - pause_for_user() + #pause_for_user() return False - pause_for_user() + #pause_for_user() ################################################## # 3) getting client certificate @@ -192,16 +189,17 @@ class RegisterUserValidationPage(ValidationPage): "Authentication error: %s" % exc.message) return False - pause_for_user() + #pause_for_user() ################ # end ! ################ update_signal.emit("end_sentinel", 100) - pause_for_user() + #pause_for_user() # here we go! :) + # this should be called CONNECT PAGE AGAIN. self.run_eip_checks_for_provider_and_connect(_domain) def run_eip_checks_for_provider_and_connect(self, domain): @@ -225,6 +223,14 @@ class RegisterUserValidationPage(ValidationPage): "probably the wizard has been launched " "in an stand-alone way.") + # XXX look for a better place to signal + # we are done. + # We could probably have a fake validatePage + # that checks if the domain transfer has been + # done to conductor object, triggers the start_signal + # and does the go_next() + self.set_done() + def eip_error_check(self): """ a version of the main app error checker, @@ -241,7 +247,8 @@ class RegisterUserValidationPage(ValidationPage): called after _do_checks has finished (connected to checker thread finished signal) """ - prevpage = "signup" if self.is_signup else "login" + is_signup = self.field("is_signup") + prevpage = "signup" if is_signup else "login" wizard = self.wizard() if self.errors: @@ -253,13 +260,16 @@ class RegisterUserValidationPage(ValidationPage): first_error) self.go_back() else: - logger.debug('going next') - # check if this "next" interferes - # with the eip signal. - self.go_next() + logger.debug('should go next, wait for user to click next') + #self.go_next() def nextId(self): wizard = self.wizard() if not wizard: return return wizard.get_page_index('lastpage') + + def initializePage(self): + super(RegisterUserValidationPage, self).initializePage() + self.set_undone() + self.completeChanged.emit() diff --git a/src/leap/gui/firstrun/wizard.py b/src/leap/gui/firstrun/wizard.py index bbb48149..8efa2018 100755 --- a/src/leap/gui/firstrun/wizard.py +++ b/src/leap/gui/firstrun/wizard.py @@ -137,6 +137,9 @@ class FirstRunWizard(QtGui.QWizard): QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/images/background.png')) + # set options + self.setOption(QtGui.QWizard.IndependentPages, on=False) + self.setWindowTitle("First Run Wizard") # TODO: set style for MAC / windows ... diff --git a/src/leap/gui/progress.py b/src/leap/gui/progress.py index 6e8abc1f..687356aa 100644 --- a/src/leap/gui/progress.py +++ b/src/leap/gui/progress.py @@ -185,6 +185,26 @@ class ValidationPage(QtGui.QWizardPage): self.onStepStatusChanged) self.errors = OrderedDict() + self.done = False + + # Sets/unsets done flag + # for isComplete checks + + def set_done(self): + self.done = True + self.completeChanged.emit() + + def set_undone(self): + self.done = False + self.completeChanged.emit() + + def is_done(self): + return self.done + + def isComplete(self): + return self.is_done() + + ######################## def set_error(self, name, error): self.errors[name] = error @@ -285,3 +305,11 @@ class ValidationPage(QtGui.QWizardPage): #logger.debug('check thread started!') #logger.debug('waiting for it to terminate...') self.checks.wait() + + def show_progress(self): + self.progress.show() + self.stepsTableWidget.show() + + def hide_progress(self): + self.progress.hide() + self.stepsTableWidget.hide() -- cgit v1.2.3