VirtualBox

source: vbox/trunk/src/VBox/Main/SystemPropertiesImpl.cpp@ 20260

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

Main: added default audio driver method to ISystemProperties

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette