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