VirtualBox

Changeset 20693 in vbox for trunk/src/VBox/Main/glue


Ignore:
Timestamp:
Jun 18, 2009 4:37:00 PM (15 years ago)
Author:
vboxsync
Message:

Python: Windows waiting for event, additional shell command

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/vboxapi.py

    r20630 r20693  
    9292                    return self.__dict__['_rootFake'].__getattr__(a)
    9393
     94    VBOX_TLB_GUID  = '{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}'
     95    VBOX_TLB_LCID  = 0
     96    VBOX_TLB_MAJOR = 1
     97    VBOX_TLB_MINOR = 0
     98
    9499    def __init__(self, params):
    95100            from win32com import universal
     
    99104            import pythoncom
    100105            import win32api
    101             self.constants = PlatformMSCOM.InterfacesWrapper()
     106            self.constants = PlatformMSCOM.InterfacesWrapper()                       
    102107
    103108    def getSessionObject(self, vbox):
     
    135140        d['BaseClass'] = impl
    136141        d['arg'] = arg
     142        d['tlb_guid'] = PlatformMSCOM.VBOX_TLB_GUID
    137143        str = ""
    138         str += "import win32com.server.util"
     144        str += "import win32com.server.util\n"
     145        #str += "from win32com import universal\n"
     146        #str += "import pythoncom\n"
     147        #str += "universal.RegisterInterfaces(tlb_guid, 0, 1, 0, ['"+iface+"'])\n"
     148
    139149        str += "class "+iface+"Impl(BaseClass):\n"
    140150        str += "   _com_interfaces_ = ['"+iface+"']\n"
    141         str += "   _typelib_guid_ = '{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}'\n"
     151        str += "   _typelib_guid_ = tlb_guid\n"
     152        str += "   _typelib_version_ = 1, 0\n"
     153        #str += "   _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER\n"
     154        #str += "   _reg_clsid_ = '{F21202A2-959A-4149-B1C3-68B9013F3335}'\n"
     155        #str += "   _reg_progid_ = 'VirtualBox."+iface+"Impl'\n"
     156        #str += "   _reg_desc_ = 'Generated callback implementation class'\n"
     157        #str += "   _reg_policy_spec_ = 'win32com.server.policy.EventHandlerPolicy'\n"
     158
    142159        str += "   def __init__(self): BaseClass.__init__(self, arg)\n"
    143160        str += "result = win32com.server.util.wrap("+iface+"Impl())\n"       
     
    146163
    147164    def waitForEvents(self, timeout):
    148         # not really supported yet
    149         pass
     165        from win32file import CloseHandle
     166        from win32con import DUPLICATE_SAME_ACCESS
     167        from win32api import GetCurrentThread,DuplicateHandle,GetCurrentProcess
     168        from win32event import MsgWaitForMultipleObjects, \
     169                               QS_ALLINPUT, WAIT_TIMEOUT, WAIT_OBJECT_0
     170        from pythoncom import PumpWaitingMessages
     171
     172        pid = GetCurrentProcess()
     173        handle = DuplicateHandle(pid, GetCurrentThread(), pid, 0, 0, DUPLICATE_SAME_ACCESS)
     174       
     175        handles = []
     176        handles.append(handle)
     177
     178        rc = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT)
     179        if rc >= WAIT_OBJECT_0 and rc < WAIT_OBJECT_0+len(handles):
     180            # is it possible?
     181            print "how come?"
     182            pass
     183        elif rc==WAIT_OBJECT_0 + len(handles):
     184            # Waiting messages
     185            PumpWaitingMessages()
     186        else:
     187            pass
     188        CloseHandle(handle)
    150189
    151190    def deinit(self):
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette