summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-11-22 02:46:57 +0900
committerkali <kali@leap.se>2012-11-22 02:46:57 +0900
commitf9a3e2cf6c4f7398411788974a2a6a9a53c9a1ab (patch)
tree8d8b32effdb41f8b0c4a27b74b939c25f629e009
parent7bf4c0aa6db8cbaa1befdb2841f722554a3a0731 (diff)
info page refactor.
-rw-r--r--src/leap/gui/firstrun/providerinfo.py86
-rw-r--r--src/leap/gui/firstrun/providerselect.py40
-rw-r--r--src/leap/gui/firstrun/providersetup.py6
3 files changed, 36 insertions, 96 deletions
diff --git a/src/leap/gui/firstrun/providerinfo.py b/src/leap/gui/firstrun/providerinfo.py
index 48763357..c5b2984c 100644
--- a/src/leap/gui/firstrun/providerinfo.py
+++ b/src/leap/gui/firstrun/providerinfo.py
@@ -3,43 +3,33 @@ Provider Info Page, used in First run Wizard
"""
import logging
-from PyQt4 import QtCore
from PyQt4 import QtGui
-import requests
-
-from leap.base import exceptions as baseexceptions
-#from leap.crypto import certs
-from leap.eip import exceptions as eipexceptions
-
-from leap.gui.progress import ValidationPage
-from leap.util.web import get_https_domain_and_port
-
-from leap.gui.constants import APP_LOGO, pause_for_user
+from leap.gui.constants import APP_LOGO
logger = logging.getLogger(__name__)
-class ProviderInfoPage(ValidationPage):
+class ProviderInfoPage(QtGui.QWizardPage):
+
def __init__(self, parent=None):
super(ProviderInfoPage, self).__init__(parent)
- self.setTitle("Provider Info")
- #self.setSubTitle("Available information about chosen provider.")
+ self.setTitle(self.tr("Provider Info"))
+ self.setSubTitle(self.tr(
+ "This is what provider says."))
self.setPixmap(
QtGui.QWizard.LogoPixmap,
QtGui.QPixmap(APP_LOGO))
- self.prev_page = "providerselection"
- self.infoWidget = None
- #self.current_page = "providerinfo"
+ self.create_info_panel()
def create_info_panel(self):
# Use stacked widget instead
# of reparenting the layout.
- self.infoWidget = QtGui.QStackedWidget()
+ infoWidget = QtGui.QStackedWidget()
info = QtGui.QWidget()
layout = QtGui.QVBoxLayout()
@@ -47,19 +37,24 @@ class ProviderInfoPage(ValidationPage):
displayName = QtGui.QLabel("")
description = QtGui.QLabel("")
enrollment_policy = QtGui.QLabel("")
+
# XXX set stylesheet...
# prettify a little bit.
# bigger fonts and so on...
+ # We could use a QFrame here
+
layout.addWidget(displayName)
layout.addWidget(description)
layout.addWidget(enrollment_policy)
layout.addStretch(1)
info.setLayout(layout)
- self.infoWidget.addWidget(info)
+ infoWidget.addWidget(info)
- self.layout.addWidget(self.infoWidget)
+ pageLayout = QtGui.QVBoxLayout()
+ pageLayout.addWidget(infoWidget)
+ self.setLayout(pageLayout)
# add refs to self to allow for
# updates.
@@ -94,59 +89,10 @@ class ProviderInfoPage(ValidationPage):
self.enrollment_policy.setText(
'enrollment policy: %s' % enroll)
- def _do_checks(self, update_signal=None):
- """
- executes actual checks in a separate thread
- """
- # We're done!
- self.set_done()
-
- def _do_validation(self):
- """
- called after _do_checks has finished
- (connected to checker thread finished signal)
- """
- print 'validation...'
- prevpage = "providerselection"
- errors = self.wizard().get_validation_error(prevpage)
-
- if not errors:
- self.hide_progress()
- self.create_info_panel()
- self.show_provider_info()
-
- else:
- logger.debug('going back with errors')
- logger.debug('ERRORS: %s' % errors)
- self.go_back()
-
def nextId(self):
wizard = self.wizard()
next_ = "providersetupvalidation"
return wizard.get_page_index(next_)
- #def isComplete(self):
- #return self.is_done()
-
def initializePage(self):
- super(ProviderInfoPage, self).initializePage()
- self.show_progress()
- self.set_undone()
- self.completeChanged.emit()
-
- def cleanupPage(self):
- wizard = self.wizard()
-
- # XXX makes sense now?
- # this was created on previous...
- if hasattr(wizard, 'providerconfig'):
- 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
+ self.show_provider_info()
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)
diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py
index 7c19dc3f..042d117c 100644
--- a/src/leap/gui/firstrun/providersetup.py
+++ b/src/leap/gui/firstrun/providersetup.py
@@ -20,9 +20,9 @@ class ProviderSetupValidationPage(ValidationPage):
is_signup = self.field("is_signup")
self.is_signup = is_signup
- self.setTitle("Setting up provider")
- #self.setSubTitle(
- #"auto configuring provider...")
+ self.setTitle("Provider setup")
+ self.setSubTitle(
+ "Doing autoconfig.")
self.setPixmap(
QtGui.QWizard.LogoPixmap,