[1] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VirtualBox COM class implementation
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[8155] | 7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
[1] | 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
|
---|
[5999] | 12 | * General Public License (GPL) as published by the Free Software
|
---|
| 13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
[8155] | 16 | *
|
---|
| 17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
| 18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
| 19 | * additional information or have any questions.
|
---|
[1] | 20 | */
|
---|
| 21 |
|
---|
| 22 | #include "GuestOSTypeImpl.h"
|
---|
| 23 | #include "Logging.h"
|
---|
[3007] | 24 | #include <iprt/cpputils.h>
|
---|
[1] | 25 |
|
---|
| 26 | // constructor / destructor
|
---|
| 27 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 28 |
|
---|
| 29 | GuestOSType::GuestOSType()
|
---|
[7233] | 30 | : mOSType (VBOXOSTYPE_Unknown)
|
---|
[2567] | 31 | , mRAMSize (0), mVRAMSize (0)
|
---|
| 32 | , mHDDSize (0), mMonitorCount (0)
|
---|
[1] | 33 | {
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | GuestOSType::~GuestOSType()
|
---|
| 37 | {
|
---|
| 38 | }
|
---|
| 39 |
|
---|
[2567] | 40 | HRESULT GuestOSType::FinalConstruct()
|
---|
| 41 | {
|
---|
| 42 | return S_OK;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | void GuestOSType::FinalRelease()
|
---|
| 46 | {
|
---|
| 47 | uninit();
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[1] | 50 | // public initializer/uninitializer for internal purposes only
|
---|
| 51 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 52 |
|
---|
| 53 | /**
|
---|
| 54 | * Initializes the guest OS type object.
|
---|
| 55 | *
|
---|
| 56 | * @returns COM result indicator
|
---|
[2567] | 57 | * @param aId os short name string
|
---|
| 58 | * @param aDescription os name string
|
---|
| 59 | * @param aOSType global OS type ID
|
---|
| 60 | * @param aRAMSize recommended RAM size in megabytes
|
---|
| 61 | * @param aVRAMSize recommended video memory size in megabytes
|
---|
| 62 | * @param aHDDSize recommended HDD size in megabytes
|
---|
[1] | 63 | */
|
---|
[7233] | 64 | HRESULT GuestOSType::init (const char *aId, const char *aDescription, VBOXOSTYPE aOSType,
|
---|
[2567] | 65 | uint32_t aRAMSize, uint32_t aVRAMSize, uint32_t aHDDSize)
|
---|
[1] | 66 | {
|
---|
[2567] | 67 | LogFlowThisFunc (("aId='%s', aDescription='%s', aType=%d, "
|
---|
| 68 | "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%d\n",
|
---|
| 69 | aId, aDescription, aOSType,
|
---|
| 70 | aRAMSize, aVRAMSize, aHDDSize));
|
---|
[1] | 71 |
|
---|
[2567] | 72 | ComAssertRet (aId && aDescription, E_INVALIDARG);
|
---|
[1] | 73 |
|
---|
[2567] | 74 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
| 75 | AutoInitSpan autoInitSpan (this);
|
---|
| 76 | AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
|
---|
[1] | 77 |
|
---|
[2567] | 78 | unconst (mID) = aId;
|
---|
| 79 | unconst (mDescription) = aDescription;
|
---|
| 80 | unconst (mOSType) = aOSType;
|
---|
| 81 | unconst (mRAMSize) = aRAMSize;
|
---|
| 82 | unconst (mVRAMSize) = aVRAMSize;
|
---|
| 83 | unconst (mHDDSize) = aHDDSize;
|
---|
| 84 |
|
---|
| 85 | /* Confirm a successful initialization when it's the case */
|
---|
| 86 | autoInitSpan.setSucceeded();
|
---|
| 87 |
|
---|
[1] | 88 | return S_OK;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[2567] | 91 | /**
|
---|
| 92 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
| 93 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
| 94 | */
|
---|
| 95 | void GuestOSType::uninit()
|
---|
| 96 | {
|
---|
| 97 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
| 98 | AutoUninitSpan autoUninitSpan (this);
|
---|
| 99 | if (autoUninitSpan.uninitDone())
|
---|
| 100 | return;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
[1] | 103 | // IGuestOSType properties
|
---|
| 104 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 105 |
|
---|
[2567] | 106 | STDMETHODIMP GuestOSType::COMGETTER(Id) (BSTR *aId)
|
---|
[1] | 107 | {
|
---|
[2567] | 108 | if (!aId)
|
---|
[1] | 109 | return E_POINTER;
|
---|
| 110 |
|
---|
[2567] | 111 | AutoCaller autoCaller (this);
|
---|
| 112 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 113 |
|
---|
| 114 | /* mID is constant during life time, no need to lock */
|
---|
| 115 | mID.cloneTo (aId);
|
---|
| 116 |
|
---|
[1] | 117 | return S_OK;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
[2567] | 120 | STDMETHODIMP GuestOSType::COMGETTER(Description) (BSTR *aDescription)
|
---|
[1] | 121 | {
|
---|
[2567] | 122 | if (!aDescription)
|
---|
[1] | 123 | return E_POINTER;
|
---|
| 124 |
|
---|
[2567] | 125 | AutoCaller autoCaller (this);
|
---|
| 126 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 127 |
|
---|
| 128 | /* mDescription is constant during life time, no need to lock */
|
---|
| 129 | mDescription.cloneTo (aDescription);
|
---|
| 130 |
|
---|
[1] | 131 | return S_OK;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
[2567] | 134 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedRAM) (ULONG *aRAMSize)
|
---|
[1] | 135 | {
|
---|
[2567] | 136 | if (!aRAMSize)
|
---|
[1] | 137 | return E_POINTER;
|
---|
| 138 |
|
---|
[2567] | 139 | AutoCaller autoCaller (this);
|
---|
| 140 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 141 |
|
---|
| 142 | /* mRAMSize is constant during life time, no need to lock */
|
---|
| 143 | *aRAMSize = mRAMSize;
|
---|
| 144 |
|
---|
[1] | 145 | return S_OK;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
[2567] | 148 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedVRAM) (ULONG *aVRAMSize)
|
---|
[1] | 149 | {
|
---|
[2567] | 150 | if (!aVRAMSize)
|
---|
[1] | 151 | return E_POINTER;
|
---|
| 152 |
|
---|
[2567] | 153 | AutoCaller autoCaller (this);
|
---|
| 154 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 155 |
|
---|
| 156 | /* mVRAMSize is constant during life time, no need to lock */
|
---|
| 157 | *aVRAMSize = mVRAMSize;
|
---|
| 158 |
|
---|
[1] | 159 | return S_OK;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[2567] | 162 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedHDD) (ULONG *aHDDSize)
|
---|
[1] | 163 | {
|
---|
[2567] | 164 | if (!aHDDSize)
|
---|
[1] | 165 | return E_POINTER;
|
---|
| 166 |
|
---|
[2567] | 167 | AutoCaller autoCaller (this);
|
---|
| 168 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 169 |
|
---|
| 170 | /* mHDDSize is constant during life time, no need to lock */
|
---|
| 171 | *aHDDSize = mHDDSize;
|
---|
| 172 |
|
---|
[1] | 173 | return S_OK;
|
---|
| 174 | }
|
---|