BIOSSettingsImpl.cpp revision 26d2a42f095ded346df2e41cc4837cb426b4753a
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync/** @file
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync *
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * VirtualBox COM class implementation
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync */
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync/*
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync *
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * available from http://www.virtualbox.org. This file is free software;
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync *
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * additional information or have any questions.
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync */
f84cd77241a1c4b9106a92280611c659243e10d1vboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync#include "BIOSSettingsImpl.h"
73c74bb1e8e8a8c2f26c69cb20f7666fcb72b1f0vboxsync#include "MachineImpl.h"
d31ded334a29f575e23dc889b603b1a586759348vboxsync#include "Logging.h"
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync#include <iprt/cpputils.h>
d31ded334a29f575e23dc889b603b1a586759348vboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync// constructor / destructor
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync/////////////////////////////////////////////////////////////////////////////
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
209c11e4b5dbb310116c99a42d773163928e002bvboxsyncHRESULT BIOSSettings::FinalConstruct()
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync{
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync return S_OK;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync}
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsyncvoid BIOSSettings::FinalRelease()
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync{
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync uninit ();
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync}
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync// public initializer/uninitializer for internal purposes only
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync/////////////////////////////////////////////////////////////////////////////
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync/**
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync * Initializes the audio adapter object.
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync *
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync * @returns COM result indicator
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync */
289060a0c3cb1d509f2cb01fca060796212376f6vboxsyncHRESULT BIOSSettings::init (Machine *aParent)
289060a0c3cb1d509f2cb01fca060796212376f6vboxsync{
289060a0c3cb1d509f2cb01fca060796212376f6vboxsync LogFlowThisFuncEnter();
289060a0c3cb1d509f2cb01fca060796212376f6vboxsync LogFlowThisFunc (("aParent: %p\n", aParent));
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync ComAssertRet (aParent, E_INVALIDARG);
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync /* Enclose the state transition NotReady->InInit->Ready */
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync AutoInitSpan autoInitSpan (this);
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync AssertReturn (autoInitSpan.isOk(), E_FAIL);
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync /* share the parent weakly */
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync unconst (mParent) = aParent;
faf968cea88f2ab4bcc3325b17bc8b095a8e3642vboxsync
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync mData.allocate();
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync autoInitSpan.setSucceeded();
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
faf968cea88f2ab4bcc3325b17bc8b095a8e3642vboxsync LogFlowThisFuncLeave();
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync return S_OK;
faf968cea88f2ab4bcc3325b17bc8b095a8e3642vboxsync}
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync/**
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * Initializes the audio adapter object given another audio adapter object
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * (a kind of copy constructor). This object shares data with
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * the object passed as an argument.
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync *
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * @note This object must be destroyed before the original object
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * it shares data with is destroyed.
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync */
ff78b877ed7acd25e2d384570a938441455d6a95vboxsyncHRESULT BIOSSettings::init (Machine *aParent, BIOSSettings *that)
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync{
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync LogFlowThisFuncEnter();
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync ComAssertRet (aParent && that, E_INVALIDARG);
f94f82d66536c7332c347dd9a3a9f0f8c79247f4vboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync /* Enclose the state transition NotReady->InInit->Ready */
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync AutoInitSpan autoInitSpan (this);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync AssertReturn (autoInitSpan.isOk(), E_FAIL);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync mParent = aParent;
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync mPeer = that;
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync AutoWriteLock thatlock (that);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync mData.share (that->mData);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync autoInitSpan.setSucceeded();
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync LogFlowThisFuncLeave();
0d4bc23ca3867d6dbedd76d5b1e3725c766adb75vboxsync return S_OK;
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync}
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync/**
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * Initializes the guest object given another guest object
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * (a kind of copy constructor). This object makes a private copy of data
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * of the original object passed as an argument.
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync */
ff78b877ed7acd25e2d384570a938441455d6a95vboxsyncHRESULT BIOSSettings::initCopy (Machine *aParent, BIOSSettings *that)
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync{
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync LogFlowThisFuncEnter();
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync ComAssertRet (aParent && that, E_INVALIDARG);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync /* Enclose the state transition NotReady->InInit->Ready */
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync AutoInitSpan autoInitSpan (this);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync AssertReturn (autoInitSpan.isOk(), E_FAIL);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync mParent = aParent;
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync // mPeer is left null
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync AutoWriteLock thatlock (that);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync mData.attachCopy (that->mData);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync autoInitSpan.setSucceeded();
f94f82d66536c7332c347dd9a3a9f0f8c79247f4vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync LogFlowThisFuncLeave();
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync return S_OK;
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync}
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync/**
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * Uninitializes the instance and sets the ready flag to FALSE.
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync * Called either from FinalRelease() or by the parent when it gets destroyed.
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync */
ff78b877ed7acd25e2d384570a938441455d6a95vboxsyncvoid BIOSSettings::uninit()
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync{
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync LogFlowThisFuncEnter();
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync /* Enclose the state transition Ready->InUninit->NotReady */
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync AutoUninitSpan autoUninitSpan (this);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync if (autoUninitSpan.uninitDone())
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync return;
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync mData.free();
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync mPeer.setNull();
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync mParent.setNull();
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync LogFlowThisFuncLeave();
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync}
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync// IBIOSSettings properties
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync/////////////////////////////////////////////////////////////////////////////
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsyncSTDMETHODIMP BIOSSettings::COMGETTER(LogoFadeIn)(BOOL *enabled)
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync{
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync if (!enabled)
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync return E_POINTER;
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync AutoCaller autoCaller (this);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync CheckComRCReturnRC (autoCaller.rc());
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync AutoReadLock alock (this);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync *enabled = mData->mLogoFadeIn;
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync return S_OK;
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync}
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsyncSTDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync{
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync AutoCaller autoCaller (this);
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync CheckComRCReturnRC (autoCaller.rc());
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync /* the machine needs to be mutable */
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync Machine::AutoMutableStateDependency adep (mParent);
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync CheckComRCReturnRC (adep.rc());
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync AutoWriteLock alock (this);
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync mData.backup();
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync mData->mLogoFadeIn = enable;
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync return S_OK;
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync}
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsyncSTDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync{
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync if (!enabled)
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync return E_POINTER;
30868e719f5a45ec4689ecb2616767cb1fd02c28vboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync AutoCaller autoCaller (this);
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync CheckComRCReturnRC (autoCaller.rc());
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoReadLock alock (this);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync *enabled = mData->mLogoFadeOut;
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync return S_OK;
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync}
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsyncSTDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync{
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoCaller autoCaller (this);
c7ff622115966b69b482bd2896662e40d823b22fvboxsync CheckComRCReturnRC (autoCaller.rc());
c7ff622115966b69b482bd2896662e40d823b22fvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync /* the machine needs to be mutable */
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync Machine::AutoMutableStateDependency adep (mParent);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync CheckComRCReturnRC (adep.rc());
853e60357f021457980af0726d25a40ecd3c0107vboxsync
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync AutoWriteLock alock (this);
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync mData.backup();
289060a0c3cb1d509f2cb01fca060796212376f6vboxsync mData->mLogoFadeOut = enable;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync return S_OK;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync}
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsyncSTDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync{
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync if (!displayTime)
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync return E_POINTER;
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoCaller autoCaller (this);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync CheckComRCReturnRC (autoCaller.rc());
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoReadLock alock (this);
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync *displayTime = mData->mLogoDisplayTime;
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync return S_OK;
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync}
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsyncSTDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync{
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoCaller autoCaller (this);
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync CheckComRCReturnRC (autoCaller.rc());
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync /* the machine needs to be mutable */
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync Machine::AutoMutableStateDependency adep (mParent);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync CheckComRCReturnRC (adep.rc());
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoWriteLock alock (this);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync mData.backup();
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync mData->mLogoDisplayTime = displayTime;
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync return S_OK;
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync}
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsyncSTDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync{
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync if (!imagePath)
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync return E_POINTER;
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoCaller autoCaller (this);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync CheckComRCReturnRC (autoCaller.rc());
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoReadLock alock (this);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync mData->mLogoImagePath.cloneTo(imagePath);
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync return S_OK;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync}
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
0bc7c910e57c78c68e89122e2244cc073d1ef06evboxsyncSTDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(INPTR BSTR imagePath)
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync{
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync /* empty strings are not allowed as path names */
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync if (imagePath && !(*imagePath))
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync return E_INVALIDARG;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync AutoCaller autoCaller (this);
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync CheckComRCReturnRC (autoCaller.rc());
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync /* the machine needs to be mutable */
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync Machine::AutoMutableStateDependency adep (mParent);
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync CheckComRCReturnRC (adep.rc());
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync AutoWriteLock alock (this);
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync mData.backup();
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync mData->mLogoImagePath = imagePath;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync return S_OK;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync}
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsyncSTDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
0bc7c910e57c78c68e89122e2244cc073d1ef06evboxsync{
0bc7c910e57c78c68e89122e2244cc073d1ef06evboxsync if (!bootMenuMode)
0bc7c910e57c78c68e89122e2244cc073d1ef06evboxsync return E_POINTER;
0bc7c910e57c78c68e89122e2244cc073d1ef06evboxsync
0bc7c910e57c78c68e89122e2244cc073d1ef06evboxsync AutoCaller autoCaller (this);
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync CheckComRCReturnRC (autoCaller.rc());
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync AutoReadLock alock (this);
3c941112ffb137d71a8e457fcc3915f2d464ed2avboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync *bootMenuMode = mData->mBootMenuMode;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync return S_OK;
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync}
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
3c941112ffb137d71a8e457fcc3915f2d464ed2avboxsyncSTDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
3c941112ffb137d71a8e457fcc3915f2d464ed2avboxsync{
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync AutoCaller autoCaller (this);
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync CheckComRCReturnRC (autoCaller.rc());
3c941112ffb137d71a8e457fcc3915f2d464ed2avboxsync
3c941112ffb137d71a8e457fcc3915f2d464ed2avboxsync /* the machine needs to be mutable */
3c941112ffb137d71a8e457fcc3915f2d464ed2avboxsync Machine::AutoMutableStateDependency adep (mParent);
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync CheckComRCReturnRC (adep.rc());
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync AutoWriteLock alock (this);
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync mData.backup();
6f516ad9911d9037a18778742caa955fe362f8ffvboxsync mData->mBootMenuMode = bootMenuMode;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
{
if (!enabled)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
AutoReadLock alock (this);
*enabled = mData->mACPIEnabled;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
{
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* the machine needs to be mutable */
Machine::AutoMutableStateDependency adep (mParent);
CheckComRCReturnRC (adep.rc());
AutoWriteLock alock (this);
mData.backup();
mData->mACPIEnabled = enable;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
{
if (!enabled)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
AutoReadLock alock (this);
*enabled = mData->mIOAPICEnabled;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
{
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* the machine needs to be mutable */
Machine::AutoMutableStateDependency adep (mParent);
CheckComRCReturnRC (adep.rc());
AutoWriteLock alock (this);
mData.backup();
mData->mIOAPICEnabled = enable;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMGETTER(PXEDebugEnabled)(BOOL *enabled)
{
if (!enabled)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
AutoReadLock alock (this);
*enabled = mData->mPXEDebugEnabled;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMSETTER(PXEDebugEnabled)(BOOL enable)
{
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* the machine needs to be mutable */
Machine::AutoMutableStateDependency adep (mParent);
CheckComRCReturnRC (adep.rc());
AutoWriteLock alock (this);
mData.backup();
mData->mPXEDebugEnabled = enable;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMGETTER(IDEControllerType)(IDEControllerType_T *aControllerType)
{
if (!aControllerType)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
AutoReadLock alock (this);
*aControllerType = mData->mIDEControllerType;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMSETTER(IDEControllerType)(IDEControllerType_T aControllerType)
{
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* the machine needs to be mutable */
Machine::AutoMutableStateDependency adep (mParent);
CheckComRCReturnRC (adep.rc());
AutoWriteLock alock (this);
/* make sure the value is allowed */
switch (aControllerType)
{
case IDEControllerType_PIIX3:
case IDEControllerType_PIIX4:
break;
default:
return setError (E_INVALIDARG,
tr("Invalid IDE controller type '%d'"),
aControllerType);
}
mData.backup();
mData->mIDEControllerType = aControllerType;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
{
if (!offset)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
AutoReadLock alock (this);
*offset = mData->mTimeOffset;
return S_OK;
}
STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
{
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
/* the machine needs to be mutable */
Machine::AutoMutableStateDependency adep (mParent);
CheckComRCReturnRC (adep.rc());
AutoWriteLock alock (this);
mData.backup();
mData->mTimeOffset = offset;
return S_OK;
}
// IBIOSSettings methods
/////////////////////////////////////////////////////////////////////////////
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
/**
* Loads settings from the given machine node.
* May be called once right after this object creation.
*
* @param aMachineNode <Machine> node.
*
* @note Locks this object for writing.
*/
HRESULT BIOSSettings::loadSettings (const settings::Key &aMachineNode)
{
using namespace settings;
AssertReturn (!aMachineNode.isNull(), E_FAIL);
AutoCaller autoCaller (this);
AssertComRCReturnRC (autoCaller.rc());
AutoWriteLock alock (this);
/* Note: we assume that the default values for attributes of optional
* nodes are assigned in the Data::Data() constructor and don't do it
* here. It implies that this method may only be called after constructing
* a new BIOSSettings object while all its data fields are in the default
* values. Exceptions are fields whose creation time defaults don't match
* values that should be applied when these fields are not explicitly set
* in the settings file (for backwards compatibility reasons). This takes
* place when a setting of a newly created object must default to A while
* the same setting of an object loaded from the old settings file must
* default to B. */
/* BIOS node (required) */
Key biosNode = aMachineNode.key ("BIOS");
/* ACPI (required) */
{
Key acpiNode = biosNode.key ("ACPI");
mData->mACPIEnabled = acpiNode.value <bool> ("enabled");
}
/* IOAPIC (optional) */
{
Key ioapicNode = biosNode.findKey ("IOAPIC");
if (!ioapicNode.isNull())
mData->mIOAPICEnabled = ioapicNode.value <bool> ("enabled");
}
/* Logo (optional) */
{
Key logoNode = biosNode.findKey ("Logo");
if (!logoNode.isNull())
{
mData->mLogoFadeIn = logoNode.value <bool> ("fadeIn");
mData->mLogoFadeOut = logoNode.value <bool> ("fadeOut");
mData->mLogoDisplayTime = logoNode.value <ULONG> ("displayTime");
mData->mLogoImagePath = logoNode.stringValue ("imagePath");
}
}
/* boot menu (optional) */
{
Key bootMenuNode = biosNode.findKey ("BootMenu");
if (!bootMenuNode.isNull())
{
mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
const char *modeStr = bootMenuNode.stringValue ("mode");
if (strcmp (modeStr, "Disabled") == 0)
mData->mBootMenuMode = BIOSBootMenuMode_Disabled;
else if (strcmp (modeStr, "MenuOnly") == 0)
mData->mBootMenuMode = BIOSBootMenuMode_MenuOnly;
else if (strcmp (modeStr, "MessageAndMenu") == 0)
mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
else
ComAssertMsgFailedRet (("Invalid boot menu mode '%s'\n", modeStr),
E_FAIL);
}
}
/* PXE debug logging (optional) */
{
Key pxedebugNode = biosNode.findKey ("PXEDebug");
if (!pxedebugNode.isNull())
mData->mPXEDebugEnabled = pxedebugNode.value <bool> ("enabled");
}
/* time offset (optional) */
{
Key timeOffsetNode = biosNode.findKey ("TimeOffset");
if (!timeOffsetNode.isNull())
mData->mTimeOffset = timeOffsetNode.value <LONG64> ("value");
}
/* IDE controller type (optional, for old machines that lack this node,
* defaults to PIIX3) */
{
mData->mIDEControllerType = IDEControllerType_PIIX3;
Key ideControllerNode = biosNode.findKey ("IDEController");
if (!ideControllerNode.isNull())
{
const char *typeStr = ideControllerNode.stringValue ("type");
if (strcmp (typeStr, "PIIX3") == 0)
mData->mIDEControllerType = IDEControllerType_PIIX3;
else if (strcmp (typeStr, "PIIX4") == 0)
mData->mIDEControllerType = IDEControllerType_PIIX4;
else
ComAssertMsgFailedRet (("Invalid boot menu mode '%s'\n", typeStr),
E_FAIL);
}
}
return S_OK;
}
/**
* Saves settings to the given machine node.
*
* @param aMachineNode <Machine> node.
*
* @note Locks this object for reading.
*/
HRESULT BIOSSettings::saveSettings (settings::Key &aMachineNode)
{
using namespace settings;
AssertReturn (!aMachineNode.isNull(), E_FAIL);
AutoCaller autoCaller (this);
AssertComRCReturnRC (autoCaller.rc());
AutoReadLock alock (this);
Key biosNode = aMachineNode.createKey ("BIOS");
/* ACPI */
{
Key acpiNode = biosNode.createKey ("ACPI");
acpiNode.setValue <bool> ("enabled", !!mData->mACPIEnabled);
}
/* IOAPIC */
{
Key ioapicNode = biosNode.createKey ("IOAPIC");
ioapicNode.setValue <bool> ("enabled", !!mData->mIOAPICEnabled);
}
/* BIOS logo (optional) **/
{
Key logoNode = biosNode.createKey ("Logo");
logoNode.setValue <bool> ("fadeIn", !!mData->mLogoFadeIn);
logoNode.setValue <bool> ("fadeOut", !!mData->mLogoFadeOut);
logoNode.setValue <ULONG> ("displayTime", mData->mLogoDisplayTime);
logoNode.setValueOr <Bstr> ("imagePath", mData->mLogoImagePath, Bstr::Null);
}
/* boot menu (optional) */
{
Key bootMenuNode = biosNode.createKey ("BootMenu");
const char *modeStr = NULL;
switch (mData->mBootMenuMode)
{
case BIOSBootMenuMode_Disabled:
modeStr = "Disabled";
break;
case BIOSBootMenuMode_MenuOnly:
modeStr = "MenuOnly";
break;
case BIOSBootMenuMode_MessageAndMenu:
modeStr = "MessageAndMenu";
break;
default:
ComAssertMsgFailedRet (("Invalid boot menu type: %d\n",
mData->mBootMenuMode),
E_FAIL);
}
bootMenuNode.setStringValue ("mode", modeStr);
}
/* time offset (optional) */
{
Key timeOffsetNode = biosNode.createKey ("TimeOffset");
timeOffsetNode.setValue <LONG64> ("value", mData->mTimeOffset);
}
/* PXE debug flag (optional) */
{
Key pxedebugNode = biosNode.createKey ("PXEDebug");
pxedebugNode.setValue <bool> ("enabled", !!mData->mPXEDebugEnabled);
}
/* IDE controller type */
{
Key ideControllerNode = biosNode.createKey ("IDEController");
const char *ideControllerTypeStr = NULL;
switch (mData->mIDEControllerType)
{
case IDEControllerType_PIIX3:
ideControllerTypeStr = "PIIX3";
break;
case IDEControllerType_PIIX4:
ideControllerTypeStr = "PIIX4";
break;
default:
ComAssertMsgFailedRet (("Invalid IDE Controller type: %d\n",
mData->mIDEControllerType),
E_FAIL);
}
ideControllerNode.setStringValue ("type", ideControllerTypeStr);
}
return S_OK;
}
void BIOSSettings::commit()
{
AutoWriteLock alock (this);
if (mData.isBackedUp())
{
mData.commit();
if (mPeer)
{
// attach new data to the peer and re-share it
AutoWriteLock peerlock (mPeer);
mPeer->mData.attach (mData);
}
}
}
void BIOSSettings::copyFrom (BIOSSettings *aThat)
{
AutoWriteLock alock (this);
// this will back up current data
mData.assignCopy (aThat->mData);
}