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