1 | /* $Id: ExtPackManagerImpl.h 37843 2011-07-08 12:34:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010 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 <iprt/fs.h>
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * An extension pack file.
|
---|
27 | */
|
---|
28 | class ATL_NO_VTABLE ExtPackFile :
|
---|
29 | public VirtualBoxBase,
|
---|
30 | VBOX_SCRIPTABLE_IMPL(IExtPackFile)
|
---|
31 | {
|
---|
32 | public:
|
---|
33 | /** @name COM and internal init/term/mapping cruft.
|
---|
34 | * @{ */
|
---|
35 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPackFile, IExtPackFile)
|
---|
36 | DECLARE_NOT_AGGREGATABLE(ExtPackFile)
|
---|
37 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
38 | BEGIN_COM_MAP(ExtPackFile)
|
---|
39 | VBOX_DEFAULT_INTERFACE_ENTRIES(IExtPackFile)
|
---|
40 | COM_INTERFACE_ENTRY(IExtPackBase)
|
---|
41 | END_COM_MAP()
|
---|
42 | DECLARE_EMPTY_CTOR_DTOR(ExtPackFile)
|
---|
43 |
|
---|
44 | HRESULT FinalConstruct();
|
---|
45 | void FinalRelease();
|
---|
46 | HRESULT initWithFile(const char *a_pszFile, class ExtPackManager *a_pExtPackMgr, VirtualBox *a_pVirtualBox);
|
---|
47 | void uninit();
|
---|
48 | RTMEMEF_NEW_AND_DELETE_OPERATORS();
|
---|
49 | /** @} */
|
---|
50 |
|
---|
51 | /** @name IExtPackBase interfaces
|
---|
52 | * @{ */
|
---|
53 | STDMETHOD(COMGETTER(Name))(BSTR *a_pbstrName);
|
---|
54 | STDMETHOD(COMGETTER(Description))(BSTR *a_pbstrDescription);
|
---|
55 | STDMETHOD(COMGETTER(Version))(BSTR *a_pbstrVersion);
|
---|
56 | STDMETHOD(COMGETTER(Revision))(ULONG *a_puRevision);
|
---|
57 | STDMETHOD(COMGETTER(VRDEModule))(BSTR *a_pbstrVrdeModule);
|
---|
58 | STDMETHOD(COMGETTER(PlugIns))(ComSafeArrayOut(IExtPackPlugIn *, a_paPlugIns));
|
---|
59 | STDMETHOD(COMGETTER(Usable))(BOOL *a_pfUsable);
|
---|
60 | STDMETHOD(COMGETTER(WhyUnusable))(BSTR *a_pbstrWhy);
|
---|
61 | STDMETHOD(COMGETTER(ShowLicense))(BOOL *a_pfShowIt);
|
---|
62 | STDMETHOD(COMGETTER(License))(BSTR *a_pbstrHtmlLicense);
|
---|
63 | STDMETHOD(QueryLicense)(IN_BSTR a_bstrPreferredLocale, IN_BSTR a_bstrPreferredLanguage,
|
---|
64 | IN_BSTR a_bstrFormat, BSTR *a_pbstrLicense);
|
---|
65 | /** @} */
|
---|
66 |
|
---|
67 | /** @name IExtPackFile interfaces
|
---|
68 | * @{ */
|
---|
69 | STDMETHOD(COMGETTER(FilePath))(BSTR *a_pbstrPath);
|
---|
70 | STDMETHOD(Install)(BOOL a_fReplace, IN_BSTR a_bstrDisplayInfo, IProgress **a_ppProgress);
|
---|
71 | /** @} */
|
---|
72 |
|
---|
73 | private:
|
---|
74 | /** @name Misc init helpers
|
---|
75 | * @{ */
|
---|
76 | HRESULT initFailed(const char *a_pszWhyFmt, ...);
|
---|
77 | /** @} */
|
---|
78 |
|
---|
79 | private:
|
---|
80 | struct Data;
|
---|
81 | /** Pointer to the private instance. */
|
---|
82 | Data *m;
|
---|
83 |
|
---|
84 | friend class ExtPackManager;
|
---|
85 | };
|
---|
86 |
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * An installed extension pack.
|
---|
90 | */
|
---|
91 | class ATL_NO_VTABLE ExtPack :
|
---|
92 | public VirtualBoxBase,
|
---|
93 | VBOX_SCRIPTABLE_IMPL(IExtPack)
|
---|
94 | {
|
---|
95 | public:
|
---|
96 | /** @name COM and internal init/term/mapping cruft.
|
---|
97 | * @{ */
|
---|
98 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPack, IExtPack)
|
---|
99 | DECLARE_NOT_AGGREGATABLE(ExtPack)
|
---|
100 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
101 | BEGIN_COM_MAP(ExtPack)
|
---|
102 | VBOX_DEFAULT_INTERFACE_ENTRIES(IExtPack)
|
---|
103 | COM_INTERFACE_ENTRY(IExtPackBase)
|
---|
104 | END_COM_MAP()
|
---|
105 | DECLARE_EMPTY_CTOR_DTOR(ExtPack)
|
---|
106 |
|
---|
107 | HRESULT FinalConstruct();
|
---|
108 | void FinalRelease();
|
---|
109 | HRESULT initWithDir(VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);
|
---|
110 | void uninit();
|
---|
111 | RTMEMEF_NEW_AND_DELETE_OPERATORS();
|
---|
112 | /** @} */
|
---|
113 |
|
---|
114 | /** @name IExtPackBase interfaces
|
---|
115 | * @{ */
|
---|
116 | STDMETHOD(COMGETTER(Name))(BSTR *a_pbstrName);
|
---|
117 | STDMETHOD(COMGETTER(Description))(BSTR *a_pbstrDescription);
|
---|
118 | STDMETHOD(COMGETTER(Version))(BSTR *a_pbstrVersion);
|
---|
119 | STDMETHOD(COMGETTER(Revision))(ULONG *a_puRevision);
|
---|
120 | STDMETHOD(COMGETTER(VRDEModule))(BSTR *a_pbstrVrdeModule);
|
---|
121 | STDMETHOD(COMGETTER(PlugIns))(ComSafeArrayOut(IExtPackPlugIn *, a_paPlugIns));
|
---|
122 | STDMETHOD(COMGETTER(Usable))(BOOL *a_pfUsable);
|
---|
123 | STDMETHOD(COMGETTER(WhyUnusable))(BSTR *a_pbstrWhy);
|
---|
124 | STDMETHOD(COMGETTER(ShowLicense))(BOOL *a_pfShowIt);
|
---|
125 | STDMETHOD(COMGETTER(License))(BSTR *a_pbstrHtmlLicense);
|
---|
126 | STDMETHOD(QueryLicense)(IN_BSTR a_bstrPreferredLocale, IN_BSTR a_bstrPreferredLanguage,
|
---|
127 | IN_BSTR a_bstrFormat, BSTR *a_pbstrLicense);
|
---|
128 | /** @} */
|
---|
129 |
|
---|
130 | /** @name IExtPack interfaces
|
---|
131 | * @{ */
|
---|
132 | STDMETHOD(QueryObject)(IN_BSTR a_bstrObjectId, IUnknown **a_ppUnknown);
|
---|
133 | /** @} */
|
---|
134 |
|
---|
135 | /** @name Internal interfaces used by ExtPackManager.
|
---|
136 | * @{ */
|
---|
137 | bool callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo);
|
---|
138 | HRESULT callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
|
---|
139 | bool callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
|
---|
140 | bool callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
|
---|
141 | bool callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
|
---|
142 | bool callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
|
---|
143 | bool callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
|
---|
144 | bool callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock);
|
---|
145 | HRESULT checkVrde(void);
|
---|
146 | HRESULT getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
|
---|
147 | bool wantsToBeDefaultVrde(void) const;
|
---|
148 | HRESULT refresh(bool *pfCanDelete);
|
---|
149 | /** @} */
|
---|
150 |
|
---|
151 | protected:
|
---|
152 | /** @name Internal helper methods.
|
---|
153 | * @{ */
|
---|
154 | void probeAndLoad(void);
|
---|
155 | bool findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
|
---|
156 | Utf8Str *a_ppStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
|
---|
157 | static bool objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
|
---|
158 | /** @} */
|
---|
159 |
|
---|
160 | /** @name Extension Pack Helpers
|
---|
161 | * @{ */
|
---|
162 | static DECLCALLBACK(int) hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
|
---|
163 | VBOXEXTPACKMODKIND enmKind, char *pszFound, size_t cbFound, bool *pfNative);
|
---|
164 | static DECLCALLBACK(int) hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath);
|
---|
165 | static DECLCALLBACK(VBOXEXTPACKCTX) hlpGetContext(PCVBOXEXTPACKHLP pHlp);
|
---|
166 | static DECLCALLBACK(int) hlpReservedN(PCVBOXEXTPACKHLP pHlp);
|
---|
167 | /** @} */
|
---|
168 |
|
---|
169 | private:
|
---|
170 | struct Data;
|
---|
171 | /** Pointer to the private instance. */
|
---|
172 | Data *m;
|
---|
173 |
|
---|
174 | friend class ExtPackManager;
|
---|
175 | };
|
---|
176 |
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Extension pack manager.
|
---|
180 | */
|
---|
181 | class ATL_NO_VTABLE ExtPackManager :
|
---|
182 | public VirtualBoxBase,
|
---|
183 | VBOX_SCRIPTABLE_IMPL(IExtPackManager)
|
---|
184 | {
|
---|
185 | /** @name COM and internal init/term/mapping cruft.
|
---|
186 | * @{ */
|
---|
187 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPackManager, IExtPackManager)
|
---|
188 | DECLARE_NOT_AGGREGATABLE(ExtPackManager)
|
---|
189 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
190 | BEGIN_COM_MAP(ExtPackManager)
|
---|
191 | VBOX_DEFAULT_INTERFACE_ENTRIES(IExtPackManager)
|
---|
192 | END_COM_MAP()
|
---|
193 | DECLARE_EMPTY_CTOR_DTOR(ExtPackManager)
|
---|
194 |
|
---|
195 | HRESULT FinalConstruct();
|
---|
196 | void FinalRelease();
|
---|
197 | HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
|
---|
198 | void uninit();
|
---|
199 | RTMEMEF_NEW_AND_DELETE_OPERATORS();
|
---|
200 | /** @} */
|
---|
201 |
|
---|
202 | /** @name IExtPack interfaces
|
---|
203 | * @{ */
|
---|
204 | STDMETHOD(COMGETTER(InstalledExtPacks))(ComSafeArrayOut(IExtPack *, a_paExtPacks));
|
---|
205 | STDMETHOD(Find)(IN_BSTR a_bstrName, IExtPack **a_pExtPack);
|
---|
206 | STDMETHOD(OpenExtPackFile)(IN_BSTR a_bstrTarball, IExtPackFile **a_ppExtPackFile);
|
---|
207 | STDMETHOD(Uninstall)(IN_BSTR a_bstrName, BOOL a_fForcedRemoval, IN_BSTR a_bstrDisplayInfo, IProgress **a_ppProgress);
|
---|
208 | STDMETHOD(Cleanup)(void);
|
---|
209 | STDMETHOD(QueryAllPlugInsForFrontend)(IN_BSTR a_bstrFrontend, ComSafeArrayOut(BSTR, a_pabstrPlugInModules));
|
---|
210 | STDMETHOD(IsExtPackUsable(IN_BSTR a_bstrExtPack, BOOL *aUsable));
|
---|
211 | /** @} */
|
---|
212 |
|
---|
213 | /** @name Internal interfaces used by other Main classes.
|
---|
214 | * @{ */
|
---|
215 | static DECLCALLBACK(int) doInstallThreadProc(RTTHREAD hThread, void *pvJob);
|
---|
216 | HRESULT doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
|
---|
217 | static DECLCALLBACK(int) doUninstallThreadProc(RTTHREAD hThread, void *pvJob);
|
---|
218 | HRESULT doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
|
---|
219 | void callAllVirtualBoxReadyHooks(void);
|
---|
220 | void callAllConsoleReadyHooks(IConsole *a_pConsole);
|
---|
221 | void callAllVmCreatedHooks(IMachine *a_pMachine);
|
---|
222 | int callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
223 | int callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
224 | void callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
225 | HRESULT checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
|
---|
226 | int getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
|
---|
227 | HRESULT getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
|
---|
228 | bool isExtPackUsable(const char *a_pszExtPack);
|
---|
229 | void dumpAllToReleaseLog(void);
|
---|
230 | /** @} */
|
---|
231 |
|
---|
232 | private:
|
---|
233 | HRESULT runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
|
---|
234 | ExtPack *findExtPack(const char *a_pszName);
|
---|
235 | void removeExtPack(const char *a_pszName);
|
---|
236 | HRESULT refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
|
---|
237 |
|
---|
238 | private:
|
---|
239 | struct Data;
|
---|
240 | /** Pointer to the private instance. */
|
---|
241 | Data *m;
|
---|
242 | };
|
---|
243 |
|
---|
244 | #endif
|
---|
245 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|