Changeset 22305 in vbox
- Timestamp:
- Aug 17, 2009 5:37:41 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 51179
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/VirtualBox.h
r8155 r22305 55 55 // for convenience 56 56 #include "VBox/com/defs.h" 57 #include "VBox/com/ptr.h" 57 58 59 template <class I> 60 inline HRESULT createCallbackWrapper(I* aInstance, 61 I** paWrapper) 62 { 63 ComPtr<ILocalOwner> ptr; 64 65 HRESULT rc = ptr.createInprocObject(CLSID_VirtualBoxCallback); 66 if (FAILED(rc)) 67 return rc; 68 69 rc = ptr->SetLocalObject(aInstance); 70 if (FAILED(rc)) 71 return rc; 72 73 ComPtr<I> ptr2 = ptr; 74 if (ptr2.isNull()) 75 return E_FAIL; 76 77 rc = ptr2.queryInterfaceTo(paWrapper); 78 return rc; 79 } 58 80 #endif -
trunk/include/VBox/com/defs.h
r21521 r22305 608 608 #define VBOX_SCRIPTABLE_IMPL(iface) \ 609 609 public iface 610 #define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface) 610 #define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface) 611 611 #endif 612 612 -
trunk/include/VBox/com/ptr.h
r17911 r22305 541 541 } 542 542 }; 543 544 543 #endif -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r21520 r22305 436 436 Bstr uuid; 437 437 machine->COMGETTER(Id)(uuid.asOutParam()); 438 GuestPropertyCallback *callback = new GuestPropertyCallback(pszPatterns, uuid); 439 callback->AddRef(); 438 GuestPropertyCallback* cbImpl = new GuestPropertyCallback(pszPatterns, uuid); 439 ComPtr<IVirtualBoxCallback> callback; 440 rc = createCallbackWrapper((IVirtualBoxCallback*)cbImpl, callback.asOutParam()); 441 if (FAILED(rc)) 442 return 1; 440 443 a->virtualBox->RegisterCallback (callback); 441 444 bool stop = false; … … 466 469 u32Timeout += (uint32_t)(u64Time + 1000 - u64NextTime); 467 470 a->eventQ->ProcessPendingEvents(); 468 if (c allback->Signalled())471 if (cbImpl->Signalled()) 469 472 stop = true; 470 473 } … … 474 477 /**@todo r=bird: get to it!*/ 475 478 RTThreadSleep(RT_MIN(1000, u32Timeout)); 476 if (c allback->Signalled())479 if (cbImpl->Signalled()) 477 480 stop = true; 478 481 #endif /* !USE_XPCOM_QUEUE */ … … 483 486 */ 484 487 a->virtualBox->UnregisterCallback(callback); 485 if (!c allback->Signalled())488 if (!cbImpl->Signalled()) 486 489 RTPrintf("Time out or interruption while waiting for a notification.\n"); 487 callback->Release();488 489 490 /* 490 491 * Done. … … 521 522 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 522 523 } 523 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r22173 r22305 854 854 uint32_t memorySize = 0; 855 855 uint32_t vramSize = 0; 856 VBoxSDLCallback *callback = NULL; 857 VBoxSDLConsoleCallback *consoleCallback = NULL; 856 VBoxSDLCallback *cbVBoxImpl = NULL; 857 /* wrapper around above object */ 858 ComPtr<IVirtualBoxCallback> callback; 859 VBoxSDLConsoleCallback *cbConsoleImpl = NULL; 860 ComPtr<IConsoleCallback> consoleCallback; 861 858 862 bool fFullscreen = false; 859 863 bool fResizable = true; … … 1850 1854 #endif 1851 1855 1856 1852 1857 for (ULONG i = 0; i < gcMonitors; i++) 1853 1858 { 1854 1859 // register our framebuffer 1855 1860 rc = gDisplay->SetFramebuffer(i, gpFramebuffer[i]); 1856 if ( rc != S_OK)1861 if (FAILED(rc)) 1857 1862 { 1858 1863 RTPrintf("Error: could not register framebuffer object!\n"); … … 1866 1871 1867 1872 // register a callback for global events 1868 callback = new VBoxSDLCallback(); 1869 callback->AddRef(); 1873 cbVBoxImpl = new VBoxSDLCallback(); 1874 rc = createCallbackWrapper((IVirtualBoxCallback*)cbVBoxImpl, callback.asOutParam()); 1875 if (FAILED(rc)) 1876 goto leave; 1870 1877 virtualBox->RegisterCallback(callback); 1871 1878 1872 1879 // register a callback for machine events 1873 consoleCallback = new VBoxSDLConsoleCallback(); 1874 consoleCallback->AddRef(); 1880 cbConsoleImpl = new VBoxSDLConsoleCallback(); 1881 rc = createCallbackWrapper((IConsoleCallback*)cbConsoleImpl, consoleCallback.asOutParam()); 1882 if (FAILED(rc)) 1883 goto leave; 1875 1884 gConsole->RegisterCallback(consoleCallback); 1876 1885 // until we've tried to to start the VM, ignore power off events 1877 c onsoleCallback->ignorePowerOffEvents(true);1886 cbConsoleImpl->ignorePowerOffEvents(true); 1878 1887 1879 1888 #ifdef VBOX_WITH_VRDP … … 2172 2181 // accept power off events from now on because we're running 2173 2182 // note that there's a possible race condition here... 2174 c onsoleCallback->ignorePowerOffEvents(false);2183 cbConsoleImpl->ignorePowerOffEvents(false); 2175 2184 2176 2185 rc = gConsole->COMGETTER(Keyboard)(gKeyboard.asOutParam()); … … 2685 2694 && machineState == MachineState_Running) 2686 2695 { 2687 c onsoleCallback->ignorePowerOffEvents(true);2696 cbConsoleImpl->ignorePowerOffEvents(true); 2688 2697 ComPtr <IProgress> progress; 2689 2698 CHECK_ERROR_BREAK(gConsole, PowerDown(progress.asOutParam())); … … 2792 2801 gMachine = NULL; 2793 2802 session = NULL; 2794 LogFlow(("Releasing callback handlers...\n"));2795 if (callback)2796 callback->Release();2797 if (consoleCallback)2798 consoleCallback->Release();2799 2800 2803 LogFlow(("Releasing VirtualBox object...\n")); 2801 2804 virtualBox = NULL; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r22189 r22305 4885 4885 mAction->setText (text); 4886 4886 } 4887 -
trunk/src/VBox/Main/Makefile.kmk
r22213 r22305 590 590 SharedFolderImpl.cpp \ 591 591 SessionImpl.cpp \ 592 VirtualBoxCallbackImpl.cpp \ 592 593 ConsoleImpl.cpp \ 593 594 ConsoleImpl2.cpp \ -
trunk/src/VBox/Main/SessionImpl.cpp
r21961 r22305 20 20 */ 21 21 22 #if defined(RT_OS_WINDOWS)23 #elif defined(RT_OS_LINUX)24 #endif25 26 22 #ifdef VBOX_WITH_SYS_V_IPC_SESSION_WATCHER 27 23 # include <errno.h> … … 335 331 336 332 if (SUCCEEDED(rc)) 337 { 333 { 338 334 mType = SessionType_Direct; 339 335 mState = SessionState_Open; -
trunk/src/VBox/Main/glue/vboxapi.py
r21968 r22305 218 218 win32com.client.gencache.EnsureDispatch('VirtualBox.Session') 219 219 win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBox') 220 win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBoxCallback') 220 221 221 222 def getSessionObject(self, vbox): 222 223 import win32com 223 224 from win32com.client import Dispatch 224 225 return win32com.client.Dispatch("VirtualBox.Session") 225 226 226 227 def getVirtualBox(self): 227 228 import win32com 228 229 from win32com.client import Dispatch 229 230 return win32com.client.Dispatch("VirtualBox.VirtualBox") … … 267 268 268 269 str += " def __init__(self): BaseClass.__init__(self, arg)\n" 269 str += "result = win32com.server.util.wrap("+iface+"Impl())\n" 270 str += "result = win32com.client.Dispatch('VirtualBox.VirtualBoxCallback')\n" 271 str += "result.SetLocalObject(win32com.server.util.wrap("+iface+"Impl())\n" 270 272 exec (str,d,d) 271 273 return d['result'] … … 342 344 str += " _com_interfaces_ = xpcom.components.interfaces."+iface+"\n" 343 345 str += " def __init__(self): BaseClass.__init__(self, arg)\n" 344 str += "result = "+iface+"Impl()\n" 346 str += "result = xpcom.components.classes['@virtualbox.org/VirtualBoxCallback;1'].createInstance()\n" 347 str += "result.setLocalObject("+iface+"Impl())\n" 345 348 exec (str,d,d) 346 349 return d['result'] -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r22214 r22305 127 127 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE1_CI NS_IMPL_QUERY_INTERFACE1_CI 128 128 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE2_CI NS_IMPL_QUERY_INTERFACE2_CI 129 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE3_CI NS_IMPL_QUERY_INTERFACE3_CI 129 130 130 131 #ifndef NS_IMPL_THREADSAFE_ISUPPORTS1_CI … … 142 143 NS_IMPL_THREADSAFE_QUERY_INTERFACE2_CI(_class, _i1, _i2) \ 143 144 NS_IMPL_CI_INTERFACE_GETTER2(_class, _i1, _i2) 145 #endif 146 147 #ifndef NS_IMPL_THREADSAFE_ISUPPORTS3_CI 148 # define NS_IMPL_THREADSAFE_ISUPPORTS3_CI(_class, _i1, _i2, _i3) \ 149 NS_IMPL_THREADSAFE_ADDREF(_class) \ 150 NS_IMPL_THREADSAFE_RELEASE(_class) \ 151 NS_IMPL_THREADSAFE_QUERY_INTERFACE3_CI(_class, _i1, _i2, _i3) \ 152 NS_IMPL_CI_INTERFACE_GETTER3(_class, _i1, _i2, _i3) 144 153 #endif 145 154 … … 164 173 #endif 165 174 175 #ifndef NS_IMPL_QUERY_INTERFACE3_AMBIGUOUS_CI 176 # define NS_IMPL_QUERY_INTERFACE3_AMBIGUOUS_CI(_class, _i1, _ic1, \ 177 _i2, _ic2, _i3, _ic3) \ 178 NS_INTERFACE_MAP_BEGIN(_class) \ 179 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(_i1, _ic1) \ 180 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(_i2, _ic2) \ 181 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(_i3, _ic3) \ 182 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, _ic1) \ 183 NS_IMPL_QUERY_CLASSINFO(_class) \ 184 NS_INTERFACE_MAP_END 185 #endif 186 166 187 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE1_AMBIGUOUS_CI NS_IMPL_QUERY_INTERFACE1_AMBIGUOUS_CI 167 188 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE2_AMBIGUOUS_CI NS_IMPL_QUERY_INTERFACE2_AMBIGUOUS_CI 189 #define NS_IMPL_THREADSAFE_QUERY_INTERFACE3_AMBIGUOUS_CI NS_IMPL_QUERY_INTERFACE3_AMBIGUOUS_CI 168 190 169 191 #ifndef NS_IMPL_THREADSAFE_ISUPPORTS1_AMBIGUOUS_CI … … 184 206 NS_IMPL_CI_INTERFACE_GETTER2(_class, _i1, _i2) 185 207 #endif 208 209 #ifndef NS_IMPL_THREADSAFE_ISUPPORTS3_AMBIGUOUS_CI 210 # define NS_IMPL_THREADSAFE_ISUPPORTS3_AMBIGUOUS_CI(_class, _i1, _ic1, \ 211 _i2, _ic2, _i3, _ic3) \ 212 NS_IMPL_THREADSAFE_ADDREF(_class) \ 213 NS_IMPL_THREADSAFE_RELEASE(_class) \ 214 NS_IMPL_THREADSAFE_QUERY_INTERFACE3_AMBIGUOUS_CI(_class, _i1, _ic1, \ 215 _i2, _ic2, _i3, _ic3) \ 216 NS_IMPL_CI_INTERFACE_GETTER3(_class, _i1, _i2, _i3) 217 #endif 218 186 219 </cpp> 187 220 </if> … … 1042 1075 </interface> 1043 1076 1077 <interface 1078 name="ILocalOwner" extends="$dispatched" 1079 uuid="308ff42a-dc45-49d4-a950-b1eee5e00bb5" wsmap="suppress" 1080 > 1081 <desc> 1082 The ILocalOwner interface allows to provide custom implementation 1083 of VirtualBox interfaces, not being fully remote-aware classes by themselved. 1084 Most importnat usecase for this interface is callbacks implementation. 1085 </desc> 1086 <method name="setLocalObject"> 1087 <desc> 1088 Set local object. 1089 </desc> 1090 <param name="object" type="$unknown" dir="in"> 1091 <desc>Local object, to forward requests to. 1092 If null, clears currently set local object(s).</desc> 1093 </param> 1094 </method> 1095 </interface> 1044 1096 1045 1097 <!-- … … 1053 1105 wsmap="suppress" 1054 1106 > 1107 1055 1108 <method name="onMachineStateChange"> 1056 1109 <desc> … … 13089 13142 13090 13143 <module name="VBoxC" context="InprocServer" threadingModel="Free"> 13091 <class name="Session" uuid="3C02F46D-C9D2-4 f11-A384-53F0CF917214"13144 <class name="Session" uuid="3C02F46D-C9D2-4F11-A384-53F0CF917214" 13092 13145 namespace="virtualbox.org"> 13093 13146 <interface name="ISession" default="yes"/> 13094 13147 </class> 13148 <class name="VirtualBoxCallback" uuid="49EE8561-5563-4715-B18C-A4B1A490DAFE" 13149 namespace="virtualbox.org"> 13150 <interface name="IVirtualBoxCallback" default="yes"/> 13151 <interface name="ILocalOwner"/> 13152 </class> 13095 13153 </module> 13096 13154 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r22173 r22305 483 483 ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox; 484 484 }; 485 486 485 #endif // ____H_VIRTUALBOXIMPL 487 486 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/win/dllmain.cpp
r19239 r22305 24 24 25 25 #include <SessionImpl.h> 26 #include <VirtualBoxCallbackImpl.h> 26 27 27 28 #include <atlbase.h> … … 34 35 BEGIN_OBJECT_MAP(ObjectMap) 35 36 OBJECT_ENTRY(CLSID_Session, Session) 37 OBJECT_ENTRY(CLSID_VirtualBoxCallback, VirtualBoxCallback) 36 38 END_OBJECT_MAP() 37 39 … … 48 50 49 51 // idempotent, so doesn't harm, and needed for COM embedding scenario 50 RTR3Init(); 52 RTR3Init(); 51 53 } 52 54 else if (dwReason == DLL_PROCESS_DETACH) … … 87 89 return _Module.UnregisterServer(TRUE); 88 90 } 89 -
trunk/src/VBox/Main/xpcom/module.cpp
r19817 r22305 47 47 #include "ConsoleImpl.h" 48 48 #include "ConsoleVRDPServer.h" 49 #include "VirtualBoxCallbackImpl.h" 49 50 50 51 #include "Logging.h" … … 79 80 NS_DECL_CLASSINFO(Console) 80 81 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole) 81 82 NS_DECL_CLASSINFO(VirtualBoxCallback) 83 NS_IMPL_THREADSAFE_ISUPPORTS3_CI(VirtualBoxCallback, IVirtualBoxCallback, IConsoleCallback, ILocalOwner) 82 84 /** 83 85 * Singleton class factory that holds a reference to the created instance … … 134 136 NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (Session) 135 137 138 NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (VirtualBoxCallback) 139 136 140 137 141 /** … … 153 157 NULL, // language helper 154 158 &NS_CLASSINFO_NAME(Session) // global class info & flags 159 }, 160 { 161 "VirtualBoxCallback component", // description 162 NS_VIRTUALBOXCALLBACK_CID, NS_VIRTUALBOXCALLBACK_CONTRACTID, // CID/ContractID 163 VirtualBoxCallbackConstructor, // constructor function 164 NULL, // registration function 165 NULL, // deregistration function 166 // SessionClassFactory::releaseInstance, 167 NULL, // destructor function 168 NS_CI_INTERFACE_GETTER_NAME(VirtualBoxCallback), // interfaces function 169 NULL, // language helper 170 &NS_CLASSINFO_NAME(VirtualBoxCallback) // global class info & flags 155 171 } 172 156 173 }; 157 174
Note:
See TracChangeset
for help on using the changeset viewer.