1 | /* $Id: ApplianceImpl.h 17827 2009-03-13 14:14:08Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2009 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifndef ____H_APPLIANCEIMPL
|
---|
25 | #define ____H_APPLIANCEIMPL
|
---|
26 |
|
---|
27 | #include "VirtualBoxBase.h"
|
---|
28 |
|
---|
29 | namespace xml
|
---|
30 | {
|
---|
31 | class Node;
|
---|
32 | class ElementNode;
|
---|
33 | }
|
---|
34 |
|
---|
35 | class VirtualBox;
|
---|
36 |
|
---|
37 | class ATL_NO_VTABLE Appliance :
|
---|
38 | public VirtualBoxBaseWithChildrenNEXT,
|
---|
39 | public VirtualBoxSupportErrorInfoImpl <Appliance, IAppliance>,
|
---|
40 | public VirtualBoxSupportTranslation <Appliance>,
|
---|
41 | public IAppliance
|
---|
42 | {
|
---|
43 | public:
|
---|
44 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Appliance)
|
---|
45 |
|
---|
46 | DECLARE_NOT_AGGREGATABLE(Appliance)
|
---|
47 |
|
---|
48 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
49 |
|
---|
50 | BEGIN_COM_MAP(Appliance)
|
---|
51 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
52 | COM_INTERFACE_ENTRY(IAppliance)
|
---|
53 | END_COM_MAP()
|
---|
54 |
|
---|
55 | NS_DECL_ISUPPORTS
|
---|
56 |
|
---|
57 | DECLARE_EMPTY_CTOR_DTOR (Appliance)
|
---|
58 |
|
---|
59 | // public initializer/uninitializer for internal purposes only
|
---|
60 | HRESULT FinalConstruct() { return S_OK; }
|
---|
61 | void FinalRelease() { uninit(); }
|
---|
62 |
|
---|
63 | HRESULT init(VirtualBox *aVirtualBox);
|
---|
64 | void uninit();
|
---|
65 |
|
---|
66 | // for VirtualBoxSupportErrorInfoImpl
|
---|
67 | static const wchar_t *getComponentName() { return L"Appliance"; }
|
---|
68 |
|
---|
69 | /* IAppliance properties */
|
---|
70 | STDMETHOD(COMGETTER(Path))(BSTR *aPath);
|
---|
71 | STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
|
---|
72 | STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
|
---|
73 |
|
---|
74 | /* IAppliance methods */
|
---|
75 | STDMETHOD(Read)(IN_BSTR path);
|
---|
76 | STDMETHOD(Interpret)(void);
|
---|
77 | STDMETHOD(ImportMachines)(IProgress **aProgress);
|
---|
78 | STDMETHOD(Write)(IN_BSTR path, IProgress **aProgress);
|
---|
79 | STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
|
---|
80 |
|
---|
81 | /* public methods only for internal purposes */
|
---|
82 |
|
---|
83 | /* private instance data */
|
---|
84 | private:
|
---|
85 | /** weak VirtualBox parent */
|
---|
86 | const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
|
---|
87 |
|
---|
88 | struct Data; // obscure, defined in AppliannceImpl.cpp
|
---|
89 | Data *m;
|
---|
90 |
|
---|
91 | HRESULT LoopThruSections(const char *pcszPath, const xml::ElementNode *pReferencesElem, const xml::ElementNode *pCurElem);
|
---|
92 | HRESULT HandleDiskSection(const char *pcszPath, const xml::ElementNode *pReferencesElem, const xml::ElementNode *pSectionElem);
|
---|
93 | HRESULT HandleNetworkSection(const char *pcszPath, const xml::ElementNode *pSectionElem);
|
---|
94 | HRESULT HandleVirtualSystemContent(const char *pcszPath, const xml::ElementNode *pContentElem);
|
---|
95 |
|
---|
96 | HRESULT searchUniqueVMName(Utf8Str& aName) const;
|
---|
97 | HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
|
---|
98 | uint32_t calcMaxProgress();
|
---|
99 | void addWarning(const char* aWarning, ...);
|
---|
100 |
|
---|
101 | struct TaskImportMachines; /* Worker thread for import */
|
---|
102 | static DECLCALLBACK(int) taskThreadImportMachines(RTTHREAD thread, void *pvUser);
|
---|
103 |
|
---|
104 | struct TaskWriteOVF; /* Worker thread for export */
|
---|
105 | static DECLCALLBACK(int) taskThreadWriteOVF(RTTHREAD thread, void *pvUser);
|
---|
106 |
|
---|
107 | friend class Machine;
|
---|
108 | };
|
---|
109 |
|
---|
110 | struct VirtualSystemDescriptionEntry
|
---|
111 | {
|
---|
112 | uint32_t ulIndex; // zero-based index of this entry within array
|
---|
113 | VirtualSystemDescriptionType_T type; // type of this entry
|
---|
114 | Utf8Str strRef; // reference number (hard disk controllers only)
|
---|
115 | Utf8Str strOvf; // original OVF value (type-dependent)
|
---|
116 | Utf8Str strVbox; // configuration value (type-dependent)
|
---|
117 | Utf8Str strExtraConfig; // extra configuration key=value strings (type-dependent)
|
---|
118 | };
|
---|
119 |
|
---|
120 | class ATL_NO_VTABLE VirtualSystemDescription :
|
---|
121 | public VirtualBoxBaseWithChildrenNEXT,
|
---|
122 | public VirtualBoxSupportErrorInfoImpl <VirtualSystemDescription, IVirtualSystemDescription>,
|
---|
123 | public VirtualBoxSupportTranslation <VirtualSystemDescription>,
|
---|
124 | public IVirtualSystemDescription
|
---|
125 | {
|
---|
126 | friend class Appliance;
|
---|
127 |
|
---|
128 | public:
|
---|
129 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
|
---|
130 |
|
---|
131 | DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
|
---|
132 |
|
---|
133 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
134 |
|
---|
135 | BEGIN_COM_MAP(VirtualSystemDescription)
|
---|
136 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
137 | COM_INTERFACE_ENTRY(IVirtualSystemDescription)
|
---|
138 | END_COM_MAP()
|
---|
139 |
|
---|
140 | NS_DECL_ISUPPORTS
|
---|
141 |
|
---|
142 | DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
|
---|
143 |
|
---|
144 | // public initializer/uninitializer for internal purposes only
|
---|
145 | HRESULT FinalConstruct() { return S_OK; }
|
---|
146 | void FinalRelease() { uninit(); }
|
---|
147 |
|
---|
148 | HRESULT init();
|
---|
149 | void uninit();
|
---|
150 |
|
---|
151 | // for VirtualBoxSupportErrorInfoImpl
|
---|
152 | static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
|
---|
153 |
|
---|
154 | /* IVirtualSystemDescription properties */
|
---|
155 | STDMETHOD(COMGETTER(Count))(ULONG *aCount);
|
---|
156 |
|
---|
157 | /* IVirtualSystemDescription methods */
|
---|
158 | STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
|
---|
159 | ComSafeArrayOut(BSTR, aRefs),
|
---|
160 | ComSafeArrayOut(BSTR, aOvfValues),
|
---|
161 | ComSafeArrayOut(BSTR, aVboxValues),
|
---|
162 | ComSafeArrayOut(BSTR, aExtraConfigValues));
|
---|
163 |
|
---|
164 | STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
|
---|
165 | ComSafeArrayIn(IN_BSTR, aVboxValues),
|
---|
166 | ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
|
---|
167 |
|
---|
168 | /* public methods only for internal purposes */
|
---|
169 |
|
---|
170 | void addEntry(VirtualSystemDescriptionType_T aType,
|
---|
171 | const Utf8Str &strRef,
|
---|
172 | const Utf8Str &aOrigValue,
|
---|
173 | const Utf8Str &aAutoValue,
|
---|
174 | const Utf8Str &strExtraConfig = "");
|
---|
175 |
|
---|
176 | std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
|
---|
177 | const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
|
---|
178 |
|
---|
179 | /* private instance data */
|
---|
180 | private:
|
---|
181 | struct Data;
|
---|
182 | Data *m;
|
---|
183 |
|
---|
184 | friend class Machine;
|
---|
185 | };
|
---|
186 |
|
---|
187 | #endif // ____H_APPLIANCEIMPL
|
---|
188 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|