VirtualBox

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

Last change on this file since 21588 was 21588, checked in by vboxsync, 16 years ago

Main: move vbox-independent OVF reader code to separate file; move some more string implementation from com::UTF8Str to iprt::MiniString

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 KB
Line 
1/* $Id: ApplianceImpl.h 21588 2009-07-14 16:22:06Z 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
29namespace xml
30{
31 class Node;
32 class ElementNode;
33}
34
35class VirtualBox;
36class Progress;
37
38class ATL_NO_VTABLE Appliance :
39 public VirtualBoxBaseWithChildrenNEXT,
40 public VirtualBoxSupportErrorInfoImpl <Appliance, IAppliance>,
41 public VirtualBoxSupportTranslation <Appliance>,
42 VBOX_SCRIPTABLE_IMPL(IAppliance)
43{
44public:
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 COM_INTERFACE_ENTRY(IDispatch)
55 END_COM_MAP()
56
57 NS_DECL_ISUPPORTS
58
59 DECLARE_EMPTY_CTOR_DTOR (Appliance)
60
61 // public initializer/uninitializer for internal purposes only
62 HRESULT FinalConstruct() { return S_OK; }
63 void FinalRelease() { uninit(); }
64
65 HRESULT init(VirtualBox *aVirtualBox);
66 void uninit();
67
68 // for VirtualBoxSupportErrorInfoImpl
69 static const wchar_t *getComponentName() { return L"Appliance"; }
70
71 /* IAppliance properties */
72 STDMETHOD(COMGETTER(Path))(BSTR *aPath);
73 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
74 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
75
76 /* IAppliance methods */
77 /* Import methods */
78 STDMETHOD(Read)(IN_BSTR path);
79 STDMETHOD(Interpret)(void);
80 STDMETHOD(ImportMachines)(IProgress **aProgress);
81 /* Export methods */
82 STDMETHOD(CreateVFSExplorer)(IN_BSTR aURI, IVFSExplorer **aExplorer);
83 STDMETHOD(Write)(IN_BSTR format, IN_BSTR path, IProgress **aProgress);
84
85 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
86
87 /* public methods only for internal purposes */
88
89 /* private instance data */
90private:
91 /** weak VirtualBox parent */
92 const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
93
94 struct Data; // opaque, defined in ApplianceImpl.cpp
95 Data *m;
96
97 HRESULT searchUniqueVMName(Utf8Str& aName) const;
98 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
99 HRESULT setUpProgress(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
100 HRESULT setUpProgressUpload(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
101 void waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, ComPtr<IProgress> &pProgressAsync);
102 void addWarning(const char* aWarning, ...);
103
104 void parseURI(Utf8Str strUri, const Utf8Str &strProtocol, Utf8Str &strFilepath, Utf8Str &strHostname, Utf8Str &strUsername, Utf8Str &strPassword);
105 HRESULT writeImpl(int aFormat, const Utf8Str &aPath, ComObjPtr<Progress> &aProgress);
106
107 struct TaskImportMachines; /* Worker thread for import */
108 static DECLCALLBACK(int) taskThreadImportMachines(RTTHREAD thread, void *pvUser);
109
110 struct TaskWriteOVF; /* Worker threads for export */
111 static DECLCALLBACK(int) taskThreadWriteOVF(RTTHREAD aThread, void *pvUser);
112
113 int writeFS(TaskWriteOVF *pTask);
114 int writeS3(TaskWriteOVF *pTask);
115
116 friend class Machine;
117};
118
119struct VirtualSystemDescriptionEntry
120{
121 uint32_t ulIndex; // zero-based index of this entry within array
122 VirtualSystemDescriptionType_T type; // type of this entry
123 Utf8Str strRef; // reference number (hard disk controllers only)
124 Utf8Str strOvf; // original OVF value (type-dependent)
125 Utf8Str strVbox; // configuration value (type-dependent)
126 Utf8Str strExtraConfig; // extra configuration key=value strings (type-dependent)
127
128 uint32_t ulSizeMB; // hard disk images only: size of the uncompressed image in MB
129};
130
131class ATL_NO_VTABLE VirtualSystemDescription :
132 public VirtualBoxBaseWithChildrenNEXT,
133 public VirtualBoxSupportErrorInfoImpl <VirtualSystemDescription, IVirtualSystemDescription>,
134 public VirtualBoxSupportTranslation <VirtualSystemDescription>,
135 VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription)
136{
137 friend class Appliance;
138
139public:
140 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
141
142 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
143
144 DECLARE_PROTECT_FINAL_CONSTRUCT()
145
146 BEGIN_COM_MAP(VirtualSystemDescription)
147 COM_INTERFACE_ENTRY(ISupportErrorInfo)
148 COM_INTERFACE_ENTRY(IVirtualSystemDescription)
149 END_COM_MAP()
150
151 NS_DECL_ISUPPORTS
152
153 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
154
155 // public initializer/uninitializer for internal purposes only
156 HRESULT FinalConstruct() { return S_OK; }
157 void FinalRelease() { uninit(); }
158
159 HRESULT init();
160 void uninit();
161
162 // for VirtualBoxSupportErrorInfoImpl
163 static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
164
165 /* IVirtualSystemDescription properties */
166 STDMETHOD(COMGETTER(Count))(ULONG *aCount);
167
168 /* IVirtualSystemDescription methods */
169 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
170 ComSafeArrayOut(BSTR, aRefs),
171 ComSafeArrayOut(BSTR, aOvfValues),
172 ComSafeArrayOut(BSTR, aVboxValues),
173 ComSafeArrayOut(BSTR, aExtraConfigValues));
174
175 STDMETHOD(GetDescriptionByType)(VirtualSystemDescriptionType_T aType,
176 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
177 ComSafeArrayOut(BSTR, aRefs),
178 ComSafeArrayOut(BSTR, aOvfValues),
179 ComSafeArrayOut(BSTR, aVboxValues),
180 ComSafeArrayOut(BSTR, aExtraConfigValues));
181
182 STDMETHOD(GetValuesByType)(VirtualSystemDescriptionType_T aType,
183 VirtualSystemDescriptionValueType_T aWhich,
184 ComSafeArrayOut(BSTR, aValues));
185
186 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
187 ComSafeArrayIn(IN_BSTR, aVboxValues),
188 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
189
190 STDMETHOD(AddDescription)(VirtualSystemDescriptionType_T aType,
191 IN_BSTR aVboxValue,
192 IN_BSTR aExtraConfigValue);
193
194 /* public methods only for internal purposes */
195
196 void addEntry(VirtualSystemDescriptionType_T aType,
197 const Utf8Str &strRef,
198 const Utf8Str &aOrigValue,
199 const Utf8Str &aAutoValue,
200 uint32_t ulSizeMB = 0,
201 const Utf8Str &strExtraConfig = "");
202
203 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
204 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
205
206 /* private instance data */
207private:
208 struct Data;
209 Data *m;
210
211 friend class Machine;
212};
213
214#endif // ____H_APPLIANCEIMPL
215/* 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