VirtualBox

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

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

Main: bugref:1909: Added API localization

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.0 KB
Line 
1/* $Id: ExtPackManagerImpl.h 90828 2021-08-24 09:44:46Z 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 */
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(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
185 /** @} */
186
187private:
188
189 // wrapped IExtPack properties
190 HRESULT getName(com::Utf8Str &aName);
191 HRESULT getDescription(com::Utf8Str &aDescription);
192 HRESULT getVersion(com::Utf8Str &aVersion);
193 HRESULT getRevision(ULONG *aRevision);
194 HRESULT getEdition(com::Utf8Str &aEdition);
195 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
196 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
197 HRESULT getUsable(BOOL *aUsable);
198 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
199 HRESULT getShowLicense(BOOL *aShowLicense);
200 HRESULT getLicense(com::Utf8Str &aLicense);
201
202 // wrapped IExtPack methods
203 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
204 const com::Utf8Str &aPreferredLanguage,
205 const com::Utf8Str &aFormat,
206 com::Utf8Str &aLicenseText);
207 HRESULT queryObject(const com::Utf8Str &aObjUuid,
208 ComPtr<IUnknown> &aReturnInterface);
209
210
211 struct Data;
212 /** Pointer to the private instance. */
213 Data *m;
214
215 friend class ExtPackManager;
216};
217
218
219/**
220 * Extension pack manager.
221 */
222class ATL_NO_VTABLE ExtPackManager :
223 public ExtPackManagerWrap
224{
225public:
226 /** @name COM and internal init/term/mapping cruft.
227 * @{ */
228 DECLARE_COMMON_CLASS_METHODS(ExtPackManager)
229
230 HRESULT FinalConstruct();
231 void FinalRelease();
232 HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
233 void uninit();
234 /** @} */
235
236 /** @name Internal interfaces used by other Main classes.
237 * @{ */
238#ifndef VBOX_COM_INPROC
239 HRESULT i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
240 HRESULT i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
241 void i_callAllVirtualBoxReadyHooks(void);
242 HRESULT i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames);
243#endif
244#ifdef VBOX_COM_INPROC
245 void i_callAllConsoleReadyHooks(IConsole *a_pConsole);
246#endif
247#ifndef VBOX_COM_INPROC
248 void i_callAllVmCreatedHooks(IMachine *a_pMachine);
249#endif
250#ifdef VBOX_COM_INPROC
251 int i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
252 int i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
253 void i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
254#endif
255 HRESULT i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
256 int i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
257 HRESULT i_getLibraryPathForExtPack(const char *a_pszModuleName, const char *a_pszExtPack, Utf8Str *a_pstrLibrary);
258 HRESULT i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
259 bool i_isExtPackUsable(const char *a_pszExtPack);
260 void i_dumpAllToReleaseLog(void);
261 uint64_t i_getUpdateCounter(void);
262 /** @} */
263
264private:
265 // wrapped IExtPackManager properties
266 HRESULT getInstalledExtPacks(std::vector<ComPtr<IExtPack> > &aInstalledExtPacks);
267
268 // wrapped IExtPackManager methods
269 HRESULT find(const com::Utf8Str &aName,
270 ComPtr<IExtPack> &aReturnData);
271 HRESULT openExtPackFile(const com::Utf8Str &aPath,
272 ComPtr<IExtPackFile> &aFile);
273 HRESULT uninstall(const com::Utf8Str &aName,
274 BOOL aForcedRemoval,
275 const com::Utf8Str &aDisplayInfo,
276 ComPtr<IProgress> &aProgess);
277 HRESULT cleanup();
278 HRESULT queryAllPlugInsForFrontend(const com::Utf8Str &aFrontendName,
279 std::vector<com::Utf8Str> &aPlugInModules);
280 HRESULT isExtPackUsable(const com::Utf8Str &aName,
281 BOOL *aUsable);
282
283 bool i_areThereAnyRunningVMs(void) const;
284 HRESULT i_runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
285 ExtPack *i_findExtPack(const char *a_pszName);
286 void i_removeExtPack(const char *a_pszName);
287 HRESULT i_refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
288
289private:
290 struct Data;
291 /** Pointer to the private instance. */
292 Data *m;
293
294 friend class ExtPackUninstallTask;
295};
296
297#endif /* !MAIN_INCLUDED_ExtPackManagerImpl_h */
298/* 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