summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/eip_status.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/gui/eip_status.py')
-rw-r--r--src/leap/bitmask/gui/eip_status.py45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/leap/bitmask/gui/eip_status.py b/src/leap/bitmask/gui/eip_status.py
index a707050a..f283b148 100644
--- a/src/leap/bitmask/gui/eip_status.py
+++ b/src/leap/bitmask/gui/eip_status.py
@@ -70,8 +70,11 @@ class EIPStatusWidget(QtGui.QWidget):
self.ui.eip_bandwidth.hide()
self.hide_fw_down_button()
+ self.hide_eip_cancel_button()
self.ui.btnFwDown.clicked.connect(
self._on_fw_down_button_clicked)
+ self.ui.btnEipCancel.clicked.connect(
+ self._on_eip_cancel_button_clicked)
# Set the EIP status icons
self.CONNECTING_ICON = None
@@ -88,6 +91,7 @@ class EIPStatusWidget(QtGui.QWidget):
self._provider = ""
self.is_restart = False
self.is_cold_start = True
+ self.user_cancelled = False
self.missing_helpers = False
@@ -285,6 +289,8 @@ class EIPStatusWidget(QtGui.QWidget):
Triggered when the app activates eip.
Disables the start/stop button.
"""
+ # XXX hack -- we show the cancel button instead.
+ self.ui.btnEipStartStop.hide()
self.set_startstop_enabled(False)
msg = self.tr("Encrypted Internet is starting")
self.set_eip_message(msg)
@@ -295,6 +301,9 @@ class EIPStatusWidget(QtGui.QWidget):
Triggered when a default provider_config has not been found.
Disables the start button and adds instructions to the user.
"""
+ # XXX this name is unfortunate. "disable" is also applied to a
+ # pushbutton being grayed out.
+
logger.debug('Hiding EIP start button')
# you might be tempted to change this for a .setEnabled(False).
# it won't work. it's under the claws of the state machine.
@@ -327,6 +336,7 @@ class EIPStatusWidget(QtGui.QWidget):
"""
# logger.debug('Showing EIP start button')
self.eip_button.show()
+ self.hide_eip_cancel_button()
# Restore the eip action menu
menu = self._systray.contextMenu()
@@ -420,6 +430,28 @@ class EIPStatusWidget(QtGui.QWidget):
self.set_eip_message(msg)
self.set_eip_status("")
+ def hide_eip_cancel_button(self):
+ """
+ Hide eip-cancel button.
+ """
+ self.ui.btnEipCancel.hide()
+
+ def show_eip_cancel_button(self):
+ """
+ Show eip-cancel button.
+ """
+ self.ui.btnEipCancel.show()
+ self.user_cancelled = False
+
+ def _on_eip_cancel_button_clicked(self):
+ """
+ Call backend to kill the openvpn process with root privileges.
+ """
+ self.eip_conductor.cancelled = True
+ self.eip_conductor._backend.bitmask_root_vpn_down()
+ self.user_cancelled = True
+ self.hide_eip_cancel_button()
+
@QtCore.Slot(dict)
def eip_stopped(self, restart=False, failed=False):
"""
@@ -433,6 +465,11 @@ class EIPStatusWidget(QtGui.QWidget):
self._reset_traffic_rates()
self.ui.eip_bandwidth.hide()
+ if self.user_cancelled:
+ self.eip_conductor._backend.tear_fw_down()
+ self.eip_button.show()
+ failed = False
+
# This is assuming the firewall works correctly, but we should test fw
# status positively.
# Or better call it from the conductor...
@@ -447,6 +484,7 @@ class EIPStatusWidget(QtGui.QWidget):
msg = failed_msg
else:
msg = clear_traffic
+
self.set_eip_message(msg)
self.ui.lblEIPStatus.show()
self.show()
@@ -523,16 +561,19 @@ class EIPStatusWidget(QtGui.QWidget):
self.eipconnection.qtsigs.connected_signal.emit()
self._on_eip_connected()
self.is_cold_start = False
+ self.hide_eip_cancel_button()
+ self.eip_button.show()
# XXX should lookup vpn_state map in EIPConnection
elif vpn_state == "AUTH":
self.set_eip_status(self.tr("Authenticating..."))
+
+ # XXX should be handled by a future state machine instead.
+ self.show_eip_cancel_button()
# we wipe up any previous error info in the EIP message
# when we detect vpn authentication is happening
msg = self.tr("Encrypted Internet is starting")
self.set_eip_message(msg)
- # on the first-run path, we hadn't showed the button yet.
- self.eip_button.show()
elif vpn_state == "GET_CONFIG":
self.set_eip_status(self.tr("Retrieving configuration..."))
elif vpn_state == "WAIT":