VirtualBox

source: vbox/trunk/src/VBox/Main/BIOSSettingsImpl.cpp@ 633

Last change on this file since 633 was 1, checked in by vboxsync, 55 years ago

import

File size: 9.1 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#include "BIOSSettingsImpl.h"
23#include "MachineImpl.h"
24#include "Logging.h"
25
26// constructor / destructor
27/////////////////////////////////////////////////////////////////////////////
28
29HRESULT BIOSSettings::FinalConstruct()
30{
31 return S_OK;
32}
33
34void BIOSSettings::FinalRelease()
35{
36 uninit ();
37}
38
39// public initializer/uninitializer for internal purposes only
40/////////////////////////////////////////////////////////////////////////////
41
42/**
43 * Initializes the audio adapter object.
44 *
45 * @returns COM result indicator
46 */
47HRESULT BIOSSettings::init (Machine *aParent)
48{
49 LogFlowThisFuncEnter();
50 LogFlowThisFunc (("aParent: %p\n", aParent));
51
52 ComAssertRet (aParent, E_INVALIDARG);
53
54 /* Enclose the state transition NotReady->InInit->Ready */
55 AutoInitSpan autoInitSpan (this);
56 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
57
58 /* share the parent weakly */
59 unconst (mParent) = aParent;
60
61 mData.allocate();
62
63 autoInitSpan.setSucceeded();
64
65 LogFlowThisFuncLeave();
66 return S_OK;
67}
68
69/**
70 * Initializes the audio adapter object given another audio adapter object
71 * (a kind of copy constructor). This object shares data with
72 * the object passed as an argument.
73 *
74 * @note This object must be destroyed before the original object
75 * it shares data with is destroyed.
76 */
77HRESULT BIOSSettings::init (Machine *aParent, BIOSSettings *that)
78{
79 LogFlowThisFuncEnter();
80 LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
81
82 ComAssertRet (aParent && that, E_INVALIDARG);
83
84 /* Enclose the state transition NotReady->InInit->Ready */
85 AutoInitSpan autoInitSpan (this);
86 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
87
88 mParent = aParent;
89 mPeer = that;
90
91 AutoLock thatlock (that);
92 mData.share (that->mData);
93
94 autoInitSpan.setSucceeded();
95
96 LogFlowThisFuncLeave();
97 return S_OK;
98}
99
100/**
101 * Initializes the guest object given another guest object
102 * (a kind of copy constructor). This object makes a private copy of data
103 * of the original object passed as an argument.
104 */
105HRESULT BIOSSettings::initCopy (Machine *aParent, BIOSSettings *that)
106{
107 LogFlowThisFuncEnter();
108 LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
109
110 ComAssertRet (aParent && that, E_INVALIDARG);
111
112 /* Enclose the state transition NotReady->InInit->Ready */
113 AutoInitSpan autoInitSpan (this);
114 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
115
116 mParent = aParent;
117 // mPeer is left null
118
119 AutoLock thatlock (that);
120 mData.attachCopy (that->mData);
121
122 autoInitSpan.setSucceeded();
123
124 LogFlowThisFuncLeave();
125 return S_OK;
126}
127
128/**
129 * Uninitializes the instance and sets the ready flag to FALSE.
130 * Called either from FinalRelease() or by the parent when it gets destroyed.
131 */
132void BIOSSettings::uninit()
133{
134 LogFlowThisFuncEnter();
135
136 /* Enclose the state transition Ready->InUninit->NotReady */
137 AutoUninitSpan autoUninitSpan (this);
138 if (autoUninitSpan.uninitDone())
139 return;
140
141 mData.free();
142
143 mPeer.setNull();
144 mParent.setNull();
145
146 LogFlowThisFuncLeave();
147}
148
149// IBIOSSettings properties
150/////////////////////////////////////////////////////////////////////////////
151
152STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeIn)(BOOL *enabled)
153{
154 if (!enabled)
155 return E_POINTER;
156
157 AutoCaller autoCaller (this);
158 CheckComRCReturnRC (autoCaller.rc());
159
160 AutoReaderLock alock (this);
161
162 *enabled = mData->mLogoFadeIn;
163
164 return S_OK;
165}
166
167STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
168{
169 AutoCaller autoCaller (this);
170 CheckComRCReturnRC (autoCaller.rc());
171
172 AutoLock alock (this);
173
174 CHECK_MACHINE_MUTABILITY (mParent);
175
176 mData.backup();
177 mData->mLogoFadeIn = enable;
178
179 return S_OK;
180}
181
182STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
183{
184 if (!enabled)
185 return E_POINTER;
186
187 AutoCaller autoCaller (this);
188 CheckComRCReturnRC (autoCaller.rc());
189
190 AutoReaderLock alock (this);
191
192 *enabled = mData->mLogoFadeOut;
193
194 return S_OK;
195}
196
197STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
198{
199 AutoCaller autoCaller (this);
200 CheckComRCReturnRC (autoCaller.rc());
201
202 AutoLock alock (this);
203
204 CHECK_MACHINE_MUTABILITY (mParent);
205
206 mData.backup();
207 mData->mLogoFadeOut = enable;
208
209 return S_OK;
210}
211
212STDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
213{
214 if (!displayTime)
215 return E_POINTER;
216
217 AutoCaller autoCaller (this);
218 CheckComRCReturnRC (autoCaller.rc());
219
220 AutoReaderLock alock (this);
221
222 *displayTime = mData->mLogoDisplayTime;
223
224 return S_OK;
225}
226
227STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
228{
229 AutoCaller autoCaller (this);
230 CheckComRCReturnRC (autoCaller.rc());
231
232 AutoLock alock (this);
233
234 CHECK_MACHINE_MUTABILITY (mParent);
235
236 mData.backup();
237 mData->mLogoDisplayTime = displayTime;
238
239 return S_OK;
240}
241
242STDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
243{
244 if (!imagePath)
245 return E_POINTER;
246
247 AutoCaller autoCaller (this);
248 CheckComRCReturnRC (autoCaller.rc());
249
250 AutoReaderLock alock (this);
251
252 mData->mLogoImagePath.cloneTo(imagePath);
253 return S_OK;
254}
255
256STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(INPTR BSTR imagePath)
257{
258 /* empty strings are not allowed as path names */
259 if (imagePath && !(*imagePath))
260 return E_INVALIDARG;
261
262 AutoCaller autoCaller (this);
263 CheckComRCReturnRC (autoCaller.rc());
264
265 AutoLock alock (this);
266
267 CHECK_MACHINE_MUTABILITY (mParent);
268
269 mData.backup();
270 mData->mLogoImagePath = imagePath;
271
272 return S_OK;
273}
274
275STDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
276{
277 if (!bootMenuMode)
278 return E_POINTER;
279
280 AutoCaller autoCaller (this);
281 CheckComRCReturnRC (autoCaller.rc());
282
283 AutoReaderLock alock (this);
284
285 *bootMenuMode = mData->mBootMenuMode;
286 return S_OK;
287}
288
289STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
290{
291 AutoCaller autoCaller (this);
292 CheckComRCReturnRC (autoCaller.rc());
293
294 AutoLock alock (this);
295
296 CHECK_MACHINE_MUTABILITY (mParent);
297
298 mData.backup();
299 mData->mBootMenuMode = bootMenuMode;
300
301 return S_OK;
302}
303
304STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
305{
306 if (!enabled)
307 return E_POINTER;
308
309 AutoCaller autoCaller (this);
310 CheckComRCReturnRC (autoCaller.rc());
311
312 AutoReaderLock alock (this);
313
314 *enabled = mData->mACPIEnabled;
315
316 return S_OK;
317}
318
319STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
320{
321 AutoCaller autoCaller (this);
322 CheckComRCReturnRC (autoCaller.rc());
323
324 AutoLock alock (this);
325
326 CHECK_MACHINE_MUTABILITY (mParent);
327
328 mData.backup();
329 mData->mACPIEnabled = enable;
330
331 return S_OK;
332}
333
334STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
335{
336 if (!enabled)
337 return E_POINTER;
338
339 AutoCaller autoCaller (this);
340 CheckComRCReturnRC (autoCaller.rc());
341
342 AutoReaderLock alock (this);
343
344 *enabled = mData->mIOAPICEnabled;
345
346 return S_OK;
347}
348
349STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
350{
351 AutoCaller autoCaller (this);
352 CheckComRCReturnRC (autoCaller.rc());
353
354 AutoLock alock (this);
355
356 CHECK_MACHINE_MUTABILITY (mParent);
357
358 mData.backup();
359 mData->mIOAPICEnabled = enable;
360
361 return S_OK;
362}
363
364// IBIOSSettings methods
365/////////////////////////////////////////////////////////////////////////////
366
367// public methods only for internal purposes
368/////////////////////////////////////////////////////////////////////////////
369
370void BIOSSettings::commit()
371{
372 AutoLock alock (this);
373 if (mData.isBackedUp())
374 {
375 mData.commit();
376 if (mPeer)
377 {
378 // attach new data to the peer and reshare it
379 AutoLock peerlock (mPeer);
380 mPeer->mData.attach (mData);
381 }
382 }
383}
384
385void BIOSSettings::copyFrom (BIOSSettings *aThat)
386{
387 AutoLock alock (this);
388
389 // this will back up current data
390 mData.assignCopy (aThat->mData);
391}
392
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