summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/app.py28
-rw-r--r--src/leap/baseapp/mainwindow.py3
-rw-r--r--src/leap/eip/openvpnconnection.py7
3 files changed, 23 insertions, 15 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index c88ca913..d594c7cd 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -9,15 +9,17 @@ sip.setapi('QVariant', 2)
sip.setapi('QString', 2)
from PyQt4.QtGui import (QApplication, QSystemTrayIcon, QMessageBox)
from PyQt4.QtCore import QTimer
-from PyQt4 import QtCore
from leap import __version__ as VERSION
from leap.baseapp.mainwindow import LeapWindow
-def sigint_handler(*args):
- #import pdb4qt as pdb; pdb.set_trace()
- app = args[0]
- app.cleanupAndQuit()
+
+def sigint_handler(*args, **kwargs):
+ logger = kwargs.get('logger', None)
+ logger.debug('SIGINT catched. shutting down...')
+ mainwindow = args[0]
+ mainwindow.shutdownSignal.emit()
+
def main():
"""
@@ -60,10 +62,6 @@ def main():
logger.info('Starting app')
app = QApplication(sys.argv)
- timer = QTimer()
- timer.start(500)
- timer.timeout.connect(lambda: None)
-
# needed for initializing qsettings
# it will write .config/leap/leap.conf
# top level app settings
@@ -82,11 +80,15 @@ def main():
window = LeapWindow(opts)
- sigint_window = partial(sigint_handler, window)
+ # this dummy timer ensures that
+ # control is given to the outside loop, so we
+ # can hook our sigint handler.
+ timer = QTimer()
+ timer.start(500)
+ timer.timeout.connect(lambda: None)
+
+ sigint_window = partial(sigint_handler, window, logger=logger)
signal.signal(signal.SIGINT, sigint_window)
- #signal.signal(signal.SIGINT, lambda: QtCore.QMetaObject.invokeMethod(window, 'cleanupAndQuit'))
- #window.shutdownSignal.connect(window.cleanupAndQuit)
- #signal.signal(signal.SIGINT, window.shutdownSignal.emit))
if debug:
# we only show the main window
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index 85185ca6..8d61bf5c 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -95,6 +95,8 @@ class LeapWindow(QtGui.QMainWindow,
lambda: self.start_or_stopVPN())
self.start_eipconnection.connect(
lambda: self.start_or_stopVPN())
+ self.shutdownSignal.connect(
+ self.cleanupAndQuit)
# status change.
# TODO unify
@@ -102,7 +104,6 @@ class LeapWindow(QtGui.QMainWindow,
lambda status: self.onOpenVPNStatusChange(status))
self.eipStatusChange.connect(
lambda newstatus: self.onEIPConnStatusChange(newstatus))
- # can I connect 2 signals?
self.eipStatusChange.connect(
lambda newstatus: self.toggleEIPAct())
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index 85874cfd..859378c0 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -390,9 +390,14 @@ to be triggered for each one of them.
"""
logger.debug("disconnecting...")
if self.connected():
- self._send_command("signal SIGTERM\n")
+ try:
+ self._send_command("signal SIGTERM\n")
+ except socket.error:
+ logger.warning('management socket died')
+ return
if self.subp:
+ # ???
return True
#shutting openvpn failured