VirtualBox

source: vbox/trunk/src/VBox/Main/include/ApplianceImpl.h@ 26624

Last change on this file since 26624 was 26603, checked in by vboxsync, 15 years ago

Main: back out r57775

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1/* $Id: ApplianceImpl.h 26603 2010-02-17 12:24:34Z 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/* VBox includes */
28#include "VirtualBoxBase.h"
29
30#include "ovfreader.h"
31
32/* VBox forward declarations */
33class Progress;
34
35class ATL_NO_VTABLE Appliance :
36 public VirtualBoxBase,
37 public VirtualBoxSupportErrorInfoImpl<Appliance, IAppliance>,
38 public VirtualBoxSupportTranslation<Appliance>,
39 VBOX_SCRIPTABLE_IMPL(IAppliance)
40{
41public:
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 COM_INTERFACE_ENTRY(IDispatch)
52 END_COM_MAP()
53
54 DECLARE_EMPTY_CTOR_DTOR (Appliance)
55
56 // public initializer/uninitializer for internal purposes only
57 HRESULT FinalConstruct() { return S_OK; }
58 void FinalRelease() { uninit(); }
59
60 HRESULT init(VirtualBox *aVirtualBox);
61 void uninit();
62
63 // for VirtualBoxSupportErrorInfoImpl
64 static const wchar_t *getComponentName() { return L"Appliance"; }
65
66 /* IAppliance properties */
67 STDMETHOD(COMGETTER(Path))(BSTR *aPath);
68 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
69 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
70
71 /* IAppliance methods */
72 /* Import methods */
73 STDMETHOD(Read)(IN_BSTR path, IProgress **aProgress);
74 STDMETHOD(Interpret)(void);
75 STDMETHOD(ImportMachines)(IProgress **aProgress);
76 /* Export methods */
77 STDMETHOD(CreateVFSExplorer)(IN_BSTR aURI, IVFSExplorer **aExplorer);
78 STDMETHOD(Write)(IN_BSTR format, IN_BSTR path, IProgress **aProgress);
79
80 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
81
82 /* public methods only for internal purposes */
83
84 /* private instance data */
85private:
86 /** weak VirtualBox parent */
87 const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
88
89 struct Data; // opaque, defined in ApplianceImpl.cpp
90 Data *m;
91
92 HRESULT searchUniqueVMName(Utf8Str& aName) const;
93 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
94 void waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, ComPtr<IProgress> &pProgressAsync);
95 void addWarning(const char* aWarning, ...);
96
97 void disksWeight(uint32_t &ulTotalMB, uint32_t &cDisks) const;
98 HRESULT setUpProgressFS(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
99 HRESULT setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
100 HRESULT setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
101
102 struct LocationInfo;
103 void parseURI(Utf8Str strUri, LocationInfo &locInfo) const;
104 void parseBucket(Utf8Str &aPath, Utf8Str &aBucket) const;
105 Utf8Str manifestFileName(Utf8Str aPath) const;
106
107 HRESULT readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
108 HRESULT importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
109
110 struct TaskOVF;
111 struct TaskImportOVF; /* Worker threads for import */
112 static DECLCALLBACK(int) taskThreadImportOVF(RTTHREAD aThread, void *pvUser);
113
114 int readFS(TaskImportOVF *pTask);
115 int readS3(TaskImportOVF *pTask);
116
117 int importFS(TaskImportOVF *pTask);
118 int importS3(TaskImportOVF *pTask);
119
120 void ConvertDiskAttachmentValues(const HardDiskController &hdc,
121 uint32_t ulAddressOnParent,
122 Bstr &controllerType,
123 int32_t &lChannel,
124 int32_t &lDevice);
125
126 HRESULT writeImpl(int aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
127
128 struct TaskExportOVF; /* Worker threads for export */
129 static DECLCALLBACK(int) taskThreadWriteOVF(RTTHREAD aThread, void *pvUser);
130
131 int writeFS(TaskExportOVF *pTask);
132 int writeS3(TaskExportOVF *pTask);
133
134 friend class Machine;
135};
136
137struct VirtualSystemDescriptionEntry
138{
139 uint32_t ulIndex; // zero-based index of this entry within array
140 VirtualSystemDescriptionType_T type; // type of this entry
141 Utf8Str strRef; // reference number (hard disk controllers only)
142 Utf8Str strOvf; // original OVF value (type-dependent)
143 Utf8Str strVbox; // configuration value (type-dependent)
144 Utf8Str strExtraConfig; // extra configuration key=value strings (type-dependent)
145
146 uint32_t ulSizeMB; // hard disk images only: size of the uncompressed image in MB
147};
148
149class ATL_NO_VTABLE VirtualSystemDescription :
150 public VirtualBoxBase,
151 public VirtualBoxSupportErrorInfoImpl<VirtualSystemDescription, IVirtualSystemDescription>,
152 public VirtualBoxSupportTranslation<VirtualSystemDescription>,
153 VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription)
154{
155 friend class Appliance;
156
157public:
158 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
159
160 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
161
162 DECLARE_PROTECT_FINAL_CONSTRUCT()
163
164 BEGIN_COM_MAP(VirtualSystemDescription)
165 COM_INTERFACE_ENTRY(ISupportErrorInfo)
166 COM_INTERFACE_ENTRY(IVirtualSystemDescription)
167 COM_INTERFACE_ENTRY(IDispatch)
168 END_COM_MAP()
169
170 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
171
172 // public initializer/uninitializer for internal purposes only
173 HRESULT FinalConstruct() { return S_OK; }
174 void FinalRelease() { uninit(); }
175
176 HRESULT init();
177 void uninit();
178
179 // for VirtualBoxSupportErrorInfoImpl
180 static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
181
182 /* IVirtualSystemDescription properties */
183 STDMETHOD(COMGETTER(Count))(ULONG *aCount);
184
185 /* IVirtualSystemDescription methods */
186 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
187 ComSafeArrayOut(BSTR, aRefs),
188 ComSafeArrayOut(BSTR, aOvfValues),
189 ComSafeArrayOut(BSTR, aVboxValues),
190 ComSafeArrayOut(BSTR, aExtraConfigValues));
191
192 STDMETHOD(GetDescriptionByType)(VirtualSystemDescriptionType_T aType,
193 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
194 ComSafeArrayOut(BSTR, aRefs),
195 ComSafeArrayOut(BSTR, aOvfValues),
196 ComSafeArrayOut(BSTR, aVboxValues),
197 ComSafeArrayOut(BSTR, aExtraConfigValues));
198
199 STDMETHOD(GetValuesByType)(VirtualSystemDescriptionType_T aType,
200 VirtualSystemDescriptionValueType_T aWhich,
201 ComSafeArrayOut(BSTR, aValues));
202
203 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
204 ComSafeArrayIn(IN_BSTR, aVboxValues),
205 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
206
207 STDMETHOD(AddDescription)(VirtualSystemDescriptionType_T aType,
208 IN_BSTR aVboxValue,
209 IN_BSTR aExtraConfigValue);
210
211 /* public methods only for internal purposes */
212
213 void addEntry(VirtualSystemDescriptionType_T aType,
214 const Utf8Str &strRef,
215 const Utf8Str &aOrigValue,
216 const Utf8Str &aAutoValue,
217 uint32_t ulSizeMB = 0,
218 const Utf8Str &strExtraConfig = "");
219
220 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
221 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
222
223 /* private instance data */
224private:
225 struct Data;
226 Data *m;
227
228 friend class Machine;
229};
230
231#endif // ____H_APPLIANCEIMPL
232/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette