Changeset 20807 in vbox for trunk/src/VBox/Main/glue
- Timestamp:
- Jun 23, 2009 8:39:42 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 48944
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/vboxapi.py
r20693 r20807 34 34 35 35 class PlatformMSCOM: 36 # Class to fake access to constants in style of foo.bar.boo 36 # Class to fake access to constants in style of foo.bar.boo 37 37 class ConstantFake: 38 38 def __init__(self, parent, name): … … 50 50 import win32com 51 51 from win32com.client import constants 52 52 53 53 if attr.startswith("__"): 54 54 raise AttributeError 55 55 56 56 consts = self.__dict__['_consts'] 57 57 58 58 fake = consts.get(attr, None) 59 59 if fake != None: 60 return fake 60 return fake 61 61 try: 62 62 name = self.__dict__['_name'] 63 63 parent = self.__dict__['_parent'] 64 while parent != None: 64 while parent != None: 65 65 if parent._name is not None: 66 66 name = parent._name+'_'+name 67 67 parent = parent._parent 68 68 69 69 if name is not None: 70 70 name += "_" + attr … … 75 75 fake = PlatformMSCOM.ConstantFake(self, attr) 76 76 consts[attr] = fake 77 return fake 77 return fake 78 78 79 79 … … 104 104 import pythoncom 105 105 import win32api 106 self.constants = PlatformMSCOM.InterfacesWrapper() 106 self.constants = PlatformMSCOM.InterfacesWrapper() 107 from win32con import DUPLICATE_SAME_ACCESS 108 from win32api import GetCurrentThread,GetCurrentThreadId,DuplicateHandle,GetCurrentProcess 109 pid = GetCurrentProcess() 110 self.tid = GetCurrentThreadId() 111 handle = DuplicateHandle(pid, GetCurrentThread(), pid, 0, 0, DUPLICATE_SAME_ACCESS) 112 self.handles = [] 113 self.handles.append(handle) 114 107 115 108 116 def getSessionObject(self, vbox): … … 118 126 def getConstants(self): 119 127 return self.constants 120 128 121 129 def getType(self): 122 130 return 'MSCOM' … … 136 144 pythoncom.CoUninitialize() 137 145 138 def createCallback(self, iface, impl, arg): 146 def createCallback(self, iface, impl, arg): 139 147 d = {} 140 148 d['BaseClass'] = impl 141 149 d['arg'] = arg 142 150 d['tlb_guid'] = PlatformMSCOM.VBOX_TLB_GUID 143 151 str = "" 144 152 str += "import win32com.server.util\n" 153 #str += "import win32com.server.register\n" 145 154 #str += "from win32com import universal\n" 146 #str += "import pythoncom\n"155 str += "import pythoncom\n" 147 156 #str += "universal.RegisterInterfaces(tlb_guid, 0, 1, 0, ['"+iface+"'])\n" 148 157 … … 150 159 str += " _com_interfaces_ = ['"+iface+"']\n" 151 160 str += " _typelib_guid_ = tlb_guid\n" 152 153 #str += " _reg_clsctx_ = pythoncom.CLSCTX_ INPROC_SERVER\n"161 str += " _typelib_version_ = 1, 0\n" 162 #str += " _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER\n" 154 163 #str += " _reg_clsid_ = '{F21202A2-959A-4149-B1C3-68B9013F3335}'\n" 155 164 #str += " _reg_progid_ = 'VirtualBox."+iface+"Impl'\n" … … 158 167 159 168 str += " def __init__(self): BaseClass.__init__(self, arg)\n" 160 str += "result = win32com.server.util.wrap("+iface+"Impl())\n" 169 #str += "win32com.server.register.UseCommandLine("+iface+"Impl)\n" 170 171 str += "result = win32com.server.util.wrap("+iface+"Impl())\n" 161 172 exec (str,d,d) 162 173 return d['result'] 163 174 164 175 def waitForEvents(self, timeout): 165 from win32file import CloseHandle 166 from win32con import DUPLICATE_SAME_ACCESS 167 from win32api import GetCurrentThread,DuplicateHandle,GetCurrentProcess 168 from win32event import MsgWaitForMultipleObjects, \ 176 from win32api import GetCurrentThreadId 177 from win32event import MsgWaitForMultipleObjects, \ 169 178 QS_ALLINPUT, WAIT_TIMEOUT, WAIT_OBJECT_0 170 179 from pythoncom import PumpWaitingMessages 171 180 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): 181 if (self.tid != GetCurrentThreadId()): 182 raise Exception("wait for events from the same thread you inited!") 183 184 rc = MsgWaitForMultipleObjects(self.handles, 0, timeout, QS_ALLINPUT) 185 if rc >= WAIT_OBJECT_0 and rc < WAIT_OBJECT_0+len(self.handles): 180 186 # is it possible? 181 187 print "how come?" 182 188 pass 183 elif rc==WAIT_OBJECT_0 + len( handles):189 elif rc==WAIT_OBJECT_0 + len(self.handles): 184 190 # Waiting messages 185 191 PumpWaitingMessages() 186 192 else: 193 # Timeout 187 194 pass 188 CloseHandle(handle)189 195 190 196 def deinit(self): 191 197 import pythoncom 198 from win32file import CloseHandle 199 200 for h in self.handles: 201 if h is not None: 202 CloseHandle(h) 203 self.handles = None 192 204 pythoncom.CoUninitialize() 193 205 pass … … 211 223 import xpcom.components 212 224 return xpcom.components.interfaces 213 225 214 226 def getType(self): 215 227 return 'XPCOM' 216 228 217 229 def getRemote(self): 218 230 return False … … 272 284 def getConstants(self): 273 285 return None 274 286 275 287 def getType(self): 276 288 return 'WEBSERVICE' 277 289 278 290 def getRemote(self): 279 291 return True … … 281 293 def getArray(self, obj, field): 282 294 return obj.__getattr__(field) 283 295 284 296 def initPerThread(self): 285 297 pass … … 326 338 327 339 def getArray(self, obj, field): 328 return self.platform.getArray(obj, field) 340 return self.platform.getArray(obj, field) 329 341 330 342 def getVirtualBox(self):
Note:
See TracChangeset
for help on using the changeset viewer.