1.1 --- a/OpenSecurity/bin/opensecurity_client_restful_server.py Thu Jun 12 10:34:46 2014 +0100
1.2 +++ b/OpenSecurity/bin/opensecurity_client_restful_server.py Thu Jun 12 14:08:36 2014 +0200
1.3 @@ -57,6 +57,8 @@
1.4 import itertools
1.5 import ctypes
1.6
1.7 +from PyQt4 import QtGui
1.8 +
1.9 from opensecurity_util import logger, setupLogger, OpenSecurityException
1.10 if sys.platform == 'win32' or sys.platform == 'cygwin':
1.11 from cygwin import Cygwin
1.12 @@ -75,6 +77,7 @@
1.13 '/credentials', 'os_credentials',
1.14 '/keyfile', 'os_keyfile',
1.15 '/log', 'os_log',
1.16 + '/message', 'os_message',
1.17 '/notification', 'os_notification',
1.18 '/password', 'os_password',
1.19 '/netmount', 'os_netmount',
1.20 @@ -94,11 +97,13 @@
1.21 """timer for the log file bouncer"""
1.22 log_file_bouncer = None
1.23
1.24 -
1.25 """The REST server object"""
1.26 server = None
1.27
1.28
1.29 +"""The System Tray Icon instance"""
1.30 +tray_icon = None
1.31 +
1.32 # ------------------------------------------------------------
1.33 # code
1.34
1.35 @@ -199,6 +204,40 @@
1.36 return "Ok"
1.37
1.38
1.39 +class os_message:
1.40 +
1.41 + """OpenSecurity '/message' handler.
1.42 +
1.43 + This is called on GET /message?text=TEXTi&timeout=TIMEOUT.
1.44 + This pops up the typical tray message (like a ballon on windows).
1.45 + """
1.46 +
1.47 + def POST(self):
1.48 + return self.GET()
1.49 +
1.50 + def GET(self):
1.51 +
1.52 + # pick the arguments
1.53 + args = web.input()
1.54 +
1.55 + # we _need_ a text
1.56 + if not "text" in args:
1.57 + raise web.badrequest('no text given')
1.58 +
1.59 + timeout = 5000
1.60 + if "timeout" in args:
1.61 + try:
1.62 + timeout=int(args.timeout)
1.63 + except:
1.64 + pass
1.65 +
1.66 + if tray_icon is None:
1.67 + raise web.badrequest('unable to access tray icon instance')
1.68 +
1.69 + tray_icon.showMessage('OpenSecurity', args.text, QtGui.QSystemTrayIcon.Information, timeout)
1.70 + return 'Shown: ' + args.text + ' timeout: ' + str(timeout) + ' ms'
1.71 +
1.72 +
1.73 class os_notification:
1.74
1.75 """OpenSecurity '/notification' handler.
1.76 @@ -266,6 +305,8 @@
1.77
1.78 return 'user queried for password'
1.79
1.80 +
1.81 +
1.82 def genNetworkDrive():
1.83 logical_drives = getLogicalDrives()
1.84 logger.info("Used logical drive letters: "+ str(logical_drives).strip('[]') )