VirtualBox

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

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

Main: make VBox interfaces scriptable (that is, callable from Python and VisualBasic)

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