VirtualBox

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

最後變更 在這個檔案從23223是 23223,由 vboxsync 提交於 16 年 前

API: big medium handling change and lots of assorted other cleanups and fixes

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 21.0 KB
 
1/* $Id: SystemPropertiesImpl.cpp 23223 2009-09-22 15:50:03Z 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.alldomusa.eu.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(Utf8Str::Null);
80 setDefaultHardDiskFolder(Utf8Str::Null);
81 setDefaultHardDiskFormat(Utf8Str::Null);
82
83 setRemoteDisplayAuthLibrary(Utf8Str::Null);
84
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<MediumFormat> hdf;
106 rc = hdf.createObject();
107 CheckComRCBreakRC (rc);
108
109 rc = hdf->init (&aVDInfo [i]);
110 CheckComRCBreakRC (rc);
111
112 mMediumFormats.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 ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
203 ULONG maxRAMArch = maxRAMSys;
204#if HC_ARCH_BITS == 32 && !defined(RT_OS_DARWIN)
205# ifdef RT_OS_WINDOWS
206 maxRAMArch = UINT32_C(1500);
207# else
208 maxRAMArch = UINT32_C(2560);
209# endif
210#endif
211 *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
212
213 return S_OK;
214}
215
216STDMETHODIMP SystemProperties::COMGETTER(MinGuestVRAM)(ULONG *minVRAM)
217{
218 if (!minVRAM)
219 return E_POINTER;
220
221 AutoCaller autoCaller(this);
222 CheckComRCReturnRC(autoCaller.rc());
223
224 /* no need to lock, this is const */
225 *minVRAM = SchemaDefs::MinGuestVRAM;
226
227 return S_OK;
228}
229
230STDMETHODIMP SystemProperties::COMGETTER(MaxGuestVRAM)(ULONG *maxVRAM)
231{
232 if (!maxVRAM)
233 return E_POINTER;
234
235 AutoCaller autoCaller(this);
236 CheckComRCReturnRC(autoCaller.rc());
237
238 /* no need to lock, this is const */
239 *maxVRAM = SchemaDefs::MaxGuestVRAM;
240
241 return S_OK;
242}
243
244STDMETHODIMP SystemProperties::COMGETTER(MinGuestCPUCount)(ULONG *minCPUCount)
245{
246 if (!minCPUCount)
247 return E_POINTER;
248
249 AutoCaller autoCaller(this);
250 CheckComRCReturnRC(autoCaller.rc());
251
252 /* no need to lock, this is const */
253 *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
254
255 return S_OK;
256}
257
258STDMETHODIMP SystemProperties::COMGETTER(MaxGuestCPUCount)(ULONG *maxCPUCount)
259{
260 if (!maxCPUCount)
261 return E_POINTER;
262
263 AutoCaller autoCaller(this);
264 CheckComRCReturnRC(autoCaller.rc());
265
266 /* no need to lock, this is const */
267 *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
268
269 return S_OK;
270}
271
272STDMETHODIMP SystemProperties::COMGETTER(MaxGuestMonitors)(ULONG *maxMonitors)
273{
274 if (!maxMonitors)
275 return E_POINTER;
276
277 AutoCaller autoCaller(this);
278 CheckComRCReturnRC(autoCaller.rc());
279
280 /* no need to lock, this is const */
281 *maxMonitors = SchemaDefs::MaxGuestMonitors;
282
283 return S_OK;
284}
285
286STDMETHODIMP SystemProperties::COMGETTER(MaxVDISize)(ULONG64 *maxVDISize)
287{
288 if (!maxVDISize)
289 return E_POINTER;
290
291 AutoCaller autoCaller(this);
292 CheckComRCReturnRC(autoCaller.rc());
293
294 /** The BIOS supports currently 32 bit LBA numbers (implementing the full
295 * 48 bit range is in theory trivial, but the crappy compiler makes things
296 * more difficult). This translates to almost 2 TBytes (to be on the safe
297 * side, the reported limit is 1 MiByte less than that, as the total number
298 * of sectors should fit in 32 bits, too), which should bei enough for
299 * the moment. The virtual ATA disks support complete LBA48 (although for
300 * example iSCSI is also currently limited to 32 bit LBA), so the
301 * theoretical maximum disk size is 128 PiByte. The user interface cannot
302 * cope with this in a reasonable way yet. */
303 /* no need to lock, this is const */
304 *maxVDISize = 2048 * 1024 - 1;
305
306 return S_OK;
307}
308
309STDMETHODIMP SystemProperties::COMGETTER(NetworkAdapterCount)(ULONG *count)
310{
311 if (!count)
312 return E_POINTER;
313
314 AutoCaller autoCaller(this);
315 CheckComRCReturnRC(autoCaller.rc());
316
317 /* no need to lock, this is const */
318 *count = SchemaDefs::NetworkAdapterCount;
319
320 return S_OK;
321}
322
323STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
324{
325 if (!count)
326 return E_POINTER;
327
328 AutoCaller autoCaller(this);
329 CheckComRCReturnRC(autoCaller.rc());
330
331 /* no need to lock, this is const */
332 *count = SchemaDefs::SerialPortCount;
333
334 return S_OK;
335}
336
337STDMETHODIMP SystemProperties::COMGETTER(ParallelPortCount)(ULONG *count)
338{
339 if (!count)
340 return E_POINTER;
341
342 AutoCaller autoCaller(this);
343 CheckComRCReturnRC(autoCaller.rc());
344
345 /* no need to lock, this is const */
346 *count = SchemaDefs::ParallelPortCount;
347
348 return S_OK;
349}
350
351STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
352{
353 CheckComArgOutPointerValid(aMaxBootPosition);
354
355 AutoCaller autoCaller(this);
356 CheckComRCReturnRC(autoCaller.rc());
357
358 /* no need to lock, this is const */
359 *aMaxBootPosition = SchemaDefs::MaxBootPosition;
360
361 return S_OK;
362}
363
364STDMETHODIMP SystemProperties::GetMaxDevicesPerPortForStorageBus (StorageBus_T aBus, ULONG *aMaxDevicesPerPort)
365{
366 CheckComArgOutPointerValid(aMaxDevicesPerPort);
367
368 AutoCaller autoCaller(this);
369 CheckComRCReturnRC(autoCaller.rc());
370
371 /* no need to lock, this is const */
372 switch (aBus)
373 {
374 case StorageBus_SATA:
375 case StorageBus_SCSI:
376 {
377 /* SATA and both SCSI controllers only support one device per port. */
378 *aMaxDevicesPerPort = 1;
379 break;
380 }
381 case StorageBus_IDE:
382 case StorageBus_Floppy:
383 {
384 /* The IDE and Floppy controllers support 2 devices. One as master
385 * and one as slave (or floppy drive 0 and 1). */
386 *aMaxDevicesPerPort = 2;
387 break;
388 }
389 default:
390 AssertMsgFailed(("Invalid bus type %d\n", aBus));
391 }
392
393 return S_OK;
394}
395
396STDMETHODIMP SystemProperties::GetMinPortCountForStorageBus (StorageBus_T aBus, ULONG *aMinPortCount)
397{
398 CheckComArgOutPointerValid(aMinPortCount);
399
400 AutoCaller autoCaller(this);
401 CheckComRCReturnRC(autoCaller.rc());
402
403 /* no need to lock, this is const */
404 switch (aBus)
405 {
406 case StorageBus_SATA:
407 {
408 *aMinPortCount = 1;
409 break;
410 }
411 case StorageBus_SCSI:
412 {
413 *aMinPortCount = 16;
414 break;
415 }
416 case StorageBus_IDE:
417 {
418 *aMinPortCount = 2;
419 break;
420 }
421 case StorageBus_Floppy:
422 {
423 *aMinPortCount = 1;
424 break;
425 }
426 default:
427 AssertMsgFailed(("Invalid bus type %d\n", aBus));
428 }
429
430 return S_OK;
431}
432
433STDMETHODIMP SystemProperties::GetMaxPortCountForStorageBus (StorageBus_T aBus, ULONG *aMaxPortCount)
434{
435 CheckComArgOutPointerValid(aMaxPortCount);
436
437 AutoCaller autoCaller(this);
438 CheckComRCReturnRC(autoCaller.rc());
439
440 /* no need to lock, this is const */
441 switch (aBus)
442 {
443 case StorageBus_SATA:
444 {
445 *aMaxPortCount = 30;
446 break;
447 }
448 case StorageBus_SCSI:
449 {
450 *aMaxPortCount = 16;
451 break;
452 }
453 case StorageBus_IDE:
454 {
455 *aMaxPortCount = 2;
456 break;
457 }
458 case StorageBus_Floppy:
459 {
460 *aMaxPortCount = 1;
461 break;
462 }
463 default:
464 AssertMsgFailed(("Invalid bus type %d\n", aBus));
465 }
466
467 return S_OK;
468}
469
470STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder) (BSTR *aDefaultMachineFolder)
471{
472 CheckComArgOutPointerValid(aDefaultMachineFolder);
473
474 AutoCaller autoCaller(this);
475 CheckComRCReturnRC(autoCaller.rc());
476
477 AutoReadLock alock(this);
478
479 m_strDefaultMachineFolderFull.cloneTo(aDefaultMachineFolder);
480
481 return S_OK;
482}
483
484STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder) (IN_BSTR aDefaultMachineFolder)
485{
486 AutoCaller autoCaller(this);
487 CheckComRCReturnRC(autoCaller.rc());
488
489 /* VirtualBox::saveSettings() needs a write lock */
490 AutoMultiWriteLock2 alock (mParent, this);
491
492 HRESULT rc = setDefaultMachineFolder (aDefaultMachineFolder);
493 if (SUCCEEDED(rc))
494 rc = mParent->saveSettings();
495
496 return rc;
497}
498
499STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFolder) (BSTR *aDefaultHardDiskFolder)
500{
501 CheckComArgOutPointerValid(aDefaultHardDiskFolder);
502
503 AutoCaller autoCaller(this);
504 CheckComRCReturnRC(autoCaller.rc());
505
506 AutoReadLock alock(this);
507
508 m_strDefaultHardDiskFolderFull.cloneTo(aDefaultHardDiskFolder);
509
510 return S_OK;
511}
512
513STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFolder) (IN_BSTR aDefaultHardDiskFolder)
514{
515 AutoCaller autoCaller(this);
516 CheckComRCReturnRC(autoCaller.rc());
517
518 /* VirtualBox::saveSettings() needs a write lock */
519 AutoMultiWriteLock2 alock (mParent, this);
520
521 HRESULT rc = setDefaultHardDiskFolder (aDefaultHardDiskFolder);
522 if (SUCCEEDED(rc))
523 rc = mParent->saveSettings();
524
525 return rc;
526}
527
528STDMETHODIMP SystemProperties::
529COMGETTER(MediumFormats) (ComSafeArrayOut(IMediumFormat *, aMediumFormats))
530{
531 if (ComSafeArrayOutIsNull(aMediumFormats))
532 return E_POINTER;
533
534 AutoCaller autoCaller(this);
535 CheckComRCReturnRC(autoCaller.rc());
536
537 AutoReadLock alock(this);
538
539 SafeIfaceArray<IMediumFormat> mediumFormats (mMediumFormats);
540 mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats));
541
542 return S_OK;
543}
544
545STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat) (BSTR *aDefaultHardDiskFormat)
546{
547 CheckComArgOutPointerValid(aDefaultHardDiskFormat);
548
549 AutoCaller autoCaller(this);
550 CheckComRCReturnRC(autoCaller.rc());
551
552 AutoReadLock alock(this);
553
554 m_strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
555
556 return S_OK;
557}
558
559STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat) (IN_BSTR aDefaultHardDiskFormat)
560{
561 AutoCaller autoCaller(this);
562 CheckComRCReturnRC(autoCaller.rc());
563
564 /* VirtualBox::saveSettings() needs a write lock */
565 AutoMultiWriteLock2 alock (mParent, this);
566
567 HRESULT rc = setDefaultHardDiskFormat (aDefaultHardDiskFormat);
568 if (SUCCEEDED(rc))
569 rc = mParent->saveSettings();
570
571 return rc;
572}
573
574STDMETHODIMP SystemProperties::COMGETTER(RemoteDisplayAuthLibrary) (BSTR *aRemoteDisplayAuthLibrary)
575{
576 CheckComArgOutPointerValid(aRemoteDisplayAuthLibrary);
577
578 AutoCaller autoCaller(this);
579 CheckComRCReturnRC(autoCaller.rc());
580
581 AutoReadLock alock(this);
582
583 m_strRemoteDisplayAuthLibrary.cloneTo(aRemoteDisplayAuthLibrary);
584
585 return S_OK;
586}
587
588STDMETHODIMP SystemProperties::COMSETTER(RemoteDisplayAuthLibrary) (IN_BSTR aRemoteDisplayAuthLibrary)
589{
590 AutoCaller autoCaller(this);
591 CheckComRCReturnRC(autoCaller.rc());
592
593 /* VirtualBox::saveSettings() needs a write lock */
594 AutoMultiWriteLock2 alock (mParent, this);
595
596 HRESULT rc = setRemoteDisplayAuthLibrary (aRemoteDisplayAuthLibrary);
597 if (SUCCEEDED(rc))
598 rc = mParent->saveSettings();
599
600 return rc;
601}
602
603STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary) (BSTR *aWebServiceAuthLibrary)
604{
605 CheckComArgOutPointerValid(aWebServiceAuthLibrary);
606
607 AutoCaller autoCaller(this);
608 CheckComRCReturnRC(autoCaller.rc());
609
610 AutoReadLock alock(this);
611
612 m_strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
613
614 return S_OK;
615}
616
617STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary) (IN_BSTR aWebServiceAuthLibrary)
618{
619 AutoCaller autoCaller(this);
620 CheckComRCReturnRC(autoCaller.rc());
621
622 /* VirtualBox::saveSettings() needs a write lock */
623 AutoMultiWriteLock2 alock (mParent, this);
624
625 HRESULT rc = setWebServiceAuthLibrary (aWebServiceAuthLibrary);
626 if (SUCCEEDED(rc))
627 rc = mParent->saveSettings();
628
629 return rc;
630}
631
632STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount) (ULONG *count)
633{
634 if (!count)
635 return E_POINTER;
636
637 AutoCaller autoCaller(this);
638 CheckComRCReturnRC(autoCaller.rc());
639
640 AutoReadLock alock(this);
641
642 *count = mLogHistoryCount;
643
644 return S_OK;
645}
646
647STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount) (ULONG count)
648{
649 AutoCaller autoCaller(this);
650 CheckComRCReturnRC(autoCaller.rc());
651
652 /* VirtualBox::saveSettings() needs a write lock */
653 AutoMultiWriteLock2 alock (mParent, this);
654
655 mLogHistoryCount = count;
656
657 HRESULT rc = mParent->saveSettings();
658
659 return rc;
660}
661
662STDMETHODIMP SystemProperties::COMGETTER(DefaultAudioDriver) (AudioDriverType_T *aAudioDriver)
663{
664 if (!aAudioDriver)
665 return E_POINTER;
666
667 AutoCaller autoCaller(this);
668 CheckComRCReturnRC(autoCaller.rc());
669
670 AutoReadLock alock(this);
671
672 *aAudioDriver = mDefaultAudioDriver;
673
674 return S_OK;
675}
676
677// public methods only for internal purposes
678/////////////////////////////////////////////////////////////////////////////
679
680HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
681{
682 AutoCaller autoCaller(this);
683 CheckComRCReturnRC(autoCaller.rc());
684
685 AutoWriteLock alock(this);
686
687 HRESULT rc = S_OK;
688
689 rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
690 CheckComRCReturnRC(rc);
691
692 rc = setDefaultHardDiskFolder(data.strDefaultHardDiskFolder);
693 CheckComRCReturnRC(rc);
694
695 rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
696 CheckComRCReturnRC(rc);
697
698 rc = setRemoteDisplayAuthLibrary(data.strRemoteDisplayAuthLibrary);
699 CheckComRCReturnRC(rc);
700
701 rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
702 CheckComRCReturnRC(rc);
703
704 mLogHistoryCount = data.ulLogHistoryCount;
705
706 return S_OK;
707}
708
709HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
710{
711 AutoCaller autoCaller(this);
712 CheckComRCReturnRC(autoCaller.rc());
713
714 AutoReadLock alock(this);
715
716 data.strDefaultMachineFolder = m_strDefaultMachineFolder;
717 data.strDefaultHardDiskFolder = m_strDefaultHardDiskFolder;
718 data.strDefaultHardDiskFormat = m_strDefaultHardDiskFormat;
719 data.strRemoteDisplayAuthLibrary = m_strRemoteDisplayAuthLibrary;
720 data.strWebServiceAuthLibrary = m_strWebServiceAuthLibrary;
721 data.ulLogHistoryCount = mLogHistoryCount;
722
723 return S_OK;
724}
725
726/**
727 * Returns a medium format object corresponding to the given format
728 * identifier or null if no such format.
729 *
730 * @param aFormat Format identifier.
731 *
732 * @return ComObjPtr<MediumFormat>
733 */
734ComObjPtr<MediumFormat> SystemProperties::mediumFormat (CBSTR aFormat)
735{
736 ComObjPtr<MediumFormat> format;
737
738 AutoCaller autoCaller(this);
739 AssertComRCReturn (autoCaller.rc(), format);
740
741 AutoReadLock alock(this);
742
743 for (MediumFormatList::const_iterator it = mMediumFormats.begin();
744 it != mMediumFormats.end(); ++ it)
745 {
746 /* MediumFormat is all const, no need to lock */
747
748 if ((*it)->id().compareIgnoreCase (aFormat) == 0)
749 {
750 format = *it;
751 break;
752 }
753 }
754
755 return format;
756}
757
758// private methods
759/////////////////////////////////////////////////////////////////////////////
760
761HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &aPath)
762{
763 Utf8Str path(aPath);
764 if (path.isEmpty())
765 path = "Machines";
766
767 /* get the full file name */
768 Utf8Str folder;
769 int vrc = mParent->calculateFullPath(path, folder);
770 if (RT_FAILURE(vrc))
771 return setError(E_FAIL,
772 tr("Invalid default machine folder '%s' (%Rrc)"),
773 path.raw(),
774 vrc);
775
776 m_strDefaultMachineFolder = path;
777 m_strDefaultMachineFolderFull = folder;
778
779 return S_OK;
780}
781
782HRESULT SystemProperties::setDefaultHardDiskFolder(const Utf8Str &aPath)
783{
784 Utf8Str path(aPath);
785 if (path.isEmpty())
786 path = "HardDisks";
787
788 /* get the full file name */
789 Utf8Str folder;
790 int vrc = mParent->calculateFullPath(path, folder);
791 if (RT_FAILURE(vrc))
792 return setError(E_FAIL,
793 tr("Invalid default hard disk folder '%s' (%Rrc)"),
794 path.raw(),
795 vrc);
796
797 m_strDefaultHardDiskFolder = path;
798 m_strDefaultHardDiskFolderFull = folder;
799
800 return S_OK;
801}
802
803HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
804{
805 if (!aFormat.isEmpty())
806 m_strDefaultHardDiskFormat = aFormat;
807 else
808 m_strDefaultHardDiskFormat = "VDI";
809
810 return S_OK;
811}
812
813HRESULT SystemProperties::setRemoteDisplayAuthLibrary(const Utf8Str &aPath)
814{
815 if (!aPath.isEmpty())
816 m_strRemoteDisplayAuthLibrary = aPath;
817 else
818 m_strRemoteDisplayAuthLibrary = "VRDPAuth";
819
820 return S_OK;
821}
822
823HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
824{
825 if (!aPath.isEmpty())
826 m_strWebServiceAuthLibrary = aPath;
827 else
828 m_strWebServiceAuthLibrary = "VRDPAuth";
829
830 return S_OK;
831}
832
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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