VirtualBox

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

Last change on this file since 53517 was 52596, checked in by vboxsync, 10 years ago

Storage/VD + Main/ExtPackManager+VirtualBox+SystemProperties: restructure previous change to fit better into the extpack design (using existing hooks) by using two new extpack helper functions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.8 KB
Line 
1/* $Id: ExtPackManagerImpl.h 52596 2014-09-04 16:45:50Z vboxsync $ */
2/** @file
3 * VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
4 */
5
6/*
7 * Copyright (C) 2010-2014 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 ____H_EXTPACKMANAGERIMPL
19#define ____H_EXTPACKMANAGERIMPL
20
21#include "VirtualBoxBase.h"
22#include <VBox/ExtPack/ExtPack.h>
23#include "ExtPackWrap.h"
24#include "ExtPackFileWrap.h"
25#include "ExtPackManagerWrap.h"
26#include <iprt/fs.h>
27
28#if !defined(VBOX_COM_INPROC)
29/**
30 * An extension pack file.
31 */
32class ATL_NO_VTABLE ExtPackFile :
33 public ExtPackFileWrap
34{
35public:
36 /** @name COM and internal init/term/mapping cruft.
37 * @{ */
38 DECLARE_EMPTY_CTOR_DTOR(ExtPackFile)
39
40 HRESULT FinalConstruct();
41 void FinalRelease();
42 HRESULT initWithFile(const char *a_pszFile, const char *a_pszDigest, class ExtPackManager *a_pExtPackMgr, VirtualBox *a_pVirtualBox);
43 void uninit();
44 /** @} */
45
46private:
47 /** @name Misc init helpers
48 * @{ */
49 HRESULT initFailed(const char *a_pszWhyFmt, ...);
50 /** @} */
51
52private:
53
54 // wrapped IExtPackFile properties
55 HRESULT getName(com::Utf8Str &aName);
56 HRESULT getDescription(com::Utf8Str &aDescription);
57 HRESULT getVersion(com::Utf8Str &aVersion);
58 HRESULT getRevision(ULONG *aRevision);
59 HRESULT getEdition(com::Utf8Str &aEdition);
60 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
61 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
62 HRESULT getUsable(BOOL *aUsable);
63 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
64 HRESULT getShowLicense(BOOL *aShowLicense);
65 HRESULT getLicense(com::Utf8Str &aLicense);
66 HRESULT getFilePath(com::Utf8Str &aFilePath);
67
68 // wrapped IExtPackFile methods
69 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
70 const com::Utf8Str &aPreferredLanguage,
71 const com::Utf8Str &aFormat,
72 com::Utf8Str &aLicenseText);
73 HRESULT install(BOOL aReplace,
74 const com::Utf8Str &aDisplayInfo,
75 ComPtr<IProgress> &aProgess);
76
77 struct Data;
78 /** Pointer to the private instance. */
79 Data *m;
80
81 friend class ExtPackManager;
82};
83#endif
84
85
86/**
87 * An installed extension pack.
88 */
89class ATL_NO_VTABLE ExtPack :
90 public ExtPackWrap
91{
92public:
93 /** @name COM and internal init/term/mapping cruft.
94 * @{ */
95 DECLARE_EMPTY_CTOR_DTOR(ExtPack)
96
97 HRESULT FinalConstruct();
98 void FinalRelease();
99 HRESULT initWithDir(VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);
100 void uninit();
101 RTMEMEF_NEW_AND_DELETE_OPERATORS();
102 /** @} */
103
104 /** @name Internal interfaces used by ExtPackManager.
105 * @{ */
106 bool i_callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo);
107 HRESULT i_callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
108 bool i_callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
109 bool i_callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
110 bool i_callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
111 bool i_callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
112 bool i_callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
113 bool i_callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock);
114 HRESULT i_checkVrde(void);
115 HRESULT i_getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
116 HRESULT i_getLibraryName(const char *a_pszModuleName, Utf8Str *a_pstrLibrary);
117 bool i_wantsToBeDefaultVrde(void) const;
118 HRESULT i_refresh(bool *pfCanDelete);
119 /** @} */
120
121protected:
122 /** @name Internal helper methods.
123 * @{ */
124 void i_probeAndLoad(void);
125 bool i_findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
126 Utf8Str *a_ppStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
127 static bool i_objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
128 /** @} */
129
130 /** @name Extension Pack Helpers
131 * @{ */
132 static DECLCALLBACK(int) i_hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
133 VBOXEXTPACKMODKIND enmKind, char *pszFound, size_t cbFound, bool *pfNative);
134 static DECLCALLBACK(int) i_hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath);
135 static DECLCALLBACK(VBOXEXTPACKCTX) i_hlpGetContext(PCVBOXEXTPACKHLP pHlp);
136 static DECLCALLBACK(int) i_hlpLoadHGCMService(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IConsole) *pConsole, const char *pszServiceLibrary, const char *pszServiceName);
137 static DECLCALLBACK(int) i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
138 static DECLCALLBACK(int) i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
139 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
140 /** @} */
141
142private:
143
144 // wrapped IExtPack properties
145 HRESULT getName(com::Utf8Str &aName);
146 HRESULT getDescription(com::Utf8Str &aDescription);
147 HRESULT getVersion(com::Utf8Str &aVersion);
148 HRESULT getRevision(ULONG *aRevision);
149 HRESULT getEdition(com::Utf8Str &aEdition);
150 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
151 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
152 HRESULT getUsable(BOOL *aUsable);
153 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
154 HRESULT getShowLicense(BOOL *aShowLicense);
155 HRESULT getLicense(com::Utf8Str &aLicense);
156
157 // wrapped IExtPack methods
158 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
159 const com::Utf8Str &aPreferredLanguage,
160 const com::Utf8Str &aFormat,
161 com::Utf8Str &aLicenseText);
162 HRESULT queryObject(const com::Utf8Str &aObjUuid,
163 ComPtr<IUnknown> &aReturnInterface);
164
165
166 struct Data;
167 /** Pointer to the private instance. */
168 Data *m;
169
170 friend class ExtPackManager;
171};
172
173
174/**
175 * Extension pack manager.
176 */
177class ATL_NO_VTABLE ExtPackManager :
178 public ExtPackManagerWrap
179{
180public:
181 /** @name COM and internal init/term/mapping cruft.
182 * @{ */
183 DECLARE_EMPTY_CTOR_DTOR(ExtPackManager)
184
185 HRESULT FinalConstruct();
186 void FinalRelease();
187 HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
188 void uninit();
189 /** @} */
190
191 /** @name Internal interfaces used by other Main classes.
192 * @{ */
193#if !defined(VBOX_COM_INPROC)
194 static DECLCALLBACK(int) i_doInstallThreadProc(RTTHREAD hThread, void *pvJob);
195 HRESULT i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
196 static DECLCALLBACK(int) i_doUninstallThreadProc(RTTHREAD hThread, void *pvJob);
197 HRESULT i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
198#endif
199 void i_callAllVirtualBoxReadyHooks(void);
200 void i_callAllConsoleReadyHooks(IConsole *a_pConsole);
201 void i_callAllVmCreatedHooks(IMachine *a_pMachine);
202 int i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
203 int i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
204 void i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
205 HRESULT i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
206 int i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
207 HRESULT i_getLibraryPathForExtPack(const char *a_pszModuleName, Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrLibrary);
208 HRESULT i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
209 bool i_isExtPackUsable(const char *a_pszExtPack);
210 void i_dumpAllToReleaseLog(void);
211 /** @} */
212
213private:
214
215 // wrapped IExtPackManager properties
216 HRESULT getInstalledExtPacks(std::vector<ComPtr<IExtPack> > &aInstalledExtPacks);
217
218 // wrapped IExtPackManager methods
219 HRESULT find(const com::Utf8Str &aName,
220 ComPtr<IExtPack> &aReturnData);
221 HRESULT openExtPackFile(const com::Utf8Str &aPath,
222 ComPtr<IExtPackFile> &aFile);
223 HRESULT uninstall(const com::Utf8Str &aName,
224 BOOL aForcedRemoval,
225 const com::Utf8Str &aDisplayInfo,
226 ComPtr<IProgress> &aProgess);
227 HRESULT cleanup();
228 HRESULT queryAllPlugInsForFrontend(const com::Utf8Str &aFrontendName,
229 std::vector<com::Utf8Str> &aPlugInModules);
230 HRESULT isExtPackUsable(const com::Utf8Str &aName,
231 BOOL *aUsable);
232
233 HRESULT i_runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
234 ExtPack *i_findExtPack(const char *a_pszName);
235 void i_removeExtPack(const char *a_pszName);
236 HRESULT i_refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
237
238private:
239 struct Data;
240 /** Pointer to the private instance. */
241 Data *m;
242};
243
244#endif
245/* 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