summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/gui/mainwindow.py17
-rw-r--r--src/leap/bitmask/gui/wizard.py76
-rw-r--r--src/leap/bitmask/services/mail/conductor.py36
3 files changed, 91 insertions, 38 deletions
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index 549097ae..91bbe9cb 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -904,7 +904,6 @@ class MainWindow(QtGui.QMainWindow):
Once the user is properly authenticated, try starting the EIP
service
"""
-
# In general we want to "filter" likely complicated error
# messages, but in this case, the messages make more sense as
# they come. Since they are "Unknown user" or "Unknown
@@ -913,19 +912,19 @@ class MainWindow(QtGui.QMainWindow):
if ok:
self._logged_user = self._login_widget.get_user()
- # We leave a bit of room for the user to see the
- # "Succeeded" message and then we switch to the EIP status
- # panel
- QtCore.QTimer.singleShot(1000, self._switch_to_status)
+ user = self._logged_user
+ domain = self._provider_config.get_domain()
+ userid = "%s@%s" % (user, domain)
+ self._mail_conductor.userid = userid
self._login_defer = None
+ self._start_eip_bootstrap()
else:
self._login_widget.set_enabled(True)
- def _switch_to_status(self):
- # TODO this method name is confusing as hell.
+ def _start_eip_bootstrap(self):
"""
Changes the stackedWidget index to the EIP status one and
- triggers the eip bootstrapping
+ triggers the eip bootstrapping.
"""
self._login_widget.logged_in()
@@ -948,6 +947,8 @@ class MainWindow(QtGui.QMainWindow):
else:
self._mail_status.set_disabled()
+ # XXX the config should be downloaded from the start_eip
+ # method.
self._download_eip_config()
###################################################################
diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py
index 8de5802e..5f5224ae 100644
--- a/src/leap/bitmask/gui/wizard.py
+++ b/src/leap/bitmask/gui/wizard.py
@@ -111,8 +111,9 @@ class Wizard(QtGui.QWizard):
self.currentIdChanged.connect(self._current_id_changed)
- self.ui.lnProvider.textChanged.connect(
- self._enable_check)
+ self.ui.lnProvider.textChanged.connect(self._enable_check)
+ self.ui.rbNewProvider.toggled.connect(
+ lambda x: self._enable_check())
self.ui.lblUser.returnPressed.connect(
self._focus_password)
@@ -146,6 +147,26 @@ class Wizard(QtGui.QWizard):
self._load_configured_providers()
+ self._provider_checks_ok = False
+ self._provider_setup_ok = False
+ self.finished.connect(self._wizard_finished)
+
+ @QtCore.Slot()
+ def _wizard_finished(self):
+ """
+ SLOT
+ TRIGGER:
+ self.finished
+
+ This method is called when the wizard is accepted or rejected.
+ Here we do the cleanup needed to use the wizard again reusing the
+ instance.
+ """
+ self._provider_checks_ok = False
+ self._provider_setup_ok = False
+ self.ui.lnProvider.setText('')
+ self.ui.grpCheckProvider.setVisible(False)
+
def _load_configured_providers(self):
"""
Loads the configured providers into the wizard providers combo box.
@@ -193,9 +214,22 @@ class Wizard(QtGui.QWizard):
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()
+ @QtCore.Slot()
+ def _enable_check(self, reset=True):
+ """
+ SLOT
+ TRIGGER:
+ self.ui.lnProvider.textChanged
+
+ Enables/disables the 'check' button in the SELECT_PROVIDER_PAGE
+ depending on the lnProvider content.
+ """
+ enabled = len(self.ui.lnProvider.text()) != 0
+ enabled = enabled and self.ui.rbNewProvider.isChecked()
+ self.ui.btnCheck.setEnabled(enabled)
+
+ if reset:
+ self._reset_provider_check()
def _focus_password(self):
"""
@@ -338,6 +372,12 @@ class Wizard(QtGui.QWizard):
if len(self.ui.lnProvider.text()) == 0:
return
+ self._provider_checks_ok = False
+
+ # just in case that the user has already setup a provider and
+ # go 'back' to check a provider
+ self._provider_setup_ok = False
+
self.ui.grpCheckProvider.setVisible(True)
self.ui.btnCheck.setEnabled(False)
self.ui.lnProvider.setEnabled(False)
@@ -447,6 +487,7 @@ class Wizard(QtGui.QWizard):
"provider.json")):
self._complete_task(data, self.ui.lblProviderInfo,
True, self.SELECT_PROVIDER_PAGE)
+ self._provider_checks_ok = True
else:
new_data = {
self._provider_bootstrapper.PASSED_KEY: False,
@@ -498,6 +539,7 @@ class Wizard(QtGui.QWizard):
"""
self._complete_task(data, self.ui.lblCheckApiCert,
True, self.SETUP_PROVIDER_PAGE)
+ self._provider_setup_ok = True
def _service_selection_changed(self, service, state):
"""
@@ -555,18 +597,22 @@ class Wizard(QtGui.QWizard):
Prepares the pages when they appear
"""
if pageId == self.SELECT_PROVIDER_PAGE:
- self._reset_provider_check()
- self._enable_check("")
+ skip = self.ui.rbExistingProvider.isChecked()
+ if not self._provider_checks_ok:
+ self._enable_check()
+ self._skip_provider_checks(skip)
+ else:
+ self._enable_check(reset=False)
if pageId == self.SETUP_PROVIDER_PAGE:
- self._reset_provider_setup()
- self.page(pageId).setSubTitle(self.tr("Gathering configuration "
- "options for %s") %
- (self._provider_config
- .get_name(),))
- self.ui.lblDownloadCaCert.setPixmap(self.QUESTION_ICON)
- self._provider_setup_defer = self._provider_bootstrapper.\
- run_provider_setup_checks(self._provider_config)
+ if not self._provider_setup_ok:
+ self._reset_provider_setup()
+ sub_title = self.tr("Gathering configuration options for {0}")
+ sub_title = sub_title.format(self._provider_config.get_name())
+ self.page(pageId).setSubTitle(sub_title)
+ self.ui.lblDownloadCaCert.setPixmap(self.QUESTION_ICON)
+ self._provider_setup_defer = self._provider_bootstrapper.\
+ run_provider_setup_checks(self._provider_config)
if pageId == self.PRESENT_PROVIDER_PAGE:
self.page(pageId).setSubTitle(self.tr("Description of services "
diff --git a/src/leap/bitmask/services/mail/conductor.py b/src/leap/bitmask/services/mail/conductor.py
index c294381b..6dcf0c6f 100644
--- a/src/leap/bitmask/services/mail/conductor.py
+++ b/src/leap/bitmask/services/mail/conductor.py
@@ -81,16 +81,12 @@ class IMAPControl(object):
"We need a non-null keymanager for initializing imap "
"service")
- if self.imap_service is None:
- # first time.
- self.imap_service, \
- self.imap_port, \
+ self.imap_service, self.imap_port, \
self.imap_factory = imap.start_imap_service(
self._soledad,
- self._keymanager)
- else:
- # we have the fetcher. just start it.
- self.imap_service.start_loop()
+ self._keymanager,
+ userid=self.userid)
+ self.imap_service.start_loop()
def stop_imap_service(self):
"""
@@ -204,6 +200,7 @@ class SMTPControl(object):
from leap.mail.smtp import setup_smtp_relay
self._smtp_service, self._smtp_port = setup_smtp_relay(
port=2013,
+ userid=self.userid,
keymanager=self._keymanager,
smtp_host=host,
smtp_port=port,
@@ -339,11 +336,25 @@ class MailConductor(IMAPControl, SMTPControl):
SMTPControl.__init__(self)
self._soledad = soledad
self._keymanager = keymanager
-
self._mail_machine = None
-
self._mail_connection = mail_connection.MailConnection()
+ self.userid = None
+
+ @property
+ def userid(self):
+ return self._userid
+
+ @userid.setter
+ def userid(self, userid):
+ """
+ Sets the user id this conductor is configured for.
+
+ :param userid: the user id, in the form "user@provider"
+ :type userid: str
+ """
+ self._userid = userid
+
def start_mail_machine(self, **kwargs):
"""
Starts mail machine.
@@ -354,15 +365,10 @@ class MailConductor(IMAPControl, SMTPControl):
# we have instantiated the connections while building the composite
# machines, and we have to use the qtsigs instantiated there.
- # XXX we could probably use a proxy here too to make the thing
- # transparent.
self.set_imap_connection(imap.conn)
self.set_smtp_connection(smtp.conn)
self._mail_machine = mail
- # XXX -------------------
- # need to keep a reference?
- #self._mail_events = mail.events
self._mail_machine.start()
self._imap_machine = imap