VirtualBox

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

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

Main: new VirtualBox::ComposeMachineFilename() API; remove the 'default hard disk folder' concept and related APIs; GUI wizards need fixing

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 23.5 KB
 
1/* $Id: SystemPropertiesImpl.cpp 33238 2010-10-19 15:41:23Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2010 Oracle Corporation
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
20#include "SystemPropertiesImpl.h"
21#include "VirtualBoxImpl.h"
22#include "MachineImpl.h"
23#include "AutoCaller.h"
24#include "Logging.h"
25
26// generated header
27#include "SchemaDefs.h"
28
29#include <iprt/path.h>
30#include <iprt/dir.h>
31#include <iprt/cpp/utils.h>
32
33#include <VBox/err.h>
34#include <VBox/param.h>
35#include <VBox/settings.h>
36#include <VBox/VBoxHDD.h>
37
38// defines
39/////////////////////////////////////////////////////////////////////////////
40
41// constructor / destructor
42/////////////////////////////////////////////////////////////////////////////
43
44SystemProperties::SystemProperties()
45 : mParent(NULL),
46 m(new settings::SystemProperties)
47{
48}
49
50SystemProperties::~SystemProperties()
51{
52 delete m;
53}
54
55
56HRESULT SystemProperties::FinalConstruct()
57{
58 return S_OK;
59}
60
61void SystemProperties::FinalRelease()
62{
63 uninit();
64}
65
66// public methods only for internal purposes
67/////////////////////////////////////////////////////////////////////////////
68
69/**
70 * Initializes the system information object.
71 *
72 * @returns COM result indicator
73 */
74HRESULT SystemProperties::init(VirtualBox *aParent)
75{
76 LogFlowThisFunc(("aParent=%p\n", aParent));
77
78 ComAssertRet(aParent, E_FAIL);
79
80 /* Enclose the state transition NotReady->InInit->Ready */
81 AutoInitSpan autoInitSpan(this);
82 AssertReturn(autoInitSpan.isOk(), E_FAIL);
83
84 unconst(mParent) = aParent;
85
86 setDefaultMachineFolder(Utf8Str::Empty);
87 setDefaultHardDiskFormat(Utf8Str::Empty);
88
89 setRemoteDisplayAuthLibrary(Utf8Str::Empty);
90
91 m->ulLogHistoryCount = 3;
92
93 HRESULT rc = S_OK;
94
95 /* Fetch info of all available hd backends. */
96
97 /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
98 /// any number of backends
99
100 VDBACKENDINFO aVDInfo[100];
101 unsigned cEntries;
102 int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
103 AssertRC(vrc);
104 if (RT_SUCCESS(vrc))
105 {
106 for (unsigned i = 0; i < cEntries; ++ i)
107 {
108 ComObjPtr<MediumFormat> hdf;
109 rc = hdf.createObject();
110 if (FAILED(rc)) break;
111
112 rc = hdf->init(&aVDInfo[i]);
113 if (FAILED(rc)) break;
114
115 m_llMediumFormats.push_back(hdf);
116 }
117 }
118
119 /* Confirm a successful initialization */
120 if (SUCCEEDED(rc))
121 autoInitSpan.setSucceeded();
122
123 return rc;
124}
125
126/**
127 * Uninitializes the instance and sets the ready flag to FALSE.
128 * Called either from FinalRelease() or by the parent when it gets destroyed.
129 */
130void SystemProperties::uninit()
131{
132 LogFlowThisFunc(("\n"));
133
134 /* Enclose the state transition Ready->InUninit->NotReady */
135 AutoUninitSpan autoUninitSpan(this);
136 if (autoUninitSpan.uninitDone())
137 return;
138
139 unconst(mParent) = NULL;
140}
141
142// ISystemProperties properties
143/////////////////////////////////////////////////////////////////////////////
144
145
146STDMETHODIMP SystemProperties::COMGETTER(MinGuestRAM)(ULONG *minRAM)
147{
148 CheckComArgOutPointerValid(minRAM);
149
150 AutoCaller autoCaller(this);
151 if (FAILED(autoCaller.rc())) return autoCaller.rc();
152
153 /* no need to lock, this is const */
154 AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
155 *minRAM = MM_RAM_MIN_IN_MB;
156
157 return S_OK;
158}
159
160STDMETHODIMP SystemProperties::COMGETTER(MaxGuestRAM)(ULONG *maxRAM)
161{
162 CheckComArgOutPointerValid(maxRAM);
163
164 AutoCaller autoCaller(this);
165 if (FAILED(autoCaller.rc())) return autoCaller.rc();
166
167 /* no need to lock, this is const */
168 AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
169 ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
170 ULONG maxRAMArch = maxRAMSys;
171 *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
172
173 return S_OK;
174}
175
176STDMETHODIMP SystemProperties::COMGETTER(MinGuestVRAM)(ULONG *minVRAM)
177{
178 CheckComArgOutPointerValid(minVRAM);
179
180 AutoCaller autoCaller(this);
181 if (FAILED(autoCaller.rc())) return autoCaller.rc();
182
183 /* no need to lock, this is const */
184 *minVRAM = SchemaDefs::MinGuestVRAM;
185
186 return S_OK;
187}
188
189STDMETHODIMP SystemProperties::COMGETTER(MaxGuestVRAM)(ULONG *maxVRAM)
190{
191 CheckComArgOutPointerValid(maxVRAM);
192
193 AutoCaller autoCaller(this);
194 if (FAILED(autoCaller.rc())) return autoCaller.rc();
195
196 /* no need to lock, this is const */
197 *maxVRAM = SchemaDefs::MaxGuestVRAM;
198
199 return S_OK;
200}
201
202STDMETHODIMP SystemProperties::COMGETTER(MinGuestCPUCount)(ULONG *minCPUCount)
203{
204 CheckComArgOutPointerValid(minCPUCount);
205
206 AutoCaller autoCaller(this);
207 if (FAILED(autoCaller.rc())) return autoCaller.rc();
208
209 /* no need to lock, this is const */
210 *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
211
212 return S_OK;
213}
214
215STDMETHODIMP SystemProperties::COMGETTER(MaxGuestCPUCount)(ULONG *maxCPUCount)
216{
217 CheckComArgOutPointerValid(maxCPUCount);
218
219 AutoCaller autoCaller(this);
220 if (FAILED(autoCaller.rc())) return autoCaller.rc();
221
222 /* no need to lock, this is const */
223 *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
224
225 return S_OK;
226}
227
228STDMETHODIMP SystemProperties::COMGETTER(MaxGuestMonitors)(ULONG *maxMonitors)
229{
230 CheckComArgOutPointerValid(maxMonitors);
231
232 AutoCaller autoCaller(this);
233 if (FAILED(autoCaller.rc())) return autoCaller.rc();
234
235 /* no need to lock, this is const */
236 *maxMonitors = SchemaDefs::MaxGuestMonitors;
237
238 return S_OK;
239}
240
241STDMETHODIMP SystemProperties::COMGETTER(InfoVDSize)(LONG64 *infoVDSize)
242{
243 CheckComArgOutPointerValid(infoVDSize);
244
245 AutoCaller autoCaller(this);
246 if (FAILED(autoCaller.rc())) return autoCaller.rc();
247
248 /** The BIOS supports currently 32 bit LBA numbers (implementing the full
249 * 48 bit range is in theory trivial, but the crappy compiler makes things
250 * more difficult). This translates to almost 2 TBytes (to be on the safe
251 * side, the reported limit is 1 MiByte less than that, as the total number
252 * of sectors should fit in 32 bits, too), which should be enough for the
253 * moment. The virtual ATA/SATA disks support complete LBA48, and SCSI
254 * supports LBA64 (almost, more like LBA55 in practice), so the theoretical
255 * maximum disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6
256 * orders of magnitude, but not with 11/13 orders of magnitude. */
257 /* no need to lock, this is const */
258 *infoVDSize = (2048LL * 1024 - 1) * _1M;
259
260 return S_OK;
261}
262
263STDMETHODIMP SystemProperties::COMGETTER(NetworkAdapterCount)(ULONG *count)
264{
265 CheckComArgOutPointerValid(count);
266
267 AutoCaller autoCaller(this);
268 if (FAILED(autoCaller.rc())) return autoCaller.rc();
269
270 /* no need to lock, this is const */
271 *count = SchemaDefs::NetworkAdapterCount;
272
273 return S_OK;
274}
275
276STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
277{
278 CheckComArgOutPointerValid(count);
279
280 AutoCaller autoCaller(this);
281 if (FAILED(autoCaller.rc())) return autoCaller.rc();
282
283 /* no need to lock, this is const */
284 *count = SchemaDefs::SerialPortCount;
285
286 return S_OK;
287}
288
289STDMETHODIMP SystemProperties::COMGETTER(ParallelPortCount)(ULONG *count)
290{
291 CheckComArgOutPointerValid(count);
292
293 AutoCaller autoCaller(this);
294 if (FAILED(autoCaller.rc())) return autoCaller.rc();
295
296 /* no need to lock, this is const */
297 *count = SchemaDefs::ParallelPortCount;
298
299 return S_OK;
300}
301
302STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
303{
304 CheckComArgOutPointerValid(aMaxBootPosition);
305
306 AutoCaller autoCaller(this);
307 if (FAILED(autoCaller.rc())) return autoCaller.rc();
308
309 /* no need to lock, this is const */
310 *aMaxBootPosition = SchemaDefs::MaxBootPosition;
311
312 return S_OK;
313}
314
315STDMETHODIMP SystemProperties::GetMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
316 ULONG *aMaxDevicesPerPort)
317{
318 CheckComArgOutPointerValid(aMaxDevicesPerPort);
319
320 AutoCaller autoCaller(this);
321 if (FAILED(autoCaller.rc())) return autoCaller.rc();
322
323 /* no need to lock, this is const */
324 switch (aBus)
325 {
326 case StorageBus_SATA:
327 case StorageBus_SCSI:
328 case StorageBus_SAS:
329 {
330 /* SATA and both SCSI controllers only support one device per port. */
331 *aMaxDevicesPerPort = 1;
332 break;
333 }
334 case StorageBus_IDE:
335 case StorageBus_Floppy:
336 {
337 /* The IDE and Floppy controllers support 2 devices. One as master
338 * and one as slave (or floppy drive 0 and 1). */
339 *aMaxDevicesPerPort = 2;
340 break;
341 }
342 default:
343 AssertMsgFailed(("Invalid bus type %d\n", aBus));
344 }
345
346 return S_OK;
347}
348
349STDMETHODIMP SystemProperties::GetMinPortCountForStorageBus(StorageBus_T aBus,
350 ULONG *aMinPortCount)
351{
352 CheckComArgOutPointerValid(aMinPortCount);
353
354 AutoCaller autoCaller(this);
355 if (FAILED(autoCaller.rc())) return autoCaller.rc();
356
357 /* no need to lock, this is const */
358 switch (aBus)
359 {
360 case StorageBus_SATA:
361 {
362 *aMinPortCount = 1;
363 break;
364 }
365 case StorageBus_SCSI:
366 {
367 *aMinPortCount = 16;
368 break;
369 }
370 case StorageBus_IDE:
371 {
372 *aMinPortCount = 2;
373 break;
374 }
375 case StorageBus_Floppy:
376 {
377 *aMinPortCount = 1;
378 break;
379 }
380 case StorageBus_SAS:
381 {
382 *aMinPortCount = 8;
383 break;
384 }
385 default:
386 AssertMsgFailed(("Invalid bus type %d\n", aBus));
387 }
388
389 return S_OK;
390}
391
392STDMETHODIMP SystemProperties::GetMaxPortCountForStorageBus(StorageBus_T aBus,
393 ULONG *aMaxPortCount)
394{
395 CheckComArgOutPointerValid(aMaxPortCount);
396
397 AutoCaller autoCaller(this);
398 if (FAILED(autoCaller.rc())) return autoCaller.rc();
399
400 /* no need to lock, this is const */
401 switch (aBus)
402 {
403 case StorageBus_SATA:
404 {
405 *aMaxPortCount = 30;
406 break;
407 }
408 case StorageBus_SCSI:
409 {
410 *aMaxPortCount = 16;
411 break;
412 }
413 case StorageBus_IDE:
414 {
415 *aMaxPortCount = 2;
416 break;
417 }
418 case StorageBus_Floppy:
419 {
420 *aMaxPortCount = 1;
421 break;
422 }
423 case StorageBus_SAS:
424 {
425 *aMaxPortCount = 8;
426 break;
427 }
428 default:
429 AssertMsgFailed(("Invalid bus type %d\n", aBus));
430 }
431
432 return S_OK;
433}
434
435STDMETHODIMP SystemProperties::GetMaxInstancesOfStorageBus(StorageBus_T aBus,
436 ULONG *aMaxInstances)
437{
438 CheckComArgOutPointerValid(aMaxInstances);
439
440 AutoCaller autoCaller(this);
441 if (FAILED(autoCaller.rc())) return autoCaller.rc();
442
443 /* no need to lock, this is const */
444 switch (aBus)
445 {
446 case StorageBus_SATA:
447 case StorageBus_SCSI:
448 case StorageBus_IDE:
449 case StorageBus_SAS:
450 case StorageBus_Floppy:
451 {
452 /** @todo raise the limits ASAP, per bus type */
453 *aMaxInstances = 1;
454 break;
455 }
456 default:
457 AssertMsgFailed(("Invalid bus type %d\n", aBus));
458 }
459
460 return S_OK;
461}
462
463STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
464 ComSafeArrayOut(DeviceType_T, aDeviceTypes))
465{
466 CheckComArgOutSafeArrayPointerValid(aDeviceTypes);
467
468 AutoCaller autoCaller(this);
469 if (FAILED(autoCaller.rc())) return autoCaller.rc();
470
471 /* no need to lock, this is const */
472 switch (aBus)
473 {
474 case StorageBus_IDE:
475 case StorageBus_SATA:
476 {
477 com::SafeArray<DeviceType_T> saDeviceTypes(2);
478 saDeviceTypes[0] = DeviceType_DVD;
479 saDeviceTypes[1] = DeviceType_HardDisk;
480 saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
481 break;
482 }
483 case StorageBus_SCSI:
484 case StorageBus_SAS:
485 {
486 com::SafeArray<DeviceType_T> saDeviceTypes(1);
487 saDeviceTypes[0] = DeviceType_HardDisk;
488 saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
489 break;
490 }
491 case StorageBus_Floppy:
492 {
493 com::SafeArray<DeviceType_T> saDeviceTypes(1);
494 saDeviceTypes[0] = DeviceType_Floppy;
495 saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
496 break;
497 }
498 default:
499 AssertMsgFailed(("Invalid bus type %d\n", aBus));
500 }
501
502 return S_OK;
503}
504
505STDMETHODIMP SystemProperties::GetDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType, BOOL *aEnabled)
506{
507 CheckComArgOutPointerValid(aEnabled);
508
509 AutoCaller autoCaller(this);
510 if (FAILED(autoCaller.rc())) return autoCaller.rc();
511
512 /* no need to lock, this is const */
513 switch (aControllerType)
514 {
515 case StorageControllerType_LsiLogic:
516 case StorageControllerType_BusLogic:
517 case StorageControllerType_IntelAhci:
518 case StorageControllerType_LsiLogicSas:
519 *aEnabled = false;
520 break;
521 case StorageControllerType_PIIX3:
522 case StorageControllerType_PIIX4:
523 case StorageControllerType_ICH6:
524 case StorageControllerType_I82078:
525 *aEnabled = true;
526 break;
527 default:
528 AssertMsgFailed(("Invalid controller type %d\n", aControllerType));
529 }
530 return S_OK;
531}
532
533STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder)(BSTR *aDefaultMachineFolder)
534{
535 CheckComArgOutPointerValid(aDefaultMachineFolder);
536
537 AutoCaller autoCaller(this);
538 if (FAILED(autoCaller.rc())) return autoCaller.rc();
539
540 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
541
542 m_strDefaultMachineFolderFull.cloneTo(aDefaultMachineFolder);
543
544 return S_OK;
545}
546
547STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder)(IN_BSTR aDefaultMachineFolder)
548{
549 AutoCaller autoCaller(this);
550 if (FAILED(autoCaller.rc())) return autoCaller.rc();
551
552 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
553 HRESULT rc = setDefaultMachineFolder(aDefaultMachineFolder);
554 alock.release();
555
556 if (SUCCEEDED(rc))
557 {
558 // VirtualBox::saveSettings() needs vbox write lock
559 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
560 rc = mParent->saveSettings();
561 }
562
563 return rc;
564}
565
566STDMETHODIMP SystemProperties::COMGETTER(MediumFormats)(ComSafeArrayOut(IMediumFormat *, aMediumFormats))
567{
568 CheckComArgOutSafeArrayPointerValid(aMediumFormats);
569
570 AutoCaller autoCaller(this);
571 if (FAILED(autoCaller.rc())) return autoCaller.rc();
572
573 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
574
575 SafeIfaceArray<IMediumFormat> mediumFormats(m_llMediumFormats);
576 mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats));
577
578 return S_OK;
579}
580
581STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat)(BSTR *aDefaultHardDiskFormat)
582{
583 CheckComArgOutPointerValid(aDefaultHardDiskFormat);
584
585 AutoCaller autoCaller(this);
586 if (FAILED(autoCaller.rc())) return autoCaller.rc();
587
588 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
589
590 m->strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
591
592 return S_OK;
593}
594
595STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat)(IN_BSTR aDefaultHardDiskFormat)
596{
597 AutoCaller autoCaller(this);
598 if (FAILED(autoCaller.rc())) return autoCaller.rc();
599
600 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
601 HRESULT rc = setDefaultHardDiskFormat(aDefaultHardDiskFormat);
602 alock.release();
603
604 if (SUCCEEDED(rc))
605 {
606 // VirtualBox::saveSettings() needs vbox write lock
607 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
608 rc = mParent->saveSettings();
609 }
610
611 return rc;
612}
613
614STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceWarning)(LONG64 *aFreeSpace)
615{
616 CheckComArgOutPointerValid(aFreeSpace);
617
618 ReturnComNotImplemented();
619}
620
621STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceWarning)(LONG64 /* aFreeSpace */)
622{
623 ReturnComNotImplemented();
624}
625
626STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentWarning)(ULONG *aFreeSpacePercent)
627{
628 CheckComArgOutPointerValid(aFreeSpacePercent);
629
630 ReturnComNotImplemented();
631}
632
633STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentWarning)(ULONG /* aFreeSpacePercent */)
634{
635 ReturnComNotImplemented();
636}
637
638STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceError)(LONG64 *aFreeSpace)
639{
640 CheckComArgOutPointerValid(aFreeSpace);
641
642 ReturnComNotImplemented();
643}
644
645STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceError)(LONG64 /* aFreeSpace */)
646{
647 ReturnComNotImplemented();
648}
649
650STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentError)(ULONG *aFreeSpacePercent)
651{
652 CheckComArgOutPointerValid(aFreeSpacePercent);
653
654 ReturnComNotImplemented();
655}
656
657STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentError)(ULONG /* aFreeSpacePercent */)
658{
659 ReturnComNotImplemented();
660}
661
662STDMETHODIMP SystemProperties::COMGETTER(RemoteDisplayAuthLibrary)(BSTR *aRemoteDisplayAuthLibrary)
663{
664 CheckComArgOutPointerValid(aRemoteDisplayAuthLibrary);
665
666 AutoCaller autoCaller(this);
667 if (FAILED(autoCaller.rc())) return autoCaller.rc();
668
669 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
670
671 m->strRemoteDisplayAuthLibrary.cloneTo(aRemoteDisplayAuthLibrary);
672
673 return S_OK;
674}
675
676STDMETHODIMP SystemProperties::COMSETTER(RemoteDisplayAuthLibrary)(IN_BSTR aRemoteDisplayAuthLibrary)
677{
678 AutoCaller autoCaller(this);
679 if (FAILED(autoCaller.rc())) return autoCaller.rc();
680
681 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
682 HRESULT rc = setRemoteDisplayAuthLibrary(aRemoteDisplayAuthLibrary);
683 alock.release();
684
685 if (SUCCEEDED(rc))
686 {
687 // VirtualBox::saveSettings() needs vbox write lock
688 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
689 rc = mParent->saveSettings();
690 }
691
692 return rc;
693}
694
695STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary)(BSTR *aWebServiceAuthLibrary)
696{
697 CheckComArgOutPointerValid(aWebServiceAuthLibrary);
698
699 AutoCaller autoCaller(this);
700 if (FAILED(autoCaller.rc())) return autoCaller.rc();
701
702 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
703
704 m->strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
705
706 return S_OK;
707}
708
709STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary)(IN_BSTR aWebServiceAuthLibrary)
710{
711 AutoCaller autoCaller(this);
712 if (FAILED(autoCaller.rc())) return autoCaller.rc();
713
714 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
715 HRESULT rc = setWebServiceAuthLibrary(aWebServiceAuthLibrary);
716 alock.release();
717
718 if (SUCCEEDED(rc))
719 {
720 // VirtualBox::saveSettings() needs vbox write lock
721 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
722 rc = mParent->saveSettings();
723 }
724
725 return rc;
726}
727
728STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount)(ULONG *count)
729{
730 CheckComArgOutPointerValid(count);
731
732 AutoCaller autoCaller(this);
733 if (FAILED(autoCaller.rc())) return autoCaller.rc();
734
735 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
736
737 *count = m->ulLogHistoryCount;
738
739 return S_OK;
740}
741
742STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount)(ULONG count)
743{
744 AutoCaller autoCaller(this);
745 if (FAILED(autoCaller.rc())) return autoCaller.rc();
746
747 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
748 m->ulLogHistoryCount = count;
749 alock.release();
750
751 // VirtualBox::saveSettings() needs vbox write lock
752 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
753 HRESULT rc = mParent->saveSettings();
754
755 return rc;
756}
757
758STDMETHODIMP SystemProperties::COMGETTER(DefaultAudioDriver)(AudioDriverType_T *aAudioDriver)
759{
760 CheckComArgOutPointerValid(aAudioDriver);
761
762 AutoCaller autoCaller(this);
763 if (FAILED(autoCaller.rc())) return autoCaller.rc();
764
765 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
766
767 *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
768
769 return S_OK;
770}
771
772// public methods only for internal purposes
773/////////////////////////////////////////////////////////////////////////////
774
775HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
776{
777 AutoCaller autoCaller(this);
778 if (FAILED(autoCaller.rc())) return autoCaller.rc();
779
780 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
781
782 HRESULT rc = S_OK;
783
784 rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
785 if (FAILED(rc)) return rc;
786
787 rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
788 if (FAILED(rc)) return rc;
789
790 rc = setRemoteDisplayAuthLibrary(data.strRemoteDisplayAuthLibrary);
791 if (FAILED(rc)) return rc;
792
793 rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
794 if (FAILED(rc)) return rc;
795
796 m->ulLogHistoryCount = data.ulLogHistoryCount;
797
798 return S_OK;
799}
800
801HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
802{
803 AutoCaller autoCaller(this);
804 if (FAILED(autoCaller.rc())) return autoCaller.rc();
805
806 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
807
808 data = *m;
809
810 return S_OK;
811}
812
813/**
814 * Returns a medium format object corresponding to the given format
815 * identifier or null if no such format.
816 *
817 * @param aFormat Format identifier.
818 *
819 * @return ComObjPtr<MediumFormat>
820 */
821ComObjPtr<MediumFormat> SystemProperties::mediumFormat(const Utf8Str &aFormat)
822{
823 ComObjPtr<MediumFormat> format;
824
825 AutoCaller autoCaller(this);
826 AssertComRCReturn (autoCaller.rc(), format);
827
828 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
829
830 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
831 it != m_llMediumFormats.end();
832 ++ it)
833 {
834 /* MediumFormat is all const, no need to lock */
835
836 if ((*it)->getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
837 {
838 format = *it;
839 break;
840 }
841 }
842
843 return format;
844}
845
846// private methods
847/////////////////////////////////////////////////////////////////////////////
848
849HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &aPath)
850{
851 Utf8Str path(aPath);
852 if (path.isEmpty())
853 path = "Machines";
854
855 /* get the full file name */
856 Utf8Str folder;
857 int vrc = mParent->calculateFullPath(path, folder);
858 if (RT_FAILURE(vrc))
859 return setError(E_FAIL,
860 tr("Invalid default machine folder '%s' (%Rrc)"),
861 path.c_str(),
862 vrc);
863
864 m->strDefaultMachineFolder = path;
865 m_strDefaultMachineFolderFull = folder;
866
867 return S_OK;
868}
869
870HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
871{
872 if (!aFormat.isEmpty())
873 m->strDefaultHardDiskFormat = aFormat;
874 else
875 m->strDefaultHardDiskFormat = "VDI";
876
877 return S_OK;
878}
879
880HRESULT SystemProperties::setRemoteDisplayAuthLibrary(const Utf8Str &aPath)
881{
882 if (!aPath.isEmpty())
883 m->strRemoteDisplayAuthLibrary = aPath;
884 else
885 m->strRemoteDisplayAuthLibrary = "VRDPAuth";
886
887 return S_OK;
888}
889
890HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
891{
892 if (!aPath.isEmpty())
893 m->strWebServiceAuthLibrary = aPath;
894 else
895 m->strWebServiceAuthLibrary = "VRDPAuth";
896
897 return S_OK;
898}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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