VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp@ 47991

Last change on this file since 47991 was 47991, checked in by vboxsync, 12 years ago

Main: Made the exclusive HW virtualization use setting global rather than per-VM.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.6 KB
Line 
1/* $Id: SystemPropertiesImpl.cpp 47991 2013-08-22 14:31:52Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "SystemPropertiesImpl.h"
19#include "VirtualBoxImpl.h"
20#include "MachineImpl.h"
21#ifdef VBOX_WITH_EXTPACK
22# include "ExtPackManagerImpl.h"
23#endif
24#include "AutoCaller.h"
25#include "Global.h"
26#include "Logging.h"
27#include "AutostartDb.h"
28
29// generated header
30#include "SchemaDefs.h"
31
32#include <iprt/dir.h>
33#include <iprt/ldr.h>
34#include <iprt/path.h>
35#include <iprt/string.h>
36#include <iprt/cpp/utils.h>
37
38#include <VBox/err.h>
39#include <VBox/param.h>
40#include <VBox/settings.h>
41#include <VBox/vd.h>
42
43// defines
44/////////////////////////////////////////////////////////////////////////////
45
46// constructor / destructor
47/////////////////////////////////////////////////////////////////////////////
48
49SystemProperties::SystemProperties()
50 : mParent(NULL),
51 m(new settings::SystemProperties)
52{
53}
54
55SystemProperties::~SystemProperties()
56{
57 delete m;
58}
59
60
61HRESULT SystemProperties::FinalConstruct()
62{
63 return BaseFinalConstruct();
64}
65
66void SystemProperties::FinalRelease()
67{
68 uninit();
69 BaseFinalRelease();
70}
71
72// public methods only for internal purposes
73/////////////////////////////////////////////////////////////////////////////
74
75/**
76 * Initializes the system information object.
77 *
78 * @returns COM result indicator
79 */
80HRESULT SystemProperties::init(VirtualBox *aParent)
81{
82 LogFlowThisFunc(("aParent=%p\n", aParent));
83
84 ComAssertRet(aParent, E_FAIL);
85
86 /* Enclose the state transition NotReady->InInit->Ready */
87 AutoInitSpan autoInitSpan(this);
88 AssertReturn(autoInitSpan.isOk(), E_FAIL);
89
90 unconst(mParent) = aParent;
91
92 setDefaultMachineFolder(Utf8Str::Empty);
93 setLoggingLevel(Utf8Str::Empty);
94 setDefaultHardDiskFormat(Utf8Str::Empty);
95
96 setVRDEAuthLibrary(Utf8Str::Empty);
97 setDefaultVRDEExtPack(Utf8Str::Empty);
98
99 m->ulLogHistoryCount = 3;
100
101
102 /* On Windows and OS X, HW virtualization use isn't exclusive by
103 * default so that VT-x or AMD-V can be shared with other
104 * hypervisors without requiring user intervention.
105 */
106#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
107 m->fExclusiveHwVirt = false;
108#else
109 m->fExclusiveHwVirt = true;
110#endif
111
112 HRESULT rc = S_OK;
113
114 /* Fetch info of all available hd backends. */
115
116 /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
117 /// any number of backends
118
119 VDBACKENDINFO aVDInfo[100];
120 unsigned cEntries;
121 int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
122 AssertRC(vrc);
123 if (RT_SUCCESS(vrc))
124 {
125 for (unsigned i = 0; i < cEntries; ++ i)
126 {
127 ComObjPtr<MediumFormat> hdf;
128 rc = hdf.createObject();
129 if (FAILED(rc)) break;
130
131 rc = hdf->init(&aVDInfo[i]);
132 if (FAILED(rc)) break;
133
134 m_llMediumFormats.push_back(hdf);
135 }
136 }
137
138 /* Confirm a successful initialization */
139 if (SUCCEEDED(rc))
140 autoInitSpan.setSucceeded();
141
142 return rc;
143}
144
145/**
146 * Uninitializes the instance and sets the ready flag to FALSE.
147 * Called either from FinalRelease() or by the parent when it gets destroyed.
148 */
149void SystemProperties::uninit()
150{
151 LogFlowThisFunc(("\n"));
152
153 /* Enclose the state transition Ready->InUninit->NotReady */
154 AutoUninitSpan autoUninitSpan(this);
155 if (autoUninitSpan.uninitDone())
156 return;
157
158 unconst(mParent) = NULL;
159}
160
161// ISystemProperties properties
162/////////////////////////////////////////////////////////////////////////////
163
164
165STDMETHODIMP SystemProperties::COMGETTER(MinGuestRAM)(ULONG *minRAM)
166{
167 CheckComArgOutPointerValid(minRAM);
168
169 AutoCaller autoCaller(this);
170 if (FAILED(autoCaller.rc())) return autoCaller.rc();
171
172 /* no need to lock, this is const */
173 AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
174 *minRAM = MM_RAM_MIN_IN_MB;
175
176 return S_OK;
177}
178
179STDMETHODIMP SystemProperties::COMGETTER(MaxGuestRAM)(ULONG *maxRAM)
180{
181 CheckComArgOutPointerValid(maxRAM);
182
183 AutoCaller autoCaller(this);
184 if (FAILED(autoCaller.rc())) return autoCaller.rc();
185
186 /* no need to lock, this is const */
187 AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
188 ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
189 ULONG maxRAMArch = maxRAMSys;
190 *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
191
192 return S_OK;
193}
194
195STDMETHODIMP SystemProperties::COMGETTER(MinGuestVRAM)(ULONG *minVRAM)
196{
197 CheckComArgOutPointerValid(minVRAM);
198
199 AutoCaller autoCaller(this);
200 if (FAILED(autoCaller.rc())) return autoCaller.rc();
201
202 /* no need to lock, this is const */
203 *minVRAM = SchemaDefs::MinGuestVRAM;
204
205 return S_OK;
206}
207
208STDMETHODIMP SystemProperties::COMGETTER(MaxGuestVRAM)(ULONG *maxVRAM)
209{
210 CheckComArgOutPointerValid(maxVRAM);
211
212 AutoCaller autoCaller(this);
213 if (FAILED(autoCaller.rc())) return autoCaller.rc();
214
215 /* no need to lock, this is const */
216 *maxVRAM = SchemaDefs::MaxGuestVRAM;
217
218 return S_OK;
219}
220
221STDMETHODIMP SystemProperties::COMGETTER(MinGuestCPUCount)(ULONG *minCPUCount)
222{
223 CheckComArgOutPointerValid(minCPUCount);
224
225 AutoCaller autoCaller(this);
226 if (FAILED(autoCaller.rc())) return autoCaller.rc();
227
228 /* no need to lock, this is const */
229 *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
230
231 return S_OK;
232}
233
234STDMETHODIMP SystemProperties::COMGETTER(MaxGuestCPUCount)(ULONG *maxCPUCount)
235{
236 CheckComArgOutPointerValid(maxCPUCount);
237
238 AutoCaller autoCaller(this);
239 if (FAILED(autoCaller.rc())) return autoCaller.rc();
240
241 /* no need to lock, this is const */
242 *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
243
244 return S_OK;
245}
246
247STDMETHODIMP SystemProperties::COMGETTER(MaxGuestMonitors)(ULONG *maxMonitors)
248{
249 CheckComArgOutPointerValid(maxMonitors);
250
251 AutoCaller autoCaller(this);
252 if (FAILED(autoCaller.rc())) return autoCaller.rc();
253
254 /* no need to lock, this is const */
255 *maxMonitors = SchemaDefs::MaxGuestMonitors;
256
257 return S_OK;
258}
259
260STDMETHODIMP SystemProperties::COMGETTER(InfoVDSize)(LONG64 *infoVDSize)
261{
262 CheckComArgOutPointerValid(infoVDSize);
263
264 AutoCaller autoCaller(this);
265 if (FAILED(autoCaller.rc())) return autoCaller.rc();
266
267 /*
268 * The BIOS supports currently 32 bit LBA numbers (implementing the full
269 * 48 bit range is in theory trivial, but the crappy compiler makes things
270 * more difficult). This translates to almost 2 TiBytes (to be on the safe
271 * side, the reported limit is 1 MiByte less than that, as the total number
272 * of sectors should fit in 32 bits, too), which should be enough for the
273 * moment. Since the MBR partition tables support only 32bit sector numbers
274 * and thus the BIOS can only boot from disks smaller than 2T this is a
275 * rather hard limit.
276 *
277 * The virtual ATA/SATA disks support complete LBA48, and SCSI supports
278 * LBA64 (almost, more like LBA55 in practice), so the theoretical maximum
279 * disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6 orders
280 * of magnitude, but not with 11..13 orders of magnitude.
281 */
282 /* no need to lock, this is const */
283 *infoVDSize = 2 * _1T - _1M;
284
285 return S_OK;
286}
287
288STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
289{
290 CheckComArgOutPointerValid(count);
291
292 AutoCaller autoCaller(this);
293 if (FAILED(autoCaller.rc())) return autoCaller.rc();
294
295 /* no need to lock, this is const */
296 *count = SchemaDefs::SerialPortCount;
297
298 return S_OK;
299}
300
301STDMETHODIMP SystemProperties::COMGETTER(ParallelPortCount)(ULONG *count)
302{
303 CheckComArgOutPointerValid(count);
304
305 AutoCaller autoCaller(this);
306 if (FAILED(autoCaller.rc())) return autoCaller.rc();
307
308 /* no need to lock, this is const */
309 *count = SchemaDefs::ParallelPortCount;
310
311 return S_OK;
312}
313
314STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
315{
316 CheckComArgOutPointerValid(aMaxBootPosition);
317
318 AutoCaller autoCaller(this);
319 if (FAILED(autoCaller.rc())) return autoCaller.rc();
320
321 /* no need to lock, this is const */
322 *aMaxBootPosition = SchemaDefs::MaxBootPosition;
323
324 return S_OK;
325}
326
327
328STDMETHODIMP SystemProperties::COMGETTER(ExclusiveHwVirt)(BOOL *aExclusiveHwVirt)
329{
330 CheckComArgOutPointerValid(aExclusiveHwVirt);
331
332 AutoCaller autoCaller(this);
333 if (FAILED(autoCaller.rc())) return autoCaller.rc();
334
335 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
336
337 *aExclusiveHwVirt = m->fExclusiveHwVirt;
338
339 return S_OK;
340}
341
342STDMETHODIMP SystemProperties::COMSETTER(ExclusiveHwVirt)(BOOL aExclusiveHwVirt)
343{
344 AutoCaller autoCaller(this);
345 if (FAILED(autoCaller.rc())) return autoCaller.rc();
346
347 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
348 m->fExclusiveHwVirt = !!aExclusiveHwVirt;
349 alock.release();
350
351 // VirtualBox::saveSettings() needs vbox write lock
352 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
353 HRESULT rc = mParent->saveSettings();
354
355 return rc;
356}
357
358STDMETHODIMP SystemProperties::GetMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *count)
359{
360 CheckComArgOutPointerValid(count);
361
362 AutoCaller autoCaller(this);
363 if (FAILED(autoCaller.rc())) return autoCaller.rc();
364
365 /* no need for locking, no state */
366 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
367 if (uResult == 0)
368 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
369
370 *count = uResult;
371
372 return S_OK;
373}
374
375STDMETHODIMP SystemProperties::GetMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType, ULONG *count)
376{
377 CheckComArgOutPointerValid(count);
378
379 AutoCaller autoCaller(this);
380 if (FAILED(autoCaller.rc())) return autoCaller.rc();
381
382 /* no need for locking, no state */
383 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
384 if (uResult == 0)
385 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
386
387 switch (aType)
388 {
389 case NetworkAttachmentType_NAT:
390 case NetworkAttachmentType_Internal:
391 /* chipset default is OK */
392 break;
393 case NetworkAttachmentType_Bridged:
394 /* Maybe use current host interface count here? */
395 break;
396 case NetworkAttachmentType_HostOnly:
397 uResult = RT_MIN(uResult, 8);
398 break;
399 default:
400 AssertMsgFailed(("Unhandled attachment type %d\n", aType));
401 }
402
403 *count = uResult;
404
405 return S_OK;
406}
407
408
409STDMETHODIMP SystemProperties::GetMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
410 ULONG *aMaxDevicesPerPort)
411{
412 CheckComArgOutPointerValid(aMaxDevicesPerPort);
413
414 AutoCaller autoCaller(this);
415 if (FAILED(autoCaller.rc())) return autoCaller.rc();
416
417 /* no need to lock, this is const */
418 switch (aBus)
419 {
420 case StorageBus_SATA:
421 case StorageBus_SCSI:
422 case StorageBus_SAS:
423 {
424 /* SATA and both SCSI controllers only support one device per port. */
425 *aMaxDevicesPerPort = 1;
426 break;
427 }
428 case StorageBus_IDE:
429 case StorageBus_Floppy:
430 {
431 /* The IDE and Floppy controllers support 2 devices. One as master
432 * and one as slave (or floppy drive 0 and 1). */
433 *aMaxDevicesPerPort = 2;
434 break;
435 }
436 default:
437 AssertMsgFailed(("Invalid bus type %d\n", aBus));
438 }
439
440 return S_OK;
441}
442
443STDMETHODIMP SystemProperties::GetMinPortCountForStorageBus(StorageBus_T aBus,
444 ULONG *aMinPortCount)
445{
446 CheckComArgOutPointerValid(aMinPortCount);
447
448 AutoCaller autoCaller(this);
449 if (FAILED(autoCaller.rc())) return autoCaller.rc();
450
451 /* no need to lock, this is const */
452 switch (aBus)
453 {
454 case StorageBus_SATA:
455 {
456 *aMinPortCount = 1;
457 break;
458 }
459 case StorageBus_SCSI:
460 {
461 *aMinPortCount = 16;
462 break;
463 }
464 case StorageBus_IDE:
465 {
466 *aMinPortCount = 2;
467 break;
468 }
469 case StorageBus_Floppy:
470 {
471 *aMinPortCount = 1;
472 break;
473 }
474 case StorageBus_SAS:
475 {
476 *aMinPortCount = 8;
477 break;
478 }
479 default:
480 AssertMsgFailed(("Invalid bus type %d\n", aBus));
481 }
482
483 return S_OK;
484}
485
486STDMETHODIMP SystemProperties::GetMaxPortCountForStorageBus(StorageBus_T aBus,
487 ULONG *aMaxPortCount)
488{
489 CheckComArgOutPointerValid(aMaxPortCount);
490
491 AutoCaller autoCaller(this);
492 if (FAILED(autoCaller.rc())) return autoCaller.rc();
493
494 /* no need to lock, this is const */
495 switch (aBus)
496 {
497 case StorageBus_SATA:
498 {
499 *aMaxPortCount = 30;
500 break;
501 }
502 case StorageBus_SCSI:
503 {
504 *aMaxPortCount = 16;
505 break;
506 }
507 case StorageBus_IDE:
508 {
509 *aMaxPortCount = 2;
510 break;
511 }
512 case StorageBus_Floppy:
513 {
514 *aMaxPortCount = 1;
515 break;
516 }
517 case StorageBus_SAS:
518 {
519 *aMaxPortCount = 8;
520 break;
521 }
522 default:
523 AssertMsgFailed(("Invalid bus type %d\n", aBus));
524 }
525
526 return S_OK;
527}
528
529STDMETHODIMP SystemProperties::GetMaxInstancesOfStorageBus(ChipsetType_T aChipset,
530 StorageBus_T aBus,
531 ULONG *aMaxInstances)
532{
533 CheckComArgOutPointerValid(aMaxInstances);
534
535 AutoCaller autoCaller(this);
536 if (FAILED(autoCaller.rc())) return autoCaller.rc();
537
538 ULONG cCtrs = 0;
539
540 /* no need to lock, this is const */
541 switch (aBus)
542 {
543 case StorageBus_SATA:
544 case StorageBus_SCSI:
545 case StorageBus_SAS:
546 cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
547 break;
548 case StorageBus_IDE:
549 case StorageBus_Floppy:
550 {
551 cCtrs = 1;
552 break;
553 }
554 default:
555 AssertMsgFailed(("Invalid bus type %d\n", aBus));
556 }
557
558 *aMaxInstances = cCtrs;
559
560 return S_OK;
561}
562
563STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
564 ComSafeArrayOut(DeviceType_T, aDeviceTypes))
565{
566 CheckComArgOutSafeArrayPointerValid(aDeviceTypes);
567
568 AutoCaller autoCaller(this);
569 if (FAILED(autoCaller.rc())) return autoCaller.rc();
570
571 /* no need to lock, this is const */
572 switch (aBus)
573 {
574 case StorageBus_IDE:
575 case StorageBus_SATA:
576 case StorageBus_SCSI:
577 case StorageBus_SAS:
578 {
579 com::SafeArray<DeviceType_T> saDeviceTypes(2);
580 saDeviceTypes[0] = DeviceType_DVD;
581 saDeviceTypes[1] = DeviceType_HardDisk;
582 saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
583 break;
584 }
585 case StorageBus_Floppy:
586 {
587 com::SafeArray<DeviceType_T> saDeviceTypes(1);
588 saDeviceTypes[0] = DeviceType_Floppy;
589 saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
590 break;
591 }
592 default:
593 AssertMsgFailed(("Invalid bus type %d\n", aBus));
594 }
595
596 return S_OK;
597}
598
599STDMETHODIMP SystemProperties::GetDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType, BOOL *aEnabled)
600{
601 CheckComArgOutPointerValid(aEnabled);
602
603 AutoCaller autoCaller(this);
604 if (FAILED(autoCaller.rc())) return autoCaller.rc();
605
606 /* no need to lock, this is const */
607 switch (aControllerType)
608 {
609 case StorageControllerType_LsiLogic:
610 case StorageControllerType_BusLogic:
611 case StorageControllerType_IntelAhci:
612 case StorageControllerType_LsiLogicSas:
613 *aEnabled = false;
614 break;
615 case StorageControllerType_PIIX3:
616 case StorageControllerType_PIIX4:
617 case StorageControllerType_ICH6:
618 case StorageControllerType_I82078:
619 *aEnabled = true;
620 break;
621 default:
622 AssertMsgFailed(("Invalid controller type %d\n", aControllerType));
623 }
624 return S_OK;
625}
626
627STDMETHODIMP SystemProperties::GetMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
628 USBControllerType_T aType,
629 ULONG *aMaxInstances)
630{
631 NOREF(aChipset);
632 CheckComArgOutPointerValid(aMaxInstances);
633
634 AutoCaller autoCaller(this);
635 if (FAILED(autoCaller.rc())) return autoCaller.rc();
636
637 ULONG cCtrs = 0;
638
639 /* no need to lock, this is const */
640 switch (aType)
641 {
642 case USBControllerType_OHCI:
643 case USBControllerType_EHCI:
644 {
645 cCtrs = 1;
646 break;
647 }
648 default:
649 AssertMsgFailed(("Invalid bus type %d\n", aType));
650 }
651
652 *aMaxInstances = cCtrs;
653
654 return S_OK;
655}
656
657STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder)(BSTR *aDefaultMachineFolder)
658{
659 CheckComArgOutPointerValid(aDefaultMachineFolder);
660
661 AutoCaller autoCaller(this);
662 if (FAILED(autoCaller.rc())) return autoCaller.rc();
663
664 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
665
666 m->strDefaultMachineFolder.cloneTo(aDefaultMachineFolder);
667
668 return S_OK;
669}
670
671STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder)(IN_BSTR aDefaultMachineFolder)
672{
673 AutoCaller autoCaller(this);
674 if (FAILED(autoCaller.rc())) return autoCaller.rc();
675
676 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
677 HRESULT rc = setDefaultMachineFolder(aDefaultMachineFolder);
678 alock.release();
679
680 if (SUCCEEDED(rc))
681 {
682 // VirtualBox::saveSettings() needs vbox write lock
683 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
684 rc = mParent->saveSettings();
685 }
686
687 return rc;
688}
689
690STDMETHODIMP SystemProperties::COMGETTER(LoggingLevel)(BSTR *aLoggingLevel)
691{
692 CheckComArgOutPointerValid(aLoggingLevel);
693
694 AutoCaller autoCaller(this);
695 if (FAILED(autoCaller.rc())) return autoCaller.rc();
696
697 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
698
699 Utf8Str useLoggingLevel(m->strLoggingLevel);
700 if (useLoggingLevel.isEmpty())
701 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
702
703 useLoggingLevel.cloneTo(aLoggingLevel);
704 return S_OK;
705}
706
707
708STDMETHODIMP SystemProperties::COMSETTER(LoggingLevel)(IN_BSTR aLoggingLevel)
709{
710 AutoCaller autoCaller(this);
711 if (FAILED(autoCaller.rc())) return autoCaller.rc();
712
713 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
714 HRESULT rc = setLoggingLevel(aLoggingLevel);
715 alock.release();
716
717 if (SUCCEEDED(rc))
718 {
719 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
720 rc = mParent->saveSettings();
721 }
722 else
723 LogRel(("Cannot set passed logging level=%ls, or the default one - Error=%Rhrc \n", aLoggingLevel, rc));
724
725 return rc;
726}
727
728STDMETHODIMP SystemProperties::COMGETTER(MediumFormats)(ComSafeArrayOut(IMediumFormat *, aMediumFormats))
729{
730 CheckComArgOutSafeArrayPointerValid(aMediumFormats);
731
732 AutoCaller autoCaller(this);
733 if (FAILED(autoCaller.rc())) return autoCaller.rc();
734
735 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
736
737 SafeIfaceArray<IMediumFormat> mediumFormats(m_llMediumFormats);
738 mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats));
739
740 return S_OK;
741}
742
743STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat)(BSTR *aDefaultHardDiskFormat)
744{
745 CheckComArgOutPointerValid(aDefaultHardDiskFormat);
746
747 AutoCaller autoCaller(this);
748 if (FAILED(autoCaller.rc())) return autoCaller.rc();
749
750 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
751
752 m->strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
753
754 return S_OK;
755}
756
757STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat)(IN_BSTR aDefaultHardDiskFormat)
758{
759 AutoCaller autoCaller(this);
760 if (FAILED(autoCaller.rc())) return autoCaller.rc();
761
762 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
763 HRESULT rc = setDefaultHardDiskFormat(aDefaultHardDiskFormat);
764 alock.release();
765
766 if (SUCCEEDED(rc))
767 {
768 // VirtualBox::saveSettings() needs vbox write lock
769 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
770 rc = mParent->saveSettings();
771 }
772
773 return rc;
774}
775
776STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceWarning)(LONG64 *aFreeSpace)
777{
778 CheckComArgOutPointerValid(aFreeSpace);
779
780 ReturnComNotImplemented();
781}
782
783STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceWarning)(LONG64 /* aFreeSpace */)
784{
785 ReturnComNotImplemented();
786}
787
788STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentWarning)(ULONG *aFreeSpacePercent)
789{
790 CheckComArgOutPointerValid(aFreeSpacePercent);
791
792 ReturnComNotImplemented();
793}
794
795STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentWarning)(ULONG /* aFreeSpacePercent */)
796{
797 ReturnComNotImplemented();
798}
799
800STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceError)(LONG64 *aFreeSpace)
801{
802 CheckComArgOutPointerValid(aFreeSpace);
803
804 ReturnComNotImplemented();
805}
806
807STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceError)(LONG64 /* aFreeSpace */)
808{
809 ReturnComNotImplemented();
810}
811
812STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentError)(ULONG *aFreeSpacePercent)
813{
814 CheckComArgOutPointerValid(aFreeSpacePercent);
815
816 ReturnComNotImplemented();
817}
818
819STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentError)(ULONG /* aFreeSpacePercent */)
820{
821 ReturnComNotImplemented();
822}
823
824STDMETHODIMP SystemProperties::COMGETTER(VRDEAuthLibrary)(BSTR *aVRDEAuthLibrary)
825{
826 CheckComArgOutPointerValid(aVRDEAuthLibrary);
827
828 AutoCaller autoCaller(this);
829 if (FAILED(autoCaller.rc())) return autoCaller.rc();
830
831 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
832
833 m->strVRDEAuthLibrary.cloneTo(aVRDEAuthLibrary);
834
835 return S_OK;
836}
837
838STDMETHODIMP SystemProperties::COMSETTER(VRDEAuthLibrary)(IN_BSTR aVRDEAuthLibrary)
839{
840 AutoCaller autoCaller(this);
841 if (FAILED(autoCaller.rc())) return autoCaller.rc();
842
843 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
844 HRESULT rc = setVRDEAuthLibrary(aVRDEAuthLibrary);
845 alock.release();
846
847 if (SUCCEEDED(rc))
848 {
849 // VirtualBox::saveSettings() needs vbox write lock
850 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
851 rc = mParent->saveSettings();
852 }
853
854 return rc;
855}
856
857STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary)(BSTR *aWebServiceAuthLibrary)
858{
859 CheckComArgOutPointerValid(aWebServiceAuthLibrary);
860
861 AutoCaller autoCaller(this);
862 if (FAILED(autoCaller.rc())) return autoCaller.rc();
863
864 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
865
866 m->strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
867
868 return S_OK;
869}
870
871STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary)(IN_BSTR aWebServiceAuthLibrary)
872{
873 AutoCaller autoCaller(this);
874 if (FAILED(autoCaller.rc())) return autoCaller.rc();
875
876 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
877 HRESULT rc = setWebServiceAuthLibrary(aWebServiceAuthLibrary);
878 alock.release();
879
880 if (SUCCEEDED(rc))
881 {
882 // VirtualBox::saveSettings() needs vbox write lock
883 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
884 rc = mParent->saveSettings();
885 }
886
887 return rc;
888}
889
890STDMETHODIMP SystemProperties::COMGETTER(DefaultVRDEExtPack)(BSTR *aExtPack)
891{
892 CheckComArgOutPointerValid(aExtPack);
893
894 AutoCaller autoCaller(this);
895 HRESULT hrc = autoCaller.rc();
896 if (SUCCEEDED(hrc))
897 {
898 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
899 Utf8Str strExtPack(m->strDefaultVRDEExtPack);
900 if (strExtPack.isNotEmpty())
901 {
902 if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
903 hrc = S_OK;
904 else
905#ifdef VBOX_WITH_EXTPACK
906 hrc = mParent->getExtPackManager()->checkVrdeExtPack(&strExtPack);
907#else
908 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
909#endif
910 }
911 else
912 {
913#ifdef VBOX_WITH_EXTPACK
914 hrc = mParent->getExtPackManager()->getDefaultVrdeExtPack(&strExtPack);
915#endif
916 if (strExtPack.isEmpty())
917 {
918 /*
919 * Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
920 * This is hardcoded uglyness, sorry.
921 */
922 char szPath[RTPATH_MAX];
923 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
924 if (RT_SUCCESS(vrc))
925 vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxVRDP");
926 if (RT_SUCCESS(vrc))
927 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
928 if (RT_SUCCESS(vrc) && RTFileExists(szPath))
929 {
930 /* Illegal extpack name, so no conflict. */
931 strExtPack = VBOXVRDP_KLUDGE_EXTPACK_NAME;
932 }
933 }
934 }
935
936 if (SUCCEEDED(hrc))
937 strExtPack.cloneTo(aExtPack);
938 }
939
940 return S_OK;
941}
942
943STDMETHODIMP SystemProperties::COMSETTER(DefaultVRDEExtPack)(IN_BSTR aExtPack)
944{
945 CheckComArgNotNull(aExtPack);
946 Utf8Str strExtPack(aExtPack);
947
948 AutoCaller autoCaller(this);
949 HRESULT hrc = autoCaller.rc();
950 if (SUCCEEDED(hrc))
951 {
952 if (strExtPack.isNotEmpty())
953 {
954 if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
955 hrc = S_OK;
956 else
957#ifdef VBOX_WITH_EXTPACK
958 hrc = mParent->getExtPackManager()->checkVrdeExtPack(&strExtPack);
959#else
960 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
961#endif
962 }
963 if (SUCCEEDED(hrc))
964 {
965 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
966 hrc = setDefaultVRDEExtPack(aExtPack);
967 if (SUCCEEDED(hrc))
968 {
969 /* VirtualBox::saveSettings() needs the VirtualBox write lock. */
970 alock.release();
971 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
972 hrc = mParent->saveSettings();
973 }
974 }
975 }
976
977 return hrc;
978}
979
980STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount)(ULONG *count)
981{
982 CheckComArgOutPointerValid(count);
983
984 AutoCaller autoCaller(this);
985 if (FAILED(autoCaller.rc())) return autoCaller.rc();
986
987 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
988
989 *count = m->ulLogHistoryCount;
990
991 return S_OK;
992}
993
994STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount)(ULONG count)
995{
996 AutoCaller autoCaller(this);
997 if (FAILED(autoCaller.rc())) return autoCaller.rc();
998
999 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1000 m->ulLogHistoryCount = count;
1001 alock.release();
1002
1003 // VirtualBox::saveSettings() needs vbox write lock
1004 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1005 HRESULT rc = mParent->saveSettings();
1006
1007 return rc;
1008}
1009
1010STDMETHODIMP SystemProperties::COMGETTER(DefaultAudioDriver)(AudioDriverType_T *aAudioDriver)
1011{
1012 CheckComArgOutPointerValid(aAudioDriver);
1013
1014 AutoCaller autoCaller(this);
1015 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1016
1017 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1018
1019 *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
1020
1021 return S_OK;
1022}
1023
1024STDMETHODIMP SystemProperties::COMGETTER(AutostartDatabasePath)(BSTR *aAutostartDbPath)
1025{
1026 CheckComArgOutPointerValid(aAutostartDbPath);
1027
1028 AutoCaller autoCaller(this);
1029 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1030
1031 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1032
1033 m->strAutostartDatabasePath.cloneTo(aAutostartDbPath);
1034
1035 return S_OK;
1036}
1037
1038STDMETHODIMP SystemProperties::COMSETTER(AutostartDatabasePath)(IN_BSTR aAutostartDbPath)
1039{
1040 AutoCaller autoCaller(this);
1041 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1042
1043 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1044 HRESULT rc = setAutostartDatabasePath(aAutostartDbPath);
1045 alock.release();
1046
1047 if (SUCCEEDED(rc))
1048 {
1049 // VirtualBox::saveSettings() needs vbox write lock
1050 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1051 rc = mParent->saveSettings();
1052 }
1053
1054 return rc;
1055}
1056
1057STDMETHODIMP SystemProperties::COMGETTER(DefaultAdditionsISO)(BSTR *aDefaultAdditionsISO)
1058{
1059 CheckComArgOutPointerValid(aDefaultAdditionsISO);
1060
1061 AutoCaller autoCaller(this);
1062 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1063
1064 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1065
1066 if (m->strDefaultAdditionsISO.isEmpty())
1067 {
1068 /* no guest additions, check if it showed up in the mean time */
1069 alock.release();
1070 {
1071 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
1072 ErrorInfoKeeper eik;
1073 (void)setDefaultAdditionsISO("");
1074 }
1075 alock.acquire();
1076 }
1077 m->strDefaultAdditionsISO.cloneTo(aDefaultAdditionsISO);
1078
1079 return S_OK;
1080}
1081
1082STDMETHODIMP SystemProperties::COMSETTER(DefaultAdditionsISO)(IN_BSTR aDefaultAdditionsISO)
1083{
1084 AutoCaller autoCaller(this);
1085 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1086
1087 /** @todo not yet implemented, settings handling is missing */
1088 ReturnComNotImplemented();
1089
1090 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1091 HRESULT rc = setDefaultAdditionsISO(aDefaultAdditionsISO);
1092 alock.release();
1093
1094 if (SUCCEEDED(rc))
1095 {
1096 // VirtualBox::saveSettings() needs vbox write lock
1097 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1098 rc = mParent->saveSettings();
1099 }
1100
1101 return rc;
1102}
1103
1104STDMETHODIMP SystemProperties::COMGETTER(DefaultFrontend)(BSTR *aDefaultFrontend)
1105{
1106 CheckComArgOutPointerValid(aDefaultFrontend);
1107
1108 AutoCaller autoCaller(this);
1109 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1110
1111 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1112 m->strDefaultFrontend.cloneTo(aDefaultFrontend);
1113
1114 return S_OK;
1115}
1116
1117STDMETHODIMP SystemProperties::COMSETTER(DefaultFrontend)(IN_BSTR aDefaultFrontend)
1118{
1119 AutoCaller autoCaller(this);
1120 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1121
1122 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1123 if (m->strDefaultFrontend == Utf8Str(aDefaultFrontend))
1124 return S_OK;
1125 HRESULT rc = setDefaultFrontend(aDefaultFrontend);
1126 alock.release();
1127
1128 if (SUCCEEDED(rc))
1129 {
1130 // VirtualBox::saveSettings() needs vbox write lock
1131 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1132 rc = mParent->saveSettings();
1133 }
1134
1135 return rc;
1136}
1137
1138// public methods only for internal purposes
1139/////////////////////////////////////////////////////////////////////////////
1140
1141HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
1142{
1143 AutoCaller autoCaller(this);
1144 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1145
1146 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1147
1148 HRESULT rc = S_OK;
1149
1150 rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
1151 if (FAILED(rc)) return rc;
1152
1153 rc = setLoggingLevel(data.strLoggingLevel);
1154 if (FAILED(rc)) return rc;
1155
1156 rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
1157 if (FAILED(rc)) return rc;
1158
1159 rc = setVRDEAuthLibrary(data.strVRDEAuthLibrary);
1160 if (FAILED(rc)) return rc;
1161
1162 rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
1163 if (FAILED(rc)) return rc;
1164
1165 rc = setDefaultVRDEExtPack(data.strDefaultVRDEExtPack);
1166 if (FAILED(rc)) return rc;
1167
1168 m->ulLogHistoryCount = data.ulLogHistoryCount;
1169 m->fExclusiveHwVirt = data.fExclusiveHwVirt;
1170
1171 rc = setAutostartDatabasePath(data.strAutostartDatabasePath);
1172 if (FAILED(rc)) return rc;
1173
1174 {
1175 /* must ignore errors signalled here, because the guest additions
1176 * file may not exist, and in this case keep the empty string */
1177 ErrorInfoKeeper eik;
1178 (void)setDefaultAdditionsISO(data.strDefaultAdditionsISO);
1179 }
1180
1181 rc = setDefaultFrontend(data.strDefaultFrontend);
1182 if (FAILED(rc)) return rc;
1183
1184 return S_OK;
1185}
1186
1187HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
1188{
1189 AutoCaller autoCaller(this);
1190 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1191
1192 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1193
1194 data = *m;
1195
1196 return S_OK;
1197}
1198
1199/**
1200 * Returns a medium format object corresponding to the given format
1201 * identifier or null if no such format.
1202 *
1203 * @param aFormat Format identifier.
1204 *
1205 * @return ComObjPtr<MediumFormat>
1206 */
1207ComObjPtr<MediumFormat> SystemProperties::mediumFormat(const Utf8Str &aFormat)
1208{
1209 ComObjPtr<MediumFormat> format;
1210
1211 AutoCaller autoCaller(this);
1212 AssertComRCReturn (autoCaller.rc(), format);
1213
1214 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1215
1216 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1217 it != m_llMediumFormats.end();
1218 ++ it)
1219 {
1220 /* MediumFormat is all const, no need to lock */
1221
1222 if ((*it)->i_getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
1223 {
1224 format = *it;
1225 break;
1226 }
1227 }
1228
1229 return format;
1230}
1231
1232/**
1233 * Returns a medium format object corresponding to the given file extension or
1234 * null if no such format.
1235 *
1236 * @param aExt File extension.
1237 *
1238 * @return ComObjPtr<MediumFormat>
1239 */
1240ComObjPtr<MediumFormat> SystemProperties::mediumFormatFromExtension(const Utf8Str &aExt)
1241{
1242 ComObjPtr<MediumFormat> format;
1243
1244 AutoCaller autoCaller(this);
1245 AssertComRCReturn (autoCaller.rc(), format);
1246
1247 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1248
1249 bool fFound = false;
1250 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1251 it != m_llMediumFormats.end() && !fFound;
1252 ++it)
1253 {
1254 /* MediumFormat is all const, no need to lock */
1255 MediumFormat::StrArray aFileList = (*it)->i_getFileExtensions();
1256 for (MediumFormat::StrArray::const_iterator it1 = aFileList.begin();
1257 it1 != aFileList.end();
1258 ++it1)
1259 {
1260 if ((*it1).compare(aExt, Utf8Str::CaseInsensitive) == 0)
1261 {
1262 format = *it;
1263 fFound = true;
1264 break;
1265 }
1266 }
1267 }
1268
1269 return format;
1270}
1271
1272// private methods
1273/////////////////////////////////////////////////////////////////////////////
1274
1275/**
1276 * Returns the user's home directory. Wrapper around RTPathUserHome().
1277 * @param strPath
1278 * @return
1279 */
1280HRESULT SystemProperties::getUserHomeDirectory(Utf8Str &strPath)
1281{
1282 char szHome[RTPATH_MAX];
1283 int vrc = RTPathUserHome(szHome, sizeof(szHome));
1284 if (RT_FAILURE(vrc))
1285 return setError(E_FAIL,
1286 tr("Cannot determine user home directory (%Rrc)"),
1287 vrc);
1288 strPath = szHome;
1289 return S_OK;
1290}
1291
1292/**
1293 * Internal implementation to set the default machine folder. Gets called
1294 * from the public attribute setter as well as loadSettings(). With 4.0,
1295 * the "default default" machine folder has changed, and we now require
1296 * a full path always.
1297 * @param aPath
1298 * @return
1299 */
1300HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &strPath)
1301{
1302 Utf8Str path(strPath); // make modifiable
1303 if ( path.isEmpty() // used by API calls to reset the default
1304 || path == "Machines" // this value (exactly like this, without path) is stored
1305 // in VirtualBox.xml if user upgrades from before 4.0 and
1306 // has not changed the default machine folder
1307 )
1308 {
1309 // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
1310 HRESULT rc = getUserHomeDirectory(path);
1311 if (FAILED(rc)) return rc;
1312 path += RTPATH_SLASH_STR "VirtualBox VMs";
1313 }
1314
1315 if (!RTPathStartsWithRoot(path.c_str()))
1316 return setError(E_INVALIDARG,
1317 tr("Given default machine folder '%s' is not fully qualified"),
1318 path.c_str());
1319
1320 m->strDefaultMachineFolder = path;
1321
1322 return S_OK;
1323}
1324
1325HRESULT SystemProperties::setLoggingLevel(const Utf8Str &aLoggingLevel)
1326{
1327 Utf8Str useLoggingLevel(aLoggingLevel);
1328 int rc = RTLogGroupSettings(RTLogRelDefaultInstance(), useLoggingLevel.c_str());
1329 // If failed and not the default logging level - try to use the default logging level.
1330 if (RT_FAILURE(rc))
1331 {
1332 // If failed write message to the release log.
1333 LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), rc));
1334 // If attempted logging level not the default one then try the default one.
1335 if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT))
1336 {
1337 rc = RTLogGroupSettings(RTLogRelDefaultInstance(), VBOXSVC_LOG_DEFAULT);
1338 // If failed report this to the release log.
1339 if (RT_FAILURE(rc))
1340 LogRel(("Cannot set default logging level Error=%Rrc \n", rc));
1341 }
1342 // On any failure - set default level as the one to be stored.
1343 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
1344 }
1345 // Set to passed value or if default used/attempted (even if error condition) use empty string.
1346 m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel);
1347 return RT_SUCCESS(rc) ? S_OK : E_FAIL;
1348}
1349
1350HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
1351{
1352 if (!aFormat.isEmpty())
1353 m->strDefaultHardDiskFormat = aFormat;
1354 else
1355 m->strDefaultHardDiskFormat = "VDI";
1356
1357 return S_OK;
1358}
1359
1360HRESULT SystemProperties::setVRDEAuthLibrary(const Utf8Str &aPath)
1361{
1362 if (!aPath.isEmpty())
1363 m->strVRDEAuthLibrary = aPath;
1364 else
1365 m->strVRDEAuthLibrary = "VBoxAuth";
1366
1367 return S_OK;
1368}
1369
1370HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
1371{
1372 if (!aPath.isEmpty())
1373 m->strWebServiceAuthLibrary = aPath;
1374 else
1375 m->strWebServiceAuthLibrary = "VBoxAuth";
1376
1377 return S_OK;
1378}
1379
1380HRESULT SystemProperties::setDefaultVRDEExtPack(const Utf8Str &aExtPack)
1381{
1382 m->strDefaultVRDEExtPack = aExtPack;
1383
1384 return S_OK;
1385}
1386
1387HRESULT SystemProperties::setAutostartDatabasePath(const Utf8Str &aPath)
1388{
1389 HRESULT rc = S_OK;
1390 AutostartDb *autostartDb = this->mParent->getAutostartDb();
1391
1392 if (!aPath.isEmpty())
1393 {
1394 /* Update path in the autostart database. */
1395 int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
1396 if (RT_SUCCESS(vrc))
1397 m->strAutostartDatabasePath = aPath;
1398 else
1399 rc = setError(E_FAIL,
1400 tr("Cannot set the autostart database path (%Rrc)"),
1401 vrc);
1402 }
1403 else
1404 {
1405 int vrc = autostartDb->setAutostartDbPath(NULL);
1406 if (RT_SUCCESS(vrc) || vrc == VERR_NOT_SUPPORTED)
1407 m->strAutostartDatabasePath = "";
1408 else
1409 rc = setError(E_FAIL,
1410 tr("Deleting the autostart database path failed (%Rrc)"),
1411 vrc);
1412 }
1413
1414 return rc;
1415}
1416
1417HRESULT SystemProperties::setDefaultAdditionsISO(const Utf8Str &aPath)
1418{
1419 Utf8Str path(aPath);
1420 if (path.isEmpty())
1421 {
1422 char strTemp[RTPATH_MAX];
1423 int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
1424 AssertRC(vrc);
1425 Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
1426
1427 vrc = RTPathExecDir(strTemp, sizeof(strTemp));
1428 AssertRC(vrc);
1429 Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
1430
1431 vrc = RTPathUserHome(strTemp, sizeof(strTemp));
1432 AssertRC(vrc);
1433 Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%ls.iso", strTemp, VirtualBox::getVersionNormalized().raw());
1434
1435 /* Check the standard image locations */
1436 if (RTFileExists(strSrc1.c_str()))
1437 path = strSrc1;
1438 else if (RTFileExists(strSrc2.c_str()))
1439 path = strSrc2;
1440 else if (RTFileExists(strSrc3.c_str()))
1441 path = strSrc3;
1442 else
1443 return setError(E_FAIL,
1444 tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
1445 }
1446
1447 if (!RTPathStartsWithRoot(path.c_str()))
1448 return setError(E_INVALIDARG,
1449 tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
1450 path.c_str());
1451
1452 if (!RTFileExists(path.c_str()))
1453 return setError(E_INVALIDARG,
1454 tr("Given default machine Guest Additions ISO file '%s' does not exist"),
1455 path.c_str());
1456
1457 m->strDefaultAdditionsISO = path;
1458
1459 return S_OK;
1460}
1461
1462HRESULT SystemProperties::setDefaultFrontend(const Utf8Str &aDefaultFrontend)
1463{
1464 m->strDefaultFrontend = aDefaultFrontend;
1465
1466 return S_OK;
1467}
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