From b3c0634dc6e01656422a6c70297fc46d808f303f Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 8 Nov 2012 06:02:36 +0900 Subject: selectprovider rename + fix onComplete function for provider entry --- src/leap/gui/firstrun/providerselect.py | 181 ++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 src/leap/gui/firstrun/providerselect.py (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py new file mode 100644 index 00000000..c282e3ab --- /dev/null +++ b/src/leap/gui/firstrun/providerselect.py @@ -0,0 +1,181 @@ +""" +Select Provider Page, used in First Run Wizard +""" +import logging + +from PyQt4 import QtCore +from PyQt4 import QtGui + +from leap.base import exceptions as baseexceptions +from leap.crypto import certs +from leap.eip import exceptions as eipexceptions + +from leap.gui.constants import APP_LOGO +from leap.gui.styles import ErrorLabelStyleSheet + +logger = logging.getLogger(__name__) + + +class SelectProviderPage(QtGui.QWizardPage): + def __init__(self, parent=None, providers=None): + super(SelectProviderPage, self).__init__(parent) + + self.setTitle("Enter Provider") + self.setSubTitle( + "Please enter the domain of the provider you want " + "to use for your connection." + ) + self.setPixmap( + QtGui.QWizard.LogoPixmap, + QtGui.QPixmap(APP_LOGO)) + + self.did_cert_check = False + + providerNameLabel = QtGui.QLabel("h&ttps://") + # note that we expect the bare domain name + # we will add the scheme later + providerNameEdit = QtGui.QLineEdit() + providerNameEdit.cursorPositionChanged.connect( + self.reset_validation_status) + providerNameLabel.setBuddy(providerNameEdit) + + # add regex validator + providerDomainRe = QtCore.QRegExp(r"^[a-z\d_-.]+$") + providerNameEdit.setValidator( + QtGui.QRegExpValidator(providerDomainRe, self)) + self.providerNameEdit = providerNameEdit + + # Eventually we will seed a list of + # well known providers here. + + #providercombo = QtGui.QComboBox() + #if providers: + #for provider in providers: + #providercombo.addItem(provider) + #providerNameSelect = providercombo + + self.registerField("provider_domain*", self.providerNameEdit) + #self.registerField('provider_name_index', providerNameSelect) + + validationMsg = QtGui.QLabel("") + validationMsg.setStyleSheet(ErrorLabelStyleSheet) + self.validationMsg = validationMsg + + # cert info + + # this is used in the callback + # for the checkbox changes. + # tricky, since the first time came + # from the exception message. + # should get string from exception too! + self.bad_cert_status = "Server certificate could not be verified." + + self.certInfo = QtGui.QLabel("") + self.certInfo.setWordWrap(True) + self.certWarning = QtGui.QLabel("") + self.trustProviderCertCheckBox = QtGui.QCheckBox( + "&Trust this provider certificate.") + + self.trustProviderCertCheckBox.stateChanged.connect( + self.onTrustCheckChanged) + self.providerNameEdit.textChanged.connect( + self.onProviderChanged) + + layout = QtGui.QGridLayout() + layout.addWidget(validationMsg, 0, 2) + layout.addWidget(providerNameLabel, 1, 1) + layout.addWidget(providerNameEdit, 1, 2) + + # XXX get a groupbox or something.... + certinfoGroup = QtGui.QGroupBox("Certificate validation") + certinfoLayout = QtGui.QVBoxLayout() + certinfoLayout.addWidget(self.certInfo) + certinfoLayout.addWidget(self.certWarning) + certinfoLayout.addWidget(self.trustProviderCertCheckBox) + certinfoGroup.setLayout(certinfoLayout) + + layout.addWidget(certinfoGroup, 4, 1, 4, 2) + self.certinfoGroup = certinfoGroup + self.certinfoGroup.hide() + + self.setLayout(layout) + + def is_insecure_cert_trusted(self): + return self.trustProviderCertCheckBox.isChecked() + + def onTrustCheckChanged(self, state): + checked = False + if state == 2: + checked = True + + if checked: + self.reset_validation_status() + else: + self.set_validation_status(self.bad_cert_status) + + # trigger signal to redraw next button + self.completeChanged.emit() + + def onProviderChanged(self, text): + self.completeChanged.emit() + + def reset_validation_status(self): + """ + empty the validation msg + """ + self.validationMsg.setText('') + + #def set_validation_status(selF, STATUS): + #self.validationMsg.setText(status) + + def add_cert_info(self, certinfo): + self.certWarning.setText( + "Do you want to trust this provider certificate?") + self.certInfo.setText( + 'SHA-256 fingerprint: %s
' % certinfo) + self.certInfo.setWordWrap(True) + self.certinfoGroup.show() + + # pagewizard methods + + def isComplete(self): + provider = self.providerNameEdit.text() + + if not provider: + return False + else: + if self.is_insecure_cert_trusted(): + return True + if not self.did_cert_check: + return True + return False + + def populateErrors(self): + # XXX could move this to ValidationMixin + + #logger.debug('getting errors') + errors = self.wizard().get_validation_error('providerselection') + if errors: + #logger.debug('errors! -> %s', errors) + self.validationMsg.setText(errors) + + def paintEvent(self, event): + """ + we hook our populate errors + on paintEvent because we need it to catch + when user enters the page coming from next, + and initializePage does not cover that case. + Maybe there's a better event to hook upon. + """ + super(SelectProviderPage, self).paintEvent(event) + self.populateErrors() + + def initializePage(self): + self.validationMsg.setText('') + self.certinfoGroup.hide() + + def nextId(self): + wizard = self.wizard() + if not wizard: + return + return wizard.get_page_index('providerinfo') -- cgit v1.2.3 From 8118056a244ca74d16380ad26a70e3da40e7e401 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 9 Nov 2012 11:21:40 +0900 Subject: connect page merged into regvalidation. Flow nearly working with fake provider, except for authentication. --- src/leap/gui/firstrun/providerselect.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index c282e3ab..a20f40b3 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -6,9 +6,9 @@ import logging from PyQt4 import QtCore from PyQt4 import QtGui -from leap.base import exceptions as baseexceptions -from leap.crypto import certs -from leap.eip import exceptions as eipexceptions +#from leap.base import exceptions as baseexceptions +#from leap.crypto import certs +#from leap.eip import exceptions as eipexceptions from leap.gui.constants import APP_LOGO from leap.gui.styles import ErrorLabelStyleSheet @@ -30,6 +30,7 @@ class SelectProviderPage(QtGui.QWizardPage): QtGui.QPixmap(APP_LOGO)) self.did_cert_check = False + self.current_page = 'providerselection' providerNameLabel = QtGui.QLabel("h&ttps://") # note that we expect the bare domain name @@ -154,7 +155,8 @@ class SelectProviderPage(QtGui.QWizardPage): # XXX could move this to ValidationMixin #logger.debug('getting errors') - errors = self.wizard().get_validation_error('providerselection') + errors = self.wizard().get_validation_error( + self.current_page) if errors: #logger.debug('errors! -> %s', errors) self.validationMsg.setText(errors) -- cgit v1.2.3 From fe16e62fa83c24d2ef379a3f9e102d336e527656 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 12:25:11 +0900 Subject: cleanup errors on page init and on field change --- src/leap/gui/firstrun/providerselect.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index a20f40b3..3fb76557 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -153,13 +153,27 @@ class SelectProviderPage(QtGui.QWizardPage): def populateErrors(self): # XXX could move this to ValidationMixin + # with some defaults for the validating fields + # (now it only allows one field, manually specified) #logger.debug('getting errors') errors = self.wizard().get_validation_error( self.current_page) if errors: - #logger.debug('errors! -> %s', errors) - self.validationMsg.setText(errors) + bad_str = getattr(self, 'bad_string', None) + cur_str = self.providerNameEdit.text() + showerr = self.validationMsg.setText + if bad_str is None: + # first time we fall here. + # save the current bad_string value + self.bad_string = cur_str + showerr(errors) + else: + # not the first time + if cur_str == bad_str: + showerr(errors) + else: + showerr('') def paintEvent(self, event): """ -- cgit v1.2.3 From 42ba228eecb5726506848bd08758bd1f925905cc Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 12:45:37 +0900 Subject: fix prevalidation error showing in register page. --- src/leap/gui/firstrun/providerselect.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 3fb76557..8d1aa869 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -175,6 +175,13 @@ class SelectProviderPage(QtGui.QWizardPage): else: showerr('') + def cleanup_errormsg(self): + """ + we reset bad_string to None + should be called before leaving the page + """ + self.bad_string = None + def paintEvent(self, event): """ we hook our populate errors @@ -190,6 +197,13 @@ class SelectProviderPage(QtGui.QWizardPage): self.validationMsg.setText('') self.certinfoGroup.hide() + def validatePage(self): + # some cleanup before we leave the page + self.cleanup_errormsg() + + # go + return True + def nextId(self): wizard = self.wizard() if not wizard: -- cgit v1.2.3 From d225d5a4eb0a8e63eb11a0311c732bda88e8385b Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 20 Nov 2012 04:11:01 +0900 Subject: TableWidget refactor so we can use it also in the inline validation widgets. --- src/leap/gui/firstrun/providerselect.py | 107 ++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 20 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 8d1aa869..fc030cf3 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -11,12 +11,13 @@ from PyQt4 import QtGui #from leap.eip import exceptions as eipexceptions from leap.gui.constants import APP_LOGO +from leap.gui.progress import InlineValidationPage from leap.gui.styles import ErrorLabelStyleSheet logger = logging.getLogger(__name__) -class SelectProviderPage(QtGui.QWizardPage): +class SelectProviderPage(InlineValidationPage): def __init__(self, parent=None, providers=None): super(SelectProviderPage, self).__init__(parent) @@ -32,6 +33,18 @@ class SelectProviderPage(QtGui.QWizardPage): self.did_cert_check = False self.current_page = 'providerselection' + self.is_done = False + + self.setupSteps() + self.setupUI() + + self.stepChanged.connect( + self.onStepStatusChanged) + + def setupUI(self): + """ + initializes the UI + """ providerNameLabel = QtGui.QLabel("h&ttps://") # note that we expect the bare domain name # we will add the scheme later @@ -61,6 +74,8 @@ class SelectProviderPage(QtGui.QWizardPage): validationMsg = QtGui.QLabel("") validationMsg.setStyleSheet(ErrorLabelStyleSheet) self.validationMsg = validationMsg + providerCheckButton = QtGui.QPushButton("check") + self.providerCheckButton = providerCheckButton # cert info @@ -81,25 +96,66 @@ class SelectProviderPage(QtGui.QWizardPage): self.onTrustCheckChanged) self.providerNameEdit.textChanged.connect( self.onProviderChanged) + self.providerCheckButton.clicked.connect( + self.onCheckButtonClicked) layout = QtGui.QGridLayout() layout.addWidget(validationMsg, 0, 2) layout.addWidget(providerNameLabel, 1, 1) layout.addWidget(providerNameEdit, 1, 2) + layout.addWidget(providerCheckButton, 1, 3) + + # add certinfo group + # XXX not shown now. should move to validation box. + #layout.addWidget(certinfoGroup, 4, 1, 4, 2) + #self.certinfoGroup = certinfoGroup + #self.certinfoGroup.hide() + + # add validation frame + self.setupValidationFrame() + layout.addWidget(self.valFrame, 4, 1, 4, 2) + self.valFrame.hide() + + self.setLayout(layout) - # XXX get a groupbox or something.... + # certinfo + + def setupCertInfoGroup(self): + # XXX not used now. certinfoGroup = QtGui.QGroupBox("Certificate validation") certinfoLayout = QtGui.QVBoxLayout() certinfoLayout.addWidget(self.certInfo) certinfoLayout.addWidget(self.certWarning) certinfoLayout.addWidget(self.trustProviderCertCheckBox) certinfoGroup.setLayout(certinfoLayout) + self.certinfoGroup = self.certinfoGroup + + # progress frame + + def setupValidationFrame(self): + qframe = QtGui.QFrame + valFrame = qframe() + valFrame.setFrameStyle(qframe.StyledPanel) # | qframe.Sunken) + valframeLayout = QtGui.QVBoxLayout() + + #dummylabel = QtGui.QLabel('test foo') + #valframeLayout.addWidget(dummylabel) + valframeLayout.addWidget(self.stepsTableWidget) + valFrame.setLayout(valframeLayout) + self.valFrame = valFrame + + # check domain + + def onCheckButtonClicked(self): + import time + time.sleep(1) + self.is_done = True + self.providerCheckButton.setDisabled(True) + self.stepChanged.emit('foo check', 0) + self.valFrame.show() + self.completeChanged.emit() - layout.addWidget(certinfoGroup, 4, 1, 4, 2) - self.certinfoGroup = certinfoGroup - self.certinfoGroup.hide() - - self.setLayout(layout) + # cert trust verification def is_insecure_cert_trusted(self): return self.trustProviderCertCheckBox.isChecked() @@ -117,7 +173,20 @@ class SelectProviderPage(QtGui.QWizardPage): # trigger signal to redraw next button self.completeChanged.emit() + def add_cert_info(self, certinfo): + self.certWarning.setText( + "Do you want to trust this provider certificate?") + self.certInfo.setText( + 'SHA-256 fingerprint: %s
' % certinfo) + self.certInfo.setWordWrap(True) + self.certinfoGroup.show() + def onProviderChanged(self, text): + provider = self.providerNameEdit.text() + if provider: + self.providerCheckButton.setDisabled(False) + else: + self.providerCheckButton.setDisabled(True) self.completeChanged.emit() def reset_validation_status(self): @@ -126,29 +195,23 @@ class SelectProviderPage(QtGui.QWizardPage): """ self.validationMsg.setText('') - #def set_validation_status(selF, STATUS): - #self.validationMsg.setText(status) - - def add_cert_info(self, certinfo): - self.certWarning.setText( - "Do you want to trust this provider certificate?") - self.certInfo.setText( - 'SHA-256 fingerprint: %s
' % certinfo) - self.certInfo.setWordWrap(True) - self.certinfoGroup.show() - # pagewizard methods def isComplete(self): provider = self.providerNameEdit.text() + if not self.is_done: + return False + if not provider: return False else: if self.is_insecure_cert_trusted(): return True if not self.did_cert_check: - return True + if self.is_done: + # XXX sure? + return True return False def populateErrors(self): @@ -195,7 +258,11 @@ class SelectProviderPage(QtGui.QWizardPage): def initializePage(self): self.validationMsg.setText('') - self.certinfoGroup.hide() + if hasattr(self, 'certinfoGroup'): + # XXX remove ? + self.certinfoGroup.hide() + self.is_done = False + self.providerCheckButton.setDisabled(True) def validatePage(self): # some cleanup before we leave the page -- cgit v1.2.3 From 4e1d0ed099a82843cbb91d5f417c552e9f1674e2 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 20 Nov 2012 19:09:11 +0900 Subject: added inline panel within zero-margin frame --- src/leap/gui/firstrun/providerselect.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index fc030cf3..3f021ee9 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -74,7 +74,7 @@ class SelectProviderPage(InlineValidationPage): validationMsg = QtGui.QLabel("") validationMsg.setStyleSheet(ErrorLabelStyleSheet) self.validationMsg = validationMsg - providerCheckButton = QtGui.QPushButton("check") + providerCheckButton = QtGui.QPushButton("chec&k") self.providerCheckButton = providerCheckButton # cert info @@ -113,7 +113,7 @@ class SelectProviderPage(InlineValidationPage): # add validation frame self.setupValidationFrame() - layout.addWidget(self.valFrame, 4, 1, 4, 2) + layout.addWidget(self.valFrame, 4, 2, 4, 2) self.valFrame.hide() self.setLayout(layout) @@ -135,8 +135,13 @@ class SelectProviderPage(InlineValidationPage): def setupValidationFrame(self): qframe = QtGui.QFrame valFrame = qframe() - valFrame.setFrameStyle(qframe.StyledPanel) # | qframe.Sunken) + valFrame.setFrameStyle(qframe.NoFrame) + # Box | qframe.Plain) + # NoFrame, StyledPanel) | qframe.Sunken) + #valFrame.setContentsMargins(0, 0, 0, 0) valframeLayout = QtGui.QVBoxLayout() + zeros = (0, 0, 0, 0) + valframeLayout.setContentsMargins(*zeros) #dummylabel = QtGui.QLabel('test foo') #valframeLayout.addWidget(dummylabel) @@ -147,12 +152,16 @@ class SelectProviderPage(InlineValidationPage): # check domain def onCheckButtonClicked(self): + print 'check button called....' + self.providerCheckButton.setDisabled(True) + self.valFrame.show() import time time.sleep(1) - self.is_done = True - self.providerCheckButton.setDisabled(True) - self.stepChanged.emit('foo check', 0) + # XXX bug here!... Y U DUPLICATE?!! + self.stepChanged.emit('xxx', 10) + self.stepChanged.emit('end_sentinel', 0) self.valFrame.show() + self.is_done = True self.completeChanged.emit() # cert trust verification -- cgit v1.2.3 From 7dceb11bcd4cf552938ccfa02daaf6f902ef385b Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 21 Nov 2012 05:15:06 +0900 Subject: tango icons for checking/checked/failed check status --- src/leap/gui/firstrun/providerselect.py | 64 +++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 10 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 3f021ee9..1326ca1d 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -6,13 +6,14 @@ import logging from PyQt4 import QtCore from PyQt4 import QtGui -#from leap.base import exceptions as baseexceptions +from leap.base import exceptions as baseexceptions #from leap.crypto import certs #from leap.eip import exceptions as eipexceptions from leap.gui.constants import APP_LOGO from leap.gui.progress import InlineValidationPage from leap.gui.styles import ErrorLabelStyleSheet +from leap.util.web import get_https_domain_and_port logger = logging.getLogger(__name__) @@ -38,9 +39,6 @@ class SelectProviderPage(InlineValidationPage): self.setupSteps() self.setupUI() - self.stepChanged.connect( - self.onStepStatusChanged) - def setupUI(self): """ initializes the UI @@ -155,16 +153,59 @@ class SelectProviderPage(InlineValidationPage): print 'check button called....' self.providerCheckButton.setDisabled(True) self.valFrame.show() - import time - time.sleep(1) - # XXX bug here!... Y U DUPLICATE?!! - self.stepChanged.emit('xxx', 10) - self.stepChanged.emit('end_sentinel', 0) - self.valFrame.show() + self.do_checks() + + def _do_checks(self, update_signal=None, failed_signal=None): + """ + executes actual checks in a separate thread + """ + finish = lambda: update_signal.emit("end_sentinel", 100) + + wizard = self.wizard() + prevpage = "providerselection" + + full_domain = self.providerNameEdit.text() + + # we check if we have a port in the domain string. + domain, port = get_https_domain_and_port(full_domain) + _domain = u"%s:%s" % (domain, port) if port != 443 else unicode(domain) + + netchecker = wizard.netchecker() + + #providercertchecker = wizard.providercertchecker() + #eipconfigchecker = wizard.eipconfigchecker(domain=_domain) + + update_signal.emit("head_sentinel", 0) + + ######################## + # 1) try name resolution + ######################## + update_signal.emit("Checking that server is reachable", 20) + logger.debug('checking name resolution') + try: + netchecker.check_name_resolution( + domain) + + except baseexceptions.LeapException as exc: + logger.error(exc.message) + wizard.set_validation_error( + prevpage, exc.usermessage) + failed_signal.emit() + return False + self.is_done = True + finish() + + def _inline_validation_ready(self): + """ + called after _do_checks has finished. + """ + # XXX check if it's really done (catch signal for completed) + #self.done = True self.completeChanged.emit() # cert trust verification + # (disabled for now) def is_insecure_cert_trusted(self): return self.trustProviderCertCheckBox.isChecked() @@ -272,6 +313,9 @@ class SelectProviderPage(InlineValidationPage): self.certinfoGroup.hide() self.is_done = False self.providerCheckButton.setDisabled(True) + self.valFrame.hide() + self.steps.removeAllSteps() + self.clearTable() def validatePage(self): # some cleanup before we leave the page -- cgit v1.2.3 From 8ad4957531f5279cf65df36b015d83443deded33 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 21 Nov 2012 05:55:23 +0900 Subject: update check status when provider entry changes. disable next button and remove any error message (but remember which was the latest bad string if you are changing providers withouth going to the next page). --- src/leap/gui/firstrun/providerselect.py | 40 ++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 1326ca1d..b6482379 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -22,10 +22,10 @@ class SelectProviderPage(InlineValidationPage): def __init__(self, parent=None, providers=None): super(SelectProviderPage, self).__init__(parent) - self.setTitle("Enter Provider") - self.setSubTitle( + self.setTitle(self.tr("Enter Provider")) + self.setSubTitle(self.tr( "Please enter the domain of the provider you want " - "to use for your connection." + "to use for your connection.") ) self.setPixmap( QtGui.QWizard.LogoPixmap, @@ -72,7 +72,7 @@ class SelectProviderPage(InlineValidationPage): validationMsg = QtGui.QLabel("") validationMsg.setStyleSheet(ErrorLabelStyleSheet) self.validationMsg = validationMsg - providerCheckButton = QtGui.QPushButton("chec&k") + providerCheckButton = QtGui.QPushButton(self.tr("chec&k")) self.providerCheckButton = providerCheckButton # cert info @@ -82,7 +82,8 @@ class SelectProviderPage(InlineValidationPage): # tricky, since the first time came # from the exception message. # should get string from exception too! - self.bad_cert_status = "Server certificate could not be verified." + self.bad_cert_status = self.tr( + "Server certificate could not be verified.") self.certInfo = QtGui.QLabel("") self.certInfo.setWordWrap(True) @@ -120,7 +121,8 @@ class SelectProviderPage(InlineValidationPage): def setupCertInfoGroup(self): # XXX not used now. - certinfoGroup = QtGui.QGroupBox("Certificate validation") + certinfoGroup = QtGui.QGroupBox( + self.tr("Certificate validation")) certinfoLayout = QtGui.QVBoxLayout() certinfoLayout.addWidget(self.certInfo) certinfoLayout.addWidget(self.certWarning) @@ -150,7 +152,6 @@ class SelectProviderPage(InlineValidationPage): # check domain def onCheckButtonClicked(self): - print 'check button called....' self.providerCheckButton.setDisabled(True) self.valFrame.show() self.do_checks() @@ -180,7 +181,7 @@ class SelectProviderPage(InlineValidationPage): ######################## # 1) try name resolution ######################## - update_signal.emit("Checking that server is reachable", 20) + update_signal.emit(self.tr("Can reach provider"), 20) logger.debug('checking name resolution') try: netchecker.check_name_resolution( @@ -191,6 +192,7 @@ class SelectProviderPage(InlineValidationPage): wizard.set_validation_error( prevpage, exc.usermessage) failed_signal.emit() + self.is_done = False return False self.is_done = True @@ -200,8 +202,9 @@ class SelectProviderPage(InlineValidationPage): """ called after _do_checks has finished. """ - # XXX check if it's really done (catch signal for completed) - #self.done = True + self.domain_checked = True + if self.is_done: + self.wizard().clean_validation_error(self.current_page) self.completeChanged.emit() # cert trust verification @@ -232,6 +235,7 @@ class SelectProviderPage(InlineValidationPage): self.certinfoGroup.show() def onProviderChanged(self, text): + self.is_done = False provider = self.providerNameEdit.text() if provider: self.providerCheckButton.setDisabled(False) @@ -242,8 +246,12 @@ class SelectProviderPage(InlineValidationPage): def reset_validation_status(self): """ empty the validation msg + and clean the inline validation widget. """ self.validationMsg.setText('') + self.steps.removeAllSteps() + self.clearTable() + self.domain_checked = False # pagewizard methods @@ -283,10 +291,19 @@ class SelectProviderPage(InlineValidationPage): showerr(errors) else: # not the first time + # XXX hey, this is getting convoluted. + # roll out this. + # but be careful about all the possibilities + # with going back and forth once you + # enter a domain. if cur_str == bad_str: showerr(errors) else: - showerr('') + if not getattr(self, 'domain_checked', None): + showerr('') + else: + self.bad_string = cur_str + showerr(errors) def cleanup_errormsg(self): """ @@ -294,6 +311,7 @@ class SelectProviderPage(InlineValidationPage): should be called before leaving the page """ self.bad_string = None + self.domain_checked = False def paintEvent(self, event): """ -- cgit v1.2.3 From 53c6c92e26970de7de0bddca0034e72af7d0ce48 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 21 Nov 2012 06:15:41 +0900 Subject: add red border to failed field --- src/leap/gui/firstrun/providerselect.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index b6482379..2786c494 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -12,7 +12,7 @@ from leap.base import exceptions as baseexceptions from leap.gui.constants import APP_LOGO from leap.gui.progress import InlineValidationPage -from leap.gui.styles import ErrorLabelStyleSheet +from leap.gui import styles from leap.util.web import get_https_domain_and_port logger = logging.getLogger(__name__) @@ -70,7 +70,7 @@ class SelectProviderPage(InlineValidationPage): #self.registerField('provider_name_index', providerNameSelect) validationMsg = QtGui.QLabel("") - validationMsg.setStyleSheet(ErrorLabelStyleSheet) + validationMsg.setStyleSheet(styles.ErrorLabelStyleSheet) self.validationMsg = validationMsg providerCheckButton = QtGui.QPushButton(self.tr("chec&k")) self.providerCheckButton = providerCheckButton @@ -284,11 +284,16 @@ class SelectProviderPage(InlineValidationPage): bad_str = getattr(self, 'bad_string', None) cur_str = self.providerNameEdit.text() showerr = self.validationMsg.setText + markred = lambda: self.providerNameEdit.setStyleSheet( + styles.ErrorLineEdit) + umarkrd = lambda: self.providerNameEdit.setStyleSheet( + styles.RegularLineEdit) if bad_str is None: # first time we fall here. # save the current bad_string value self.bad_string = cur_str showerr(errors) + markred() else: # not the first time # XXX hey, this is getting convoluted. @@ -298,9 +303,11 @@ class SelectProviderPage(InlineValidationPage): # enter a domain. if cur_str == bad_str: showerr(errors) + markred() else: if not getattr(self, 'domain_checked', None): showerr('') + umarkrd() else: self.bad_string = cur_str showerr(errors) -- cgit v1.2.3 From 7bf4c0aa6db8cbaa1befdb2841f722554a3a0731 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 21 Nov 2012 23:01:06 +0900 Subject: fixed ui freeze using queue for passing status between worker and parent --- src/leap/gui/firstrun/providerselect.py | 200 ++++++++++++++++++++++++++++---- 1 file changed, 176 insertions(+), 24 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 2786c494..08e09ee3 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -1,14 +1,17 @@ """ Select Provider Page, used in First Run Wizard """ +from functools import partial import logging +import requests + from PyQt4 import QtCore from PyQt4 import QtGui from leap.base import exceptions as baseexceptions #from leap.crypto import certs -#from leap.eip import exceptions as eipexceptions +from leap.eip import exceptions as eipexceptions from leap.gui.constants import APP_LOGO from leap.gui.progress import InlineValidationPage @@ -17,8 +20,24 @@ from leap.util.web import get_https_domain_and_port logger = logging.getLogger(__name__) +# XXX check newer version in progress... + + +def delay(obj, method_str): + """ + this is a hack to get responsiveness in the ui + """ + QtCore.QTimer().singleShot( + 10, + lambda: QtCore.QMetaObject.invokeMethod( + obj, method_str)) + class SelectProviderPage(InlineValidationPage): + + #disableCheckButton = QtCore.pyqtSignal() + launchChecks = QtCore.pyqtSignal() + def __init__(self, parent=None, providers=None): super(SelectProviderPage, self).__init__(parent) @@ -39,6 +58,11 @@ class SelectProviderPage(InlineValidationPage): self.setupSteps() self.setupUI() + #self.disableCheckButton.connect( + #self.onDisableCheckButton) + self.launchChecks.connect( + self.launch_checks) + def setupUI(self): """ initializes the UI @@ -149,21 +173,41 @@ class SelectProviderPage(InlineValidationPage): valFrame.setLayout(valframeLayout) self.valFrame = valFrame - # check domain - - def onCheckButtonClicked(self): + @QtCore.pyqtSlot() + def onDisableCheckButton(self): + print 'CHECK BUTTON DISABLED!!!' self.providerCheckButton.setDisabled(True) - self.valFrame.show() + + @QtCore.pyqtSlot() + def launch_checks(self): + # trying to delay this... + #timer = QtCore.QTimer() + #timer.singleShot(0, self.do_checks) self.do_checks() - def _do_checks(self, update_signal=None, failed_signal=None): + def onCheckButtonClicked(self): + #self.disableCheckButton.emit() + # XXX trying to get responsiveness. + # UI here is blocking, although I'm using + # threads and signals :( + QtCore.QMetaObject.invokeMethod( + self, "onDisableCheckButton") + + QtCore.QMetaObject.invokeMethod( + self, "showStepsFrame") + + delay(self, "launch_checks") + + print 'ON CHECK BUTTON --- DONE!' + print 'timer.....' + + def _do_checks(self): """ executes actual checks in a separate thread """ - finish = lambda: update_signal.emit("end_sentinel", 100) wizard = self.wizard() - prevpage = "providerselection" + curpage = "providerselection" full_domain = self.providerNameEdit.text() @@ -173,35 +217,143 @@ class SelectProviderPage(InlineValidationPage): netchecker = wizard.netchecker() - #providercertchecker = wizard.providercertchecker() - #eipconfigchecker = wizard.eipconfigchecker(domain=_domain) + providercertchecker = wizard.providercertchecker() + eipconfigchecker = wizard.eipconfigchecker(domain=_domain) + + def fail(): + self.is_done = False + return False - update_signal.emit("head_sentinel", 0) + yield(("head_sentinel", 0), lambda: None) ######################## # 1) try name resolution ######################## - update_signal.emit(self.tr("Can reach provider"), 20) logger.debug('checking name resolution') - try: - netchecker.check_name_resolution( - domain) - - except baseexceptions.LeapException as exc: - logger.error(exc.message) - wizard.set_validation_error( - prevpage, exc.usermessage) - failed_signal.emit() - self.is_done = False - return False + def namecheck(): + try: + netchecker.check_name_resolution( + domain) + + except baseexceptions.LeapException as exc: + logger.error(exc.message) + wizard.set_validation_error( + curpage, exc.usermessage) + return fail() + + except Exception as exc: + wizard.set_validation_error( + curpage, exc.message) + return fail() + + else: + return True + + # XXX catch more exceptions + + yield(("check name", 20), namecheck) + + ######################### + # 2) try https connection + ######################### + + logger.debug('checking https connection') + + def httpscheck(): + try: + providercertchecker.is_https_working( + "https://%s" % _domain, + verify=True) + + except eipexceptions.HttpsBadCertError as exc: + logger.debug('exception') + # XXX skipping for now... + ############################################## + # We had this validation logic + # in the provider selection page before + ############################################## + #if self.trustProviderCertCheckBox.isChecked(): + #pass + #else: + wizard.set_validation_error( + curpage, exc.usermessage) + #fingerprint = certs.get_cert_fingerprint( + #domain=domain, sep=" ") + + # it's ok if we've trusted this fgprt before + #trustedcrts = wizard.trusted_certs + #if trustedcrts and \ + # fingerprint.replace(' ', '') in trustedcrts: + #pass + #else: + # let your user face panick :P + #self.add_cert_info(fingerprint) + #self.did_cert_check = True + #self.completeChanged.emit() + #return False + return fail() + + except baseexceptions.LeapException as exc: + wizard.set_validation_error( + curpage, exc.usermessage) + return fail() + + except Exception as exc: + wizard.set_validation_error( + curpage, exc.message) + return fail() + + else: + return True + + yield(("https check", 40), httpscheck) + + ################################## + # 3) try download provider info... + ################################## + + def fetchinfo(): + try: + # XXX we already set _domain in the initialization + # so it should not be needed here. + eipconfigchecker.fetch_definition(domain=_domain) + wizard.set_providerconfig( + eipconfigchecker.defaultprovider.config) + except requests.exceptions.SSLError: + # XXX we should have catched this before. + # but cert checking is broken. + wizard.set_validation_error( + curpage, + self.tr( + "Could not get info from provider.")) + return fail() + except requests.exceptions.ConnectionError: + wizard.set_validation_error( + curpage, + self.tr( + "Could not download provider info " + "(refused conn.).")) + return fail() + + except Exception as exc: + wizard.set_validation_error( + curpage, exc.message) + return fail() + + else: + return True + yield(("fetch info", 80), fetchinfo) + + # done! self.is_done = True - finish() + yield(("end_sentinel", 100), lambda: None) def _inline_validation_ready(self): """ called after _do_checks has finished. """ + print 'VALIDATION READY ---------------' self.domain_checked = True if self.is_done: self.wizard().clean_validation_error(self.current_page) -- cgit v1.2.3 From f9a3e2cf6c4f7398411788974a2a6a9a53c9a1ab Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 22 Nov 2012 02:46:57 +0900 Subject: info page refactor. --- src/leap/gui/firstrun/providerselect.py | 40 ++++++++++++++------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 08e09ee3..0250ab8c 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -58,8 +58,6 @@ class SelectProviderPage(InlineValidationPage): self.setupSteps() self.setupUI() - #self.disableCheckButton.connect( - #self.onDisableCheckButton) self.launchChecks.connect( self.launch_checks) @@ -160,15 +158,10 @@ class SelectProviderPage(InlineValidationPage): qframe = QtGui.QFrame valFrame = qframe() valFrame.setFrameStyle(qframe.NoFrame) - # Box | qframe.Plain) - # NoFrame, StyledPanel) | qframe.Sunken) - #valFrame.setContentsMargins(0, 0, 0, 0) valframeLayout = QtGui.QVBoxLayout() zeros = (0, 0, 0, 0) valframeLayout.setContentsMargins(*zeros) - #dummylabel = QtGui.QLabel('test foo') - #valframeLayout.addWidget(dummylabel) valframeLayout.addWidget(self.stepsTableWidget) valFrame.setLayout(valframeLayout) self.valFrame = valFrame @@ -180,16 +173,9 @@ class SelectProviderPage(InlineValidationPage): @QtCore.pyqtSlot() def launch_checks(self): - # trying to delay this... - #timer = QtCore.QTimer() - #timer.singleShot(0, self.do_checks) self.do_checks() def onCheckButtonClicked(self): - #self.disableCheckButton.emit() - # XXX trying to get responsiveness. - # UI here is blocking, although I'm using - # threads and signals :( QtCore.QMetaObject.invokeMethod( self, "onDisableCheckButton") @@ -198,12 +184,10 @@ class SelectProviderPage(InlineValidationPage): delay(self, "launch_checks") - print 'ON CHECK BUTTON --- DONE!' - print 'timer.....' - def _do_checks(self): """ - executes actual checks in a separate thread + generator that yields actual checks + that are executed in a separate thread """ wizard = self.wizard() @@ -229,9 +213,13 @@ class SelectProviderPage(InlineValidationPage): ######################## # 1) try name resolution ######################## - logger.debug('checking name resolution') def namecheck(): + """ + in which we check if + we are able to name resolve + this domain + """ try: netchecker.check_name_resolution( domain) @@ -250,17 +238,21 @@ class SelectProviderPage(InlineValidationPage): else: return True - # XXX catch more exceptions + logger.debug('checking name resolution') yield(("check name", 20), namecheck) ######################### # 2) try https connection ######################### - logger.debug('checking https connection') - def httpscheck(): + """ + in which we check + if the provider + is offering service over + https + """ try: providercertchecker.is_https_working( "https://%s" % _domain, @@ -307,6 +299,7 @@ class SelectProviderPage(InlineValidationPage): else: return True + logger.debug('checking https connection') yield(("https check", 40), httpscheck) ################################## @@ -343,9 +336,11 @@ class SelectProviderPage(InlineValidationPage): else: return True + yield(("fetch info", 80), fetchinfo) # done! + self.is_done = True yield(("end_sentinel", 100), lambda: None) @@ -353,7 +348,6 @@ class SelectProviderPage(InlineValidationPage): """ called after _do_checks has finished. """ - print 'VALIDATION READY ---------------' self.domain_checked = True if self.is_done: self.wizard().clean_validation_error(self.current_page) -- cgit v1.2.3 From 60ae69dd79fc4a17e54e9f898b04c7130d8b9f6e Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 22 Nov 2012 06:26:02 +0900 Subject: fix widgets focus on providerselect page it works with enter, enter, enter :) dedicated to DJ Focus... --- src/leap/gui/firstrun/providerselect.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 0250ab8c..d029b1db 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -61,6 +61,9 @@ class SelectProviderPage(InlineValidationPage): self.launchChecks.connect( self.launch_checks) + self.providerNameEdit.editingFinished.connect( + lambda: self.providerCheckButton.setFocus(True)) + def setupUI(self): """ initializes the UI @@ -94,7 +97,7 @@ class SelectProviderPage(InlineValidationPage): validationMsg = QtGui.QLabel("") validationMsg.setStyleSheet(styles.ErrorLabelStyleSheet) self.validationMsg = validationMsg - providerCheckButton = QtGui.QPushButton(self.tr("chec&k")) + providerCheckButton = QtGui.QPushButton(self.tr("chec&k!")) self.providerCheckButton = providerCheckButton # cert info @@ -238,7 +241,6 @@ class SelectProviderPage(InlineValidationPage): else: return True - logger.debug('checking name resolution') yield(("check name", 20), namecheck) @@ -349,9 +351,14 @@ class SelectProviderPage(InlineValidationPage): called after _do_checks has finished. """ self.domain_checked = True + self.completeChanged.emit() + # let's set focus... if self.is_done: self.wizard().clean_validation_error(self.current_page) - self.completeChanged.emit() + nextbutton = self.wizard().button(QtGui.QWizard.NextButton) + nextbutton.setFocus() + else: + self.providerNameEdit.setFocus() # cert trust verification # (disabled for now) -- cgit v1.2.3 From 7a263b8ee74cc92ba39796cd9ad48395adfa7450 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 23 Nov 2012 05:13:36 +0900 Subject: refactor validation mixin; progress until register page --- src/leap/gui/firstrun/providerselect.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index d029b1db..dffde040 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -1,7 +1,6 @@ """ Select Provider Page, used in First Run Wizard """ -from functools import partial import logging import requests @@ -20,10 +19,9 @@ from leap.util.web import get_https_domain_and_port logger = logging.getLogger(__name__) -# XXX check newer version in progress... - def delay(obj, method_str): + # XXX check newer version in progress.py... """ this is a hack to get responsiveness in the ui """ @@ -40,6 +38,7 @@ class SelectProviderPage(InlineValidationPage): def __init__(self, parent=None, providers=None): super(SelectProviderPage, self).__init__(parent) + self.current_page = 'providerselection' self.setTitle(self.tr("Enter Provider")) self.setSubTitle(self.tr( @@ -51,7 +50,6 @@ class SelectProviderPage(InlineValidationPage): QtGui.QPixmap(APP_LOGO)) self.did_cert_check = False - self.current_page = 'providerselection' self.is_done = False @@ -346,7 +344,7 @@ class SelectProviderPage(InlineValidationPage): self.is_done = True yield(("end_sentinel", 100), lambda: None) - def _inline_validation_ready(self): + def on_checks_validation_ready(self): """ called after _do_checks has finished. """ -- cgit v1.2.3 From d5136a5f3b2aa8b16e8341f2eb99d05993028acf Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 27 Nov 2012 00:12:22 +0900 Subject: inline validation at register page. inline widget and focus and red marks and whistles. --- src/leap/gui/firstrun/providerselect.py | 58 ++++++++++----------------------- 1 file changed, 18 insertions(+), 40 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index dffde040..e59a23a9 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -169,7 +169,7 @@ class SelectProviderPage(InlineValidationPage): @QtCore.pyqtSlot() def onDisableCheckButton(self): - print 'CHECK BUTTON DISABLED!!!' + #print 'CHECK BUTTON DISABLED!!!' self.providerCheckButton.setDisabled(True) @QtCore.pyqtSlot() @@ -183,6 +183,8 @@ class SelectProviderPage(InlineValidationPage): QtCore.QMetaObject.invokeMethod( self, "showStepsFrame") + # is this still needed? + # XXX can I doo delay(self, "do_checks") ? delay(self, "launch_checks") def _do_checks(self): @@ -192,8 +194,6 @@ class SelectProviderPage(InlineValidationPage): """ wizard = self.wizard() - curpage = "providerselection" - full_domain = self.providerNameEdit.text() # we check if we have a port in the domain string. @@ -205,10 +205,6 @@ class SelectProviderPage(InlineValidationPage): providercertchecker = wizard.providercertchecker() eipconfigchecker = wizard.eipconfigchecker(domain=_domain) - def fail(): - self.is_done = False - return False - yield(("head_sentinel", 0), lambda: None) ######################## @@ -227,20 +223,16 @@ class SelectProviderPage(InlineValidationPage): except baseexceptions.LeapException as exc: logger.error(exc.message) - wizard.set_validation_error( - curpage, exc.usermessage) - return fail() + return self.fail(exc.usermessage) except Exception as exc: - wizard.set_validation_error( - curpage, exc.message) - return fail() + return self.fail(exc.message) else: return True logger.debug('checking name resolution') - yield(("check name", 20), namecheck) + yield((self.tr("checking domain name"), 20), namecheck) ######################### # 2) try https connection @@ -260,6 +252,7 @@ class SelectProviderPage(InlineValidationPage): except eipexceptions.HttpsBadCertError as exc: logger.debug('exception') + return self.fail(exc.usermessage) # XXX skipping for now... ############################################## # We had this validation logic @@ -268,8 +261,6 @@ class SelectProviderPage(InlineValidationPage): #if self.trustProviderCertCheckBox.isChecked(): #pass #else: - wizard.set_validation_error( - curpage, exc.usermessage) #fingerprint = certs.get_cert_fingerprint( #domain=domain, sep=" ") @@ -284,23 +275,18 @@ class SelectProviderPage(InlineValidationPage): #self.did_cert_check = True #self.completeChanged.emit() #return False - return fail() except baseexceptions.LeapException as exc: - wizard.set_validation_error( - curpage, exc.usermessage) - return fail() + return self.fail(exc.usermessage) except Exception as exc: - wizard.set_validation_error( - curpage, exc.message) - return fail() + return self.fail(exc.message) else: return True logger.debug('checking https connection') - yield(("https check", 40), httpscheck) + yield((self.tr("checking https connection"), 40), httpscheck) ################################## # 3) try download provider info... @@ -316,28 +302,20 @@ class SelectProviderPage(InlineValidationPage): except requests.exceptions.SSLError: # XXX we should have catched this before. # but cert checking is broken. - wizard.set_validation_error( - curpage, - self.tr( - "Could not get info from provider.")) - return fail() + return self.fail(self.tr( + "Could not get info from provider.")) except requests.exceptions.ConnectionError: - wizard.set_validation_error( - curpage, - self.tr( - "Could not download provider info " - "(refused conn.).")) - return fail() + return self.fail(self.tr( + "Could not download provider info " + "(refused conn.).")) except Exception as exc: - wizard.set_validation_error( - curpage, exc.message) - return fail() - + return self.fail( + self.tr(exc.message)) else: return True - yield(("fetch info", 80), fetchinfo) + yield((self.tr("fetching provider info"), 80), fetchinfo) # done! -- cgit v1.2.3 From 1bb7e85425f2f427401cd02726c55922874a59a0 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 27 Nov 2012 03:34:08 +0900 Subject: login validation inline --- src/leap/gui/firstrun/providerselect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index e59a23a9..3ffc6ff6 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -11,12 +11,12 @@ from PyQt4 import QtGui from leap.base import exceptions as baseexceptions #from leap.crypto import certs from leap.eip import exceptions as eipexceptions - -from leap.gui.constants import APP_LOGO from leap.gui.progress import InlineValidationPage from leap.gui import styles from leap.util.web import get_https_domain_and_port +from leap.gui.constants import APP_LOGO + logger = logging.getLogger(__name__) -- cgit v1.2.3 From eec567a0a26edddb30b15ea4ef67f042c160d5ba Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 28 Nov 2012 02:03:22 +0900 Subject: move delay function to gui/utils --- src/leap/gui/firstrun/providerselect.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 3ffc6ff6..a4be51a9 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -13,6 +13,7 @@ from leap.base import exceptions as baseexceptions from leap.eip import exceptions as eipexceptions from leap.gui.progress import InlineValidationPage from leap.gui import styles +from leap.gui.utils import delay from leap.util.web import get_https_domain_and_port from leap.gui.constants import APP_LOGO @@ -20,20 +21,8 @@ from leap.gui.constants import APP_LOGO logger = logging.getLogger(__name__) -def delay(obj, method_str): - # XXX check newer version in progress.py... - """ - this is a hack to get responsiveness in the ui - """ - QtCore.QTimer().singleShot( - 10, - lambda: QtCore.QMetaObject.invokeMethod( - obj, method_str)) - - class SelectProviderPage(InlineValidationPage): - #disableCheckButton = QtCore.pyqtSignal() launchChecks = QtCore.pyqtSignal() def __init__(self, parent=None, providers=None): @@ -183,8 +172,6 @@ class SelectProviderPage(InlineValidationPage): QtCore.QMetaObject.invokeMethod( self, "showStepsFrame") - # is this still needed? - # XXX can I doo delay(self, "do_checks") ? delay(self, "launch_checks") def _do_checks(self): -- cgit v1.2.3 From f40bfa7b674418f9903e826d20ad943efcc47807 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 7 Dec 2012 02:16:25 +0900 Subject: register tests --- src/leap/gui/firstrun/providerselect.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index a4be51a9..fd48f7f9 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -40,7 +40,7 @@ class SelectProviderPage(InlineValidationPage): self.did_cert_check = False - self.is_done = False + self.done = False self.setupSteps() self.setupUI() @@ -131,7 +131,7 @@ class SelectProviderPage(InlineValidationPage): # certinfo - def setupCertInfoGroup(self): + def setupCertInfoGroup(self): # pragma: no cover # XXX not used now. certinfoGroup = QtGui.QGroupBox( self.tr("Certificate validation")) @@ -188,7 +188,6 @@ class SelectProviderPage(InlineValidationPage): _domain = u"%s:%s" % (domain, port) if port != 443 else unicode(domain) netchecker = wizard.netchecker() - providercertchecker = wizard.providercertchecker() eipconfigchecker = wizard.eipconfigchecker(domain=_domain) @@ -205,6 +204,7 @@ class SelectProviderPage(InlineValidationPage): this domain """ try: + #import ipdb;ipdb.set_trace() netchecker.check_name_resolution( domain) @@ -306,7 +306,7 @@ class SelectProviderPage(InlineValidationPage): # done! - self.is_done = True + self.done = True yield(("end_sentinel", 100), lambda: None) def on_checks_validation_ready(self): @@ -316,7 +316,7 @@ class SelectProviderPage(InlineValidationPage): self.domain_checked = True self.completeChanged.emit() # let's set focus... - if self.is_done: + if self.is_done(): self.wizard().clean_validation_error(self.current_page) nextbutton = self.wizard().button(QtGui.QWizard.NextButton) nextbutton.setFocus() @@ -329,7 +329,7 @@ class SelectProviderPage(InlineValidationPage): def is_insecure_cert_trusted(self): return self.trustProviderCertCheckBox.isChecked() - def onTrustCheckChanged(self, state): + def onTrustCheckChanged(self, state): # pragma: no cover XXX checked = False if state == 2: checked = True @@ -342,7 +342,7 @@ class SelectProviderPage(InlineValidationPage): # trigger signal to redraw next button self.completeChanged.emit() - def add_cert_info(self, certinfo): + def add_cert_info(self, certinfo): # pragma: no cover XXX self.certWarning.setText( "Do you want to trust this provider certificate?") self.certInfo.setText( @@ -351,7 +351,7 @@ class SelectProviderPage(InlineValidationPage): self.certinfoGroup.show() def onProviderChanged(self, text): - self.is_done = False + self.done = False provider = self.providerNameEdit.text() if provider: self.providerCheckButton.setDisabled(False) @@ -374,7 +374,7 @@ class SelectProviderPage(InlineValidationPage): def isComplete(self): provider = self.providerNameEdit.text() - if not self.is_done: + if not self.is_done(): return False if not provider: @@ -383,7 +383,7 @@ class SelectProviderPage(InlineValidationPage): if self.is_insecure_cert_trusted(): return True if not self.did_cert_check: - if self.is_done: + if self.is_done(): # XXX sure? return True return False @@ -452,7 +452,7 @@ class SelectProviderPage(InlineValidationPage): if hasattr(self, 'certinfoGroup'): # XXX remove ? self.certinfoGroup.hide() - self.is_done = False + self.done = False self.providerCheckButton.setDisabled(True) self.valFrame.hide() self.steps.removeAllSteps() -- cgit v1.2.3 From 8fb39dd87db76bd4450e0137f34d7d0ee66de935 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 9 Jan 2013 00:17:32 +0900 Subject: fix provider domain regex --- src/leap/gui/firstrun/providerselect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index fd48f7f9..62742181 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -64,7 +64,7 @@ class SelectProviderPage(InlineValidationPage): providerNameLabel.setBuddy(providerNameEdit) # add regex validator - providerDomainRe = QtCore.QRegExp(r"^[a-z\d_-.]+$") + providerDomainRe = QtCore.QRegExp(r"^[a-z1-9_\-\.]+$") providerNameEdit.setValidator( QtGui.QRegExpValidator(providerDomainRe, self)) self.providerNameEdit = providerNameEdit -- cgit v1.2.3 From 8e6a15e2f2d35c606aa0c1a2102c28ceccc23b78 Mon Sep 17 00:00:00 2001 From: antialias Date: Mon, 7 Jan 2013 16:50:52 -0400 Subject: this should be the complete list of userfacing strings. see #665. --- src/leap/gui/firstrun/providerselect.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 62742181..28fb829c 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -101,7 +101,7 @@ class SelectProviderPage(InlineValidationPage): self.certInfo.setWordWrap(True) self.certWarning = QtGui.QLabel("") self.trustProviderCertCheckBox = QtGui.QCheckBox( - "&Trust this provider certificate.") + self.tr("&Trust this provider certificate.")) self.trustProviderCertCheckBox.stateChanged.connect( self.onTrustCheckChanged) @@ -344,9 +344,10 @@ class SelectProviderPage(InlineValidationPage): def add_cert_info(self, certinfo): # pragma: no cover XXX self.certWarning.setText( - "Do you want to trust this provider certificate?") + self.tr("Do you want to trust this provider certificate?")) + # XXX Check if this needs to abstracted to remove certinfo self.certInfo.setText( - 'SHA-256 fingerprint: %s
' % certinfo) + self.tr('SHA-256 fingerprint: %s
' % certinfo)) self.certInfo.setWordWrap(True) self.certinfoGroup.show() -- cgit v1.2.3 From ade0eded09176fd687d1ee30724468c048d15065 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 11 Jan 2013 09:16:49 +0900 Subject: fix for missing cacert bundle frozen app cannot find requests cacert bundle. added to Resources to get us going. --- src/leap/gui/firstrun/providerselect.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 28fb829c..ccecd519 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -287,8 +287,6 @@ class SelectProviderPage(InlineValidationPage): wizard.set_providerconfig( eipconfigchecker.defaultprovider.config) except requests.exceptions.SSLError: - # XXX we should have catched this before. - # but cert checking is broken. return self.fail(self.tr( "Could not get info from provider.")) except requests.exceptions.ConnectionError: -- cgit v1.2.3 From ff59da55ef9a176b36cef19d67e7ec363bf5d739 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 24 Jan 2013 02:30:00 +0900 Subject: wizard rephrasing & punctuation --- src/leap/gui/firstrun/providerselect.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index ccecd519..917b16fd 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -32,7 +32,7 @@ class SelectProviderPage(InlineValidationPage): self.setTitle(self.tr("Enter Provider")) self.setSubTitle(self.tr( "Please enter the domain of the provider you want " - "to use for your connection.") + "to use for your connection") ) self.setPixmap( QtGui.QWizard.LogoPixmap, @@ -219,7 +219,7 @@ class SelectProviderPage(InlineValidationPage): return True logger.debug('checking name resolution') - yield((self.tr("checking domain name"), 20), namecheck) + yield((self.tr("Checking if it is a valid provider"), 20), namecheck) ######################### # 2) try https connection @@ -273,7 +273,7 @@ class SelectProviderPage(InlineValidationPage): return True logger.debug('checking https connection') - yield((self.tr("checking https connection"), 40), httpscheck) + yield((self.tr("Checking for a secure connection"), 40), httpscheck) ################################## # 3) try download provider info... @@ -300,7 +300,7 @@ class SelectProviderPage(InlineValidationPage): else: return True - yield((self.tr("fetching provider info"), 80), fetchinfo) + yield((self.tr("Getting info from the provider"), 80), fetchinfo) # done! -- cgit v1.2.3 From 0f9a1d4bc85def69dae0621eb7daaf5a0ee48004 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 1 Feb 2013 00:49:10 +0900 Subject: add watermark image to wizard --- src/leap/gui/firstrun/providerselect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/leap/gui/firstrun/providerselect.py') diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index 917b16fd..36bb4510 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -16,7 +16,7 @@ from leap.gui import styles from leap.gui.utils import delay from leap.util.web import get_https_domain_and_port -from leap.gui.constants import APP_LOGO +from leap.gui.constants import APP_LOGO, APP_WATERMARK logger = logging.getLogger(__name__) @@ -34,6 +34,10 @@ class SelectProviderPage(InlineValidationPage): "Please enter the domain of the provider you want " "to use for your connection") ) + self.setPixmap( + QtGui.QWizard.WatermarkPixmap, + QtGui.QPixmap(APP_WATERMARK)) + self.setPixmap( QtGui.QWizard.LogoPixmap, QtGui.QPixmap(APP_LOGO)) -- cgit v1.2.3