1.1 --- a/OpenSecurity/bin/opensecurity_tray.pyw Tue Dec 10 17:45:07 2013 +0100
1.2 +++ b/OpenSecurity/bin/opensecurity_tray.pyw Wed Dec 11 14:42:55 2013 +0100
1.3 @@ -36,6 +36,7 @@
1.4 import os
1.5 import subprocess
1.6 import sys
1.7 +import urllib2
1.8
1.9 from PyQt4 import QtCore
1.10 from PyQt4 import QtGui
1.11 @@ -49,6 +50,30 @@
1.12 # code
1.13
1.14
1.15 +class OpenSecurityWait(QtGui.QDialog):
1.16 +
1.17 + """OpenSecurity: please wait ..."""
1.18 +
1.19 + def __init__(self, parent = None, flags = QtCore.Qt.WindowFlags(0)):
1.20 + super(OpenSecurityWait, self).__init__(parent, flags)
1.21 + self.setWindowTitle('OpenSecurity')
1.22 + self.setup_ui()
1.23 +
1.24 +
1.25 + def setup_ui(self):
1.26 + """Create the widgets."""
1.27 +
1.28 + lyMain = QtGui.QVBoxLayout(self)
1.29 + lyMain.setContentsMargins(8, 8, 8, 8)
1.30 +
1.31 + # content area: left pixmap, right text
1.32 + lbTitle = QtGui.QLabel('Creating secure subsystem. Please stand by ...')
1.33 + lyMain.addWidget(lbTitle)
1.34 +
1.35 + self.setMinimumSize(400, 50)
1.36 + self.resize(lyMain.minimumSize())
1.37 +
1.38 +
1.39 class OpenSecurityTrayIcon(QtGui.QSystemTrayIcon):
1.40
1.41 """This is the OpenSecuirty Tray Icon"""
1.42 @@ -67,11 +92,31 @@
1.43
1.44 def clicked_browser(self):
1.45 """wish for safe internet browsing"""
1.46 - dlg_launch_image = os.path.join(sys.path[0], 'launch.pyw')
1.47 - process_command = [sys.executable, dlg_launch_image, '192.168.56.101', '/usr/bin/iceweasel']
1.48 - print(process_command)
1.49 - process = subprocess.Popen(process_command, shell = False)
1.50 - process.communicate()
1.51 +
1.52 + # TODO: HARDCODED ADDRESS OF OPENSECURITYD
1.53 +
1.54 + # tell the user to wait
1.55 + dlg = OpenSecurityWait()
1.56 + dlg.show()
1.57 + QtGui.QApplication.instance().processEvents()
1.58 +
1.59 + try:
1.60 +
1.61 + # get a proper browsing VM
1.62 + browsing_vm = urllib2.urlopen('http://127.0.0.1:8080/browsing').readline()
1.63 + dlg_launch_image = os.path.join(sys.path[0], 'launch.pyw')
1.64 + process_command = [sys.executable, dlg_launch_image, browsing_vm, '/usr/bin/iceweasel']
1.65 + print(process_command)
1.66 + process = subprocess.Popen(process_command, shell = False)
1.67 + process.communicate()
1.68 +
1.69 + except:
1.70 + dlg.hide()
1.71 + QtGui.QApplication.instance().processEvents()
1.72 + QtGui.QMessageBox.critical(None, 'Failed to invoke Safe Internet Browsing', 'OpenSecurity Error')
1.73 +
1.74 + dlg.hide()
1.75 + QtGui.QApplication.instance().processEvents()
1.76
1.77
1.78 def clicked_exit(self):