1 | /* $Id: ExtPackManagerImpl.h 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2020 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 | */
|
---|
40 | class ATL_NO_VTABLE ExtPackFile :
|
---|
41 | public ExtPackFileWrap
|
---|
42 | {
|
---|
43 | public:
|
---|
44 | /** @name COM and internal init/term/mapping cruft.
|
---|
45 | * @{ */
|
---|
46 | DECLARE_EMPTY_CTOR_DTOR(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 |
|
---|
54 | private:
|
---|
55 | /** @name Misc init helpers
|
---|
56 | * @{ */
|
---|
57 | HRESULT initFailed(const char *a_pszWhyFmt, ...);
|
---|
58 | /** @} */
|
---|
59 |
|
---|
60 | private:
|
---|
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 | */
|
---|
98 | class ATL_NO_VTABLE ExtPack :
|
---|
99 | public ExtPackWrap
|
---|
100 | {
|
---|
101 | public:
|
---|
102 | /** @name COM and internal init/term/mapping cruft.
|
---|
103 | * @{ */
|
---|
104 | DECLARE_EMPTY_CTOR_DTOR(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 |
|
---|
142 | protected:
|
---|
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(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
|
---|
177 | /** @} */
|
---|
178 |
|
---|
179 | private:
|
---|
180 |
|
---|
181 | // wrapped IExtPack properties
|
---|
182 | HRESULT getName(com::Utf8Str &aName);
|
---|
183 | HRESULT getDescription(com::Utf8Str &aDescription);
|
---|
184 | HRESULT getVersion(com::Utf8Str &aVersion);
|
---|
185 | HRESULT getRevision(ULONG *aRevision);
|
---|
186 | HRESULT getEdition(com::Utf8Str &aEdition);
|
---|
187 | HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
|
---|
188 | HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
|
---|
189 | HRESULT getUsable(BOOL *aUsable);
|
---|
190 | HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
|
---|
191 | HRESULT getShowLicense(BOOL *aShowLicense);
|
---|
192 | HRESULT getLicense(com::Utf8Str &aLicense);
|
---|
193 |
|
---|
194 | // wrapped IExtPack methods
|
---|
195 | HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
|
---|
196 | const com::Utf8Str &aPreferredLanguage,
|
---|
197 | const com::Utf8Str &aFormat,
|
---|
198 | com::Utf8Str &aLicenseText);
|
---|
199 | HRESULT queryObject(const com::Utf8Str &aObjUuid,
|
---|
200 | ComPtr<IUnknown> &aReturnInterface);
|
---|
201 |
|
---|
202 |
|
---|
203 | struct Data;
|
---|
204 | /** Pointer to the private instance. */
|
---|
205 | Data *m;
|
---|
206 |
|
---|
207 | friend class ExtPackManager;
|
---|
208 | };
|
---|
209 |
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Extension pack manager.
|
---|
213 | */
|
---|
214 | class ATL_NO_VTABLE ExtPackManager :
|
---|
215 | public ExtPackManagerWrap
|
---|
216 | {
|
---|
217 | public:
|
---|
218 | /** @name COM and internal init/term/mapping cruft.
|
---|
219 | * @{ */
|
---|
220 | DECLARE_EMPTY_CTOR_DTOR(ExtPackManager)
|
---|
221 |
|
---|
222 | HRESULT FinalConstruct();
|
---|
223 | void FinalRelease();
|
---|
224 | HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
|
---|
225 | void uninit();
|
---|
226 | /** @} */
|
---|
227 |
|
---|
228 | /** @name Internal interfaces used by other Main classes.
|
---|
229 | * @{ */
|
---|
230 | #ifndef VBOX_COM_INPROC
|
---|
231 | HRESULT i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
|
---|
232 | HRESULT i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
|
---|
233 | void i_callAllVirtualBoxReadyHooks(void);
|
---|
234 | HRESULT i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames);
|
---|
235 | #endif
|
---|
236 | #ifdef VBOX_COM_INPROC
|
---|
237 | void i_callAllConsoleReadyHooks(IConsole *a_pConsole);
|
---|
238 | #endif
|
---|
239 | #ifndef VBOX_COM_INPROC
|
---|
240 | void i_callAllVmCreatedHooks(IMachine *a_pMachine);
|
---|
241 | #endif
|
---|
242 | #ifdef VBOX_COM_INPROC
|
---|
243 | int i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
244 | int i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
245 | void i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
246 | #endif
|
---|
247 | HRESULT i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
|
---|
248 | int i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
|
---|
249 | HRESULT i_getLibraryPathForExtPack(const char *a_pszModuleName, const char *a_pszExtPack, Utf8Str *a_pstrLibrary);
|
---|
250 | HRESULT i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
|
---|
251 | bool i_isExtPackUsable(const char *a_pszExtPack);
|
---|
252 | void i_dumpAllToReleaseLog(void);
|
---|
253 | uint64_t i_getUpdateCounter(void);
|
---|
254 | /** @} */
|
---|
255 |
|
---|
256 | private:
|
---|
257 | // wrapped IExtPackManager properties
|
---|
258 | HRESULT getInstalledExtPacks(std::vector<ComPtr<IExtPack> > &aInstalledExtPacks);
|
---|
259 |
|
---|
260 | // wrapped IExtPackManager methods
|
---|
261 | HRESULT find(const com::Utf8Str &aName,
|
---|
262 | ComPtr<IExtPack> &aReturnData);
|
---|
263 | HRESULT openExtPackFile(const com::Utf8Str &aPath,
|
---|
264 | ComPtr<IExtPackFile> &aFile);
|
---|
265 | HRESULT uninstall(const com::Utf8Str &aName,
|
---|
266 | BOOL aForcedRemoval,
|
---|
267 | const com::Utf8Str &aDisplayInfo,
|
---|
268 | ComPtr<IProgress> &aProgess);
|
---|
269 | HRESULT cleanup();
|
---|
270 | HRESULT queryAllPlugInsForFrontend(const com::Utf8Str &aFrontendName,
|
---|
271 | std::vector<com::Utf8Str> &aPlugInModules);
|
---|
272 | HRESULT isExtPackUsable(const com::Utf8Str &aName,
|
---|
273 | BOOL *aUsable);
|
---|
274 |
|
---|
275 | bool i_areThereAnyRunningVMs(void) const;
|
---|
276 | HRESULT i_runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
|
---|
277 | ExtPack *i_findExtPack(const char *a_pszName);
|
---|
278 | void i_removeExtPack(const char *a_pszName);
|
---|
279 | HRESULT i_refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
|
---|
280 |
|
---|
281 | private:
|
---|
282 | struct Data;
|
---|
283 | /** Pointer to the private instance. */
|
---|
284 | Data *m;
|
---|
285 |
|
---|
286 | friend class ExtPackUninstallTask;
|
---|
287 | };
|
---|
288 |
|
---|
289 | #endif /* !MAIN_INCLUDED_ExtPackManagerImpl_h */
|
---|
290 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|