Changeset 22357 in vbox
- Timestamp:
- Aug 19, 2009 9:32:54 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/VirtualBox.h
r22305 r22357 63 63 ComPtr<ILocalOwner> ptr; 64 64 65 HRESULT rc = ptr.createInprocObject(CLSID_ VirtualBoxCallback);65 HRESULT rc = ptr.createInprocObject(CLSID_CallbackWrapper); 66 66 if (FAILED(rc)) 67 67 return rc; -
trunk/src/VBox/Main/VirtualBoxCallbackImpl.cpp
r22305 r22357 23 23 #include "Logging.h" 24 24 25 HRESULT VirtualBoxCallback::FinalConstruct()25 HRESULT CallbackWrapper::FinalConstruct() 26 26 { 27 27 return S_OK; 28 28 } 29 29 30 void VirtualBoxCallback::FinalRelease()30 void CallbackWrapper::FinalRelease() 31 31 { 32 32 } 33 33 34 34 // public initializers/uninitializers only for internal purposes 35 HRESULT VirtualBoxCallback::init()35 HRESULT CallbackWrapper::init() 36 36 { 37 37 return S_OK; 38 38 } 39 39 40 void VirtualBoxCallback::uninit(bool aFinalRelease)40 void CallbackWrapper::uninit(bool aFinalRelease) 41 41 { 42 42 } … … 45 45 ///////////////////////////////////////////////////////////////////////////// 46 46 47 STDMETHODIMP VirtualBoxCallback::SetLocalObject(IUnknown *aCallback)47 STDMETHODIMP CallbackWrapper::SetLocalObject(IUnknown *aCallback) 48 48 { 49 49 if (aCallback == NULL) … … 68 68 // IVirtualBoxCallback methods 69 69 ///////////////////////////////////////////////////////////////////////////// 70 STDMETHODIMP VirtualBoxCallback::OnMachineStateChange(IN_BSTR machineId, MachineState_T state)70 STDMETHODIMP CallbackWrapper::OnMachineStateChange(IN_BSTR machineId, MachineState_T state) 71 71 { 72 72 if (mVBoxCallback.isNull()) … … 76 76 } 77 77 78 STDMETHODIMP VirtualBoxCallback::OnMachineDataChange(IN_BSTR machineId)78 STDMETHODIMP CallbackWrapper::OnMachineDataChange(IN_BSTR machineId) 79 79 { 80 80 AutoReadLock alock(this); … … 87 87 88 88 89 STDMETHODIMP VirtualBoxCallback::OnExtraDataCanChange(IN_BSTR machineId, IN_BSTR key, IN_BSTR value,89 STDMETHODIMP CallbackWrapper::OnExtraDataCanChange(IN_BSTR machineId, IN_BSTR key, IN_BSTR value, 90 90 BSTR *error, BOOL *changeAllowed) 91 91 { … … 96 96 } 97 97 98 STDMETHODIMP VirtualBoxCallback::OnExtraDataChange(IN_BSTR machineId, IN_BSTR key, IN_BSTR value)98 STDMETHODIMP CallbackWrapper::OnExtraDataChange(IN_BSTR machineId, IN_BSTR key, IN_BSTR value) 99 99 { 100 100 if (mVBoxCallback.isNull()) … … 104 104 } 105 105 106 STDMETHODIMP VirtualBoxCallback::OnMediaRegistered(IN_BSTR mediaId, DeviceType_T mediaType,106 STDMETHODIMP CallbackWrapper::OnMediaRegistered(IN_BSTR mediaId, DeviceType_T mediaType, 107 107 BOOL registered) 108 108 { … … 114 114 115 115 116 STDMETHODIMP VirtualBoxCallback::OnMachineRegistered(IN_BSTR aMachineId, BOOL registered)116 STDMETHODIMP CallbackWrapper::OnMachineRegistered(IN_BSTR aMachineId, BOOL registered) 117 117 { 118 118 if (mVBoxCallback.isNull()) … … 122 122 } 123 123 124 STDMETHODIMP VirtualBoxCallback::OnSessionStateChange(IN_BSTR aMachineId, SessionState_T state)124 STDMETHODIMP CallbackWrapper::OnSessionStateChange(IN_BSTR aMachineId, SessionState_T state) 125 125 { 126 126 if (mVBoxCallback.isNull()) … … 130 130 } 131 131 132 STDMETHODIMP VirtualBoxCallback::OnSnapshotTaken(IN_BSTR aMachineId, IN_BSTR aSnapshotId)132 STDMETHODIMP CallbackWrapper::OnSnapshotTaken(IN_BSTR aMachineId, IN_BSTR aSnapshotId) 133 133 { 134 134 if (mVBoxCallback.isNull()) … … 138 138 } 139 139 140 STDMETHODIMP VirtualBoxCallback::OnSnapshotDiscarded(IN_BSTR aMachineId, IN_BSTR aSnapshotId)140 STDMETHODIMP CallbackWrapper::OnSnapshotDiscarded(IN_BSTR aMachineId, IN_BSTR aSnapshotId) 141 141 { 142 142 if (mVBoxCallback.isNull()) … … 146 146 } 147 147 148 STDMETHODIMP VirtualBoxCallback::OnSnapshotChange(IN_BSTR aMachineId, IN_BSTR aSnapshotId)148 STDMETHODIMP CallbackWrapper::OnSnapshotChange(IN_BSTR aMachineId, IN_BSTR aSnapshotId) 149 149 { 150 150 if (mVBoxCallback.isNull()) … … 154 154 } 155 155 156 STDMETHODIMP VirtualBoxCallback::OnGuestPropertyChange(IN_BSTR aMachineId, IN_BSTR key, IN_BSTR value, IN_BSTR flags)156 STDMETHODIMP CallbackWrapper::OnGuestPropertyChange(IN_BSTR aMachineId, IN_BSTR key, IN_BSTR value, IN_BSTR flags) 157 157 { 158 158 if (mVBoxCallback.isNull()) … … 163 163 164 164 165 STDMETHODIMP VirtualBoxCallback::OnMousePointerShapeChange(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot, 166 ULONG width, ULONG height, BYTE *shape) 165 // IConsoleCallback methods 166 ///////////////////////////////////////////////////////////////////////////// 167 STDMETHODIMP CallbackWrapper::OnMousePointerShapeChange(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot, 168 ULONG width, ULONG height, BYTE *shape) 167 169 { 168 170 if (mConsoleCallback.isNull()) … … 173 175 174 176 175 STDMETHODIMP VirtualBoxCallback::OnMouseCapabilityChange(BOOL supportsAbsolute, BOOL needsHostCursor)177 STDMETHODIMP CallbackWrapper::OnMouseCapabilityChange(BOOL supportsAbsolute, BOOL needsHostCursor) 176 178 { 177 179 if (mConsoleCallback.isNull()) … … 181 183 } 182 184 183 STDMETHODIMP VirtualBoxCallback::OnKeyboardLedsChange(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)185 STDMETHODIMP CallbackWrapper::OnKeyboardLedsChange(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock) 184 186 { 185 187 if (mConsoleCallback.isNull()) … … 189 191 } 190 192 191 STDMETHODIMP VirtualBoxCallback::OnStateChange(MachineState_T machineState)193 STDMETHODIMP CallbackWrapper::OnStateChange(MachineState_T machineState) 192 194 { 193 195 if (mConsoleCallback.isNull()) … … 197 199 } 198 200 199 STDMETHODIMP VirtualBoxCallback::OnAdditionsStateChange()201 STDMETHODIMP CallbackWrapper::OnAdditionsStateChange() 200 202 { 201 203 if (mConsoleCallback.isNull()) … … 205 207 } 206 208 207 STDMETHODIMP VirtualBoxCallback::OnDVDDriveChange()209 STDMETHODIMP CallbackWrapper::OnDVDDriveChange() 208 210 { 209 211 if (mConsoleCallback.isNull()) … … 213 215 } 214 216 215 STDMETHODIMP VirtualBoxCallback::OnFloppyDriveChange()217 STDMETHODIMP CallbackWrapper::OnFloppyDriveChange() 216 218 { 217 219 if (mConsoleCallback.isNull()) … … 221 223 } 222 224 223 STDMETHODIMP VirtualBoxCallback::OnNetworkAdapterChange(INetworkAdapter *aNetworkAdapter)225 STDMETHODIMP CallbackWrapper::OnNetworkAdapterChange(INetworkAdapter *aNetworkAdapter) 224 226 { 225 227 if (mConsoleCallback.isNull()) … … 229 231 } 230 232 231 STDMETHODIMP VirtualBoxCallback::OnSerialPortChange(ISerialPort *aSerialPort)233 STDMETHODIMP CallbackWrapper::OnSerialPortChange(ISerialPort *aSerialPort) 232 234 { 233 235 if (mConsoleCallback.isNull()) … … 237 239 } 238 240 239 STDMETHODIMP VirtualBoxCallback::OnParallelPortChange(IParallelPort *aParallelPort)241 STDMETHODIMP CallbackWrapper::OnParallelPortChange(IParallelPort *aParallelPort) 240 242 { 241 243 if (mConsoleCallback.isNull()) … … 244 246 return mConsoleCallback->OnParallelPortChange(aParallelPort); 245 247 } 246 STDMETHODIMP VirtualBoxCallback::OnVRDPServerChange()248 STDMETHODIMP CallbackWrapper::OnVRDPServerChange() 247 249 { 248 250 if (mConsoleCallback.isNull()) … … 252 254 } 253 255 254 STDMETHODIMP VirtualBoxCallback::OnUSBControllerChange()256 STDMETHODIMP CallbackWrapper::OnUSBControllerChange() 255 257 { 256 258 if (mConsoleCallback.isNull()) … … 260 262 } 261 263 262 STDMETHODIMP VirtualBoxCallback::OnUSBDeviceStateChange(IUSBDevice *aDevice,264 STDMETHODIMP CallbackWrapper::OnUSBDeviceStateChange(IUSBDevice *aDevice, 263 265 BOOL aAttached, 264 266 IVirtualBoxErrorInfo *aError) … … 270 272 } 271 273 272 STDMETHODIMP VirtualBoxCallback::OnSharedFolderChange(Scope_T aScope)274 STDMETHODIMP CallbackWrapper::OnSharedFolderChange(Scope_T aScope) 273 275 { 274 276 if (mConsoleCallback.isNull()) … … 278 280 } 279 281 280 STDMETHODIMP VirtualBoxCallback::OnStorageControllerChange()282 STDMETHODIMP CallbackWrapper::OnStorageControllerChange() 281 283 { 282 284 if (mConsoleCallback.isNull()) … … 286 288 } 287 289 288 STDMETHODIMP VirtualBoxCallback::OnRuntimeError(BOOL fFatal, IN_BSTR id, IN_BSTR message)290 STDMETHODIMP CallbackWrapper::OnRuntimeError(BOOL fFatal, IN_BSTR id, IN_BSTR message) 289 291 { 290 292 if (mConsoleCallback.isNull()) … … 294 296 } 295 297 296 STDMETHODIMP VirtualBoxCallback::OnCanShowWindow(BOOL *canShow)298 STDMETHODIMP CallbackWrapper::OnCanShowWindow(BOOL *canShow) 297 299 { 298 300 if (mConsoleCallback.isNull()) … … 302 304 } 303 305 304 STDMETHODIMP VirtualBoxCallback::OnShowWindow(ULONG64 *winId)306 STDMETHODIMP CallbackWrapper::OnShowWindow(ULONG64 *winId) 305 307 { 306 308 if (mConsoleCallback.isNull()) -
trunk/src/VBox/Main/glue/vboxapi.py
r22305 r22357 218 218 win32com.client.gencache.EnsureDispatch('VirtualBox.Session') 219 219 win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBox') 220 win32com.client.gencache.EnsureDispatch('VirtualBox. VirtualBoxCallback')220 win32com.client.gencache.EnsureDispatch('VirtualBox.CallbackWrapper') 221 221 222 222 def getSessionObject(self, vbox): … … 261 261 str += " _typelib_version_ = 1, 0\n" 262 262 263 # generate capitalized version of callback s - that's how Python COM264 # looks them up on Windows263 # generate capitalized version of callback methods - 264 # that's how Python COM looks them up 265 265 for m in dir(impl): 266 266 if m.startswith("on"): … … 268 268 269 269 str += " def __init__(self): BaseClass.__init__(self, arg)\n" 270 str += "result = win32com.client.Dispatch('VirtualBox. VirtualBoxCallback')\n"271 str += "result.SetLocalObject( win32com.server.util.wrap("+iface+"Impl())\n"270 str += "result = win32com.client.Dispatch('VirtualBox.CallbackWrapper')\n" 271 str += "result.SetLocalObject("+iface+"Impl())\n" 272 272 exec (str,d,d) 273 273 return d['result'] … … 330 330 331 331 def initPerThread(self): 332 pass 332 import xpcom 333 xpcom._xpcom.AttachThread() 333 334 334 335 def deinitPerThread(self): 335 pass 336 import xpcom 337 xpcom._xpcom.DetachThread() 336 338 337 339 def createCallback(self, iface, impl, arg): -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r22323 r22357 1081 1081 <desc> 1082 1082 The ILocalOwner interface allows to register local objects 1083 (created without COM calls). Once registered, calls to methods 1084 of such objects can be made from remote COM processes. 1083 (created without COM calls, but with new()). 1084 Once registered, calls to methods of such objects can be made 1085 from remote COM processes. 1085 1086 The main usecase is the event callback implementation where 1086 1087 API clients provide callback objects. … … 13148 13149 <interface name="ISession" default="yes"/> 13149 13150 </class> 13150 <class name=" VirtualBoxCallback" uuid="49EE8561-5563-4715-B18C-A4B1A490DAFE"13151 <class name="CallbackWrapper" uuid="49EE8561-5563-4715-B18C-A4B1A490DAFE" 13151 13152 namespace="virtualbox.org"> 13152 <interface name="IVirtualBoxCallback" default="yes"/> 13153 <interface name="ILocalOwner"/> 13153 <interface name="ILocalOwner" default="yes"/> 13154 <interface name="IVirtualBoxCallback"/> 13155 <interface name="IConsoleCallback"/> 13154 13156 </class> 13155 13157 </module> -
trunk/src/VBox/Main/include/VirtualBoxCallbackImpl.h
r22306 r22357 23 23 #endif 24 24 25 class ATL_NO_VTABLE VirtualBoxCallback:25 class ATL_NO_VTABLE CallbackWrapper : 26 26 public VirtualBoxBase, 27 public VirtualBoxSupportErrorInfoImpl< VirtualBoxCallback, IVirtualBoxCallback>,28 public VirtualBoxSupportTranslation< VirtualBoxCallback>,27 public VirtualBoxSupportErrorInfoImpl<CallbackWrapper, IVirtualBoxCallback>, 28 public VirtualBoxSupportTranslation<CallbackWrapper>, 29 29 VBOX_SCRIPTABLE_IMPL(ILocalOwner), 30 30 VBOX_SCRIPTABLE_IMPL(IConsoleCallback), 31 31 VBOX_SCRIPTABLE_IMPL(IVirtualBoxCallback) 32 32 #ifdef RT_OS_WINDOWS 33 , public CComCoClass< VirtualBoxCallback, &CLSID_VirtualBoxCallback>33 , public CComCoClass<CallbackWrapper, &CLSID_CallbackWrapper> 34 34 #endif 35 35 { … … 39 39 40 40 DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX) 41 DECLARE_NOT_AGGREGATABLE( VirtualBoxCallback)41 DECLARE_NOT_AGGREGATABLE(CallbackWrapper) 42 42 43 43 DECLARE_PROTECT_FINAL_CONSTRUCT() … … 103 103 104 104 // for VirtualBoxSupportErrorInfoImpl 105 static const wchar_t *getComponentName() { return L" VirtualBoxCallback"; }105 static const wchar_t *getComponentName() { return L"CallbackWrapper"; } 106 106 107 107 private: -
trunk/src/VBox/Main/xpcom/module.cpp
r22305 r22357 80 80 NS_DECL_CLASSINFO(Console) 81 81 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole) 82 NS_DECL_CLASSINFO( VirtualBoxCallback)83 NS_IMPL_THREADSAFE_ISUPPORTS3_CI( VirtualBoxCallback, IVirtualBoxCallback, IConsoleCallback, ILocalOwner)82 NS_DECL_CLASSINFO(CallbackWrapper) 83 NS_IMPL_THREADSAFE_ISUPPORTS3_CI(CallbackWrapper, IVirtualBoxCallback, IConsoleCallback, ILocalOwner) 84 84 /** 85 85 * Singleton class factory that holds a reference to the created instance … … 136 136 NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (Session) 137 137 138 NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC ( VirtualBoxCallback)138 NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (CallbackWrapper) 139 139 140 140 … … 159 159 }, 160 160 { 161 " VirtualBoxCallbackcomponent", // description162 NS_ VIRTUALBOXCALLBACK_CID, NS_VIRTUALBOXCALLBACK_CONTRACTID, // CID/ContractID163 VirtualBoxCallbackConstructor, // constructor function161 "CallbackWrapper component", // description 162 NS_CALLBACKWRAPPER_CID, NS_CALLBACKWRAPPER_CONTRACTID, // CID/ContractID 163 CallbackWrapperConstructor, // constructor function 164 164 NULL, // registration function 165 165 NULL, // deregistration function 166 // SessionClassFactory::releaseInstance,167 166 NULL, // destructor function 168 NS_CI_INTERFACE_GETTER_NAME( VirtualBoxCallback), // interfaces function167 NS_CI_INTERFACE_GETTER_NAME(CallbackWrapper), // interfaces function 169 168 NULL, // language helper 170 &NS_CLASSINFO_NAME( VirtualBoxCallback) // global class info & flags169 &NS_CLASSINFO_NAME(CallbackWrapper) // global class info & flags 171 170 } 172 171 -
trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
r22164 r22357 1604 1604 // send address of the instance wrapper, and set the low bit to indicate 1605 1605 // to the remote party that this is a remote instance wrapper. 1606 PtrBits bits = ((PtrBits)(uintptr_t) wrapper) | PTRBITS_REMOTE_BIT; 1606 PtrBits bits = ((PtrBits)(uintptr_t) wrapper); 1607 NS_ASSERTION((bits & PTRBITS_REMOTE_BIT) == 0, "remote bit wrong)"); 1608 bits |= PTRBITS_REMOTE_BIT; 1607 1609 writer.PutBytes(&bits, sizeof(bits)); 1608 1610 } -
trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
r21300 r22357 493 493 494 494 #ifdef VBOX 495 495 496 static nsIEventQueue* g_mainEventQ = nsnull; 496 497 … … 575 576 PyXPCOMMethod_DeinitCOM(PyObject *self, PyObject *args) 576 577 { 577 Py_BEGIN_ALLOW_THREADS; 578 deinitVBoxPython(); 579 Py_END_ALLOW_THREADS; 580 return PyInt_FromLong(0); 578 Py_BEGIN_ALLOW_THREADS; 579 deinitVBoxPython(); 580 Py_END_ALLOW_THREADS; 581 return PyInt_FromLong(0); 582 } 583 584 static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); 585 586 static PyObject* 587 PyXPCOMMethod_AttachThread(PyObject *self, PyObject *args) 588 { 589 nsresult rv; 590 PRInt32 result = 0; 591 nsCOMPtr<nsIEventQueueService> eqs; 592 593 // Create the Event Queue for this thread... 594 Py_BEGIN_ALLOW_THREADS; 595 eqs = 596 do_GetService(kEventQueueServiceCID, &rv); 597 Py_END_ALLOW_THREADS; 598 if (NS_FAILED(rv)) 599 { 600 result = 1; 601 goto done; 602 } 603 604 Py_BEGIN_ALLOW_THREADS; 605 rv = eqs->CreateThreadEventQueue(); 606 Py_END_ALLOW_THREADS; 607 if (NS_FAILED(rv)) 608 { 609 result = 2; 610 goto done; 611 } 612 613 done: 614 /** @todo: better throw an exception on error */ 615 return PyInt_FromLong(result); 616 } 617 618 static PyObject* 619 PyXPCOMMethod_DetachThread(PyObject *self, PyObject *args) 620 { 621 nsresult rv; 622 PRInt32 result = 0; 623 nsCOMPtr<nsIEventQueueService> eqs; 624 625 // Destroy the Event Queue for this thread... 626 Py_BEGIN_ALLOW_THREADS; 627 eqs = 628 do_GetService(kEventQueueServiceCID, &rv); 629 Py_END_ALLOW_THREADS; 630 if (NS_FAILED(rv)) 631 { 632 result = 1; 633 goto done; 634 } 635 636 Py_BEGIN_ALLOW_THREADS; 637 rv = eqs->DestroyThreadEventQueue(); 638 Py_END_ALLOW_THREADS; 639 if (NS_FAILED(rv)) 640 { 641 result = 2; 642 goto done; 643 } 644 645 done: 646 /** @todo: better throw an exception on error */ 647 return PyInt_FromLong(result); 581 648 } 582 649 #endif … … 609 676 #ifdef VBOX 610 677 {"WaitForEvents", PyXPCOMMethod_WaitForEvents, 1}, 611 {"DeinitCOM", PyXPCOMMethod_DeinitCOM, 1}, 678 {"DeinitCOM", PyXPCOMMethod_DeinitCOM, 1}, 679 {"AttachThread", PyXPCOMMethod_AttachThread, 1}, 680 {"DetachThread", PyXPCOMMethod_DetachThread, 1}, 612 681 #endif 613 682 // These should no longer be used - just use the logging.getLogger('pyxpcom')...
Note:
See TracChangeset
for help on using the changeset viewer.