VirtualBox

source: vbox/trunk/src/VBox/Main/include/ExtPackManagerImpl.h

Last change on this file was 101293, checked in by vboxsync, 8 months ago

Main/ExtPack*: tidying up. (Please, do NOT use 'm' as a local variable, that's just so confusing.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.3 KB
RevLine 
[33474]1/* $Id: ExtPackManagerImpl.h 101293 2023-09-27 14:20:49Z vboxsync $ */
2/** @file
3 * VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
4 */
5
6/*
[98103]7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
[33474]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
[33474]26 */
27
[76562]28#ifndef MAIN_INCLUDED_ExtPackManagerImpl_h
29#define MAIN_INCLUDED_ExtPackManagerImpl_h
[76487]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[33474]33
34#include "VirtualBoxBase.h"
35#include <VBox/ExtPack/ExtPack.h>
[50914]36#include "ExtPackWrap.h"
37#include "ExtPackFileWrap.h"
38#include "ExtPackManagerWrap.h"
[33623]39#include <iprt/fs.h>
[33474]40
[63147]41
42/** The name of the oracle extension back. */
43#define ORACLE_PUEL_EXTPACK_NAME "Oracle VM VirtualBox Extension Pack"
44
45
[68828]46#ifndef VBOX_COM_INPROC
[34714]47/**
48 * An extension pack file.
49 */
50class ATL_NO_VTABLE ExtPackFile :
[50914]51 public ExtPackFileWrap
[34714]52{
53public:
54 /** @name COM and internal init/term/mapping cruft.
55 * @{ */
[90828]56 DECLARE_COMMON_CLASS_METHODS(ExtPackFile)
[33474]57
[34714]58 HRESULT FinalConstruct();
59 void FinalRelease();
[39878]60 HRESULT initWithFile(const char *a_pszFile, const char *a_pszDigest, class ExtPackManager *a_pExtPackMgr, VirtualBox *a_pVirtualBox);
[34714]61 void uninit();
62 /** @} */
63
64private:
[34787]65 /** @name Misc init helpers
66 * @{ */
67 HRESULT initFailed(const char *a_pszWhyFmt, ...);
68 /** @} */
69
70private:
[50914]71
72 // wrapped IExtPackFile properties
73 HRESULT getName(com::Utf8Str &aName);
74 HRESULT getDescription(com::Utf8Str &aDescription);
75 HRESULT getVersion(com::Utf8Str &aVersion);
76 HRESULT getRevision(ULONG *aRevision);
77 HRESULT getEdition(com::Utf8Str &aEdition);
78 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
[94714]79 HRESULT getCryptoModule(com::Utf8Str &aCryptoModule);
[50914]80 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
81 HRESULT getUsable(BOOL *aUsable);
82 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
83 HRESULT getShowLicense(BOOL *aShowLicense);
84 HRESULT getLicense(com::Utf8Str &aLicense);
85 HRESULT getFilePath(com::Utf8Str &aFilePath);
86
87 // wrapped IExtPackFile methods
88 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
89 const com::Utf8Str &aPreferredLanguage,
90 const com::Utf8Str &aFormat,
91 com::Utf8Str &aLicenseText);
92 HRESULT install(BOOL aReplace,
93 const com::Utf8Str &aDisplayInfo,
94 ComPtr<IProgress> &aProgess);
95
[34714]96 struct Data;
97 /** Pointer to the private instance. */
98 Data *m;
99
100 friend class ExtPackManager;
[58981]101 friend class ExtPackInstallTask;
[34714]102};
[68828]103#endif /* !VBOX_COM_INPROC */
[34714]104
105
[33474]106/**
[34714]107 * An installed extension pack.
[33474]108 */
109class ATL_NO_VTABLE ExtPack :
[50914]110 public ExtPackWrap
[33474]111{
112public:
113 /** @name COM and internal init/term/mapping cruft.
114 * @{ */
[90828]115 DECLARE_COMMON_CLASS_METHODS(ExtPack)
[33474]116
117 HRESULT FinalConstruct();
118 void FinalRelease();
[73825]119 HRESULT initWithDir(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);
[33474]120 void uninit();
[34787]121 RTMEMEF_NEW_AND_DELETE_OPERATORS();
[33474]122 /** @} */
123
124 /** @name Internal interfaces used by ExtPackManager.
125 * @{ */
[68828]126#ifndef VBOX_COM_INPROC
[50914]127 bool i_callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo);
128 HRESULT i_callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
129 bool i_callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
[68828]130#endif
131#ifdef VBOX_COM_INPROC
[50914]132 bool i_callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
[68828]133#endif
134#ifndef VBOX_COM_INPROC
[50914]135 bool i_callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
[68828]136#endif
137#ifdef VBOX_COM_INPROC
[93449]138 bool i_callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM,
139 AutoWriteLock *a_pLock, int *a_pvrc);
140 bool i_callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM, AutoWriteLock *a_pLock, int *a_pvrc);
141 bool i_callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM, AutoWriteLock *a_pLock);
[68828]142#endif
[50914]143 HRESULT i_checkVrde(void);
[94714]144 HRESULT i_checkCrypto(void);
[50914]145 HRESULT i_getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
[94714]146 HRESULT i_getCryptoLibraryName(Utf8Str *a_pstrCryptoLibrary);
[50914]147 HRESULT i_getLibraryName(const char *a_pszModuleName, Utf8Str *a_pstrLibrary);
148 bool i_wantsToBeDefaultVrde(void) const;
[94714]149 bool i_wantsToBeDefaultCrypto(void) const;
[50914]150 HRESULT i_refresh(bool *pfCanDelete);
[75663]151#ifndef VBOX_COM_INPROC
152 bool i_areThereCloudProviderUninstallVetos();
153 void i_notifyCloudProviderManager();
154#endif
[33474]155 /** @} */
156
[33623]157protected:
158 /** @name Internal helper methods.
159 * @{ */
[50914]160 void i_probeAndLoad(void);
161 bool i_findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
162 Utf8Str *a_ppStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
163 static bool i_objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
[33623]164 /** @} */
165
166 /** @name Extension Pack Helpers
167 * @{ */
[50914]168 static DECLCALLBACK(int) i_hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
169 VBOXEXTPACKMODKIND enmKind, char *pszFound, size_t cbFound, bool *pfNative);
170 static DECLCALLBACK(int) i_hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath);
171 static DECLCALLBACK(VBOXEXTPACKCTX) i_hlpGetContext(PCVBOXEXTPACKHLP pHlp);
172 static DECLCALLBACK(int) i_hlpLoadHGCMService(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IConsole) *pConsole, const char *pszServiceLibrary, const char *pszServiceName);
[52596]173 static DECLCALLBACK(int) i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
174 static DECLCALLBACK(int) i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
[73825]175 static DECLCALLBACK(uint32_t) i_hlpCreateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IUnknown) *pInitiator,
176 const char *pcszDescription, uint32_t cOperations,
177 uint32_t uTotalOperationsWeight, const char *pcszFirstOperationDescription,
178 uint32_t uFirstOperationWeight, VBOXEXTPACK_IF_CS(IProgress) **ppProgressOut);
179 static DECLCALLBACK(uint32_t) i_hlpGetCanceledProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
180 bool *pfCanceled);
181 static DECLCALLBACK(uint32_t) i_hlpUpdateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
182 uint32_t uPercent);
183 static DECLCALLBACK(uint32_t) i_hlpNextOperationProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
184 const char *pcszNextOperationDescription,
185 uint32_t uNextOperationWeight);
[74219]186 static DECLCALLBACK(uint32_t) i_hlpWaitOtherProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
[74804]187 VBOXEXTPACK_IF_CS(IProgress) *pProgressOther,
188 uint32_t cTimeoutMS);
[73825]189 static DECLCALLBACK(uint32_t) i_hlpCompleteProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
190 uint32_t uResultCode);
[86057]191 static DECLCALLBACK(uint32_t) i_hlpCreateEvent(PCVBOXEXTPACKHLP pHlp,
192 VBOXEXTPACK_IF_CS(IEventSource) *aSource,
193 /* VBoxEventType_T */ uint32_t aType, bool aWaitable,
194 VBOXEXTPACK_IF_CS(IEvent) **ppEventOut);
[86058]195 static DECLCALLBACK(uint32_t) i_hlpCreateVetoEvent(PCVBOXEXTPACKHLP pHlp,
196 VBOXEXTPACK_IF_CS(IEventSource) *aSource,
197 /* VBoxEventType_T */ uint32_t aType,
198 VBOXEXTPACK_IF_CS(IVetoEvent) **ppEventOut);
[91312]199 static DECLCALLBACK(const char *) i_hlpTranslate(PCVBOXEXTPACKHLP pHlp,
[101293]200 const char *pszComponent,
201 const char *pszSourceText,
202 const char *pszComment = NULL,
203 const size_t uNum = ~(size_t)0);
[91312]204 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
[33623]205 /** @} */
206
[33474]207private:
[50914]208
209 // wrapped IExtPack properties
210 HRESULT getName(com::Utf8Str &aName);
211 HRESULT getDescription(com::Utf8Str &aDescription);
212 HRESULT getVersion(com::Utf8Str &aVersion);
213 HRESULT getRevision(ULONG *aRevision);
214 HRESULT getEdition(com::Utf8Str &aEdition);
215 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
[94714]216 HRESULT getCryptoModule(com::Utf8Str &aCryptoModule);
[50914]217 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
218 HRESULT getUsable(BOOL *aUsable);
219 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
220 HRESULT getShowLicense(BOOL *aShowLicense);
221 HRESULT getLicense(com::Utf8Str &aLicense);
222
223 // wrapped IExtPack methods
224 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
225 const com::Utf8Str &aPreferredLanguage,
226 const com::Utf8Str &aFormat,
227 com::Utf8Str &aLicenseText);
228 HRESULT queryObject(const com::Utf8Str &aObjUuid,
229 ComPtr<IUnknown> &aReturnInterface);
230
231
[33474]232 struct Data;
233 /** Pointer to the private instance. */
234 Data *m;
235
236 friend class ExtPackManager;
237};
238
239
240/**
241 * Extension pack manager.
242 */
243class ATL_NO_VTABLE ExtPackManager :
[50914]244 public ExtPackManagerWrap
[33474]245{
[50914]246public:
[33474]247 /** @name COM and internal init/term/mapping cruft.
248 * @{ */
[90828]249 DECLARE_COMMON_CLASS_METHODS(ExtPackManager)
[33474]250
251 HRESULT FinalConstruct();
252 void FinalRelease();
[34794]253 HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
[33474]254 void uninit();
255 /** @} */
256
257 /** @name Internal interfaces used by other Main classes.
258 * @{ */
[68828]259#ifndef VBOX_COM_INPROC
[50914]260 HRESULT i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
261 HRESULT i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
[68828]262 void i_callAllVirtualBoxReadyHooks(void);
[73716]263 HRESULT i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames);
[46823]264#endif
[68828]265#ifdef VBOX_COM_INPROC
[50914]266 void i_callAllConsoleReadyHooks(IConsole *a_pConsole);
[68828]267#endif
268#ifndef VBOX_COM_INPROC
[50914]269 void i_callAllVmCreatedHooks(IMachine *a_pMachine);
[68828]270#endif
271#ifdef VBOX_COM_INPROC
[93449]272 int i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM);
273 int i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM);
274 void i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM);
[68828]275#endif
[50914]276 HRESULT i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
277 int i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
[94714]278 HRESULT i_checkCryptoExtPack(Utf8Str const *a_pstrExtPack);
279 int i_getCryptoLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
[63147]280 HRESULT i_getLibraryPathForExtPack(const char *a_pszModuleName, const char *a_pszExtPack, Utf8Str *a_pstrLibrary);
[50914]281 HRESULT i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
[94714]282 HRESULT i_getDefaultCryptoExtPack(Utf8Str *a_pstrExtPack);
[50914]283 bool i_isExtPackUsable(const char *a_pszExtPack);
284 void i_dumpAllToReleaseLog(void);
[73716]285 uint64_t i_getUpdateCounter(void);
[33474]286 /** @} */
287
288private:
[50914]289 // wrapped IExtPackManager properties
290 HRESULT getInstalledExtPacks(std::vector<ComPtr<IExtPack> > &aInstalledExtPacks);
291
292 // wrapped IExtPackManager methods
293 HRESULT find(const com::Utf8Str &aName,
294 ComPtr<IExtPack> &aReturnData);
295 HRESULT openExtPackFile(const com::Utf8Str &aPath,
296 ComPtr<IExtPackFile> &aFile);
297 HRESULT uninstall(const com::Utf8Str &aName,
298 BOOL aForcedRemoval,
299 const com::Utf8Str &aDisplayInfo,
300 ComPtr<IProgress> &aProgess);
301 HRESULT cleanup();
302 HRESULT queryAllPlugInsForFrontend(const com::Utf8Str &aFrontendName,
303 std::vector<com::Utf8Str> &aPlugInModules);
304 HRESULT isExtPackUsable(const com::Utf8Str &aName,
305 BOOL *aUsable);
306
[59319]307 bool i_areThereAnyRunningVMs(void) const;
[50914]308 HRESULT i_runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
309 ExtPack *i_findExtPack(const char *a_pszName);
310 void i_removeExtPack(const char *a_pszName);
311 HRESULT i_refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
312
[33521]313private:
[33474]314 struct Data;
315 /** Pointer to the private instance. */
316 Data *m;
[58981]317
318 friend class ExtPackUninstallTask;
[33474]319};
320
[76562]321#endif /* !MAIN_INCLUDED_ExtPackManagerImpl_h */
[33474]322/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use