VirtualBox

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

Last change on this file since 94134 was 93449, checked in by vboxsync, 3 years ago

Main,ExtPacks: Don't like with the VMM anymore, use the function table. bugref:10074

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