VirtualBox

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

Last change on this file since 101505 was 101293, checked in by vboxsync, 15 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
Line 
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/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
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
26 */
27
28#ifndef MAIN_INCLUDED_ExtPackManagerImpl_h
29#define MAIN_INCLUDED_ExtPackManagerImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "VirtualBoxBase.h"
35#include <VBox/ExtPack/ExtPack.h>
36#include "ExtPackWrap.h"
37#include "ExtPackFileWrap.h"
38#include "ExtPackManagerWrap.h"
39#include <iprt/fs.h>
40
41
42/** The name of the oracle extension back. */
43#define ORACLE_PUEL_EXTPACK_NAME "Oracle VM VirtualBox Extension Pack"
44
45
46#ifndef VBOX_COM_INPROC
47/**
48 * An extension pack file.
49 */
50class ATL_NO_VTABLE ExtPackFile :
51 public ExtPackFileWrap
52{
53public:
54 /** @name COM and internal init/term/mapping cruft.
55 * @{ */
56 DECLARE_COMMON_CLASS_METHODS(ExtPackFile)
57
58 HRESULT FinalConstruct();
59 void FinalRelease();
60 HRESULT initWithFile(const char *a_pszFile, const char *a_pszDigest, class ExtPackManager *a_pExtPackMgr, VirtualBox *a_pVirtualBox);
61 void uninit();
62 /** @} */
63
64private:
65 /** @name Misc init helpers
66 * @{ */
67 HRESULT initFailed(const char *a_pszWhyFmt, ...);
68 /** @} */
69
70private:
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);
79 HRESULT getCryptoModule(com::Utf8Str &aCryptoModule);
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
96 struct Data;
97 /** Pointer to the private instance. */
98 Data *m;
99
100 friend class ExtPackManager;
101 friend class ExtPackInstallTask;
102};
103#endif /* !VBOX_COM_INPROC */
104
105
106/**
107 * An installed extension pack.
108 */
109class ATL_NO_VTABLE ExtPack :
110 public ExtPackWrap
111{
112public:
113 /** @name COM and internal init/term/mapping cruft.
114 * @{ */
115 DECLARE_COMMON_CLASS_METHODS(ExtPack)
116
117 HRESULT FinalConstruct();
118 void FinalRelease();
119 HRESULT initWithDir(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);
120 void uninit();
121 RTMEMEF_NEW_AND_DELETE_OPERATORS();
122 /** @} */
123
124 /** @name Internal interfaces used by ExtPackManager.
125 * @{ */
126#ifndef VBOX_COM_INPROC
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);
130#endif
131#ifdef VBOX_COM_INPROC
132 bool i_callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
133#endif
134#ifndef VBOX_COM_INPROC
135 bool i_callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
136#endif
137#ifdef VBOX_COM_INPROC
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);
142#endif
143 HRESULT i_checkVrde(void);
144 HRESULT i_checkCrypto(void);
145 HRESULT i_getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
146 HRESULT i_getCryptoLibraryName(Utf8Str *a_pstrCryptoLibrary);
147 HRESULT i_getLibraryName(const char *a_pszModuleName, Utf8Str *a_pstrLibrary);
148 bool i_wantsToBeDefaultVrde(void) const;
149 bool i_wantsToBeDefaultCrypto(void) const;
150 HRESULT i_refresh(bool *pfCanDelete);
151#ifndef VBOX_COM_INPROC
152 bool i_areThereCloudProviderUninstallVetos();
153 void i_notifyCloudProviderManager();
154#endif
155 /** @} */
156
157protected:
158 /** @name Internal helper methods.
159 * @{ */
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);
164 /** @} */
165
166 /** @name Extension Pack Helpers
167 * @{ */
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);
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);
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);
186 static DECLCALLBACK(uint32_t) i_hlpWaitOtherProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
187 VBOXEXTPACK_IF_CS(IProgress) *pProgressOther,
188 uint32_t cTimeoutMS);
189 static DECLCALLBACK(uint32_t) i_hlpCompleteProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
190 uint32_t uResultCode);
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);
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);
199 static DECLCALLBACK(const char *) i_hlpTranslate(PCVBOXEXTPACKHLP pHlp,
200 const char *pszComponent,
201 const char *pszSourceText,
202 const char *pszComment = NULL,
203 const size_t uNum = ~(size_t)0);
204 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
205 /** @} */
206
207private:
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);
216 HRESULT getCryptoModule(com::Utf8Str &aCryptoModule);
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
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 :
244 public ExtPackManagerWrap
245{
246public:
247 /** @name COM and internal init/term/mapping cruft.
248 * @{ */
249 DECLARE_COMMON_CLASS_METHODS(ExtPackManager)
250
251 HRESULT FinalConstruct();
252 void FinalRelease();
253 HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
254 void uninit();
255 /** @} */
256
257 /** @name Internal interfaces used by other Main classes.
258 * @{ */
259#ifndef VBOX_COM_INPROC
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);
262 void i_callAllVirtualBoxReadyHooks(void);
263 HRESULT i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames);
264#endif
265#ifdef VBOX_COM_INPROC
266 void i_callAllConsoleReadyHooks(IConsole *a_pConsole);
267#endif
268#ifndef VBOX_COM_INPROC
269 void i_callAllVmCreatedHooks(IMachine *a_pMachine);
270#endif
271#ifdef VBOX_COM_INPROC
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);
275#endif
276 HRESULT i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
277 int i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
278 HRESULT i_checkCryptoExtPack(Utf8Str const *a_pstrExtPack);
279 int i_getCryptoLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
280 HRESULT i_getLibraryPathForExtPack(const char *a_pszModuleName, const char *a_pszExtPack, Utf8Str *a_pstrLibrary);
281 HRESULT i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
282 HRESULT i_getDefaultCryptoExtPack(Utf8Str *a_pstrExtPack);
283 bool i_isExtPackUsable(const char *a_pszExtPack);
284 void i_dumpAllToReleaseLog(void);
285 uint64_t i_getUpdateCounter(void);
286 /** @} */
287
288private:
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
307 bool i_areThereAnyRunningVMs(void) const;
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
313private:
314 struct Data;
315 /** Pointer to the private instance. */
316 Data *m;
317
318 friend class ExtPackUninstallTask;
319};
320
321#endif /* !MAIN_INCLUDED_ExtPackManagerImpl_h */
322/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette