From 9f3e9eee381fe68b3e8c28fe4a0dec45e4e80488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Thu, 1 Aug 2013 16:05:39 -0300 Subject: Fail gracefully when the events server fails to start --- src/leap/app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/leap/app.py b/src/leap/app.py index f45e46c4..6ba27813 100644 --- a/src/leap/app.py +++ b/src/leap/app.py @@ -131,7 +131,11 @@ def main(): """ Starts the main event loop and launches the main window. """ - event_server.ensure_server(event_server.SERVER_PORT) + try: + event_server.ensure_server(event_server.SERVER_PORT) + except Exception as e: + # We don't even have logger configured in here + print "Could not ensure server: %r" % (e,) _, opts = leap_argparse.init_leapc_args() standalone = opts.standalone -- cgit v1.2.3 From 3ad64e8c0236480d4112531718b9c13f285ac438 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 1 Aug 2013 16:19:01 -0300 Subject: Enable translation for string in code. --- src/leap/gui/login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/leap/gui/login.py b/src/leap/gui/login.py index 80f2f3db..d857959b 100644 --- a/src/leap/gui/login.py +++ b/src/leap/gui/login.py @@ -97,7 +97,7 @@ class LoginWidget(QtGui.QWidget): """ self.ui.cmbProviders.blockSignals(True) self.ui.cmbProviders.clear() - self.ui.cmbProviders.addItems(provider_list + ["Other..."]) + self.ui.cmbProviders.addItems(provider_list + [self.tr("Other...")]) self.ui.cmbProviders.blockSignals(False) def select_provider_by_name(self, name): -- cgit v1.2.3 From d1d9005201ea772c7599aa279650e49e1d91c27a Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 1 Aug 2013 16:34:45 -0300 Subject: Update docstring and remove unused import. --- src/leap/gui/login.py | 1 - src/leap/gui/mainwindow.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/leap/gui/login.py b/src/leap/gui/login.py index d857959b..36934ace 100644 --- a/src/leap/gui/login.py +++ b/src/leap/gui/login.py @@ -19,7 +19,6 @@ Login widget implementation """ import logging -import keyring from PySide import QtCore, QtGui from ui_login import Ui_LoginWidget diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index 1c871aa2..ed4ad864 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -754,8 +754,7 @@ class MainWindow(QtGui.QMainWindow): """ SLOT TRIGGERS: - self.ui.btnLogin.clicked - self.ui.lnPassword.returnPressed + self._login_widget.login Starts the login sequence. Which involves bootstrapping the selected provider if the selection is valid (not empty), then -- cgit v1.2.3 From 571fdf3908bc34d063e6a316abed448efbe1bfdb Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 1 Aug 2013 16:10:29 -0300 Subject: Add cancel button to login. Closes #3318. --- src/leap/gui/login.py | 22 ++++++++++++++++++++++ src/leap/gui/mainwindow.py | 29 ++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/leap/gui/login.py b/src/leap/gui/login.py index 36934ace..3eb1fe39 100644 --- a/src/leap/gui/login.py +++ b/src/leap/gui/login.py @@ -36,6 +36,8 @@ class LoginWidget(QtGui.QWidget): # Emitted when the login button is clicked login = QtCore.Signal() + cancel_login = QtCore.Signal() + # Emitted when the user selects "Other..." in the provider # combobox or click "Create Account" show_wizard = QtCore.Signal() @@ -193,6 +195,26 @@ class LoginWidget(QtGui.QWidget): self.ui.chkRemember.setEnabled(enabled) self.ui.cmbProviders.setEnabled(enabled) + def set_cancel(self, enabled=False): + """ + Enables or disables the cancel action in the "log in" process. + + :param enabled: wether it should be enabled or not + :type enabled: bool + """ + self.ui.btnLogin.setEnabled(enabled) + text = self.tr("Cancel") + login_or_cancel = self.cancel_login + + if not enabled: + text = self.tr("Log In") + login_or_cancel = self.login + + self.ui.btnLogin.setText(text) + + self.ui.btnLogin.clicked.disconnect() + self.ui.btnLogin.clicked.connect(login_or_cancel) + def _focus_password(self): """ Focuses in the password lineedit diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index ed4ad864..9dd44f4c 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -141,6 +141,7 @@ class MainWindow(QtGui.QMainWindow): self.ui.loginLayout.addWidget(self._login_widget) self._login_widget.login.connect(self._login) + self._login_widget.cancel_login.connect(self._cancel_login) self._login_widget.show_wizard.connect( self._launch_wizard) @@ -274,6 +275,7 @@ class MainWindow(QtGui.QMainWindow): self._keymanager = None self._login_defer = None + self._download_provider_defer = None self._smtp_config = SMTPConfig() @@ -709,9 +711,9 @@ class MainWindow(QtGui.QMainWindow): """ provider = self._login_widget.get_selected_provider() - self._provider_bootstrapper.run_provider_select_checks( - provider, - download_if_needed=True) + pb = self._provider_bootstrapper + d = pb.run_provider_select_checks(provider, download_if_needed=True) + self._download_provider_defer = d def _load_provider_config(self, data): """ @@ -787,6 +789,7 @@ class MainWindow(QtGui.QMainWindow): self._login_widget.set_status(self.tr("Logging in..."), error=False) self._login_widget.set_enabled(False) + self._login_widget.set_cancel(True) if self._login_widget.get_remember() and has_keyring(): # in the keyring and in the settings @@ -805,6 +808,25 @@ class MainWindow(QtGui.QMainWindow): self._download_provider_config() + def _cancel_login(self): + """ + SLOT + TRIGGERS: + self._login_widget.cancel_login + + Stops the login sequence. + """ + logger.debug("Cancelling log in.") + self._login_widget.set_cancel(False) + + if self._download_provider_defer: + logger.debug("Cancelling download provider defer.") + self._download_provider_defer.cancel() + + if self._login_defer: + logger.debug("Cancelling login defer.") + self._login_defer.cancel() + def _provider_config_loaded(self, data): """ SLOT @@ -1249,6 +1271,7 @@ class MainWindow(QtGui.QMainWindow): """ passed = data[self._provider_bootstrapper.PASSED_KEY] if not passed: + self._login_widget.set_cancel(False) self._login_widget.set_enabled(True) self._login_widget.set_status( data[self._provider_bootstrapper.ERROR_KEY]) -- cgit v1.2.3 From 599f6bf0d4f819ab1613bf9449c122025da07c13 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 1 Aug 2013 17:52:17 -0300 Subject: Add defer canceling to the app quit method. --- src/leap/gui/mainwindow.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index 9dd44f4c..2325ecf0 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -1402,8 +1402,13 @@ class MainWindow(QtGui.QMainWindow): self._logger_window.close() if self._login_defer: + logger.debug("Cancelling login defer.") self._login_defer.cancel() + if self._download_provider_defer: + logger.debug("Cancelling download provider defer.") + self._download_provider_defer.cancel() + self.close() if self._quit_callback: -- cgit v1.2.3