1 | /* $Id: ApplianceImpl.h 16503 2009-02-04 10:31:15Z 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 | VirtualSystemDescriptionType_T type; /* Of which type is this value */
|
---|
103 | uint32_t ulRef; // reference number
|
---|
104 | Utf8Str strOrig; /* The original OVF value */
|
---|
105 | Utf8Str strConfig; /* The value which VBox suggest */
|
---|
106 | Utf8Str strExtraConfig; /* Additional configuration data for this type */
|
---|
107 | };
|
---|
108 |
|
---|
109 | class ATL_NO_VTABLE VirtualSystemDescription :
|
---|
110 | public VirtualBoxBaseWithChildrenNEXT,
|
---|
111 | public VirtualBoxSupportErrorInfoImpl <VirtualSystemDescription, IVirtualSystemDescription>,
|
---|
112 | public VirtualBoxSupportTranslation <VirtualSystemDescription>,
|
---|
113 | public IVirtualSystemDescription
|
---|
114 | {
|
---|
115 | friend class Appliance;
|
---|
116 | public:
|
---|
117 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
|
---|
118 |
|
---|
119 | DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
|
---|
120 |
|
---|
121 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
122 |
|
---|
123 | BEGIN_COM_MAP(VirtualSystemDescription)
|
---|
124 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
125 | COM_INTERFACE_ENTRY(IVirtualSystemDescription)
|
---|
126 | END_COM_MAP()
|
---|
127 |
|
---|
128 | NS_DECL_ISUPPORTS
|
---|
129 |
|
---|
130 | DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
|
---|
131 |
|
---|
132 | // public initializer/uninitializer for internal purposes only
|
---|
133 | HRESULT FinalConstruct() { return S_OK; }
|
---|
134 | void FinalRelease() { uninit(); }
|
---|
135 |
|
---|
136 | HRESULT init();
|
---|
137 | void uninit();
|
---|
138 |
|
---|
139 | // for VirtualBoxSupportErrorInfoImpl
|
---|
140 | static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
|
---|
141 |
|
---|
142 | /* IVirtualSystemDescription properties */
|
---|
143 |
|
---|
144 | /* IVirtualSystemDescription methods */
|
---|
145 | STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
|
---|
146 | ComSafeArrayOut(ULONG, aRefs),
|
---|
147 | ComSafeArrayOut(BSTR, aOrigValues),
|
---|
148 | ComSafeArrayOut(BSTR, aConfigValues),
|
---|
149 | ComSafeArrayOut(BSTR, aExtraConfigValues));
|
---|
150 | STDMETHOD(SetFinalValues)(ComSafeArrayIn(IN_BSTR, aFinalValues));
|
---|
151 |
|
---|
152 | /* public methods only for internal purposes */
|
---|
153 |
|
---|
154 | /* private instance data */
|
---|
155 | private:
|
---|
156 | void addEntry(VirtualSystemDescriptionType_T aType,
|
---|
157 | uint32_t ulRef,
|
---|
158 | const Utf8Str &aOrigValue,
|
---|
159 | const Utf8Str &aAutoValue);
|
---|
160 |
|
---|
161 | std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
|
---|
162 |
|
---|
163 | struct Data;
|
---|
164 | Data *m;
|
---|
165 | };
|
---|
166 |
|
---|
167 | #endif // ____H_APPLIANCEIMPL
|
---|