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