summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-09-06 11:41:33 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-09-06 13:55:21 -0400
commitb5e628de0c4b19be112e5c2d44991c1421d7d791 (patch)
treead05c1735c56e7ece943d4bce735c9d114394850
parent7514c1905357b1b3bdbcfb813b6f2f5aff1a10ae (diff)
[feature] webkit window serving bitmask-js
-rw-r--r--src/leap/bitmask/gui/README.rst7
-rw-r--r--src/leap/bitmask/gui/__init__.py0
-rw-r--r--src/leap/bitmask/gui/app.py72
3 files changed, 75 insertions, 4 deletions
diff --git a/src/leap/bitmask/gui/README.rst b/src/leap/bitmask/gui/README.rst
index b131adfb..431bcfc8 100644
--- a/src/leap/bitmask/gui/README.rst
+++ b/src/leap/bitmask/gui/README.rst
@@ -1,6 +1,5 @@
-To Be Done
-----------
-bitmask.gui is a module that depends on PyQt.QWebEngine
-It SHOULD be declared as extra in bitmask setup.py
+bitmask.gui is a module that depends on PyQt.
+It is declared as an extra in bitmask setup.py
+
Its function is to launch a minimalistic browser that serves the bitmask_www
interface.
diff --git a/src/leap/bitmask/gui/__init__.py b/src/leap/bitmask/gui/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/leap/bitmask/gui/__init__.py
diff --git a/src/leap/bitmask/gui/app.py b/src/leap/bitmask/gui/app.py
new file mode 100644
index 00000000..b6e8510b
--- /dev/null
+++ b/src/leap/bitmask/gui/app.py
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+# app.py
+# Copyright (C) 2016 LEAP Encryption Acess Project
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Main entrypoint for the Bitmask Qt GUI.
+It just launches a wekbit browser that runs the local web-ui served by bitmaskd
+when the web service is running.
+"""
+
+import sys
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+from PyQt5 import QtWebKit, QtWebKitWidgets
+
+BITMASK_URI = 'http://localhost:7070'
+
+qApp = None
+
+
+class BrowserWindow(QtWidgets.QDialog):
+
+ def __init__(self, parent):
+ super(BrowserWindow, self).__init__(parent)
+ self.view = QtWebKitWidgets.QWebView(self)
+ self.setWindowTitle('Bitmask')
+ self.resize(800, 600)
+ self.load_app()
+
+ def load_app(self):
+ self.view.load(QtCore.QUrl(BITMASK_URI))
+
+ def shutdown(self):
+ print('[bitmask] shutting down...')
+ try:
+ self.view.stop()
+ QtCore.QTimer.singleShot(0, qApp.deleteLater)
+
+ except Exception as ex:
+ print('exception catched: %r' % ex)
+ sys.exit(1)
+
+
+def start_app():
+
+ global qApp
+
+ qApp = QtWidgets.QApplication([])
+ browser = BrowserWindow(None)
+
+ qApp.setQuitOnLastWindowClosed(True)
+ qApp.lastWindowClosed.connect(browser.shutdown)
+
+ browser.show()
+ sys.exit(qApp.exec_())
+
+
+if __name__ == "__main__":
+ start_app()