1 | /* $Id: ExtPackManagerImpl.h 33693 2010-11-02 14:52:24Z 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 | */
|
---|
31 | class ATL_NO_VTABLE ExtPack :
|
---|
32 | public VirtualBoxBase,
|
---|
33 | VBOX_SCRIPTABLE_IMPL(IExtPack)
|
---|
34 | {
|
---|
35 | public:
|
---|
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(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(Usable))(BOOL *a_pfUsable);
|
---|
61 | STDMETHOD(COMGETTER(WhyUnusable))(BSTR *a_pbstrWhy);
|
---|
62 | /** @} */
|
---|
63 |
|
---|
64 | /** @name Internal interfaces used by ExtPackManager.
|
---|
65 | * @{ */
|
---|
66 | void callInstalledHook(void);
|
---|
67 | HRESULT callUninstallHookAndClose(bool a_fForcedRemoval);
|
---|
68 | void callVmCreatedHook(IMachine *a_pMachine);
|
---|
69 | int callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM);
|
---|
70 | int callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM);
|
---|
71 | void callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM);
|
---|
72 | HRESULT refresh(bool *pfCanDelete);
|
---|
73 | /** @} */
|
---|
74 |
|
---|
75 | protected:
|
---|
76 | /** @name Internal helper methods.
|
---|
77 | * @{ */
|
---|
78 | void probeAndLoad(void);
|
---|
79 | bool findModule(const char *a_pszName, const char *a_pszExt,
|
---|
80 | Utf8Str *a_pStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
|
---|
81 | static bool objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
|
---|
82 | /** @} */
|
---|
83 |
|
---|
84 | /** @name Extension Pack Helpers
|
---|
85 | * @{ */
|
---|
86 | static DECLCALLBACK(int) hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
|
---|
87 | char *pszFound, size_t cbFound, bool *pfNative);
|
---|
88 | /** @} */
|
---|
89 |
|
---|
90 | private:
|
---|
91 | struct Data;
|
---|
92 | /** Pointer to the private instance. */
|
---|
93 | Data *m;
|
---|
94 |
|
---|
95 | friend class ExtPackManager;
|
---|
96 | };
|
---|
97 |
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Extension pack manager.
|
---|
101 | */
|
---|
102 | class ATL_NO_VTABLE ExtPackManager :
|
---|
103 | public VirtualBoxBase,
|
---|
104 | VBOX_SCRIPTABLE_IMPL(IExtPackManager)
|
---|
105 | {
|
---|
106 | /** @name COM and internal init/term/mapping cruft.
|
---|
107 | * @{ */
|
---|
108 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPackManager, IExtPackManager)
|
---|
109 | DECLARE_NOT_AGGREGATABLE(ExtPackManager)
|
---|
110 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
111 | BEGIN_COM_MAP(ExtPackManager)
|
---|
112 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
113 | COM_INTERFACE_ENTRY(IExtPackManager)
|
---|
114 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
115 | END_COM_MAP()
|
---|
116 | DECLARE_EMPTY_CTOR_DTOR(ExtPackManager)
|
---|
117 |
|
---|
118 | HRESULT FinalConstruct();
|
---|
119 | void FinalRelease();
|
---|
120 | HRESULT init(const char *a_pszDropZonePath, bool a_fCheckDropZone);
|
---|
121 | void uninit();
|
---|
122 | /** @} */
|
---|
123 |
|
---|
124 | /** @name IExtPack interfaces
|
---|
125 | * @{ */
|
---|
126 | STDMETHOD(COMGETTER(InstalledExtPacks))(ComSafeArrayOut(IExtPack *, a_paExtPacks));
|
---|
127 | STDMETHOD(Find)(IN_BSTR a_bstrName, IExtPack **a_pExtPack);
|
---|
128 | STDMETHOD(Install)(IN_BSTR a_bstrTarball, BSTR *a_pbstrName);
|
---|
129 | STDMETHOD(Uninstall)(IN_BSTR a_bstrName, BOOL a_fForcedRemoval);
|
---|
130 | /** @} */
|
---|
131 |
|
---|
132 | /** @name Internal interfaces used by other Main classes.
|
---|
133 | * @{ */
|
---|
134 | void processDropZone(void);
|
---|
135 | void callAllVmCreatedHooks(IMachine *a_pMachine);
|
---|
136 | int callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
137 | int callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
138 | void callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM);
|
---|
139 | /** @} */
|
---|
140 |
|
---|
141 | private:
|
---|
142 | HRESULT runSetUidToRootHelper(const char *a_pszCommand, ...);
|
---|
143 | ExtPack *findExtPack(const char *a_pszName);
|
---|
144 | void removeExtPack(const char *a_pszName);
|
---|
145 | HRESULT refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
|
---|
146 |
|
---|
147 | private:
|
---|
148 | struct Data;
|
---|
149 | /** Pointer to the private instance. */
|
---|
150 | Data *m;
|
---|
151 | };
|
---|
152 |
|
---|
153 | #endif
|
---|
154 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|