ExtPackManagerImpl.cpp revision 81964179b862d4e3e3da1e8bd66b7e92cdc65140
883N/A * available from http://www.virtualbox.org. This file is free software;
883N/A#include "ExtPackManagerImpl.h"
2110N/A#include "ExtPackUtil.h"
883N/A#include "AutoCaller.h"
883N/A#include "SystemPropertiesImpl.h"
883N/A#include "VirtualBoxImpl.h"
883N/Astruct ExtPackBaseData
883N/A bool fMadeReadyCall;
883N/A if (pstrTarName)
883N/A delete pstrTarName;
883N/A iprt::MiniString *pStrLoadErr = VBoxExtPackLoadDescFromVfsFile(hXmlFile, &m->Desc, &m->ObjInfoDesc);
883N/A delete pStrLoadErr;
883N/A return initFailed(tr("Extension pack name mismatch between the downloaded file and the XML inside it (xml='%s' file='%s')"),
883N/A#ifdef VBOX_WITH_XPCOM
883N/A return QueryLicense(Bstr::Empty.raw(), Bstr::Empty.raw(), bstrHtml.raw(), a_pbstrHtmlLicense);
883N/A/* Same as ExtPack::QueryLicense, should really explore the subject of base classes here... */
883N/ASTDMETHODIMP ExtPackFile::QueryLicense(IN_BSTR a_bstrPreferredLocale, IN_BSTR a_bstrPreferredLanguage, IN_BSTR a_bstrFormat,
883N/A return setError(E_FAIL, tr("The license format can only have the values 'html', 'rtf' and 'txt'."));
883N/A RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-%s.%s", strPreferredLocale.c_str(), strFormat.c_str());
883N/A RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-_%s.%s", strPreferredLocale.c_str(), strFormat.c_str());
883N/A RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX ".%s", strFormat.c_str());
char *pszName;
if (pvFile)
szName);
return hrc;
return hrc;
if (m->fUsable)
return hrc;
m = NULL;
return S_OK;
HRESULT ExtPack::initWithDir(VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir)
m = new Data;
m->fUsable = false;
m->pThis = this;
m->fMadeReadyCall = false;
probeAndLoad();
return S_OK;
uninit();
m = NULL;
bool ExtPack::callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo)
if ( m != NULL
if ( m != NULL
if (!a_fForcedRemoval)
return hrc;
if ( m != NULL
&& m->fUsable
&& !m->fMadeReadyCall)
m->fMadeReadyCall = true;
if ( m != NULL
&& m->fUsable
&& !m->fMadeReadyCall)
m->fMadeReadyCall = true;
bool ExtPack::callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock)
if ( m != NULL
&& m->fUsable)
bool ExtPack::callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc)
if ( m != NULL
&& m->fUsable)
bool ExtPack::callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc)
if ( m != NULL
&& m->fUsable)
if ( m != NULL
&& m->fUsable)
if ( m != NULL
&& m->fUsable)
hrc = setError(E_FAIL, tr("The extension pack '%s' does not include a VRDE module"), m->Desc.strName.c_str());
return hrc;
return hrc;
return m->fUsable
if (a_pfCanDelete)
*a_pfCanDelete = false;
int vrc = RTPathQueryInfoEx(m->strExtPackPath.c_str(), &ObjInfoExtPack, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
if (a_pfCanDelete)
*a_pfCanDelete = true;
return S_OK;
vrc = RTPathJoin(szDescFilePath, sizeof(szDescFilePath), m->strExtPackPath.c_str(), VBOX_EXTPACK_DESCRIPTION_NAME);
vrc = RTPathQueryInfoEx(m->strMainModPath.c_str(), &ObjInfoMainMod, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
if (m->fUsable)
probeAndLoad();
probeAndLoad();
return S_OK;
m->fUsable = false;
m->fMadeReadyCall = false;
int vrc = RTPathQueryInfoEx(m->strExtPackPath.c_str(), &m->ObjInfoExtPack, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK);
m->strWhyUnusable.printf(tr("RTPathQueryInfoEx on '%s' failed: %Rrc"), m->strExtPackPath.c_str(), vrc);
m->strWhyUnusable.printf(tr("'%s' is a symbolic link, this is not allowed"), m->strExtPackPath.c_str(), vrc);
m->strWhyUnusable.printf(tr("'%s' is a symbolic file, not a directory"), m->strExtPackPath.c_str(), vrc);
m->strWhyUnusable.printf(tr("'%s' is not a directory (fMode=%#x)"), m->strExtPackPath.c_str(), m->ObjInfoExtPack.Attr.fMode);
vrc = SUPR3HardenedVerifyDir(m->strExtPackPath.c_str(), true /*fRecursive*/, true /*fCheckFiles*/, szErr, sizeof(szErr));
iprt::MiniString *pStrLoadErr = VBoxExtPackLoadDesc(m->strExtPackPath.c_str(), &m->Desc, &m->ObjInfoDesc);
delete pStrLoadErr;
m->strWhyUnusable.printf(tr("The description name ('%s') and directory name ('%s') does not match"),
bool fIsNative;
m->strWhyUnusable.printf(tr("Failed to locate the main module ('%s')"), m->Desc.strMainModule.c_str());
if (fIsNative)
m->fUsable = true;
if (!a_pszExt)
const char *pszDefExt;
switch (a_enmKind)
AssertFailedReturn(false);
if (!a_pObjInfo)
if (a_pfNative)
*a_pfNative = true;
/* gcc.x86/module.rel */
if (!a_pszExt)
if (a_pfNative)
*a_pfNative = false;
/* x86/module.rel */
if (!a_pszExt)
if (a_pfNative)
*a_pfNative = false;
case RTFSOBJATTRADD_UNIX:
ExtPack::hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt, VBOXEXTPACKMODKIND enmKind,
AssertReturn(enmKind > VBOXEXTPACKMODKIND_INVALID && enmKind < VBOXEXTPACKMODKIND_END, VERR_INVALID_PARAMETER);
return VERR_FILE_NOT_FOUND;
ExtPack::hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath)
return vrc;
return VERR_NOT_IMPLEMENTED;
return hrc;
return hrc;
return hrc;
return hrc;
return hrc;
#ifdef VBOX_WITH_XPCOM
return hrc;
return hrc;
return hrc;
STDMETHODIMP ExtPack::QueryLicense(IN_BSTR a_bstrPreferredLocale, IN_BSTR a_bstrPreferredLanguage, IN_BSTR a_bstrFormat,
return setError(E_FAIL, tr("The license format can only have the values 'html', 'rtf' and 'txt'."));
RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-%s.%s", strPreferredLocale.c_str(), strFormat.c_str());
RTStrPrintf(szName, sizeof(szName), VBOX_EXTPACK_LICENSE_NAME_PREFIX "-_%s.%s", strPreferredLocale.c_str(), strFormat.c_str());
if (!m->fUsable)
void *pvFile;
hrc = setError(VBOX_E_IPRT_ERROR, tr("The license file '%s' is empty or contains invalid UTF-8 encoding"),
szPath);
hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("The license file '%s' was not found in extension pack '%s'"),
return hrc;
if ( m->pReg
if (pvUnknown)
return hrc;
m = NULL;
return S_OK;
m = new Data;
int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &m->hVBoxVMM, RTLDRFLAGS_GLOBAL, szError, sizeof(szError));
if (pstrName)
delete pstrName;
return hrc;
uninit();
m = NULL;
STDMETHODIMP ExtPackManager::COMGETTER(InstalledExtPacks)(ComSafeArrayOut(IExtPack *, a_paExtPacks))
return hrc;
return hrc;
return hrc;
if (!pExtPack)
LogRel(("ExtPackManager: Extension pack '%s' is not installed, so nothing to uninstall.\n", strName.c_str()));
(const char *)NULL);
if (!pExtPack)
return hrc;
(const char *)NULL);
return hrc;
STDMETHODIMP ExtPackManager::QueryAllPlugInsForFrontend(IN_BSTR a_bstrFrontend, ComSafeArrayOut(BSTR, a_pabstrPlugInModules))
return hrc;
return S_OK;
unsigned cArgs = 0;
const char *pszLastArg;
&hProcess);
if (pvNew)
&ProcStatus);
if (offStdErrBuf > 0)
if ( offStdErrBuf > 0
offStdErrBuf = 0;
&& offStdErrBuf == 0)
hrc = setError(VBOX_E_IPRT_ERROR, tr("Failed to launch the helper application '%s' (%Rrc)"), szExecName, vrc);
return hrc;
it++)
if ( pExtPackData
return (*it);
return NULL;
it++)
if ( pExtPackData
HRESULT ExtPackManager::refreshExtPack(const char *a_pszName, bool a_fUnusableIsError, ExtPack **a_ppExtPack)
if (pExtPack)
bool fCanDelete;
if (fCanDelete)
if (!fExists)
vrc = RTPathJoin(szDir, sizeof(szDir), m->strBaseDir.c_str(), Entry.szName); /* not really necessary */
fExists = true;
if (fExists)
&& pExtPack
if (a_ppExtPack)
return hrc;
else if (pExtPack)
(const char *)NULL);
(const char *)NULL);
return hrc;
it++;
it++;
int vrc;
return vrc;
return VINF_SUCCESS;
int vrc;
return vrc;
return VINF_SUCCESS;
if (pExtPack)
hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No extension pack by the name '%s' was found"), a_pstrExtPack->c_str());
return hrc;
int ExtPackManager::getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary)
if (pExtPack)
hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No extension pack by the name '%s' was found"), a_pstrExtPack->c_str());
return hrc;
it++)
return hrc;