VirtualBox

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

Last change on this file since 20961 was 20262, checked in by vboxsync, 15 years ago

Main: fix linux burns

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