summaryrefslogtreecommitdiff
path: root/src/leap/gui
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-12 17:12:20 -0300
committerTomás Touceda <chiiph@leap.se>2013-03-12 17:12:20 -0300
commit364c6d5e9882f47ff5938f731641bc7509e32fc0 (patch)
treeefd416bf91990b56c2f70a0aed1d21629a9f87e0 /src/leap/gui
parenta120904b512394346b286bb417adf34fc622e739 (diff)
Make the wizard provider setup only
Also: - Add a way to enable/disable services for a provider - Run EIP only if it is enabled
Diffstat (limited to 'src/leap/gui')
-rw-r--r--src/leap/gui/mainwindow.py25
-rw-r--r--src/leap/gui/ui/mainwindow.ui3
-rw-r--r--src/leap/gui/ui/wizard.ui106
-rw-r--r--src/leap/gui/wizard.py128
4 files changed, 88 insertions, 174 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index 3af87366..f8ca4c35 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -175,6 +175,8 @@ class MainWindow(QtGui.QMainWindow):
self._action_visible = QtGui.QAction(self.tr("Hide"), self)
self._action_visible.triggered.connect(self._toggle_visible)
+ self._enabled_services = []
+
self._center_window()
self._wizard = None
self._wizard_firstrun = False
@@ -214,6 +216,11 @@ class MainWindow(QtGui.QMainWindow):
if self._wizard:
possible_username = self._wizard.get_username()
possible_password = self._wizard.get_password()
+ self.ui.chkRemember.setChecked(self._wizard.get_remember())
+ self._enabled_services = list(self._wizard.get_services())
+ settings.setValue("%s/Services" %
+ (self.ui.cmbProviders.currentText(),),
+ self._enabled_services)
if possible_username is not None:
self.ui.lnUser.setText(possible_username)
self._focus_password()
@@ -487,6 +494,11 @@ class MainWindow(QtGui.QMainWindow):
password = self.ui.lnPassword.text()
provider = self.ui.cmbProviders.currentText()
+ settings = QtCore.QSettings()
+ self._enabled_services = settings.value(
+ "%s/Services" %
+ (self.ui.cmbProviders.currentText(),), "").split(",")
+
if len(provider) == 0:
self._set_status(self.tr("Please select a valid provider"))
return
@@ -608,15 +620,20 @@ class MainWindow(QtGui.QMainWindow):
self._set_eip_status(self.tr("Checking configuration, please wait..."))
- if self._provider_config.provides_eip():
+ if self._provider_config.provides_eip() and \
+ self._enabled_services.count("openvpn") > 0:
self._eip_bootstrapper.run_eip_setup_checks(
self._checker_thread,
self._provider_config,
download_if_needed=True)
else:
- self._set_eip_status(self.tr("%s does not support EIP") %
- (self._provider_config.get_domain(),),
- error=True)
+ if self._enabled_services.count("openvpn") > 0:
+ self._set_eip_status(self.tr("%s does not support EIP") %
+ (self._provider_config.get_domain(),),
+ error=True)
+ else:
+ self._set_eip_status(self.tr("EIP is disabled"))
+ self.ui.btnEipStartStop.setEnabled(False)
def _set_eip_status_icon(self, status):
"""
diff --git a/src/leap/gui/ui/mainwindow.ui b/src/leap/gui/ui/mainwindow.ui
index d723114c..a8a8aa59 100644
--- a/src/leap/gui/ui/mainwindow.ui
+++ b/src/leap/gui/ui/mainwindow.ui
@@ -70,7 +70,7 @@
<item row="2" column="0" colspan="5">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_2">
@@ -389,6 +389,7 @@
</tabstops>
<resources>
<include location="../../../../data/resources/mainwindow.qrc"/>
+ <include location="../../../../data/resources/locale.qrc"/>
</resources>
<connections/>
</ui>
diff --git a/src/leap/gui/ui/wizard.ui b/src/leap/gui/ui/wizard.ui
index ad4c0500..b8fed183 100644
--- a/src/leap/gui/ui/wizard.ui
+++ b/src/leap/gui/ui/wizard.ui
@@ -632,123 +632,29 @@
</item>
</layout>
</widget>
- <widget class="WizardPage" name="eip_setup_page">
+ <widget class="QWizardPage" name="service_selection">
<property name="title">
- <string>EIP Setup</string>
+ <string>Service selection</string>
</property>
<property name="subTitle">
- <string>Setting up Encrypted Internet</string>
+ <string>Please select the services you would like to have</string>
</property>
<attribute name="pageId">
<string notr="true">5</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
- <spacer name="verticalSpacer_5">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="groupBox_3">
+ <widget class="QGroupBox" name="grpServices">
<property name="title">
- <string>Checking EIP</string>
+ <string notr="true">Services by PROVIDER</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
- <item row="1" column="0">
- <widget class="QLabel" name="label_19">
- <property name="text">
- <string>Download EIP configuration</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_20">
- <property name="text">
- <string>Download client certificate</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="lblDownloadEIPConfig">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>24</width>
- <height>24</height>
- </size>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="lblDownloadClientCert">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>24</width>
- <height>24</height>
- </size>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap>
- </property>
- </widget>
- </item>
<item row="0" column="0">
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
+ <layout class="QVBoxLayout" name="serviceListLayout"/>
</item>
</layout>
</widget>
</item>
- <item row="2" column="0">
- <spacer name="verticalSpacer_6">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<widget class="QWizardPage" name="finish_page">
diff --git a/src/leap/gui/wizard.py b/src/leap/gui/wizard.py
index 1f0bc877..83f64020 100644
--- a/src/leap/gui/wizard.py
+++ b/src/leap/gui/wizard.py
@@ -27,9 +27,7 @@ from functools import partial
from ui_wizard import Ui_Wizard
from leap.config.providerconfig import ProviderConfig
from leap.crypto.srpregister import SRPRegister
-from leap.crypto.srpauth import SRPAuth
from leap.services.eip.providerbootstrapper import ProviderBootstrapper
-from leap.services.eip.eipbootstrapper import EIPBootstrapper
logger = logging.getLogger(__name__)
@@ -44,7 +42,7 @@ class Wizard(QtGui.QWizard):
PRESENT_PROVIDER_PAGE = 2
SETUP_PROVIDER_PAGE = 3
REGISTER_USER_PAGE = 4
- SETUP_EIP_PAGE = 5
+ SERVICES_PAGE = 5
FINISH_PAGE = 6
WEAK_PASSWORDS = ("123456", "qweasd", "qwerty",
@@ -65,6 +63,16 @@ class Wizard(QtGui.QWizard):
self.ERROR_ICON = QtGui.QPixmap(":/images/Dialog-error.png")
self.OK_ICON = QtGui.QPixmap(":/images/Dialog-accept.png")
+ # Correspondence for services and their name to display
+ self.SERVICE_DISPLAY = [
+ self.tr("Encrypted Internet")
+ ]
+ self.SERVICE_CONFIG = [
+ "openvpn"
+ ]
+
+ self._selected_services = set()
+
self._show_register = False
self.ui.grpCheckProvider.setVisible(False)
@@ -86,13 +94,6 @@ class Wizard(QtGui.QWizard):
self._provider_bootstrapper.check_api_certificate.connect(
self._check_api_certificate)
- self._eip_bootstrapper = EIPBootstrapper()
-
- self._eip_bootstrapper.download_config.connect(
- self._download_eip_config)
- self._eip_bootstrapper.download_client_certificate.connect(
- self._download_client_certificate)
-
self._domain = None
self._provider_config = ProviderConfig()
@@ -135,6 +136,12 @@ class Wizard(QtGui.QWizard):
def get_password(self):
return self._password
+ def get_remember(self):
+ return self.ui.chkRemember.isChecked()
+
+ def get_services(self):
+ return self._selected_services
+
def _enable_check(self, text):
self.ui.btnCheck.setEnabled(len(self.ui.lnProvider.text()) != 0)
self._reset_provider_check()
@@ -214,19 +221,11 @@ class Wizard(QtGui.QWizard):
if ok:
self._set_register_status(self.tr("<font color='green'>"
"<b>User registration OK. "
- "Logging in...</b></font>"))
+ "</b></font>"))
self.ui.lblPassword2.clearFocus()
-
- srp_auth = SRPAuth(self._provider_config)
- srp_auth.authentication_finished.connect(
- self._authentication_finished)
-
- auth_partial = partial(srp_auth.authenticate,
- self._username,
- self._password)
- self._checker_thread.add_checks([auth_partial])
-
self.ui.chkRemember.setEnabled(True)
+
+ self.page(self.REGISTER_USER_PAGE).set_completed()
else:
old_username = self._username
self._username = None
@@ -241,24 +240,6 @@ class Wizard(QtGui.QWizard):
logger.error("Unknown error: %r" % (req.content,))
self.ui.btnRegister.setEnabled(True)
- def _authentication_finished(self, ok, message):
- """
- SLOT
- TRIGGER: srp_auth.authentication_finished
-
- Finish the authentication process as it comes from the
- register form
- """
- if ok:
- self._set_register_status(self.tr("<font color='green'>"
- "<b>Login succeeded!"
- "</b></font>"))
- self.page(self.REGISTER_USER_PAGE).set_completed()
- else:
- self._set_register_status(message)
- self.ui.btnRegister.setEnabled(True)
- self.ui.chkRemember.setEnabled(False)
-
def _set_register_status(self, status, error=False):
"""
Sets the status label in the registration page to status
@@ -291,13 +272,6 @@ class Wizard(QtGui.QWizard):
self.ui.lblCheckCaFpr.setPixmap(None)
self.ui.lblCheckApiCert.setPixmap(None)
- def _reset_eip_check(self):
- """
- Resets the UI for the EIP check
- """
- self.ui.lblDownloadEIPConfig.setPixmap(None)
- self.ui.lblDownloadClientCert.setPixmap(None)
-
def _check_provider(self):
"""
SLOT
@@ -447,28 +421,47 @@ class Wizard(QtGui.QWizard):
self._complete_task(data, self.ui.lblCheckApiCert,
True, self.SETUP_PROVIDER_PAGE)
- def _download_eip_config(self, data):
+ def _service_selection_changed(self, service, state):
"""
SLOT
- TRIGGER: self._eip_bootstrapper.download_config
+ TRIGGER: service_checkbox.stateChanged
+ Adds the service to the state if the state is checked, removes
+ it otherwise
+
+ @param service: service to handle
+ @type service: str
+ @param state: state of the checkbox
+ @type state: int
+ """
+ if state == QtCore.Qt.Checked:
+ self._selected_services = \
+ self._selected_services.union({service})
+ else:
+ self._selected_services = \
+ self._selected_services.difference({service})
- Sets the status for the EIP config downloading check
+ def _populate_services(self):
"""
- self._complete_task(data, self.ui.lblDownloadEIPConfig)
- self.ui.lblDownloadClientCert.setPixmap(self.QUESTION_ICON)
-
- def _download_client_certificate(self, data):
+ Loads the services that the provider provides into the UI for
+ the user to enable or disable
"""
- SLOT
- TRIGGER: self._provider_bootstrapper.download_client_certificate
+ self.ui.grpServices.setTitle(
+ self.tr("Services by %s") %
+ (self._provider_config.get_name(),))
- Sets the status for the download client certificate check and
- completes the page if passed. Also stops the eip bootstrapper
- thread since it's not needed from this point on unless the
- check chain is restarted
- """
- self._complete_task(data, self.ui.lblDownloadClientCert,
- True, self.SETUP_EIP_PAGE)
+ for service in self._provider_config.get_services():
+ try:
+ checkbox = QtGui.QCheckBox(self)
+ service_index = self.SERVICE_CONFIG.index(service)
+ checkbox.setText(self.SERVICE_DISPLAY[service_index])
+ self.ui.serviceListLayout.addWidget(checkbox)
+ checkbox.stateChanged.connect(
+ partial(self._service_selection_changed, service))
+ checkbox.setChecked(True)
+ except ValueError:
+ logger.error(
+ self.tr("Something went wrong while trying to "
+ "load service %s" % (service,)))
def _current_id_changed(self, pageId):
"""
@@ -492,12 +485,6 @@ class Wizard(QtGui.QWizard):
run_provider_setup_checks(self._checker_thread,
self._provider_config)
- if pageId == self.SETUP_EIP_PAGE:
- self._reset_eip_check()
- self.ui.lblDownloadEIPConfig.setPixmap(self.QUESTION_ICON)
- self._eip_bootstrapper.run_eip_setup_checks(self._checker_thread,
- self._provider_config)
-
if pageId == self.PRESENT_PROVIDER_PAGE:
self.page(pageId).setSubTitle(self.tr("Services offered by %s") %
(self._provider_config
@@ -521,6 +508,9 @@ class Wizard(QtGui.QWizard):
(self._provider_config
.get_name(),))
+ if pageId == self.SERVICES_PAGE:
+ self._populate_services()
+
def nextId(self):
"""
Sets the next page id for the wizard based on wether the user
@@ -533,6 +523,6 @@ class Wizard(QtGui.QWizard):
if self._show_register:
return self.REGISTER_USER_PAGE
else:
- return self.SETUP_EIP_PAGE
+ return self.SERVICES_PAGE
return QtGui.QWizard.nextId(self)