summaryrefslogtreecommitdiff
path: root/src/leap/app.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-05-16 15:07:56 -0300
committerTomás Touceda <chiiph@leap.se>2013-05-16 15:07:56 -0300
commit709cbe02bee29cc75ffe9ccbc65c2db4e53e270f (patch)
tree57ce5db8064070472361e4ff32c69dae4a29ffa3 /src/leap/app.py
parent602201a6fdd4b52a61f0b2a7ab25202c6cc1abb5 (diff)
parent319e1d55a2f8e9c521450f60c571f24a907553ee (diff)
Merge remote-tracking branch 'kali/feature/use-qtreactor2' into develop
Diffstat (limited to 'src/leap/app.py')
-rw-r--r--src/leap/app.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index bb8add0d..797cea8a 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -17,7 +17,6 @@
import logging
import signal
-import socket
import sys
from functools import partial
@@ -28,14 +27,19 @@ from leap.common.events import server as event_server
from leap.util import __version__ as VERSION
from leap.util import leap_argparse
from leap.gui import locale_rc
+from leap.gui import twisted_main
from leap.gui.mainwindow import MainWindow
from leap.platform_init import IS_MAC
from leap.platform_init.locks import we_are_the_one_and_only
+from leap.services.tx import leap_services
import codecs
codecs.register(lambda name: codecs.lookup('utf-8')
if name == 'cp65001' else None)
+# pylint: avoid unused import
+assert(locale_rc)
+
def sigint_handler(*args, **kwargs):
"""
@@ -48,9 +52,15 @@ def sigint_handler(*args, **kwargs):
mainwindow.quit()
+def install_qtreactor(logger):
+ import qt4reactor
+ qt4reactor.install()
+ logger.debug("Qt4 reactor installed")
+
+
def main():
"""
- Launches the main event loop
+ Starts the main event loop and launches the main window.
"""
event_server.ensure_server(event_server.SERVER_PORT)
@@ -96,6 +106,9 @@ def main():
logger.info('Starting app')
app = QtGui.QApplication(sys.argv)
+ # install the qt4reactor.
+ install_qtreactor(logger)
+
# To test:
# $ LANG=es ./app.py
locale = QtCore.QLocale.system().name()
@@ -119,7 +132,10 @@ def main():
timer.start(500)
timer.timeout.connect(lambda: None)
- window = MainWindow(standalone, bypass_checks)
+ window = MainWindow(
+ lambda: twisted_main.quit(app),
+ standalone=standalone,
+ bypass_checks=bypass_checks)
window.show()
sigint_window = partial(sigint_handler, window, logger=logger)
@@ -128,8 +144,11 @@ def main():
if IS_MAC:
window.raise_()
+ tx_app = leap_services()
+ assert(tx_app)
+
# Run main loop
- sys.exit(app.exec_())
+ twisted_main.start(app)
if __name__ == "__main__":
main()