[13607] | 1 | /* $Id: SystemPropertiesImpl.cpp 16560 2009-02-06 18:06:04Z vboxsync $ */
|
---|
[13606] | 2 |
|
---|
[1] | 3 | /** @file
|
---|
| 4 | *
|
---|
| 5 | * VirtualBox COM class implementation
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
[13606] | 9 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
[1] | 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
|
---|
[5999] | 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.
|
---|
[8155] | 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.
|
---|
[1] | 22 | */
|
---|
| 23 |
|
---|
| 24 | #include "SystemPropertiesImpl.h"
|
---|
| 25 | #include "VirtualBoxImpl.h"
|
---|
| 26 | #include "MachineImpl.h"
|
---|
| 27 | #include "Logging.h"
|
---|
| 28 |
|
---|
| 29 | // generated header
|
---|
| 30 | #include "SchemaDefs.h"
|
---|
| 31 |
|
---|
| 32 | #include <iprt/path.h>
|
---|
| 33 | #include <iprt/dir.h>
|
---|
[16560] | 34 |
|
---|
| 35 | #include <VBox/err.h>
|
---|
[16558] | 36 | #include <VBox/param.h>
|
---|
[16560] | 37 | #include <VBox/settings.h>
|
---|
[1] | 38 |
|
---|
| 39 | // defines
|
---|
| 40 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 41 |
|
---|
| 42 | // constructor / destructor
|
---|
| 43 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 44 |
|
---|
[13606] | 45 | DEFINE_EMPTY_CTOR_DTOR (SystemProperties)
|
---|
| 46 |
|
---|
[1] | 47 | HRESULT SystemProperties::FinalConstruct()
|
---|
| 48 | {
|
---|
| 49 | return S_OK;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | void SystemProperties::FinalRelease()
|
---|
| 53 | {
|
---|
[13606] | 54 | uninit ();
|
---|
[1] | 55 | }
|
---|
| 56 |
|
---|
| 57 | // public methods only for internal purposes
|
---|
| 58 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | * Initializes the system information object.
|
---|
| 62 | *
|
---|
| 63 | * @returns COM result indicator
|
---|
| 64 | */
|
---|
| 65 | HRESULT SystemProperties::init (VirtualBox *aParent)
|
---|
| 66 | {
|
---|
[13606] | 67 | LogFlowThisFunc (("aParent=%p\n", aParent));
|
---|
[1] | 68 |
|
---|
| 69 | ComAssertRet (aParent, E_FAIL);
|
---|
| 70 |
|
---|
[13606] | 71 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
| 72 | AutoInitSpan autoInitSpan (this);
|
---|
[14579] | 73 | AssertReturn (autoInitSpan.isOk(), E_FAIL);
|
---|
[1] | 74 |
|
---|
[13606] | 75 | unconst (mParent) = aParent;
|
---|
[1] | 76 |
|
---|
| 77 | setDefaultMachineFolder (NULL);
|
---|
[13580] | 78 | setDefaultHardDiskFolder (NULL);
|
---|
[14224] | 79 | setDefaultHardDiskFormat (NULL);
|
---|
| 80 |
|
---|
[1] | 81 | setRemoteDisplayAuthLibrary (NULL);
|
---|
| 82 |
|
---|
| 83 | mHWVirtExEnabled = false;
|
---|
[5150] | 84 | mLogHistoryCount = 3;
|
---|
[1] | 85 |
|
---|
[13580] | 86 | HRESULT rc = S_OK;
|
---|
| 87 |
|
---|
| 88 | /* Fetch info of all available hd backends. */
|
---|
| 89 |
|
---|
| 90 | /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
|
---|
| 91 | /// any number of backends
|
---|
| 92 |
|
---|
| 93 | /// @todo We currently leak memory because it's not actually clear what to
|
---|
| 94 | /// free in structures returned by VDBackendInfo. Must be fixed ASAP!
|
---|
| 95 |
|
---|
| 96 | VDBACKENDINFO aVDInfo [100];
|
---|
| 97 | unsigned cEntries;
|
---|
| 98 | int vrc = VDBackendInfo (RT_ELEMENTS (aVDInfo), aVDInfo, &cEntries);
|
---|
| 99 | AssertRC (vrc);
|
---|
[13835] | 100 | if (RT_SUCCESS (vrc))
|
---|
[13580] | 101 | {
|
---|
| 102 | for (unsigned i = 0; i < cEntries; ++ i)
|
---|
| 103 | {
|
---|
| 104 | ComObjPtr <HardDiskFormat> hdf;
|
---|
| 105 | rc = hdf.createObject();
|
---|
| 106 | CheckComRCBreakRC (rc);
|
---|
| 107 |
|
---|
| 108 | rc = hdf->init (&aVDInfo [i]);
|
---|
| 109 | CheckComRCBreakRC (rc);
|
---|
| 110 |
|
---|
| 111 | mHardDiskFormats.push_back (hdf);
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[13606] | 115 | /* Confirm a successful initialization */
|
---|
| 116 | if (SUCCEEDED (rc))
|
---|
| 117 | autoInitSpan.setSucceeded();
|
---|
[13580] | 118 |
|
---|
| 119 | return rc;
|
---|
[1] | 120 | }
|
---|
| 121 |
|
---|
| 122 | /**
|
---|
| 123 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
| 124 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
| 125 | */
|
---|
| 126 | void SystemProperties::uninit()
|
---|
| 127 | {
|
---|
[13606] | 128 | LogFlowThisFunc (("\n"));
|
---|
[1] | 129 |
|
---|
[13606] | 130 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
| 131 | AutoUninitSpan autoUninitSpan (this);
|
---|
| 132 | if (autoUninitSpan.uninitDone())
|
---|
| 133 | return;
|
---|
[1] | 134 |
|
---|
[13606] | 135 | unconst (mParent).setNull();
|
---|
[1] | 136 | }
|
---|
| 137 |
|
---|
| 138 | // ISystemProperties properties
|
---|
| 139 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestRAM)(ULONG *minRAM)
|
---|
| 143 | {
|
---|
| 144 | if (!minRAM)
|
---|
| 145 | return E_POINTER;
|
---|
| 146 |
|
---|
[13606] | 147 | AutoCaller autoCaller (this);
|
---|
| 148 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 149 |
|
---|
| 150 | /* no need to lock, this is const */
|
---|
[1] | 151 | *minRAM = SchemaDefs::MinGuestRAM;
|
---|
| 152 |
|
---|
| 153 | return S_OK;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestRAM)(ULONG *maxRAM)
|
---|
| 157 | {
|
---|
| 158 | if (!maxRAM)
|
---|
| 159 | return E_POINTER;
|
---|
| 160 |
|
---|
[13606] | 161 | AutoCaller autoCaller (this);
|
---|
| 162 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 163 |
|
---|
| 164 | /* no need to lock, this is const */
|
---|
[1] | 165 | *maxRAM = SchemaDefs::MaxGuestRAM;
|
---|
| 166 |
|
---|
| 167 | return S_OK;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestVRAM)(ULONG *minVRAM)
|
---|
| 171 | {
|
---|
| 172 | if (!minVRAM)
|
---|
| 173 | return E_POINTER;
|
---|
| 174 |
|
---|
[13606] | 175 | AutoCaller autoCaller (this);
|
---|
| 176 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 177 |
|
---|
| 178 | /* no need to lock, this is const */
|
---|
[1] | 179 | *minVRAM = SchemaDefs::MinGuestVRAM;
|
---|
| 180 |
|
---|
| 181 | return S_OK;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestVRAM)(ULONG *maxVRAM)
|
---|
| 185 | {
|
---|
| 186 | if (!maxVRAM)
|
---|
| 187 | return E_POINTER;
|
---|
| 188 |
|
---|
[13606] | 189 | AutoCaller autoCaller (this);
|
---|
| 190 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 191 |
|
---|
| 192 | /* no need to lock, this is const */
|
---|
[1] | 193 | *maxVRAM = SchemaDefs::MaxGuestVRAM;
|
---|
| 194 |
|
---|
| 195 | return S_OK;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
[1721] | 198 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestMonitors)(ULONG *maxMonitors)
|
---|
| 199 | {
|
---|
| 200 | if (!maxMonitors)
|
---|
| 201 | return E_POINTER;
|
---|
| 202 |
|
---|
[13606] | 203 | AutoCaller autoCaller (this);
|
---|
| 204 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 205 |
|
---|
| 206 | /* no need to lock, this is const */
|
---|
[1721] | 207 | *maxMonitors = SchemaDefs::MaxGuestMonitors;
|
---|
| 208 |
|
---|
| 209 | return S_OK;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
[1] | 212 | STDMETHODIMP SystemProperties::COMGETTER(MaxVDISize)(ULONG64 *maxVDISize)
|
---|
| 213 | {
|
---|
| 214 | if (!maxVDISize)
|
---|
| 215 | return E_POINTER;
|
---|
| 216 |
|
---|
[13606] | 217 | AutoCaller autoCaller (this);
|
---|
| 218 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 219 |
|
---|
[1] | 220 | /** The BIOS supports currently 32 bit LBA numbers (implementing the full
|
---|
| 221 | * 48 bit range is in theory trivial, but the crappy compiler makes things
|
---|
| 222 | * more difficult). This translates to almost 2 TBytes (to be on the safe
|
---|
| 223 | * side, the reported limit is 1 MiByte less than that, as the total number
|
---|
| 224 | * of sectors should fit in 32 bits, too), which should bei enough for
|
---|
| 225 | * the moment. The virtual ATA disks support complete LBA48 (although for
|
---|
| 226 | * example iSCSI is also currently limited to 32 bit LBA), so the
|
---|
| 227 | * theoretical maximum disk size is 128 PiByte. The user interface cannot
|
---|
| 228 | * cope with this in a reasonable way yet. */
|
---|
[13606] | 229 | /* no need to lock, this is const */
|
---|
[1] | 230 | *maxVDISize = 2048 * 1024 - 1;
|
---|
| 231 |
|
---|
| 232 | return S_OK;
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | STDMETHODIMP SystemProperties::COMGETTER(NetworkAdapterCount)(ULONG *count)
|
---|
| 236 | {
|
---|
| 237 | if (!count)
|
---|
| 238 | return E_POINTER;
|
---|
| 239 |
|
---|
[13606] | 240 | AutoCaller autoCaller (this);
|
---|
| 241 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 242 |
|
---|
| 243 | /* no need to lock, this is const */
|
---|
[1] | 244 | *count = SchemaDefs::NetworkAdapterCount;
|
---|
| 245 |
|
---|
| 246 | return S_OK;
|
---|
| 247 | }
|
---|
| 248 |
|
---|
[3494] | 249 | STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
|
---|
| 250 | {
|
---|
| 251 | if (!count)
|
---|
| 252 | return E_POINTER;
|
---|
[1] | 253 |
|
---|
[13606] | 254 | AutoCaller autoCaller (this);
|
---|
| 255 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 256 |
|
---|
| 257 | /* no need to lock, this is const */
|
---|
[3494] | 258 | *count = SchemaDefs::SerialPortCount;
|
---|
| 259 |
|
---|
| 260 | return S_OK;
|
---|
| 261 | }
|
---|
| 262 |
|
---|
[3652] | 263 | STDMETHODIMP SystemProperties::COMGETTER(ParallelPortCount)(ULONG *count)
|
---|
| 264 | {
|
---|
| 265 | if (!count)
|
---|
| 266 | return E_POINTER;
|
---|
| 267 |
|
---|
[13606] | 268 | AutoCaller autoCaller (this);
|
---|
| 269 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 270 |
|
---|
| 271 | /* no need to lock, this is const */
|
---|
[3652] | 272 | *count = SchemaDefs::ParallelPortCount;
|
---|
| 273 |
|
---|
| 274 | return S_OK;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
[1] | 277 | STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
|
---|
| 278 | {
|
---|
[14972] | 279 | CheckComArgOutPointerValid(aMaxBootPosition);
|
---|
[1] | 280 |
|
---|
[13606] | 281 | AutoCaller autoCaller (this);
|
---|
| 282 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 283 |
|
---|
| 284 | /* no need to lock, this is const */
|
---|
[1] | 285 | *aMaxBootPosition = SchemaDefs::MaxBootPosition;
|
---|
| 286 |
|
---|
| 287 | return S_OK;
|
---|
| 288 | }
|
---|
| 289 |
|
---|
[13580] | 290 | STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder) (BSTR *aDefaultMachineFolder)
|
---|
[1] | 291 | {
|
---|
[14972] | 292 | CheckComArgOutPointerValid(aDefaultMachineFolder);
|
---|
[1] | 293 |
|
---|
[13606] | 294 | AutoCaller autoCaller (this);
|
---|
| 295 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 296 |
|
---|
[13606] | 297 | AutoReadLock alock (this);
|
---|
| 298 |
|
---|
[13580] | 299 | mDefaultMachineFolderFull.cloneTo (aDefaultMachineFolder);
|
---|
[1] | 300 |
|
---|
| 301 | return S_OK;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
[15051] | 304 | STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder) (IN_BSTR aDefaultMachineFolder)
|
---|
[1] | 305 | {
|
---|
[13606] | 306 | AutoCaller autoCaller (this);
|
---|
| 307 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 308 |
|
---|
[13606] | 309 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
| 310 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
| 311 |
|
---|
[13580] | 312 | HRESULT rc = setDefaultMachineFolder (aDefaultMachineFolder);
|
---|
[13606] | 313 | if (SUCCEEDED (rc))
|
---|
| 314 | rc = mParent->saveSettings();
|
---|
[1] | 315 |
|
---|
[13606] | 316 | return rc;
|
---|
[1] | 317 | }
|
---|
| 318 |
|
---|
[13580] | 319 | STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFolder) (BSTR *aDefaultHardDiskFolder)
|
---|
[1] | 320 | {
|
---|
[14972] | 321 | CheckComArgOutPointerValid(aDefaultHardDiskFolder);
|
---|
[1] | 322 |
|
---|
[13606] | 323 | AutoCaller autoCaller (this);
|
---|
| 324 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 325 |
|
---|
[13606] | 326 | AutoReadLock alock (this);
|
---|
| 327 |
|
---|
[13580] | 328 | mDefaultHardDiskFolderFull.cloneTo (aDefaultHardDiskFolder);
|
---|
[1] | 329 |
|
---|
| 330 | return S_OK;
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[15051] | 333 | STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFolder) (IN_BSTR aDefaultHardDiskFolder)
|
---|
[1] | 334 | {
|
---|
[13606] | 335 | AutoCaller autoCaller (this);
|
---|
| 336 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 337 |
|
---|
[13606] | 338 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
| 339 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
| 340 |
|
---|
[13580] | 341 | HRESULT rc = setDefaultHardDiskFolder (aDefaultHardDiskFolder);
|
---|
[13606] | 342 | if (SUCCEEDED (rc))
|
---|
| 343 | rc = mParent->saveSettings();
|
---|
[1] | 344 |
|
---|
[13606] | 345 | return rc;
|
---|
[1] | 346 | }
|
---|
| 347 |
|
---|
[13580] | 348 | STDMETHODIMP SystemProperties::
|
---|
| 349 | COMGETTER(HardDiskFormats) (ComSafeArrayOut (IHardDiskFormat *, aHardDiskFormats))
|
---|
| 350 | {
|
---|
| 351 | if (ComSafeArrayOutIsNull (aHardDiskFormats))
|
---|
| 352 | return E_POINTER;
|
---|
| 353 |
|
---|
[13606] | 354 | AutoCaller autoCaller (this);
|
---|
| 355 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[13580] | 356 |
|
---|
[13606] | 357 | AutoReadLock alock (this);
|
---|
| 358 |
|
---|
[13580] | 359 | SafeIfaceArray <IHardDiskFormat> hardDiskFormats (mHardDiskFormats);
|
---|
| 360 | hardDiskFormats.detachTo (ComSafeArrayOutArg (aHardDiskFormats));
|
---|
| 361 |
|
---|
| 362 | return S_OK;
|
---|
| 363 | }
|
---|
| 364 |
|
---|
[14224] | 365 | STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat) (BSTR *aDefaultHardDiskFormat)
|
---|
| 366 | {
|
---|
[14972] | 367 | CheckComArgOutPointerValid(aDefaultHardDiskFormat);
|
---|
[14224] | 368 |
|
---|
| 369 | AutoCaller autoCaller (this);
|
---|
| 370 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 371 |
|
---|
| 372 | AutoReadLock alock (this);
|
---|
| 373 |
|
---|
| 374 | mDefaultHardDiskFormat.cloneTo (aDefaultHardDiskFormat);
|
---|
| 375 |
|
---|
| 376 | return S_OK;
|
---|
| 377 | }
|
---|
| 378 |
|
---|
[15051] | 379 | STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat) (IN_BSTR aDefaultHardDiskFormat)
|
---|
[14224] | 380 | {
|
---|
| 381 | AutoCaller autoCaller (this);
|
---|
| 382 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 383 |
|
---|
| 384 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
| 385 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
| 386 |
|
---|
| 387 | HRESULT rc = setDefaultHardDiskFormat (aDefaultHardDiskFormat);
|
---|
| 388 | if (SUCCEEDED (rc))
|
---|
| 389 | rc = mParent->saveSettings();
|
---|
| 390 |
|
---|
| 391 | return rc;
|
---|
| 392 | }
|
---|
| 393 |
|
---|
[1] | 394 | STDMETHODIMP SystemProperties::COMGETTER(RemoteDisplayAuthLibrary) (BSTR *aRemoteDisplayAuthLibrary)
|
---|
| 395 | {
|
---|
[14972] | 396 | CheckComArgOutPointerValid(aRemoteDisplayAuthLibrary);
|
---|
[1] | 397 |
|
---|
[13606] | 398 | AutoCaller autoCaller (this);
|
---|
| 399 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 400 |
|
---|
[13606] | 401 | AutoReadLock alock (this);
|
---|
| 402 |
|
---|
[1] | 403 | mRemoteDisplayAuthLibrary.cloneTo (aRemoteDisplayAuthLibrary);
|
---|
| 404 |
|
---|
| 405 | return S_OK;
|
---|
| 406 | }
|
---|
| 407 |
|
---|
[15051] | 408 | STDMETHODIMP SystemProperties::COMSETTER(RemoteDisplayAuthLibrary) (IN_BSTR aRemoteDisplayAuthLibrary)
|
---|
[1] | 409 | {
|
---|
[13606] | 410 | AutoCaller autoCaller (this);
|
---|
| 411 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 412 |
|
---|
[13606] | 413 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
| 414 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
| 415 |
|
---|
[1] | 416 | HRESULT rc = setRemoteDisplayAuthLibrary (aRemoteDisplayAuthLibrary);
|
---|
[13606] | 417 | if (SUCCEEDED (rc))
|
---|
| 418 | rc = mParent->saveSettings();
|
---|
[1] | 419 |
|
---|
[13606] | 420 | return rc;
|
---|
[1] | 421 | }
|
---|
| 422 |
|
---|
[5771] | 423 | STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary) (BSTR *aWebServiceAuthLibrary)
|
---|
| 424 | {
|
---|
[14972] | 425 | CheckComArgOutPointerValid(aWebServiceAuthLibrary);
|
---|
[5771] | 426 |
|
---|
[13606] | 427 | AutoCaller autoCaller (this);
|
---|
| 428 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[5771] | 429 |
|
---|
[13606] | 430 | AutoReadLock alock (this);
|
---|
| 431 |
|
---|
[5771] | 432 | mWebServiceAuthLibrary.cloneTo (aWebServiceAuthLibrary);
|
---|
| 433 |
|
---|
| 434 | return S_OK;
|
---|
| 435 | }
|
---|
| 436 |
|
---|
[15051] | 437 | STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary) (IN_BSTR aWebServiceAuthLibrary)
|
---|
[5771] | 438 | {
|
---|
[13606] | 439 | AutoCaller autoCaller (this);
|
---|
| 440 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[5771] | 441 |
|
---|
[13606] | 442 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
| 443 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
| 444 |
|
---|
[5771] | 445 | HRESULT rc = setWebServiceAuthLibrary (aWebServiceAuthLibrary);
|
---|
[13606] | 446 | if (SUCCEEDED (rc))
|
---|
| 447 | rc = mParent->saveSettings();
|
---|
[5771] | 448 |
|
---|
[13606] | 449 | return rc;
|
---|
[5771] | 450 | }
|
---|
| 451 |
|
---|
[1] | 452 | STDMETHODIMP SystemProperties::COMGETTER(HWVirtExEnabled) (BOOL *enabled)
|
---|
| 453 | {
|
---|
| 454 | if (!enabled)
|
---|
| 455 | return E_POINTER;
|
---|
| 456 |
|
---|
[13606] | 457 | AutoCaller autoCaller (this);
|
---|
| 458 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 459 |
|
---|
[13606] | 460 | AutoReadLock alock (this);
|
---|
| 461 |
|
---|
[1] | 462 | *enabled = mHWVirtExEnabled;
|
---|
| 463 |
|
---|
| 464 | return S_OK;
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | STDMETHODIMP SystemProperties::COMSETTER(HWVirtExEnabled) (BOOL enabled)
|
---|
| 468 | {
|
---|
[13606] | 469 | AutoCaller autoCaller (this);
|
---|
| 470 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 471 |
|
---|
[13606] | 472 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
| 473 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
| 474 |
|
---|
[1] | 475 | mHWVirtExEnabled = enabled;
|
---|
| 476 |
|
---|
[13606] | 477 | HRESULT rc = mParent->saveSettings();
|
---|
| 478 |
|
---|
| 479 | return rc;
|
---|
[1] | 480 | }
|
---|
| 481 |
|
---|
[5150] | 482 | STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount) (ULONG *count)
|
---|
| 483 | {
|
---|
| 484 | if (!count)
|
---|
| 485 | return E_POINTER;
|
---|
| 486 |
|
---|
[13606] | 487 | AutoCaller autoCaller (this);
|
---|
| 488 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[5150] | 489 |
|
---|
[13606] | 490 | AutoReadLock alock (this);
|
---|
| 491 |
|
---|
[5150] | 492 | *count = mLogHistoryCount;
|
---|
| 493 |
|
---|
| 494 | return S_OK;
|
---|
| 495 | }
|
---|
| 496 |
|
---|
| 497 | STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount) (ULONG count)
|
---|
| 498 | {
|
---|
[13606] | 499 | AutoCaller autoCaller (this);
|
---|
| 500 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[5150] | 501 |
|
---|
[13606] | 502 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
| 503 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
| 504 |
|
---|
[5150] | 505 | mLogHistoryCount = count;
|
---|
| 506 |
|
---|
[13606] | 507 | HRESULT rc = mParent->saveSettings();
|
---|
| 508 |
|
---|
| 509 | return rc;
|
---|
[5150] | 510 | }
|
---|
| 511 |
|
---|
[1] | 512 | // public methods only for internal purposes
|
---|
| 513 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 514 |
|
---|
[6076] | 515 | HRESULT SystemProperties::loadSettings (const settings::Key &aGlobal)
|
---|
[1] | 516 | {
|
---|
[6076] | 517 | using namespace settings;
|
---|
| 518 |
|
---|
[13606] | 519 | AutoCaller autoCaller (this);
|
---|
| 520 | CheckComRCReturnRC (autoCaller.rc());
|
---|
| 521 |
|
---|
[8083] | 522 | AutoWriteLock alock (this);
|
---|
[1] | 523 |
|
---|
[6076] | 524 | AssertReturn (!aGlobal.isNull(), E_FAIL);
|
---|
[1] | 525 |
|
---|
[6076] | 526 | HRESULT rc = S_OK;
|
---|
[1] | 527 |
|
---|
[6076] | 528 | Key properties = aGlobal.key ("SystemProperties");
|
---|
[1] | 529 |
|
---|
[6076] | 530 | Bstr bstr;
|
---|
[1] | 531 |
|
---|
[6076] | 532 | bstr = properties.stringValue ("defaultMachineFolder");
|
---|
| 533 | rc = setDefaultMachineFolder (bstr);
|
---|
| 534 | CheckComRCReturnRC (rc);
|
---|
[1] | 535 |
|
---|
[13580] | 536 | bstr = properties.stringValue ("defaultHardDiskFolder");
|
---|
| 537 | rc = setDefaultHardDiskFolder (bstr);
|
---|
| 538 | CheckComRCReturnRC (rc);
|
---|
| 539 |
|
---|
[14224] | 540 | bstr = properties.stringValue ("defaultHardDiskFormat");
|
---|
| 541 | rc = setDefaultHardDiskFormat (bstr);
|
---|
| 542 | CheckComRCReturnRC (rc);
|
---|
| 543 |
|
---|
[6076] | 544 | bstr = properties.stringValue ("remoteDisplayAuthLibrary");
|
---|
| 545 | rc = setRemoteDisplayAuthLibrary (bstr);
|
---|
| 546 | CheckComRCReturnRC (rc);
|
---|
[1] | 547 |
|
---|
[6076] | 548 | bstr = properties.stringValue ("webServiceAuthLibrary");
|
---|
| 549 | rc = setWebServiceAuthLibrary (bstr);
|
---|
| 550 | CheckComRCReturnRC (rc);
|
---|
[5771] | 551 |
|
---|
[6076] | 552 | /* Note: not <BOOL> because Win32 defines BOOL as int */
|
---|
[6096] | 553 | mHWVirtExEnabled = properties.valueOr <bool> ("HWVirtExEnabled", false);
|
---|
[1] | 554 |
|
---|
[6096] | 555 | mLogHistoryCount = properties.valueOr <ULONG> ("LogHistoryCount", 3);
|
---|
[1] | 556 |
|
---|
[6076] | 557 | return S_OK;
|
---|
[1] | 558 | }
|
---|
| 559 |
|
---|
[6076] | 560 | HRESULT SystemProperties::saveSettings (settings::Key &aGlobal)
|
---|
[1] | 561 | {
|
---|
[6076] | 562 | using namespace settings;
|
---|
| 563 |
|
---|
[13606] | 564 | AutoCaller autoCaller (this);
|
---|
| 565 | CheckComRCReturnRC (autoCaller.rc());
|
---|
[1] | 566 |
|
---|
[13606] | 567 | AutoReadLock alock (this);
|
---|
| 568 |
|
---|
[6076] | 569 | ComAssertRet (!aGlobal.isNull(), E_FAIL);
|
---|
[1] | 570 |
|
---|
[6076] | 571 | /* first, delete the entry */
|
---|
| 572 | Key properties = aGlobal.findKey ("SystemProperties");
|
---|
| 573 | if (!properties.isNull())
|
---|
| 574 | properties.zap();
|
---|
| 575 | /* then, recreate it */
|
---|
| 576 | properties = aGlobal.createKey ("SystemProperties");
|
---|
[1] | 577 |
|
---|
| 578 | if (mDefaultMachineFolder)
|
---|
[6076] | 579 | properties.setValue <Bstr> ("defaultMachineFolder", mDefaultMachineFolder);
|
---|
[1] | 580 |
|
---|
[13580] | 581 | if (mDefaultHardDiskFolder)
|
---|
| 582 | properties.setValue <Bstr> ("defaultHardDiskFolder", mDefaultHardDiskFolder);
|
---|
| 583 |
|
---|
[14224] | 584 | if (mDefaultHardDiskFormat)
|
---|
| 585 | properties.setValue <Bstr> ("defaultHardDiskFormat", mDefaultHardDiskFormat);
|
---|
| 586 |
|
---|
[1] | 587 | if (mRemoteDisplayAuthLibrary)
|
---|
[6076] | 588 | properties.setValue <Bstr> ("remoteDisplayAuthLibrary", mRemoteDisplayAuthLibrary);
|
---|
[1] | 589 |
|
---|
[5771] | 590 | if (mWebServiceAuthLibrary)
|
---|
[6076] | 591 | properties.setValue <Bstr> ("webServiceAuthLibrary", mWebServiceAuthLibrary);
|
---|
[5771] | 592 |
|
---|
[6076] | 593 | properties.setValue <bool> ("HWVirtExEnabled", !!mHWVirtExEnabled);
|
---|
[1] | 594 |
|
---|
[6076] | 595 | properties.setValue <ULONG> ("LogHistoryCount", mLogHistoryCount);
|
---|
[5150] | 596 |
|
---|
[1] | 597 | return S_OK;
|
---|
| 598 | }
|
---|
| 599 |
|
---|
[14225] | 600 | /**
|
---|
| 601 | * Rerurns a hard disk format object corresponding to the given format
|
---|
| 602 | * identifier or null if no such format.
|
---|
| 603 | *
|
---|
| 604 | * @param aFormat Format identifier.
|
---|
| 605 | *
|
---|
| 606 | * @return ComObjPtr<HardDiskFormat>
|
---|
| 607 | */
|
---|
[15051] | 608 | ComObjPtr <HardDiskFormat> SystemProperties::hardDiskFormat (CBSTR aFormat)
|
---|
[14225] | 609 | {
|
---|
| 610 | ComObjPtr <HardDiskFormat> format;
|
---|
| 611 |
|
---|
| 612 | AutoCaller autoCaller (this);
|
---|
| 613 | AssertComRCReturn (autoCaller.rc(), format);
|
---|
| 614 |
|
---|
| 615 | AutoReadLock alock (this);
|
---|
| 616 |
|
---|
| 617 | for (HardDiskFormatList::const_iterator it = mHardDiskFormats.begin();
|
---|
| 618 | it != mHardDiskFormats.end(); ++ it)
|
---|
| 619 | {
|
---|
| 620 | /* HardDiskFormat is all const, no need to lock */
|
---|
| 621 |
|
---|
[16081] | 622 | if ((*it)->id().compareIgnoreCase (aFormat) == 0)
|
---|
[14225] | 623 | {
|
---|
| 624 | format = *it;
|
---|
| 625 | break;
|
---|
| 626 | }
|
---|
| 627 | }
|
---|
| 628 |
|
---|
| 629 | return format;
|
---|
| 630 | }
|
---|
| 631 |
|
---|
[1] | 632 | // private methods
|
---|
| 633 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 634 |
|
---|
[15051] | 635 | HRESULT SystemProperties::setDefaultMachineFolder (CBSTR aPath)
|
---|
[1] | 636 | {
|
---|
| 637 | Utf8Str path;
|
---|
| 638 | if (aPath && *aPath)
|
---|
| 639 | path = aPath;
|
---|
| 640 | else
|
---|
[13580] | 641 | path = "Machines";
|
---|
[1] | 642 |
|
---|
[13580] | 643 | /* get the full file name */
|
---|
| 644 | Utf8Str folder;
|
---|
| 645 | int vrc = mParent->calculateFullPath (path, folder);
|
---|
[13835] | 646 | if (RT_FAILURE (vrc))
|
---|
[1] | 647 | return setError (E_FAIL,
|
---|
[13837] | 648 | tr ("Invalid default machine folder '%ls' (%Rrc)"),
|
---|
[1] | 649 | path.raw(), vrc);
|
---|
| 650 |
|
---|
[13580] | 651 | mDefaultMachineFolder = path;
|
---|
| 652 | mDefaultMachineFolderFull = folder;
|
---|
[1] | 653 |
|
---|
| 654 | return S_OK;
|
---|
| 655 | }
|
---|
| 656 |
|
---|
[15051] | 657 | HRESULT SystemProperties::setDefaultHardDiskFolder (CBSTR aPath)
|
---|
[1] | 658 | {
|
---|
| 659 | Utf8Str path;
|
---|
| 660 | if (aPath && *aPath)
|
---|
| 661 | path = aPath;
|
---|
| 662 | else
|
---|
[13580] | 663 | path = "HardDisks";
|
---|
[1] | 664 |
|
---|
[13580] | 665 | /* get the full file name */
|
---|
| 666 | Utf8Str folder;
|
---|
| 667 | int vrc = mParent->calculateFullPath (path, folder);
|
---|
[13835] | 668 | if (RT_FAILURE (vrc))
|
---|
[1] | 669 | return setError (E_FAIL,
|
---|
[13837] | 670 | tr ("Invalid default hard disk folder '%ls' (%Rrc)"),
|
---|
[1] | 671 | path.raw(), vrc);
|
---|
| 672 |
|
---|
[13580] | 673 | mDefaultHardDiskFolder = path;
|
---|
| 674 | mDefaultHardDiskFolderFull = folder;
|
---|
[1] | 675 |
|
---|
| 676 | return S_OK;
|
---|
| 677 | }
|
---|
| 678 |
|
---|
[15051] | 679 | HRESULT SystemProperties::setDefaultHardDiskFormat (CBSTR aFormat)
|
---|
[14224] | 680 | {
|
---|
| 681 | if (aFormat && *aFormat)
|
---|
| 682 | mDefaultHardDiskFormat = aFormat;
|
---|
| 683 | else
|
---|
| 684 | mDefaultHardDiskFormat = "VDI";
|
---|
| 685 |
|
---|
| 686 | return S_OK;
|
---|
| 687 | }
|
---|
| 688 |
|
---|
[15051] | 689 | HRESULT SystemProperties::setRemoteDisplayAuthLibrary (CBSTR aPath)
|
---|
[1] | 690 | {
|
---|
| 691 | if (aPath && *aPath)
|
---|
[14224] | 692 | mRemoteDisplayAuthLibrary = aPath;
|
---|
[1] | 693 | else
|
---|
[14224] | 694 | mRemoteDisplayAuthLibrary = "VRDPAuth";
|
---|
[1] | 695 |
|
---|
| 696 | return S_OK;
|
---|
| 697 | }
|
---|
| 698 |
|
---|
[15051] | 699 | HRESULT SystemProperties::setWebServiceAuthLibrary (CBSTR aPath)
|
---|
[5771] | 700 | {
|
---|
| 701 | if (aPath && *aPath)
|
---|
[14224] | 702 | mWebServiceAuthLibrary = aPath;
|
---|
[5771] | 703 | else
|
---|
[14224] | 704 | mWebServiceAuthLibrary = "VRDPAuth";
|
---|
[5771] | 705 |
|
---|
| 706 | return S_OK;
|
---|
| 707 | }
|
---|
[14772] | 708 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|