import SOAPpy import mws from SOAPpy.Types import faultType, voidType, simplify, booleanType class General(mws.mwsAuthentication, mws.mwsGeneral): version = "v1.0" author = "Magnus Agust Skulason, maggias@gmail.com" def restartServer(self): # This is not possible at this stage # A solution has been suggested here: http://discussion.forum.nokia.com/forum/showthread.php?t=140125 # But implementation is considered out side the scope of this project pass def displayMessage(self, message, type): try: # Launches an external program that displays the message to the user of the phone # Parameter passing is done through a simple text file leto = mws.launchExternalThreadObject() leto.setModule("General") leto.setObject("General") leto.setFunction("displayMessageUI") leto.addParameter("message",message) leto.addParameter("type", type) mws.launchExternalThread(leto) return "success" except Exception, e: raise faultType("SOAP-ENV:Server","displayMessage failed.",e) def displayMessageUI(self, message, type): import appuifw appuifw.note(u'' + message, type) def getUserConfirmation(self, message, receiptRequest): try: endpoint = receiptRequest['endpoint'] interfaceName = receiptRequest['interfaceName'] correlator = receiptRequest['correlator'] leto = mws.launchExternalThreadObject() leto.setModule("General") leto.setObject("General") leto.setFunction("getUserConfirmationUI") leto.addParameter("message",message) leto.addParameter("endpoint",endpoint) leto.addParameter("interfaceName",interfaceName) leto.addParameter("correlator",correlator) mws.launchExternalThread(leto) except Exception, e: raise faultType("SOAP-ENV:Server","getUserConfirmation failed.",e) def getUserConfirmationUI(self, message, endpoint, interfaceName, correlator): import sys import appuifw result = appuifw.query(u'' + message, 'query') returnValue = "" if (result == True): returnValue = "true" else: returnValue = "false" # call the callback function with the answer try: print "endpoint" print endpoint server = SOAPpy.SOAPProxy(endpoint) server.getUserConfirmationResult(returnValue, correlator) except Exception, e: f = open("c:\\pylaunch.txt", "w") f.write("Exception: ") f.write(e.__str__()) f.flush() f.close() sys.exit() def launchApplication(self, application, parameters): try: e32.start_exe(u'' + application,u'' + parameters) return "success" except Exception, e: raise faultType("SOAP-ENV:Server","launchApplication failed.",e) def getWLANs(self): # Returns MAC address, SSID and ConnectionMode of awailable WLANS import wlantools output = [] wlanData = wlantools.scan() for n in range(0, len(wlanData)): output.append({'SSID' : wlanData[n]['SSID'], 'MAC':wlanData[n]['BSSID'], 'ConnectionMode':wlanData[n]['ConnectionMode']}) return output