VirtualBox

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

Last change on this file since 93412 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.4 KB
Line 
1/* $Id: ExtPackManagerImpl.h 93115 2022-01-01 11:31:46Z 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, AutoWriteLock *a_pLock, int *a_pvrc);
128 bool i_callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
129 bool i_callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock);
130#endif
131 HRESULT i_checkVrde(void);
132 HRESULT i_getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
133 HRESULT i_getLibraryName(const char *a_pszModuleName, Utf8Str *a_pstrLibrary);
134 bool i_wantsToBeDefaultVrde(void) const;
135 HRESULT i_refresh(bool *pfCanDelete);
136#ifndef VBOX_COM_INPROC
137 bool i_areThereCloudProviderUninstallVetos();
138 void i_notifyCloudProviderManager();
139#endif
140 /** @} */
141
142protected:
143 /** @name Internal helper methods.
144 * @{ */
145 void i_probeAndLoad(void);
146 bool i_findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
147 Utf8Str *a_ppStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
148 static bool i_objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
149 /** @} */
150
151 /** @name Extension Pack Helpers
152 * @{ */
153 static DECLCALLBACK(int) i_hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
154 VBOXEXTPACKMODKIND enmKind, char *pszFound, size_t cbFound, bool *pfNative);
155 static DECLCALLBACK(int) i_hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath);
156 static DECLCALLBACK(VBOXEXTPACKCTX) i_hlpGetContext(PCVBOXEXTPACKHLP pHlp);
157 static DECLCALLBACK(int) i_hlpLoadHGCMService(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IConsole) *pConsole, const char *pszServiceLibrary, const char *pszServiceName);
158 static DECLCALLBACK(int) i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
159 static DECLCALLBACK(int) i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
160 static DECLCALLBACK(uint32_t) i_hlpCreateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IUnknown) *pInitiator,
161 const char *pcszDescription, uint32_t cOperations,
162 uint32_t uTotalOperationsWeight, const char *pcszFirstOperationDescription,
163 uint32_t uFirstOperationWeight, VBOXEXTPACK_IF_CS(IProgress) **ppProgressOut);
164 static DECLCALLBACK(uint32_t) i_hlpGetCanceledProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
165 bool *pfCanceled);
166 static DECLCALLBACK(uint32_t) i_hlpUpdateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
167 uint32_t uPercent);
168 static DECLCALLBACK(uint32_t) i_hlpNextOperationProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
169 const char *pcszNextOperationDescription,
170 uint32_t uNextOperationWeight);
171 static DECLCALLBACK(uint32_t) i_hlpWaitOtherProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
172 VBOXEXTPACK_IF_CS(IProgress) *pProgressOther,
173 uint32_t cTimeoutMS);
174 static DECLCALLBACK(uint32_t) i_hlpCompleteProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
175 uint32_t uResultCode);
176 static DECLCALLBACK(uint32_t) i_hlpCreateEvent(PCVBOXEXTPACKHLP pHlp,
177 VBOXEXTPACK_IF_CS(IEventSource) *aSource,
178 /* VBoxEventType_T */ uint32_t aType, bool aWaitable,
179 VBOXEXTPACK_IF_CS(IEvent) **ppEventOut);
180 static DECLCALLBACK(uint32_t) i_hlpCreateVetoEvent(PCVBOXEXTPACKHLP pHlp,
181 VBOXEXTPACK_IF_CS(IEventSource) *aSource,
182 /* VBoxEventType_T */ uint32_t aType,
183 VBOXEXTPACK_IF_CS(IVetoEvent) **ppEventOut);
184 static DECLCALLBACK(const char *) i_hlpTranslate(PCVBOXEXTPACKHLP pHlp,
185 const char *pszComponent,
186 const char *pszSourceText,
187 const char *pszComment = NULL,
188 const size_t aNum = ~(size_t)0);
189 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
190 /** @} */
191
192private:
193
194 // wrapped IExtPack properties
195 HRESULT getName(com::Utf8Str &aName);
196 HRESULT getDescription(com::Utf8Str &aDescription);
197 HRESULT getVersion(com::Utf8Str &aVersion);
198 HRESULT getRevision(ULONG *aRevision);
199 HRESULT getEdition(com::Utf8Str &aEdition);
200 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
201 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
202 HRESULT getUsable(BOOL *aUsable);
203 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
204 HRESULT getShowLicense(BOOL *aShowLicense);
205 HRESULT getLicense(com::Utf8Str &aLicense);
206
207 // wrapped IExtPack methods
208 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
209 const com::Utf8Str &aPreferredLanguage,
210 const com::Utf8Str &aFormat,
211 com::Utf8Str &aLicenseText);
212 HRESULT queryObject(const com::Utf8Str &aObjUuid,
213 ComPtr<IUnknown> &aReturnInterface);
214
215
216 struct Data;
217 /** Pointer to the private instance. */
218 Data *m;
219
220 friend class ExtPackManager;
221};
222
223
224/**
225 * Extension pack manager.
226 */
227class ATL_NO_VTABLE ExtPackManager :
228 public ExtPackManagerWrap
229{
230public:
231 /** @name COM and internal init/term/mapping cruft.
232 * @{ */
233 DECLARE_COMMON_CLASS_METHODS(ExtPackManager)
234
235 HRESULT FinalConstruct();
236 void FinalRelease();
237 HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
238 void uninit();
239 /** @} */
240
241 /** @name Internal interfaces used by other Main classes.
242 * @{ */
243#ifndef VBOX_COM_INPROC
244 HRESULT i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
245 HRESULT i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
246 void i_callAllVirtualBoxReadyHooks(void);
247 HRESULT i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames);
248#endif
249#ifdef VBOX_COM_INPROC
250 void i_callAllConsoleReadyHooks(IConsole *a_pConsole);
251#endif
252#ifndef VBOX_COM_INPROC
253 void i_callAllVmCreatedHooks(IMachine *a_pMachine);
254#endif
255#ifdef VBOX_COM_INPROC
256 int i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
257 int i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
258 void i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
259#endif
260 HRESULT i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
261 int i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
262 HRESULT i_getLibraryPathForExtPack(const char *a_pszModuleName, const char *a_pszExtPack, Utf8Str *a_pstrLibrary);
263 HRESULT i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
264 bool i_isExtPackUsable(const char *a_pszExtPack);
265 void i_dumpAllToReleaseLog(void);
266 uint64_t i_getUpdateCounter(void);
267 /** @} */
268
269private:
270 // wrapped IExtPackManager properties
271 HRESULT getInstalledExtPacks(std::vector<ComPtr<IExtPack> > &aInstalledExtPacks);
272
273 // wrapped IExtPackManager methods
274 HRESULT find(const com::Utf8Str &aName,
275 ComPtr<IExtPack> &aReturnData);
276 HRESULT openExtPackFile(const com::Utf8Str &aPath,
277 ComPtr<IExtPackFile> &aFile);
278 HRESULT uninstall(const com::Utf8Str &aName,
279 BOOL aForcedRemoval,
280 const com::Utf8Str &aDisplayInfo,
281 ComPtr<IProgress> &aProgess);
282 HRESULT cleanup();
283 HRESULT queryAllPlugInsForFrontend(const com::Utf8Str &aFrontendName,
284 std::vector<com::Utf8Str> &aPlugInModules);
285 HRESULT isExtPackUsable(const com::Utf8Str &aName,
286 BOOL *aUsable);
287
288 bool i_areThereAnyRunningVMs(void) const;
289 HRESULT i_runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
290 ExtPack *i_findExtPack(const char *a_pszName);
291 void i_removeExtPack(const char *a_pszName);
292 HRESULT i_refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
293
294private:
295 struct Data;
296 /** Pointer to the private instance. */
297 Data *m;
298
299 friend class ExtPackUninstallTask;
300};
301
302#endif /* !MAIN_INCLUDED_ExtPackManagerImpl_h */
303/* 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