1 | /* $Id: ApplianceImpl.h 16931 2009-02-18 20:32:10Z 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 | }
|
---|
33 |
|
---|
34 | class VirtualBox;
|
---|
35 |
|
---|
36 | class ATL_NO_VTABLE Appliance :
|
---|
37 | public VirtualBoxBaseWithChildrenNEXT,
|
---|
38 | public VirtualBoxSupportErrorInfoImpl <Appliance, IAppliance>,
|
---|
39 | public VirtualBoxSupportTranslation <Appliance>,
|
---|
40 | public IAppliance
|
---|
41 | {
|
---|
42 |
|
---|
43 | public:
|
---|
44 |
|
---|
45 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Appliance)
|
---|
46 |
|
---|
47 | DECLARE_NOT_AGGREGATABLE(Appliance)
|
---|
48 |
|
---|
49 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
50 |
|
---|
51 | BEGIN_COM_MAP(Appliance)
|
---|
52 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
53 | COM_INTERFACE_ENTRY(IAppliance)
|
---|
54 | END_COM_MAP()
|
---|
55 |
|
---|
56 | NS_DECL_ISUPPORTS
|
---|
57 |
|
---|
58 | DECLARE_EMPTY_CTOR_DTOR (Appliance)
|
---|
59 |
|
---|
60 | // public initializer/uninitializer for internal purposes only
|
---|
61 | HRESULT FinalConstruct() { return S_OK; }
|
---|
62 | void FinalRelease() { uninit(); }
|
---|
63 |
|
---|
64 | HRESULT init(VirtualBox *aVirtualBox);
|
---|
65 | void uninit();
|
---|
66 |
|
---|
67 | // for VirtualBoxSupportErrorInfoImpl
|
---|
68 | static const wchar_t *getComponentName() { return L"Appliance"; }
|
---|
69 |
|
---|
70 | /* IAppliance properties */
|
---|
71 | STDMETHOD(COMGETTER(Path))(BSTR *aPath);
|
---|
72 | STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
|
---|
73 | STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
|
---|
74 |
|
---|
75 | /* IAppliance methods */
|
---|
76 | STDMETHOD(Read)(IN_BSTR path);
|
---|
77 | STDMETHOD(Interpret)(void);
|
---|
78 | STDMETHOD(ImportMachines)(IProgress **aProgress);
|
---|
79 |
|
---|
80 | /* public methods only for internal purposes */
|
---|
81 |
|
---|
82 | /* private instance data */
|
---|
83 | private:
|
---|
84 | /** weak VirtualBox parent */
|
---|
85 | VirtualBox* mVirtualBox;
|
---|
86 |
|
---|
87 | struct Task; /* Worker thread for import */
|
---|
88 |
|
---|
89 | struct Data; // obscure, defined in AppliannceImpl.cpp
|
---|
90 | Data *m;
|
---|
91 |
|
---|
92 | HRESULT LoopThruSections(const char *pcszPath, const xml::Node *pReferencesElem, const xml::Node *pCurElem);
|
---|
93 | HRESULT HandleDiskSection(const char *pcszPath, const xml::Node *pReferencesElem, const xml::Node *pSectionElem);
|
---|
94 | HRESULT HandleNetworkSection(const char *pcszPath, const xml::Node *pSectionElem);
|
---|
95 | HRESULT HandleVirtualSystemContent(const char *pcszPath, const xml::Node *pContentElem);
|
---|
96 |
|
---|
97 | HRESULT searchUniqueVMName(Utf8Str& aName) const;
|
---|
98 | HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
|
---|
99 |
|
---|
100 | static DECLCALLBACK(int) taskThread(RTTHREAD thread, void *pvUser);
|
---|
101 | };
|
---|
102 |
|
---|
103 | struct VirtualSystemDescriptionEntry
|
---|
104 | {
|
---|
105 | uint32_t ulIndex; // zero-based index of this entry within array
|
---|
106 | VirtualSystemDescriptionType_T type; // type of this entry
|
---|
107 | Utf8Str strRef; // reference number (hard disk controllers only)
|
---|
108 | Utf8Str strOrig; // original OVF value (type-dependent)
|
---|
109 | Utf8Str strConfig; // configuration value (type-dependent)
|
---|
110 | Utf8Str strExtraConfig; // extra configuration key=value strings (type-dependent)
|
---|
111 | };
|
---|
112 |
|
---|
113 | class ATL_NO_VTABLE VirtualSystemDescription :
|
---|
114 | public VirtualBoxBaseWithChildrenNEXT,
|
---|
115 | public VirtualBoxSupportErrorInfoImpl <VirtualSystemDescription, IVirtualSystemDescription>,
|
---|
116 | public VirtualBoxSupportTranslation <VirtualSystemDescription>,
|
---|
117 | public IVirtualSystemDescription
|
---|
118 | {
|
---|
119 | friend class Appliance;
|
---|
120 | public:
|
---|
121 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
|
---|
122 |
|
---|
123 | DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
|
---|
124 |
|
---|
125 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
126 |
|
---|
127 | BEGIN_COM_MAP(VirtualSystemDescription)
|
---|
128 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
129 | COM_INTERFACE_ENTRY(IVirtualSystemDescription)
|
---|
130 | END_COM_MAP()
|
---|
131 |
|
---|
132 | NS_DECL_ISUPPORTS
|
---|
133 |
|
---|
134 | DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
|
---|
135 |
|
---|
136 | // public initializer/uninitializer for internal purposes only
|
---|
137 | HRESULT FinalConstruct() { return S_OK; }
|
---|
138 | void FinalRelease() { uninit(); }
|
---|
139 |
|
---|
140 | HRESULT init();
|
---|
141 | void uninit();
|
---|
142 |
|
---|
143 | // for VirtualBoxSupportErrorInfoImpl
|
---|
144 | static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
|
---|
145 |
|
---|
146 | /* IVirtualSystemDescription properties */
|
---|
147 | STDMETHOD(COMGETTER(Count))(ULONG *aCount);
|
---|
148 |
|
---|
149 | /* IVirtualSystemDescription methods */
|
---|
150 | STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
|
---|
151 | ComSafeArrayOut(BSTR, aRefs),
|
---|
152 | ComSafeArrayOut(BSTR, aOrigValues),
|
---|
153 | ComSafeArrayOut(BSTR, aConfigValues),
|
---|
154 | ComSafeArrayOut(BSTR, aExtraConfigValues));
|
---|
155 |
|
---|
156 | STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
|
---|
157 | ComSafeArrayIn(IN_BSTR, aConfigValues),
|
---|
158 | ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
|
---|
159 |
|
---|
160 | STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
|
---|
161 |
|
---|
162 | /* public methods only for internal purposes */
|
---|
163 |
|
---|
164 | /* private instance data */
|
---|
165 | private:
|
---|
166 | void addEntry(VirtualSystemDescriptionType_T aType,
|
---|
167 | const Utf8Str &strRef,
|
---|
168 | const Utf8Str &aOrigValue,
|
---|
169 | const Utf8Str &aAutoValue,
|
---|
170 | const Utf8Str &strExtraConfig = "");
|
---|
171 |
|
---|
172 | void addWarning(const char* aWarning, ...);
|
---|
173 |
|
---|
174 | std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
|
---|
175 | const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
|
---|
176 |
|
---|
177 | struct Data;
|
---|
178 | Data *m;
|
---|
179 | };
|
---|
180 |
|
---|
181 | #endif // ____H_APPLIANCEIMPL
|
---|