summaryrefslogtreecommitdiff
path: root/src/leap/gui/mainwindow.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui/mainwindow.py')
-rw-r--r--src/leap/gui/mainwindow.py72
1 files changed, 43 insertions, 29 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index 73354684..5c7a3928 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -101,7 +101,9 @@ class MainWindow(QtGui.QMainWindow):
user_stopped_eip = False
def __init__(self, quit_callback,
- standalone=False, bypass_checks=False):
+ standalone=False,
+ openvpn_verb=1,
+ bypass_checks=False):
"""
Constructor for the client main window
@@ -215,7 +217,7 @@ class MainWindow(QtGui.QMainWindow):
self._smtp_bootstrapper.download_config.connect(
self._smtp_bootstrapped_stage)
- self._vpn = VPN()
+ self._vpn = VPN(openvpn_verb=openvpn_verb)
self._vpn.qtsigs.state_changed.connect(
self._status_panel.update_vpn_state)
self._vpn.qtsigs.status_changed.connect(
@@ -588,13 +590,7 @@ class MainWindow(QtGui.QMainWindow):
Displays the context menu from the tray icon
"""
- get_action = lambda visible: (
- self.tr("Show Main Window"),
- self.tr("Hide Main Window"))[int(visible)]
-
- # set labels
- visible = self.isVisible()
- self._action_visible.setText(get_action(visible))
+ self._update_hideshow_menu()
context_menu = self._systray.contextMenu()
if not IS_MAC:
@@ -604,6 +600,19 @@ class MainWindow(QtGui.QMainWindow):
# this works however.
context_menu.exec_(self._systray.geometry().center())
+ def _update_hideshow_menu(self):
+ """
+ Updates the Hide/Show main window menu text based on the
+ visibility of the window.
+ """
+ get_action = lambda visible: (
+ self.tr("Show Main Window"),
+ self.tr("Hide Main Window"))[int(visible)]
+
+ # set labels
+ visible = self.isVisible()
+ self._action_visible.setText(get_action(visible))
+
def _toggle_visible(self):
"""
SLOT
@@ -617,6 +626,8 @@ class MainWindow(QtGui.QMainWindow):
else:
self.hide()
+ self._update_hideshow_menu()
+
def _center_window(self):
"""
Centers the mainwindow based on the desktop geometry
@@ -803,7 +814,6 @@ 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
@@ -831,7 +841,6 @@ class MainWindow(QtGui.QMainWindow):
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.")
@@ -1091,6 +1100,7 @@ class MainWindow(QtGui.QMainWindow):
self._status_panel.eip_started()
+ # XXX refactor into status_panel method?
self._action_eip_startstop.setText(self.tr("Turn OFF"))
self._action_eip_startstop.disconnect(self)
self._action_eip_startstop.triggered.connect(
@@ -1254,29 +1264,34 @@ class MainWindow(QtGui.QMainWindow):
loaded
"""
leap_assert(self._eip_config, "We need an eip config!")
+ passed = data[self._eip_bootstrapper.PASSED_KEY]
+
+ if not passed:
+ error_msg = self.tr("There was a problem with the provider")
+ self._status_panel.set_eip_status(error_msg, error=True)
+ logger.error(data[self._eip_bootstrapper.ERROR_KEY])
+ self._already_started_eip = False
+ return
provider_config = self._get_best_provider_config()
domain = provider_config.get_domain()
- if data[self._eip_bootstrapper.PASSED_KEY] and \
- (self._eip_config.loaded() or
- self._eip_config.load(os.path.join("leap",
- "providers",
- domain,
- "eip-service.json"))):
- self._start_eip()
+ loaded = self._eip_config.loaded()
+ if not loaded:
+ eip_config_path = os.path.join("leap", "providers",
+ domain, "eip-service.json")
+ api_version = provider_config.get_api_version()
+ self._eip_config.set_api_version(api_version)
+ loaded = self._eip_config.load(eip_config_path)
+
+ if loaded:
+ self._start_eip()
else:
- if data[self._eip_bootstrapper.PASSED_KEY]:
- self._status_panel.set_eip_status(
- self.tr("Could not load Encrypted Internet "
- "Configuration."),
- error=True)
- else:
- self._status_panel.set_eip_status(
- data[self._eip_bootstrapper.ERROR_KEY],
- error=True)
- self._already_started_eip = False
+ self._status_panel.set_eip_status(
+ self.tr("Could not load Encrypted Internet "
+ "Configuration."),
+ error=True)
def _logout(self):
"""
@@ -1319,7 +1334,6 @@ 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(
self.tr("Unable to connect: Problem with provider"))