Changeset 34086 in vbox for trunk/src/VBox/Main
- Timestamp:
- Nov 15, 2010 5:45:50 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67776
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r34048 r34086 532 532 #ifdef VBOX_WITH_EXTPACK 533 533 unconst(mptrExtPackManager).createObject(); 534 rc = mptrExtPackManager->init(NULL, false); /* Drop zone handling is VBoxSVC only. */534 rc = mptrExtPackManager->init(NULL, NULL, false); /* Drop zone handling is VBoxSVC only. */ 535 535 AssertComRCReturnRC(rc); 536 536 #endif -
trunk/src/VBox/Main/ExtPackManagerImpl.cpp
r34074 r34086 42 42 #include "AutoCaller.h" 43 43 #include "Global.h" 44 #include "SystemPropertiesImpl.h" 45 #include "VirtualBoxImpl.h" 44 46 45 47 … … 97 99 /** The extension pack registration structure. */ 98 100 PCVBOXEXTPACKREG pReg; 101 /** Pointer to the VirtualBox object (for VRDE registration). */ 102 VirtualBox *pVirtualBox; 99 103 }; 100 104 … … 117 121 /** The list of installed extension packs. */ 118 122 ExtPackList llInstalledExtPacks; 123 /** Pointer to the VirtualBox object, our parent. */ 124 VirtualBox *pVirtualBox; 119 125 }; 120 126 … … 139 145 * 140 146 * @returns COM status code. 147 * @param a_pVirtualBox Pointer to the VirtualBox object (grandparent). 141 148 * @param a_pszName The name of the extension pack. This is also the 142 149 * name of the subdirector under @a a_pszParentDir … … 144 151 * @param a_pszParentDir The parent directory. 145 152 */ 146 HRESULT ExtPack::init( const char *a_pszName, const char *a_pszParentDir)153 HRESULT ExtPack::init(VirtualBox *a_pVirtualBox, const char *a_pszName, const char *a_pszParentDir) 147 154 { 148 155 AutoInitSpan autoInitSpan(this); … … 158 165 /* pfnFindModule = */ ExtPack::hlpFindModule, 159 166 /* pfnGetFilePath = */ ExtPack::hlpGetFilePath, 167 /* pfnRegisterVrde = */ ExtPack::hlpRegisterVrde, 160 168 /* u32EndMarker = */ VBOXEXTPACKHLP_VERSION 161 169 }; … … 183 191 m->pThis = this; 184 192 m->pReg = NULL; 193 m->pVirtualBox = a_pVirtualBox; 185 194 186 195 /* … … 229 238 /** 230 239 * Calls the installed hook. 240 * 241 * @param a_pVirtualBox The VirtualBox interface. 231 242 * @remarks Caller holds the extension manager lock. 232 243 */ 233 void ExtPack::callInstalledHook( void)244 void ExtPack::callInstalledHook(IVirtualBox *a_pVirtualBox) 234 245 { 235 246 if ( m->hMainMod != NIL_RTLDRMOD 236 247 && m->pReg->pfnInstalled) 237 m->pReg->pfnInstalled(m->pReg );248 m->pReg->pfnInstalled(m->pReg, a_pVirtualBox); 238 249 } 239 250 … … 242 253 * 243 254 * @returns S_OK or COM error status with error information. 255 * @param a_pVirtualBox The VirtualBox interface. 244 256 * @param a_fForcedRemoval When set, we'll ignore complaints from the 245 257 * uninstall hook. 246 258 * @remarks The caller holds the manager's write lock. 247 259 */ 248 HRESULT ExtPack::callUninstallHookAndClose( bool a_fForcedRemoval)260 HRESULT ExtPack::callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval) 249 261 { 250 262 HRESULT hrc = S_OK; … … 252 264 if (m->hMainMod != NIL_RTLDRMOD) 253 265 { 254 if (m->pReg->pfnUninstall )255 { 256 int vrc = m->pReg->pfnUninstall(m->pReg );266 if (m->pReg->pfnUninstall && !a_fForcedRemoval) 267 { 268 int vrc = m->pReg->pfnUninstall(m->pReg, a_pVirtualBox); 257 269 if (RT_FAILURE(vrc)) 258 270 { … … 274 286 275 287 /** 288 * Calls the pfnVirtualBoxReady hook. 289 * 290 * @param a_pVirtualBox The VirtualBox interface. 291 * @remarks Caller holds the extension manager lock. 292 */ 293 void ExtPack::callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox) 294 { 295 if ( m->hMainMod != NIL_RTLDRMOD 296 && m->pReg->pfnVirtualBoxReady) 297 m->pReg->pfnVirtualBoxReady(m->pReg, a_pVirtualBox); 298 } 299 300 /** 276 301 * Calls the pfnVMCreate hook. 277 302 * 303 * @param a_pVirtualBox The VirtualBox interface. 278 304 * @param a_pMachine The machine interface of the new VM. 279 305 * @remarks Caller holds the extension manager lock. 280 306 */ 281 void ExtPack::callVmCreatedHook(I Machine *a_pMachine)307 void ExtPack::callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine) 282 308 { 283 309 if ( m->hMainMod != NIL_RTLDRMOD 284 310 && m->pReg->pfnVMCreated) 285 m->pReg->pfnVMCreated(m->pReg, a_p Machine);311 m->pReg->pfnVMCreated(m->pReg, a_pVirtualBox, a_pMachine); 286 312 } 287 313 … … 530 556 && m->pReg->u32EndMarker == VBOXEXTPACKREG_VERSION) 531 557 { 532 if ( (!m->pReg->pfnInstalled || RT_VALID_PTR(m->pReg->pfnInstalled)) 533 && (!m->pReg->pfnUninstall || RT_VALID_PTR(m->pReg->pfnUninstall)) 534 && (!m->pReg->pfnUnload || RT_VALID_PTR(m->pReg->pfnUnload)) 535 && (!m->pReg->pfnVMCreated || RT_VALID_PTR(m->pReg->pfnVMCreated)) 536 && (!m->pReg->pfnVMConfigureVMM || RT_VALID_PTR(m->pReg->pfnVMConfigureVMM)) 537 && (!m->pReg->pfnVMPowerOn || RT_VALID_PTR(m->pReg->pfnVMPowerOn)) 538 && (!m->pReg->pfnVMPowerOff || RT_VALID_PTR(m->pReg->pfnVMPowerOff)) 539 && (!m->pReg->pfnQueryObject || RT_VALID_PTR(m->pReg->pfnQueryObject)) 558 if ( (!m->pReg->pfnInstalled || RT_VALID_PTR(m->pReg->pfnInstalled)) 559 && (!m->pReg->pfnUninstall || RT_VALID_PTR(m->pReg->pfnUninstall)) 560 && (!m->pReg->pfnVirtualBoxReady || RT_VALID_PTR(m->pReg->pfnVirtualBoxReady)) 561 && (!m->pReg->pfnUnload || RT_VALID_PTR(m->pReg->pfnUnload)) 562 && (!m->pReg->pfnVMCreated || RT_VALID_PTR(m->pReg->pfnVMCreated)) 563 && (!m->pReg->pfnVMConfigureVMM || RT_VALID_PTR(m->pReg->pfnVMConfigureVMM)) 564 && (!m->pReg->pfnVMPowerOn || RT_VALID_PTR(m->pReg->pfnVMPowerOn)) 565 && (!m->pReg->pfnVMPowerOff || RT_VALID_PTR(m->pReg->pfnVMPowerOff)) 566 && (!m->pReg->pfnQueryObject || RT_VALID_PTR(m->pReg->pfnQueryObject)) 540 567 ) 541 568 { … … 760 787 } 761 788 789 /*static*/ DECLCALLBACK(int) 790 ExtPack::hlpRegisterVrde(PCVBOXEXTPACKHLP pHlp, const char *pszName, bool fSetDefault) 791 { 792 /* 793 * Validate the input and get our bearings. 794 */ 795 AssertPtrReturn(pszName, VERR_INVALID_POINTER); 796 797 AssertPtrReturn(pHlp, VERR_INVALID_POINTER); 798 AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER); 799 ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp); 800 AssertPtrReturn(m, VERR_INVALID_POINTER); 801 ExtPack *pThis = m->pThis; 802 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 803 AssertPtrReturn(pThis->m->pVirtualBox, VERR_WRONG_ORDER); 804 805 /* 806 * Find the given module and register it (will succeed if it's already 807 * registered). 808 */ 809 /** @todo Might consider redoing this VRDERegistration interface to be an aspect of the extension 810 * pack manager instead of IVirtualBox. That would make sure we won't have any broke paths and stuff later on. */ 811 int vrc = VERR_MODULE_NOT_FOUND; 812 #if 0 /** @todo causing lock order asserts. Should execute the above todo I think. */ 813 Utf8Str strFound; 814 if (pThis->findModule(pszName, NULL, &strFound, NULL, NULL)) 815 { 816 Bstr bstrFound(strFound); 817 HRESULT hrc = pThis->m->pVirtualBox->VRDERegisterLibrary(bstrFound.raw()); 818 if (SUCCEEDED(hrc) && fSetDefault) 819 { 820 /* 821 * Is there a default already? 822 */ 823 SystemProperties *pSysProps = pThis->m->pVirtualBox->getSystemProperties(); 824 Bstr bstrDefaultLib; 825 hrc = pSysProps->COMGETTER(DefaultVRDELibrary)(bstrDefaultLib.asOutParam()); 826 if (SUCCEEDED(hrc) && bstrDefaultLib.isEmpty()) 827 { 828 bstrDefaultLib = strFound; 829 hrc = pSysProps->COMSETTER(DefaultVRDELibrary)(bstrDefaultLib.raw()); 830 } 831 } 832 vrc = Global::vboxStatusCodeFromCOM(hrc); 833 } 834 #endif 835 return vrc; 836 } 837 762 838 763 839 … … 896 972 * 897 973 * @returns COM status code. 974 * @param a_pVirtualBox Pointer to the VirtualBox object. 898 975 * @param a_pszDropZoneDir The path to the drop zone directory. 899 976 * @param a_fCheckDropZone Whether to check the drop zone for new … … 901 978 * and then only when wanted. 902 979 */ 903 HRESULT ExtPackManager::init( const char *a_pszDropZoneDir, bool a_fCheckDropZone)980 HRESULT ExtPackManager::init(VirtualBox *a_pVirtualBox, const char *a_pszDropZoneDir, bool a_fCheckDropZone) 904 981 { 905 982 AutoInitSpan autoInitSpan(this); … … 928 1005 m->strCertificatDirPath = szCertificatDir; 929 1006 m->strDropZoneDir = a_pszDropZoneDir; 1007 m->pVirtualBox = a_pVirtualBox; 930 1008 931 1009 /* … … 962 1040 HRESULT hrc2 = NewExtPack.createObject(); 963 1041 if (SUCCEEDED(hrc2)) 964 hrc2 = NewExtPack->init( Entry.szName, szBaseDir);1042 hrc2 = NewExtPack->init(m->pVirtualBox, Entry.szName, szBaseDir); 965 1043 if (SUCCEEDED(hrc2)) 966 1044 m->llInstalledExtPacks.push_back(NewExtPack); … … 1110 1188 { 1111 1189 LogRel(("ExtPackManager: Successfully installed extension pack '%s'.\n", pStrName->c_str())); 1112 pExtPack->callInstalledHook( );1190 pExtPack->callInstalledHook(m->pVirtualBox); 1113 1191 } 1114 1192 } … … 1176 1254 * Call the uninstall hook and unload the main dll. 1177 1255 */ 1178 hrc = pExtPack->callUninstallHookAndClose( a_fForcedRemoval != FALSE);1256 hrc = pExtPack->callUninstallHookAndClose(m->pVirtualBox, a_fForcedRemoval != FALSE); 1179 1257 if (SUCCEEDED(hrc)) 1180 1258 { … … 1574 1652 hrc = NewExtPack.createObject(); 1575 1653 if (SUCCEEDED(hrc)) 1576 hrc = NewExtPack->init( a_pszName, m->strBaseDir.c_str());1654 hrc = NewExtPack->init(m->pVirtualBox, a_pszName, m->strBaseDir.c_str()); 1577 1655 if (SUCCEEDED(hrc)) 1578 1656 { … … 1691 1769 1692 1770 /** 1693 * Calls the pfnVMCreated hook for all working extension packs. 1694 * 1695 * @param a_pMachine The machine interface of the new VM. 1696 */ 1697 void ExtPackManager::callAllVmCreatedHooks(IMachine *a_pMachine) 1771 * Calls the pfnVirtualBoxReady hook for all working extension packs. 1772 */ 1773 void ExtPackManager::callAllVirtualBoxReadyHooks(void) 1698 1774 { 1699 1775 AutoCaller autoCaller(this); … … 1706 1782 it != m->llInstalledExtPacks.end(); 1707 1783 it++) 1708 (*it)->callVmCreatedHook(a_pMachine); 1784 (*it)->callVirtualBoxReadyHook(m->pVirtualBox); 1785 } 1786 1787 /** 1788 * Calls the pfnVMCreated hook for all working extension packs. 1789 * 1790 * @param a_pMachine The machine interface of the new VM. 1791 */ 1792 void ExtPackManager::callAllVmCreatedHooks(IMachine *a_pMachine) 1793 { 1794 AutoCaller autoCaller(this); 1795 HRESULT hrc = autoCaller.rc(); 1796 if (FAILED(hrc)) 1797 return; 1798 AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS); 1799 1800 for (ExtPackList::iterator it = m->llInstalledExtPacks.begin(); 1801 it != m->llInstalledExtPacks.end(); 1802 it++) 1803 (*it)->callVmCreatedHook(m->pVirtualBox, a_pMachine); 1709 1804 } 1710 1805 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r33952 r34086 504 504 if (SUCCEEDED(rc)) 505 505 /** @todo Define drop zone location. */ 506 rc = m->ptrExtPackManager->init( NULL /*a_pszDropZoneDir*/, false /*a_fCheckDropZone*/);506 rc = m->ptrExtPackManager->init(this, NULL /*a_pszDropZoneDir*/, false /*a_fCheckDropZone*/); 507 507 if (FAILED(rc)) 508 508 throw rc; … … 570 570 if (SUCCEEDED(rc)) 571 571 autoInitSpan.setSucceeded(); 572 573 #ifdef VBOX_WITH_EXTPACK 574 /* Let the extension packs have a go at things. */ 575 if (SUCCEEDED(rc)) 576 m->ptrExtPackManager->callAllVirtualBoxReadyHooks(); 577 #endif 572 578 573 579 LogFlowThisFunc(("rc=%08X\n", rc)); -
trunk/src/VBox/Main/include/ExtPackManagerImpl.h
r34073 r34086 48 48 HRESULT FinalConstruct(); 49 49 void FinalRelease(); 50 HRESULT init( const char *a_pszName, const char *a_pszParentDir);50 HRESULT init(VirtualBox *a_pVirtualBox, const char *a_pszName, const char *a_pszParentDir); 51 51 void uninit(); 52 52 /** @} */ … … 66 66 /** @name Internal interfaces used by ExtPackManager. 67 67 * @{ */ 68 void callInstalledHook(void); 69 HRESULT callUninstallHookAndClose(bool a_fForcedRemoval); 70 void callVmCreatedHook(IMachine *a_pMachine); 68 void callInstalledHook(IVirtualBox *a_pVirtualBox); 69 HRESULT callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval); 70 void callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox); 71 void callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine); 71 72 int callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM); 72 73 int callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM); … … 89 90 char *pszFound, size_t cbFound, bool *pfNative); 90 91 static DECLCALLBACK(int) hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath); 92 static DECLCALLBACK(int) hlpRegisterVrde(PCVBOXEXTPACKHLP pHlp, const char *pszName, bool fSetDefault); 91 93 /** @} */ 92 94 … … 121 123 HRESULT FinalConstruct(); 122 124 void FinalRelease(); 123 HRESULT init( const char *a_pszDropZonePath, bool a_fCheckDropZone);125 HRESULT init(VirtualBox *a_pVirtualBox, const char *a_pszDropZonePath, bool a_fCheckDropZone); 124 126 void uninit(); 125 127 /** @} */ … … 138 140 * @{ */ 139 141 void processDropZone(void); 142 void callAllVirtualBoxReadyHooks(void); 140 143 void callAllVmCreatedHooks(IMachine *a_pMachine); 141 144 int callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
Note:
See TracChangeset
for help on using the changeset viewer.