VirtualBox

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

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

ExtPack: Don't hold any locks when calling extension pack hooks (except for pfnUnload and pfnUninstall).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/* $Id: ExtPackManagerImpl.h 34287 2010-11-23 15:20:03Z 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/**
27 * An extension pack.
28 *
29 * This
30 */
31class ATL_NO_VTABLE ExtPack :
32 public VirtualBoxBase,
33 VBOX_SCRIPTABLE_IMPL(IExtPack)
34{
35public:
36 /** @name COM and internal init/term/mapping cruft.
37 * @{ */
38 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPack, IExtPack)
39 DECLARE_NOT_AGGREGATABLE(ExtPack)
40 DECLARE_PROTECT_FINAL_CONSTRUCT()
41 BEGIN_COM_MAP(ExtPack)
42 COM_INTERFACE_ENTRY(ISupportErrorInfo)
43 COM_INTERFACE_ENTRY(IExtPack)
44 COM_INTERFACE_ENTRY(IDispatch)
45 END_COM_MAP()
46 DECLARE_EMPTY_CTOR_DTOR(ExtPack)
47
48 HRESULT FinalConstruct();
49 void FinalRelease();
50 HRESULT init(VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszParentDir);
51 void uninit();
52 /** @} */
53
54 /** @name IExtPack interfaces
55 * @{ */
56 STDMETHOD(COMGETTER(Name))(BSTR *a_pbstrName);
57 STDMETHOD(COMGETTER(Description))(BSTR *a_pbstrDescription);
58 STDMETHOD(COMGETTER(Version))(BSTR *a_pbstrVersion);
59 STDMETHOD(COMGETTER(Revision))(ULONG *a_puRevision);
60 STDMETHOD(COMGETTER(VRDEModule))(BSTR *a_pbstrVrdeModule);
61 STDMETHOD(COMGETTER(PlugIns))(ComSafeArrayOut(IExtPackPlugIn *, a_paPlugIns));
62 STDMETHOD(COMGETTER(Usable))(BOOL *a_pfUsable);
63 STDMETHOD(COMGETTER(WhyUnusable))(BSTR *a_pbstrWhy);
64 STDMETHOD(QueryObject)(IN_BSTR a_bstrObjectId, IUnknown **a_ppUnknown);
65 /** @} */
66
67 /** @name Internal interfaces used by ExtPackManager.
68 * @{ */
69 bool callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
70 HRESULT callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
71 bool callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
72 bool callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
73 bool callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
74 bool callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
75 bool callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock, int *a_pvrc);
76 bool callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, AutoWriteLock *a_pLock);
77 HRESULT checkVrde(void);
78 HRESULT getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
79 bool wantsToBeDefaultVrde(void) const;
80 HRESULT refresh(bool *pfCanDelete);
81 /** @} */
82
83protected:
84 /** @name Internal helper methods.
85 * @{ */
86 void probeAndLoad(void);
87 bool findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
88 Utf8Str *a_ppStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
89 static bool objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
90 /** @} */
91
92 /** @name Extension Pack Helpers
93 * @{ */
94 static DECLCALLBACK(int) hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
95 VBOXEXTPACKMODKIND enmKind, char *pszFound, size_t cbFound, bool *pfNative);
96 static DECLCALLBACK(int) hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath);
97 static DECLCALLBACK(VBOXEXTPACKCTX) hlpGetContext(PCVBOXEXTPACKHLP pHlp);
98 static DECLCALLBACK(int) hlpReservedN(PCVBOXEXTPACKHLP pHlp);
99 /** @} */
100
101private:
102 struct Data;
103 /** Pointer to the private instance. */
104 Data *m;
105
106 friend class ExtPackManager;
107};
108
109
110/**
111 * Extension pack manager.
112 */
113class ATL_NO_VTABLE ExtPackManager :
114 public VirtualBoxBase,
115 VBOX_SCRIPTABLE_IMPL(IExtPackManager)
116{
117 /** @name COM and internal init/term/mapping cruft.
118 * @{ */
119 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPackManager, IExtPackManager)
120 DECLARE_NOT_AGGREGATABLE(ExtPackManager)
121 DECLARE_PROTECT_FINAL_CONSTRUCT()
122 BEGIN_COM_MAP(ExtPackManager)
123 COM_INTERFACE_ENTRY(ISupportErrorInfo)
124 COM_INTERFACE_ENTRY(IExtPackManager)
125 COM_INTERFACE_ENTRY(IDispatch)
126 END_COM_MAP()
127 DECLARE_EMPTY_CTOR_DTOR(ExtPackManager)
128
129 HRESULT FinalConstruct();
130 void FinalRelease();
131 HRESULT init(VirtualBox *a_pVirtualBox, const char *a_pszDropZonePath, bool a_fCheckDropZone,
132 VBOXEXTPACKCTX a_enmContext);
133 void uninit();
134 /** @} */
135
136 /** @name IExtPack interfaces
137 * @{ */
138 STDMETHOD(COMGETTER(InstalledExtPacks))(ComSafeArrayOut(IExtPack *, a_paExtPacks));
139 STDMETHOD(Find)(IN_BSTR a_bstrName, IExtPack **a_pExtPack);
140 STDMETHOD(Install)(IN_BSTR a_bstrTarball, BSTR *a_pbstrName);
141 STDMETHOD(Uninstall)(IN_BSTR a_bstrName, BOOL a_fForcedRemoval);
142 STDMETHOD(Cleanup)(void);
143 STDMETHOD(QueryAllPlugInsForFrontend)(IN_BSTR a_bstrFrontend, ComSafeArrayOut(BSTR, a_pabstrPlugInModules));
144 /** @} */
145
146 /** @name Internal interfaces used by other Main classes.
147 * @{ */
148 void processDropZone(void);
149 void callAllVirtualBoxReadyHooks(void);
150 void callAllConsoleReadyHooks(IConsole *a_pConsole);
151 void callAllVmCreatedHooks(IMachine *a_pMachine);
152 int callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
153 int callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
154 void callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
155 HRESULT checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
156 int getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
157 HRESULT getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
158 /** @} */
159
160private:
161 HRESULT runSetUidToRootHelper(const char *a_pszCommand, ...);
162 ExtPack *findExtPack(const char *a_pszName);
163 void removeExtPack(const char *a_pszName);
164 HRESULT refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
165
166private:
167 struct Data;
168 /** Pointer to the private instance. */
169 Data *m;
170};
171
172#endif
173/* 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