VirtualBox

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

Last change on this file since 34787 was 34787, checked in by vboxsync, 14 years ago

Main,VBoxManage,FE/Qt: Implemented IExtPackFile and dropped IExtPackManager::Install.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1/* $Id: ExtPackManagerImpl.h 34787 2010-12-07 14:51: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 */
28class ATL_NO_VTABLE ExtPackFile :
29 public VirtualBoxBase,
30 VBOX_SCRIPTABLE_IMPL(IExtPackFile)
31{
32public:
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 COM_INTERFACE_ENTRY(ISupportErrorInfo)
40 COM_INTERFACE_ENTRY(IExtPackFile)
41 COM_INTERFACE_ENTRY(IExtPackBase)
42 COM_INTERFACE_ENTRY(IDispatch)
43 END_COM_MAP()
44 DECLARE_EMPTY_CTOR_DTOR(ExtPackFile)
45
46 HRESULT FinalConstruct();
47 void FinalRelease();
48 HRESULT initWithFile(const char *a_pszFile, class ExtPackManager *a_pExtPackMgr);
49 void uninit();
50 RTMEMEF_NEW_AND_DELETE_OPERATORS();
51 /** @} */
52
53 /** @name IExtPackBase interfaces
54 * @{ */
55 STDMETHOD(COMGETTER(Name))(BSTR *a_pbstrName);
56 STDMETHOD(COMGETTER(Description))(BSTR *a_pbstrDescription);
57 STDMETHOD(COMGETTER(Version))(BSTR *a_pbstrVersion);
58 STDMETHOD(COMGETTER(Revision))(ULONG *a_puRevision);
59 STDMETHOD(COMGETTER(VRDEModule))(BSTR *a_pbstrVrdeModule);
60 STDMETHOD(COMGETTER(PlugIns))(ComSafeArrayOut(IExtPackPlugIn *, a_paPlugIns));
61 STDMETHOD(COMGETTER(Usable))(BOOL *a_pfUsable);
62 STDMETHOD(COMGETTER(WhyUnusable))(BSTR *a_pbstrWhy);
63 /** @} */
64
65 /** @name IExtPackFile interfaces
66 * @{ */
67 STDMETHOD(COMGETTER(FilePath))(BSTR *a_pbstrPath);
68 STDMETHOD(Install)(void);
69 /** @} */
70
71private:
72 /** @name Misc init helpers
73 * @{ */
74 HRESULT initFailed(const char *a_pszWhyFmt, ...);
75 /** @} */
76
77private:
78 struct Data;
79 /** Pointer to the private instance. */
80 Data *m;
81
82 friend class ExtPackManager;
83};
84
85
86/**
87 * An installed extension pack.
88 */
89class ATL_NO_VTABLE ExtPack :
90 public VirtualBoxBase,
91 VBOX_SCRIPTABLE_IMPL(IExtPack)
92{
93public:
94 /** @name COM and internal init/term/mapping cruft.
95 * @{ */
96 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPack, IExtPack)
97 DECLARE_NOT_AGGREGATABLE(ExtPack)
98 DECLARE_PROTECT_FINAL_CONSTRUCT()
99 BEGIN_COM_MAP(ExtPack)
100 COM_INTERFACE_ENTRY(ISupportErrorInfo)
101 COM_INTERFACE_ENTRY(IExtPack)
102 COM_INTERFACE_ENTRY(IExtPackBase)
103 COM_INTERFACE_ENTRY(IDispatch)
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 /** @} */
125
126 /** @name IExtPack interfaces
127 * @{ */
128 STDMETHOD(QueryObject)(IN_BSTR a_bstrObjectId, IUnknown **a_ppUnknown);
129 /** @} */
130
131 /** @name Internal interfaces used by ExtPackManager.
132 * @{ */
133 bool callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
134 HRESULT callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
135 bool callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
136 bool callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
137 bool callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
138 bool callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
139 bool callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
140 bool callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock);
141 HRESULT checkVrde(void);
142 HRESULT getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
143 bool wantsToBeDefaultVrde(void) const;
144 HRESULT refresh(bool *pfCanDelete);
145 /** @} */
146
147protected:
148 /** @name Internal helper methods.
149 * @{ */
150 void probeAndLoad(void);
151 bool findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
152 Utf8Str *a_ppStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
153 static bool objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
154 /** @} */
155
156 /** @name Extension Pack Helpers
157 * @{ */
158 static DECLCALLBACK(int) hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
159 VBOXEXTPACKMODKIND enmKind, char *pszFound, size_t cbFound, bool *pfNative);
160 static DECLCALLBACK(int) hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath);
161 static DECLCALLBACK(VBOXEXTPACKCTX) hlpGetContext(PCVBOXEXTPACKHLP pHlp);
162 static DECLCALLBACK(int) hlpReservedN(PCVBOXEXTPACKHLP pHlp);
163 /** @} */
164
165private:
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 VirtualBoxBase,
179 VBOX_SCRIPTABLE_IMPL(IExtPackManager)
180{
181 /** @name COM and internal init/term/mapping cruft.
182 * @{ */
183 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPackManager, IExtPackManager)
184 DECLARE_NOT_AGGREGATABLE(ExtPackManager)
185 DECLARE_PROTECT_FINAL_CONSTRUCT()
186 BEGIN_COM_MAP(ExtPackManager)
187 COM_INTERFACE_ENTRY(ISupportErrorInfo)
188 COM_INTERFACE_ENTRY(IExtPackManager)
189 COM_INTERFACE_ENTRY(IDispatch)
190 END_COM_MAP()
191 DECLARE_EMPTY_CTOR_DTOR(ExtPackManager)
192
193 HRESULT FinalConstruct();
194 void FinalRelease();
195 HRESULT init(VirtualBox *a_pVirtualBox, const char *a_pszDropZonePath, bool a_fCheckDropZone,
196 VBOXEXTPACKCTX a_enmContext);
197 void uninit();
198 RTMEMEF_NEW_AND_DELETE_OPERATORS();
199 /** @} */
200
201 /** @name IExtPack interfaces
202 * @{ */
203 STDMETHOD(COMGETTER(InstalledExtPacks))(ComSafeArrayOut(IExtPack *, a_paExtPacks));
204 STDMETHOD(Find)(IN_BSTR a_bstrName, IExtPack **a_pExtPack);
205 STDMETHOD(OpenExtPackFile)(IN_BSTR a_bstrTarball, IExtPackFile **a_ppExtPackFile);
206 STDMETHOD(Uninstall)(IN_BSTR a_bstrName, BOOL a_fForcedRemoval);
207 STDMETHOD(Cleanup)(void);
208 STDMETHOD(QueryAllPlugInsForFrontend)(IN_BSTR a_bstrFrontend, ComSafeArrayOut(BSTR, a_pabstrPlugInModules));
209 /** @} */
210
211 /** @name Internal interfaces used by other Main classes.
212 * @{ */
213 HRESULT doInstall(ExtPackFile *a_pExtPackFile);
214 /*void processDropZone(void);*/
215 void callAllVirtualBoxReadyHooks(void);
216 void callAllConsoleReadyHooks(IConsole *a_pConsole);
217 void callAllVmCreatedHooks(IMachine *a_pMachine);
218 int callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
219 int callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
220 void callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
221 HRESULT checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
222 int getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
223 HRESULT getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
224 /** @} */
225
226private:
227 HRESULT runSetUidToRootHelper(const char *a_pszCommand, ...);
228 ExtPack *findExtPack(const char *a_pszName);
229 void removeExtPack(const char *a_pszName);
230 HRESULT refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
231
232private:
233 struct Data;
234 /** Pointer to the private instance. */
235 Data *m;
236};
237
238#endif
239/* 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