VirtualBox

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

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 58.9 KB
Line 
1/* $Id: SystemPropertiesImpl.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. 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#define LOG_GROUP LOG_GROUP_MAIN_SYSTEMPROPERTIES
19#include "SystemPropertiesImpl.h"
20#include "VirtualBoxImpl.h"
21#include "MachineImpl.h"
22#ifdef VBOX_WITH_EXTPACK
23# include "ExtPackManagerImpl.h"
24#endif
25#include "AutoCaller.h"
26#include "Global.h"
27#include "LoggingNew.h"
28#include "AutostartDb.h"
29
30// generated header
31#include "SchemaDefs.h"
32
33#include <iprt/dir.h>
34#include <iprt/ldr.h>
35#include <iprt/path.h>
36#include <iprt/string.h>
37#include <iprt/uri.h>
38#include <iprt/cpp/utils.h>
39
40#include <iprt/errcore.h>
41#include <VBox/param.h>
42#include <VBox/settings.h>
43#include <VBox/vd.h>
44
45// defines
46/////////////////////////////////////////////////////////////////////////////
47
48// constructor / destructor
49/////////////////////////////////////////////////////////////////////////////
50
51SystemProperties::SystemProperties()
52 : mParent(NULL),
53 m(new settings::SystemProperties)
54{
55}
56
57SystemProperties::~SystemProperties()
58{
59 delete m;
60}
61
62
63HRESULT SystemProperties::FinalConstruct()
64{
65 return BaseFinalConstruct();
66}
67
68void SystemProperties::FinalRelease()
69{
70 uninit();
71 BaseFinalRelease();
72}
73
74// public methods only for internal purposes
75/////////////////////////////////////////////////////////////////////////////
76
77/**
78 * Initializes the system information object.
79 *
80 * @returns COM result indicator
81 */
82HRESULT SystemProperties::init(VirtualBox *aParent)
83{
84 LogFlowThisFunc(("aParent=%p\n", aParent));
85
86 ComAssertRet(aParent, E_FAIL);
87
88 /* Enclose the state transition NotReady->InInit->Ready */
89 AutoInitSpan autoInitSpan(this);
90 AssertReturn(autoInitSpan.isOk(), E_FAIL);
91
92 unconst(mParent) = aParent;
93
94 i_setDefaultMachineFolder(Utf8Str::Empty);
95 i_setLoggingLevel(Utf8Str::Empty);
96 i_setDefaultHardDiskFormat(Utf8Str::Empty);
97
98 i_setVRDEAuthLibrary(Utf8Str::Empty);
99 i_setDefaultVRDEExtPack(Utf8Str::Empty);
100
101 m->uLogHistoryCount = 3;
102
103
104 /* On Windows, OS X and Solaris, HW virtualization use isn't exclusive
105 * by default so that VT-x or AMD-V can be shared with other
106 * hypervisors without requiring user intervention.
107 * NB: See also SystemProperties constructor in settings.h
108 */
109#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS)
110 m->fExclusiveHwVirt = false;
111#else
112 m->fExclusiveHwVirt = true;
113#endif
114
115 HRESULT rc = S_OK;
116
117 /* Fetch info of all available hd backends. */
118
119 /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
120 /// any number of backends
121
122 VDBACKENDINFO aVDInfo[100];
123 unsigned cEntries;
124 int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
125 AssertRC(vrc);
126 if (RT_SUCCESS(vrc))
127 {
128 for (unsigned i = 0; i < cEntries; ++ i)
129 {
130 ComObjPtr<MediumFormat> hdf;
131 rc = hdf.createObject();
132 if (FAILED(rc)) break;
133
134 rc = hdf->init(&aVDInfo[i]);
135 if (FAILED(rc)) break;
136
137 m_llMediumFormats.push_back(hdf);
138 }
139 }
140
141 /* Confirm a successful initialization */
142 if (SUCCEEDED(rc))
143 autoInitSpan.setSucceeded();
144
145 return rc;
146}
147
148/**
149 * Uninitializes the instance and sets the ready flag to FALSE.
150 * Called either from FinalRelease() or by the parent when it gets destroyed.
151 */
152void SystemProperties::uninit()
153{
154 LogFlowThisFunc(("\n"));
155
156 /* Enclose the state transition Ready->InUninit->NotReady */
157 AutoUninitSpan autoUninitSpan(this);
158 if (autoUninitSpan.uninitDone())
159 return;
160
161 unconst(mParent) = NULL;
162}
163
164// wrapped ISystemProperties properties
165/////////////////////////////////////////////////////////////////////////////
166
167HRESULT SystemProperties::getMinGuestRAM(ULONG *minRAM)
168
169{
170 /* no need to lock, this is const */
171 AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
172 *minRAM = MM_RAM_MIN_IN_MB;
173
174 return S_OK;
175}
176
177HRESULT SystemProperties::getMaxGuestRAM(ULONG *maxRAM)
178{
179 /* no need to lock, this is const */
180 AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
181 ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
182 ULONG maxRAMArch = maxRAMSys;
183 *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
184
185 return S_OK;
186}
187
188HRESULT SystemProperties::getMinGuestVRAM(ULONG *minVRAM)
189{
190 /* no need to lock, this is const */
191 *minVRAM = SchemaDefs::MinGuestVRAM;
192
193 return S_OK;
194}
195
196HRESULT SystemProperties::getMaxGuestVRAM(ULONG *maxVRAM)
197{
198 /* no need to lock, this is const */
199 *maxVRAM = SchemaDefs::MaxGuestVRAM;
200
201 return S_OK;
202}
203
204HRESULT SystemProperties::getMinGuestCPUCount(ULONG *minCPUCount)
205{
206 /* no need to lock, this is const */
207 *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
208
209 return S_OK;
210}
211
212HRESULT SystemProperties::getMaxGuestCPUCount(ULONG *maxCPUCount)
213{
214 /* no need to lock, this is const */
215 *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
216
217 return S_OK;
218}
219
220HRESULT SystemProperties::getMaxGuestMonitors(ULONG *maxMonitors)
221{
222
223 /* no need to lock, this is const */
224 *maxMonitors = SchemaDefs::MaxGuestMonitors;
225
226 return S_OK;
227}
228
229
230HRESULT SystemProperties::getInfoVDSize(LONG64 *infoVDSize)
231{
232 /*
233 * The BIOS supports currently 32 bit LBA numbers (implementing the full
234 * 48 bit range is in theory trivial, but the crappy compiler makes things
235 * more difficult). This translates to almost 2 TiBytes (to be on the safe
236 * side, the reported limit is 1 MiByte less than that, as the total number
237 * of sectors should fit in 32 bits, too), which should be enough for the
238 * moment. Since the MBR partition tables support only 32bit sector numbers
239 * and thus the BIOS can only boot from disks smaller than 2T this is a
240 * rather hard limit.
241 *
242 * The virtual ATA/SATA disks support complete LBA48, and SCSI supports
243 * LBA64 (almost, more like LBA55 in practice), so the theoretical maximum
244 * disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6 orders
245 * of magnitude, but not with 11..13 orders of magnitude.
246 */
247 /* no need to lock, this is const */
248 *infoVDSize = 2 * _1T - _1M;
249
250 return S_OK;
251}
252
253
254HRESULT SystemProperties::getSerialPortCount(ULONG *count)
255{
256 /* no need to lock, this is const */
257 *count = SchemaDefs::SerialPortCount;
258
259 return S_OK;
260}
261
262
263HRESULT SystemProperties::getParallelPortCount(ULONG *count)
264{
265 /* no need to lock, this is const */
266 *count = SchemaDefs::ParallelPortCount;
267
268 return S_OK;
269}
270
271
272HRESULT SystemProperties::getMaxBootPosition(ULONG *aMaxBootPosition)
273{
274 /* no need to lock, this is const */
275 *aMaxBootPosition = SchemaDefs::MaxBootPosition;
276
277 return S_OK;
278}
279
280
281HRESULT SystemProperties::getRawModeSupported(BOOL *aRawModeSupported)
282{
283 *aRawModeSupported = FALSE;
284 return S_OK;
285}
286
287
288HRESULT SystemProperties::getExclusiveHwVirt(BOOL *aExclusiveHwVirt)
289{
290 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
291
292 *aExclusiveHwVirt = m->fExclusiveHwVirt;
293
294 return S_OK;
295}
296
297HRESULT SystemProperties::setExclusiveHwVirt(BOOL aExclusiveHwVirt)
298{
299 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
300 m->fExclusiveHwVirt = !!aExclusiveHwVirt;
301 alock.release();
302
303 // VirtualBox::i_saveSettings() needs vbox write lock
304 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
305 HRESULT rc = mParent->i_saveSettings();
306
307 return rc;
308}
309
310HRESULT SystemProperties::getMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *aMaxNetworkAdapters)
311{
312 /* no need for locking, no state */
313 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
314 if (uResult == 0)
315 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
316 *aMaxNetworkAdapters = uResult;
317 return S_OK;
318}
319
320HRESULT SystemProperties::getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType, ULONG *count)
321{
322 /* no need for locking, no state */
323 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
324 if (uResult == 0)
325 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
326
327 switch (aType)
328 {
329 case NetworkAttachmentType_NAT:
330 case NetworkAttachmentType_Internal:
331 case NetworkAttachmentType_NATNetwork:
332 /* chipset default is OK */
333 break;
334 case NetworkAttachmentType_Bridged:
335 /* Maybe use current host interface count here? */
336 break;
337 case NetworkAttachmentType_HostOnly:
338 uResult = RT_MIN(uResult, 8);
339 break;
340 default:
341 AssertMsgFailed(("Unhandled attachment type %d\n", aType));
342 }
343
344 *count = uResult;
345
346 return S_OK;
347}
348
349
350HRESULT SystemProperties::getMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
351 ULONG *aMaxDevicesPerPort)
352{
353 /* no need to lock, this is const */
354 switch (aBus)
355 {
356 case StorageBus_SATA:
357 case StorageBus_SCSI:
358 case StorageBus_SAS:
359 case StorageBus_USB:
360 case StorageBus_PCIe:
361 case StorageBus_VirtioSCSI:
362 {
363 /* SATA and both SCSI controllers only support one device per port. */
364 *aMaxDevicesPerPort = 1;
365 break;
366 }
367 case StorageBus_IDE:
368 case StorageBus_Floppy:
369 {
370 /* The IDE and Floppy controllers support 2 devices. One as master
371 * and one as slave (or floppy drive 0 and 1). */
372 *aMaxDevicesPerPort = 2;
373 break;
374 }
375 default:
376 AssertMsgFailed(("Invalid bus type %d\n", aBus));
377 }
378
379 return S_OK;
380}
381
382HRESULT SystemProperties::getMinPortCountForStorageBus(StorageBus_T aBus,
383 ULONG *aMinPortCount)
384{
385 /* no need to lock, this is const */
386 switch (aBus)
387 {
388 case StorageBus_SATA:
389 case StorageBus_SAS:
390 case StorageBus_PCIe:
391 case StorageBus_VirtioSCSI:
392 {
393 *aMinPortCount = 1;
394 break;
395 }
396 case StorageBus_SCSI:
397 {
398 *aMinPortCount = 16;
399 break;
400 }
401 case StorageBus_IDE:
402 {
403 *aMinPortCount = 2;
404 break;
405 }
406 case StorageBus_Floppy:
407 {
408 *aMinPortCount = 1;
409 break;
410 }
411 case StorageBus_USB:
412 {
413 *aMinPortCount = 8;
414 break;
415 }
416 default:
417 AssertMsgFailed(("Invalid bus type %d\n", aBus));
418 }
419
420 return S_OK;
421}
422
423HRESULT SystemProperties::getMaxPortCountForStorageBus(StorageBus_T aBus,
424 ULONG *aMaxPortCount)
425{
426 /* no need to lock, this is const */
427 switch (aBus)
428 {
429 case StorageBus_SATA:
430 {
431 *aMaxPortCount = 30;
432 break;
433 }
434 case StorageBus_SCSI:
435 {
436 *aMaxPortCount = 16;
437 break;
438 }
439 case StorageBus_IDE:
440 {
441 *aMaxPortCount = 2;
442 break;
443 }
444 case StorageBus_Floppy:
445 {
446 *aMaxPortCount = 1;
447 break;
448 }
449 case StorageBus_SAS:
450 case StorageBus_PCIe:
451 {
452 *aMaxPortCount = 255;
453 break;
454 }
455 case StorageBus_USB:
456 {
457 *aMaxPortCount = 8;
458 break;
459 }
460 case StorageBus_VirtioSCSI:
461 {
462 *aMaxPortCount = 256;
463 break;
464 }
465 default:
466 AssertMsgFailed(("Invalid bus type %d\n", aBus));
467 }
468
469 return S_OK;
470}
471
472HRESULT SystemProperties::getMaxInstancesOfStorageBus(ChipsetType_T aChipset,
473 StorageBus_T aBus,
474 ULONG *aMaxInstances)
475{
476 ULONG cCtrs = 0;
477
478 /* no need to lock, this is const */
479 switch (aBus)
480 {
481 case StorageBus_SATA:
482 case StorageBus_SCSI:
483 case StorageBus_SAS:
484 case StorageBus_PCIe:
485 case StorageBus_VirtioSCSI:
486 cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
487 break;
488 case StorageBus_USB:
489 case StorageBus_IDE:
490 case StorageBus_Floppy:
491 {
492 cCtrs = 1;
493 break;
494 }
495 default:
496 AssertMsgFailed(("Invalid bus type %d\n", aBus));
497 }
498
499 *aMaxInstances = cCtrs;
500
501 return S_OK;
502}
503
504HRESULT SystemProperties::getDeviceTypesForStorageBus(StorageBus_T aBus,
505 std::vector<DeviceType_T> &aDeviceTypes)
506{
507 aDeviceTypes.resize(0);
508
509 /* no need to lock, this is const */
510 switch (aBus)
511 {
512 case StorageBus_IDE:
513 case StorageBus_SATA:
514 case StorageBus_SCSI:
515 case StorageBus_SAS:
516 case StorageBus_USB:
517 case StorageBus_VirtioSCSI:
518 {
519 aDeviceTypes.resize(2);
520 aDeviceTypes[0] = DeviceType_DVD;
521 aDeviceTypes[1] = DeviceType_HardDisk;
522 break;
523 }
524 case StorageBus_Floppy:
525 {
526 aDeviceTypes.resize(1);
527 aDeviceTypes[0] = DeviceType_Floppy;
528 break;
529 }
530 case StorageBus_PCIe:
531 {
532 aDeviceTypes.resize(1);
533 aDeviceTypes[0] = DeviceType_HardDisk;
534 break;
535 }
536 default:
537 AssertMsgFailed(("Invalid bus type %d\n", aBus));
538 }
539
540 return S_OK;
541}
542
543HRESULT SystemProperties::getStorageBusForStorageControllerType(StorageControllerType_T aStorageControllerType,
544 StorageBus_T *aStorageBus)
545{
546 /* no need to lock, this is const */
547 switch (aStorageControllerType)
548 {
549 case StorageControllerType_LsiLogic:
550 case StorageControllerType_BusLogic:
551 *aStorageBus = StorageBus_SCSI;
552 break;
553 case StorageControllerType_IntelAhci:
554 *aStorageBus = StorageBus_SATA;
555 break;
556 case StorageControllerType_PIIX3:
557 case StorageControllerType_PIIX4:
558 case StorageControllerType_ICH6:
559 *aStorageBus = StorageBus_IDE;
560 break;
561 case StorageControllerType_I82078:
562 *aStorageBus = StorageBus_Floppy;
563 break;
564 case StorageControllerType_LsiLogicSas:
565 *aStorageBus = StorageBus_SAS;
566 break;
567 case StorageControllerType_USB:
568 *aStorageBus = StorageBus_USB;
569 break;
570 case StorageControllerType_NVMe:
571 *aStorageBus = StorageBus_PCIe;
572 break;
573 case StorageControllerType_VirtioSCSI:
574 *aStorageBus = StorageBus_VirtioSCSI;
575 break;
576 default:
577 return setError(E_FAIL, tr("Invalid storage controller type %d\n"), aStorageBus);
578 }
579
580 return S_OK;
581}
582
583HRESULT SystemProperties::getStorageControllerTypesForStorageBus(StorageBus_T aStorageBus,
584 std::vector<StorageControllerType_T> &aStorageControllerTypes)
585{
586 aStorageControllerTypes.resize(0);
587
588 /* no need to lock, this is const */
589 switch (aStorageBus)
590 {
591 case StorageBus_IDE:
592 aStorageControllerTypes.resize(3);
593 aStorageControllerTypes[0] = StorageControllerType_PIIX4;
594 aStorageControllerTypes[1] = StorageControllerType_PIIX3;
595 aStorageControllerTypes[2] = StorageControllerType_ICH6;
596 break;
597 case StorageBus_SATA:
598 aStorageControllerTypes.resize(1);
599 aStorageControllerTypes[0] = StorageControllerType_IntelAhci;
600 break;
601 case StorageBus_SCSI:
602 aStorageControllerTypes.resize(2);
603 aStorageControllerTypes[0] = StorageControllerType_LsiLogic;
604 aStorageControllerTypes[1] = StorageControllerType_BusLogic;
605 break;
606 case StorageBus_Floppy:
607 aStorageControllerTypes.resize(1);
608 aStorageControllerTypes[0] = StorageControllerType_I82078;
609 break;
610 case StorageBus_SAS:
611 aStorageControllerTypes.resize(1);
612 aStorageControllerTypes[0] = StorageControllerType_LsiLogicSas;
613 break;
614 case StorageBus_USB:
615 aStorageControllerTypes.resize(1);
616 aStorageControllerTypes[0] = StorageControllerType_USB;
617 break;
618 case StorageBus_PCIe:
619 aStorageControllerTypes.resize(1);
620 aStorageControllerTypes[0] = StorageControllerType_NVMe;
621 break;
622 case StorageBus_VirtioSCSI:
623 aStorageControllerTypes.resize(1);
624 aStorageControllerTypes[0] = StorageControllerType_VirtioSCSI;
625 break;
626 default:
627 return setError(E_FAIL, tr("Invalid storage bus %d\n"), aStorageBus);
628 }
629
630 return S_OK;
631}
632
633HRESULT SystemProperties::getDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType,
634 BOOL *aEnabled)
635{
636 /* no need to lock, this is const */
637 switch (aControllerType)
638 {
639 case StorageControllerType_LsiLogic:
640 case StorageControllerType_BusLogic:
641 case StorageControllerType_IntelAhci:
642 case StorageControllerType_LsiLogicSas:
643 case StorageControllerType_USB:
644 case StorageControllerType_NVMe:
645 case StorageControllerType_VirtioSCSI:
646 *aEnabled = false;
647 break;
648 case StorageControllerType_PIIX3:
649 case StorageControllerType_PIIX4:
650 case StorageControllerType_ICH6:
651 case StorageControllerType_I82078:
652 *aEnabled = true;
653 break;
654 default:
655 AssertMsgFailed(("Invalid controller type %d\n", aControllerType));
656 }
657 return S_OK;
658}
659
660HRESULT SystemProperties::getStorageControllerHotplugCapable(StorageControllerType_T aControllerType,
661 BOOL *aHotplugCapable)
662{
663 switch (aControllerType)
664 {
665 case StorageControllerType_IntelAhci:
666 case StorageControllerType_USB:
667 *aHotplugCapable = true;
668 break;
669 case StorageControllerType_LsiLogic:
670 case StorageControllerType_LsiLogicSas:
671 case StorageControllerType_BusLogic:
672 case StorageControllerType_NVMe:
673 case StorageControllerType_VirtioSCSI:
674 case StorageControllerType_PIIX3:
675 case StorageControllerType_PIIX4:
676 case StorageControllerType_ICH6:
677 case StorageControllerType_I82078:
678 *aHotplugCapable = false;
679 break;
680 default:
681 AssertMsgFailedReturn(("Invalid controller type %d\n", aControllerType), E_FAIL);
682 }
683
684 return S_OK;
685}
686
687HRESULT SystemProperties::getMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
688 USBControllerType_T aType,
689 ULONG *aMaxInstances)
690{
691 NOREF(aChipset);
692 ULONG cCtrs = 0;
693
694 /* no need to lock, this is const */
695 switch (aType)
696 {
697 case USBControllerType_OHCI:
698 case USBControllerType_EHCI:
699 case USBControllerType_XHCI:
700 {
701 cCtrs = 1;
702 break;
703 }
704 default:
705 AssertMsgFailed(("Invalid bus type %d\n", aType));
706 }
707
708 *aMaxInstances = cCtrs;
709
710 return S_OK;
711}
712
713HRESULT SystemProperties::getDefaultMachineFolder(com::Utf8Str &aDefaultMachineFolder)
714{
715 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
716 aDefaultMachineFolder = m->strDefaultMachineFolder;
717 return S_OK;
718}
719
720HRESULT SystemProperties::setDefaultMachineFolder(const com::Utf8Str &aDefaultMachineFolder)
721{
722 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
723 HRESULT rc = i_setDefaultMachineFolder(aDefaultMachineFolder);
724 alock.release();
725 if (SUCCEEDED(rc))
726 {
727 // VirtualBox::i_saveSettings() needs vbox write lock
728 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
729 rc = mParent->i_saveSettings();
730 }
731
732 return rc;
733}
734
735HRESULT SystemProperties::getLoggingLevel(com::Utf8Str &aLoggingLevel)
736{
737 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
738
739 aLoggingLevel = m->strLoggingLevel;
740
741 if (aLoggingLevel.isEmpty())
742 aLoggingLevel = VBOXSVC_LOG_DEFAULT;
743
744 return S_OK;
745}
746
747
748HRESULT SystemProperties::setLoggingLevel(const com::Utf8Str &aLoggingLevel)
749{
750 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
751 HRESULT rc = i_setLoggingLevel(aLoggingLevel);
752 alock.release();
753
754 if (SUCCEEDED(rc))
755 {
756 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
757 rc = mParent->i_saveSettings();
758 }
759 else
760 LogRel(("Cannot set passed logging level=%s, or the default one - Error=%Rhrc \n", aLoggingLevel.c_str(), rc));
761
762 return rc;
763}
764
765HRESULT SystemProperties::getMediumFormats(std::vector<ComPtr<IMediumFormat> > &aMediumFormats)
766{
767 MediumFormatList mediumFormats(m_llMediumFormats);
768 aMediumFormats.resize(mediumFormats.size());
769 size_t i = 0;
770 for (MediumFormatList::const_iterator it = mediumFormats.begin(); it != mediumFormats.end(); ++it, ++i)
771 (*it).queryInterfaceTo(aMediumFormats[i].asOutParam());
772 return S_OK;
773}
774
775HRESULT SystemProperties::getDefaultHardDiskFormat(com::Utf8Str &aDefaultHardDiskFormat)
776{
777 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
778 aDefaultHardDiskFormat = m->strDefaultHardDiskFormat;
779 return S_OK;
780}
781
782
783HRESULT SystemProperties::setDefaultHardDiskFormat(const com::Utf8Str &aDefaultHardDiskFormat)
784{
785 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
786 HRESULT rc = i_setDefaultHardDiskFormat(aDefaultHardDiskFormat);
787 alock.release();
788 if (SUCCEEDED(rc))
789 {
790 // VirtualBox::i_saveSettings() needs vbox write lock
791 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
792 rc = mParent->i_saveSettings();
793 }
794
795 return rc;
796}
797
798HRESULT SystemProperties::getFreeDiskSpaceWarning(LONG64 *aFreeSpace)
799{
800 NOREF(aFreeSpace);
801 ReturnComNotImplemented();
802}
803
804HRESULT SystemProperties::setFreeDiskSpaceWarning(LONG64 /* aFreeSpace */)
805{
806 ReturnComNotImplemented();
807}
808
809HRESULT SystemProperties::getFreeDiskSpacePercentWarning(ULONG *aFreeSpacePercent)
810{
811 NOREF(aFreeSpacePercent);
812 ReturnComNotImplemented();
813}
814
815HRESULT SystemProperties::setFreeDiskSpacePercentWarning(ULONG /* aFreeSpacePercent */)
816{
817 ReturnComNotImplemented();
818}
819
820HRESULT SystemProperties::getFreeDiskSpaceError(LONG64 *aFreeSpace)
821{
822 NOREF(aFreeSpace);
823 ReturnComNotImplemented();
824}
825
826HRESULT SystemProperties::setFreeDiskSpaceError(LONG64 /* aFreeSpace */)
827{
828 ReturnComNotImplemented();
829}
830
831HRESULT SystemProperties::getFreeDiskSpacePercentError(ULONG *aFreeSpacePercent)
832{
833 NOREF(aFreeSpacePercent);
834 ReturnComNotImplemented();
835}
836
837HRESULT SystemProperties::setFreeDiskSpacePercentError(ULONG /* aFreeSpacePercent */)
838{
839 ReturnComNotImplemented();
840}
841
842HRESULT SystemProperties::getVRDEAuthLibrary(com::Utf8Str &aVRDEAuthLibrary)
843{
844 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
845
846 aVRDEAuthLibrary = m->strVRDEAuthLibrary;
847
848 return S_OK;
849}
850
851HRESULT SystemProperties::setVRDEAuthLibrary(const com::Utf8Str &aVRDEAuthLibrary)
852{
853 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
854 HRESULT rc = i_setVRDEAuthLibrary(aVRDEAuthLibrary);
855 alock.release();
856 if (SUCCEEDED(rc))
857 {
858 // VirtualBox::i_saveSettings() needs vbox write lock
859 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
860 rc = mParent->i_saveSettings();
861 }
862
863 return rc;
864}
865
866HRESULT SystemProperties::getWebServiceAuthLibrary(com::Utf8Str &aWebServiceAuthLibrary)
867{
868 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
869
870 aWebServiceAuthLibrary = m->strWebServiceAuthLibrary;
871
872 return S_OK;
873}
874
875HRESULT SystemProperties::setWebServiceAuthLibrary(const com::Utf8Str &aWebServiceAuthLibrary)
876{
877 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
878 HRESULT rc = i_setWebServiceAuthLibrary(aWebServiceAuthLibrary);
879 alock.release();
880
881 if (SUCCEEDED(rc))
882 {
883 // VirtualBox::i_saveSettings() needs vbox write lock
884 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
885 rc = mParent->i_saveSettings();
886 }
887
888 return rc;
889}
890
891HRESULT SystemProperties::getDefaultVRDEExtPack(com::Utf8Str &aExtPack)
892{
893 HRESULT hrc = S_OK;
894 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
895 Utf8Str strExtPack(m->strDefaultVRDEExtPack);
896 if (strExtPack.isNotEmpty())
897 {
898 if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
899 hrc = S_OK;
900 else
901#ifdef VBOX_WITH_EXTPACK
902 hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&strExtPack);
903#else
904 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
905#endif
906 }
907 else
908 {
909#ifdef VBOX_WITH_EXTPACK
910 hrc = mParent->i_getExtPackManager()->i_getDefaultVrdeExtPack(&strExtPack);
911#endif
912 if (strExtPack.isEmpty())
913 {
914 /*
915 * Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
916 * This is hardcoded uglyness, sorry.
917 */
918 char szPath[RTPATH_MAX];
919 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
920 if (RT_SUCCESS(vrc))
921 vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxVRDP");
922 if (RT_SUCCESS(vrc))
923 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
924 if (RT_SUCCESS(vrc) && RTFileExists(szPath))
925 {
926 /* Illegal extpack name, so no conflict. */
927 strExtPack = VBOXVRDP_KLUDGE_EXTPACK_NAME;
928 }
929 }
930 }
931
932 if (SUCCEEDED(hrc))
933 aExtPack = strExtPack;
934
935 return S_OK;
936}
937
938
939HRESULT SystemProperties::setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
940{
941 HRESULT hrc = S_OK;
942 if (aExtPack.isNotEmpty())
943 {
944 if (aExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
945 hrc = S_OK;
946 else
947#ifdef VBOX_WITH_EXTPACK
948 hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&aExtPack);
949#else
950 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), aExtPack.c_str());
951#endif
952 }
953 if (SUCCEEDED(hrc))
954 {
955 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
956 hrc = i_setDefaultVRDEExtPack(aExtPack);
957 if (SUCCEEDED(hrc))
958 {
959 /* VirtualBox::i_saveSettings() needs the VirtualBox write lock. */
960 alock.release();
961 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
962 hrc = mParent->i_saveSettings();
963 }
964 }
965
966 return hrc;
967}
968
969
970HRESULT SystemProperties::getLogHistoryCount(ULONG *count)
971{
972 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
973
974 *count = m->uLogHistoryCount;
975
976 return S_OK;
977}
978
979
980HRESULT SystemProperties::setLogHistoryCount(ULONG count)
981{
982 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
983 m->uLogHistoryCount = count;
984 alock.release();
985
986 // VirtualBox::i_saveSettings() needs vbox write lock
987 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
988 HRESULT rc = mParent->i_saveSettings();
989
990 return rc;
991}
992
993HRESULT SystemProperties::getDefaultAudioDriver(AudioDriverType_T *aAudioDriver)
994{
995 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
996
997 *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
998
999 return S_OK;
1000}
1001
1002HRESULT SystemProperties::getAutostartDatabasePath(com::Utf8Str &aAutostartDbPath)
1003{
1004 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1005
1006 aAutostartDbPath = m->strAutostartDatabasePath;
1007
1008 return S_OK;
1009}
1010
1011HRESULT SystemProperties::setAutostartDatabasePath(const com::Utf8Str &aAutostartDbPath)
1012{
1013 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1014 HRESULT rc = i_setAutostartDatabasePath(aAutostartDbPath);
1015 alock.release();
1016
1017 if (SUCCEEDED(rc))
1018 {
1019 // VirtualBox::i_saveSettings() needs vbox write lock
1020 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1021 rc = mParent->i_saveSettings();
1022 }
1023
1024 return rc;
1025}
1026
1027HRESULT SystemProperties::getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO)
1028{
1029 return i_getDefaultAdditionsISO(aDefaultAdditionsISO);
1030}
1031
1032HRESULT SystemProperties::setDefaultAdditionsISO(const com::Utf8Str &aDefaultAdditionsISO)
1033{
1034 RT_NOREF(aDefaultAdditionsISO);
1035 /** @todo not yet implemented, settings handling is missing */
1036 ReturnComNotImplemented();
1037#if 0 /* not implemented */
1038 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1039 HRESULT rc = i_setDefaultAdditionsISO(aDefaultAdditionsISO);
1040 alock.release();
1041
1042 if (SUCCEEDED(rc))
1043 {
1044 // VirtualBox::i_saveSettings() needs vbox write lock
1045 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1046 rc = mParent->i_saveSettings();
1047 }
1048
1049 return rc;
1050#endif
1051}
1052
1053HRESULT SystemProperties::getDefaultFrontend(com::Utf8Str &aDefaultFrontend)
1054{
1055 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1056 aDefaultFrontend = m->strDefaultFrontend;
1057 return S_OK;
1058}
1059
1060HRESULT SystemProperties::setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
1061{
1062 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1063 if (m->strDefaultFrontend == Utf8Str(aDefaultFrontend))
1064 return S_OK;
1065 HRESULT rc = i_setDefaultFrontend(aDefaultFrontend);
1066 alock.release();
1067
1068 if (SUCCEEDED(rc))
1069 {
1070 // VirtualBox::i_saveSettings() needs vbox write lock
1071 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1072 rc = mParent->i_saveSettings();
1073 }
1074
1075 return rc;
1076}
1077
1078HRESULT SystemProperties::getScreenShotFormats(std::vector<BitmapFormat_T> &aBitmapFormats)
1079{
1080 aBitmapFormats.push_back(BitmapFormat_BGR0);
1081 aBitmapFormats.push_back(BitmapFormat_BGRA);
1082 aBitmapFormats.push_back(BitmapFormat_RGBA);
1083 aBitmapFormats.push_back(BitmapFormat_PNG);
1084 return S_OK;
1085}
1086
1087HRESULT SystemProperties::getProxyMode(ProxyMode_T *pProxyMode)
1088{
1089 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1090 ProxyMode_T enmMode = *pProxyMode = (ProxyMode_T)m->uProxyMode;
1091 AssertMsgReturn(enmMode == ProxyMode_System || enmMode == ProxyMode_NoProxy || enmMode == ProxyMode_Manual,
1092 ("enmMode=%d\n", enmMode), E_UNEXPECTED);
1093 return S_OK;
1094}
1095
1096HRESULT SystemProperties::setProxyMode(ProxyMode_T aProxyMode)
1097{
1098 /* Validate input. */
1099 switch (aProxyMode)
1100 {
1101 case ProxyMode_System:
1102 case ProxyMode_NoProxy:
1103 case ProxyMode_Manual:
1104 break;
1105 default:
1106 return setError(E_INVALIDARG, tr("Invalid ProxyMode value: %d"), (int)aProxyMode);
1107 }
1108
1109 /* Set and write out settings. */
1110 {
1111 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1112 m->uProxyMode = aProxyMode;
1113 }
1114 AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS); /* required for saving. */
1115 return mParent->i_saveSettings();
1116}
1117
1118HRESULT SystemProperties::getProxyURL(com::Utf8Str &aProxyURL)
1119{
1120 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1121 aProxyURL = m->strProxyUrl;
1122 return S_OK;
1123}
1124
1125HRESULT SystemProperties::setProxyURL(const com::Utf8Str &aProxyURL)
1126{
1127 /*
1128 * Validate input.
1129 */
1130 Utf8Str const *pStrProxyUrl = &aProxyURL;
1131 Utf8Str strTmp;
1132 if (pStrProxyUrl->isNotEmpty())
1133 {
1134 /* RTUriParse requires a scheme, so append 'http://' if none seems present: */
1135 if (pStrProxyUrl->find("://") == RTCString::npos)
1136 {
1137 strTmp.printf("http://%s", aProxyURL.c_str());
1138 pStrProxyUrl = &strTmp;
1139 }
1140
1141 /* Use RTUriParse to check the format. There must be a hostname, but nothing
1142 can follow it and the port. */
1143 RTURIPARSED Parsed;
1144 int vrc = RTUriParse(pStrProxyUrl->c_str(), &Parsed);
1145 if (RT_FAILURE(vrc))
1146 return setErrorBoth(E_INVALIDARG, vrc, tr("Failed to parse proxy URL: %Rrc"), vrc);
1147 if ( Parsed.cchAuthorityHost == 0
1148 && !RTUriIsSchemeMatch(pStrProxyUrl->c_str(), "direct"))
1149 return setError(E_INVALIDARG, tr("Proxy URL must include a hostname"));
1150 if (Parsed.cchPath > 0)
1151 return setError(E_INVALIDARG, tr("Proxy URL must not include a path component (%.*s)"),
1152 Parsed.cchPath, pStrProxyUrl->c_str() + Parsed.offPath);
1153 if (Parsed.cchQuery > 0)
1154 return setError(E_INVALIDARG, tr("Proxy URL must not include a query component (?%.*s)"),
1155 Parsed.cchQuery, pStrProxyUrl->c_str() + Parsed.offQuery);
1156 if (Parsed.cchFragment > 0)
1157 return setError(E_INVALIDARG, tr("Proxy URL must not include a fragment component (#%.*s)"),
1158 Parsed.cchFragment, pStrProxyUrl->c_str() + Parsed.offFragment);
1159 }
1160
1161 /*
1162 * Set and write out settings.
1163 */
1164 {
1165 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1166 m->strProxyUrl = *pStrProxyUrl;
1167 }
1168 AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS); /* required for saving. */
1169 return mParent->i_saveSettings();
1170}
1171
1172HRESULT SystemProperties::getSupportedParavirtProviders(std::vector<ParavirtProvider_T> &aSupportedParavirtProviders)
1173{
1174 static const ParavirtProvider_T aParavirtProviders[] =
1175 {
1176 ParavirtProvider_None,
1177 ParavirtProvider_Default,
1178 ParavirtProvider_Legacy,
1179 ParavirtProvider_Minimal,
1180 ParavirtProvider_HyperV,
1181 ParavirtProvider_KVM,
1182 };
1183 aSupportedParavirtProviders.assign(aParavirtProviders,
1184 aParavirtProviders + RT_ELEMENTS(aParavirtProviders));
1185 return S_OK;
1186}
1187
1188HRESULT SystemProperties::getSupportedClipboardModes(std::vector<ClipboardMode_T> &aSupportedClipboardModes)
1189{
1190 static const ClipboardMode_T aClipboardModes[] =
1191 {
1192 ClipboardMode_Disabled,
1193 ClipboardMode_HostToGuest,
1194 ClipboardMode_GuestToHost,
1195 ClipboardMode_Bidirectional,
1196 };
1197 aSupportedClipboardModes.assign(aClipboardModes,
1198 aClipboardModes + RT_ELEMENTS(aClipboardModes));
1199 return S_OK;
1200}
1201
1202HRESULT SystemProperties::getSupportedDnDModes(std::vector<DnDMode_T> &aSupportedDnDModes)
1203{
1204 static const DnDMode_T aDnDModes[] =
1205 {
1206 DnDMode_Disabled,
1207 DnDMode_HostToGuest,
1208 DnDMode_GuestToHost,
1209 DnDMode_Bidirectional,
1210 };
1211 aSupportedDnDModes.assign(aDnDModes,
1212 aDnDModes + RT_ELEMENTS(aDnDModes));
1213 return S_OK;
1214}
1215
1216HRESULT SystemProperties::getSupportedFirmwareTypes(std::vector<FirmwareType_T> &aSupportedFirmwareTypes)
1217{
1218 static const FirmwareType_T aFirmwareTypes[] =
1219 {
1220 FirmwareType_BIOS,
1221 FirmwareType_EFI,
1222 FirmwareType_EFI32,
1223 FirmwareType_EFI64,
1224 FirmwareType_EFIDUAL,
1225 };
1226 aSupportedFirmwareTypes.assign(aFirmwareTypes,
1227 aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
1228 return S_OK;
1229}
1230
1231HRESULT SystemProperties::getSupportedPointingHIDTypes(std::vector<PointingHIDType_T> &aSupportedPointingHIDTypes)
1232{
1233 static const PointingHIDType_T aPointingHIDTypes[] =
1234 {
1235 PointingHIDType_PS2Mouse,
1236#ifdef DEBUG
1237 PointingHIDType_USBMouse,
1238#endif
1239 PointingHIDType_USBTablet,
1240#ifdef DEBUG
1241 PointingHIDType_ComboMouse,
1242#endif
1243 PointingHIDType_USBMultiTouch,
1244 };
1245 aSupportedPointingHIDTypes.assign(aPointingHIDTypes,
1246 aPointingHIDTypes + RT_ELEMENTS(aPointingHIDTypes));
1247 return S_OK;
1248}
1249
1250HRESULT SystemProperties::getSupportedKeyboardHIDTypes(std::vector<KeyboardHIDType_T> &aSupportedKeyboardHIDTypes)
1251{
1252 static const KeyboardHIDType_T aKeyboardHIDTypes[] =
1253 {
1254 KeyboardHIDType_PS2Keyboard,
1255 KeyboardHIDType_USBKeyboard,
1256#ifdef DEBUG
1257 KeyboardHIDType_ComboKeyboard,
1258#endif
1259 };
1260 aSupportedKeyboardHIDTypes.assign(aKeyboardHIDTypes,
1261 aKeyboardHIDTypes + RT_ELEMENTS(aKeyboardHIDTypes));
1262 return S_OK;
1263}
1264
1265HRESULT SystemProperties::getSupportedVFSTypes(std::vector<VFSType_T> &aSupportedVFSTypes)
1266{
1267 static const VFSType_T aVFSTypes[] =
1268 {
1269 VFSType_File,
1270 VFSType_Cloud,
1271 VFSType_S3,
1272#ifdef DEBUG
1273 VFSType_WebDav,
1274#endif
1275 };
1276 aSupportedVFSTypes.assign(aVFSTypes,
1277 aVFSTypes + RT_ELEMENTS(aVFSTypes));
1278 return S_OK;
1279}
1280
1281HRESULT SystemProperties::getSupportedImportOptions(std::vector<ImportOptions_T> &aSupportedImportOptions)
1282{
1283 static const ImportOptions_T aImportOptions[] =
1284 {
1285 ImportOptions_KeepAllMACs,
1286 ImportOptions_KeepNATMACs,
1287 ImportOptions_ImportToVDI,
1288 };
1289 aSupportedImportOptions.assign(aImportOptions,
1290 aImportOptions + RT_ELEMENTS(aImportOptions));
1291 return S_OK;
1292}
1293
1294HRESULT SystemProperties::getSupportedExportOptions(std::vector<ExportOptions_T> &aSupportedExportOptions)
1295{
1296 static const ExportOptions_T aExportOptions[] =
1297 {
1298 ExportOptions_CreateManifest,
1299 ExportOptions_ExportDVDImages,
1300 ExportOptions_StripAllMACs,
1301 ExportOptions_StripAllNonNATMACs,
1302 };
1303 aSupportedExportOptions.assign(aExportOptions,
1304 aExportOptions + RT_ELEMENTS(aExportOptions));
1305 return S_OK;
1306}
1307
1308HRESULT SystemProperties::getSupportedRecordingAudioCodecs(std::vector<RecordingAudioCodec_T> &aSupportedRecordingAudioCodecs)
1309{
1310 static const RecordingAudioCodec_T aRecordingAudioCodecs[] =
1311 {
1312#ifdef DEBUG
1313 RecordingAudioCodec_WavPCM,
1314#endif
1315 RecordingAudioCodec_Opus,
1316 };
1317 aSupportedRecordingAudioCodecs.assign(aRecordingAudioCodecs,
1318 aRecordingAudioCodecs + RT_ELEMENTS(aRecordingAudioCodecs));
1319 return S_OK;
1320}
1321
1322HRESULT SystemProperties::getSupportedRecordingVideoCodecs(std::vector<RecordingVideoCodec_T> &aSupportedRecordingVideoCodecs)
1323{
1324 static const RecordingVideoCodec_T aRecordingVideoCodecs[] =
1325 {
1326 RecordingVideoCodec_VP8,
1327#ifdef DEBUG
1328 RecordingVideoCodec_VP9,
1329 RecordingVideoCodec_AV1,
1330#endif
1331 };
1332 aSupportedRecordingVideoCodecs.assign(aRecordingVideoCodecs,
1333 aRecordingVideoCodecs + RT_ELEMENTS(aRecordingVideoCodecs));
1334 return S_OK;
1335}
1336
1337HRESULT SystemProperties::getSupportedRecordingVSMethods(std::vector<RecordingVideoScalingMethod_T> &aSupportedRecordingVideoScalingMethods)
1338{
1339 static const RecordingVideoScalingMethod_T aRecordingVideoScalingMethods[] =
1340 {
1341 RecordingVideoScalingMethod_None,
1342#ifdef DEBUG
1343 RecordingVideoScalingMethod_NearestNeighbor,
1344 RecordingVideoScalingMethod_Bilinear,
1345 RecordingVideoScalingMethod_Bicubic,
1346#endif
1347 };
1348 aSupportedRecordingVideoScalingMethods.assign(aRecordingVideoScalingMethods,
1349 aRecordingVideoScalingMethods + RT_ELEMENTS(aRecordingVideoScalingMethods));
1350 return S_OK;
1351}
1352
1353HRESULT SystemProperties::getSupportedRecordingVRCModes(std::vector<RecordingVideoRateControlMode_T> &aSupportedRecordingVideoRateControlModes)
1354{
1355 static const RecordingVideoRateControlMode_T aRecordingVideoRateControlModes[] =
1356 {
1357 RecordingVideoRateControlMode_CBR,
1358#ifdef DEBUG
1359 RecordingVideoRateControlMode_VBR,
1360#endif
1361 };
1362 aSupportedRecordingVideoRateControlModes.assign(aRecordingVideoRateControlModes,
1363 aRecordingVideoRateControlModes + RT_ELEMENTS(aRecordingVideoRateControlModes));
1364 return S_OK;
1365}
1366
1367HRESULT SystemProperties::getSupportedGraphicsControllerTypes(std::vector<GraphicsControllerType_T> &aSupportedGraphicsControllerTypes)
1368{
1369 static const GraphicsControllerType_T aGraphicsControllerTypes[] =
1370 {
1371 GraphicsControllerType_VBoxVGA,
1372 GraphicsControllerType_VMSVGA,
1373 GraphicsControllerType_VBoxSVGA,
1374 GraphicsControllerType_Null,
1375 };
1376 aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes,
1377 aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
1378 return S_OK;
1379}
1380
1381HRESULT SystemProperties::getSupportedCloneOptions(std::vector<CloneOptions_T> &aSupportedCloneOptions)
1382{
1383 static const CloneOptions_T aCloneOptions[] =
1384 {
1385 CloneOptions_Link,
1386 CloneOptions_KeepAllMACs,
1387 CloneOptions_KeepNATMACs,
1388 CloneOptions_KeepDiskNames,
1389 CloneOptions_KeepHwUUIDs,
1390 };
1391 aSupportedCloneOptions.assign(aCloneOptions,
1392 aCloneOptions + RT_ELEMENTS(aCloneOptions));
1393 return S_OK;
1394}
1395
1396HRESULT SystemProperties::getSupportedAutostopTypes(std::vector<AutostopType_T> &aSupportedAutostopTypes)
1397{
1398 static const AutostopType_T aAutostopTypes[] =
1399 {
1400 AutostopType_Disabled,
1401 AutostopType_SaveState,
1402 AutostopType_PowerOff,
1403 AutostopType_AcpiShutdown,
1404 };
1405 aSupportedAutostopTypes.assign(aAutostopTypes,
1406 aAutostopTypes + RT_ELEMENTS(aAutostopTypes));
1407 return S_OK;
1408}
1409
1410HRESULT SystemProperties::getSupportedVMProcPriorities(std::vector<VMProcPriority_T> &aSupportedVMProcPriorities)
1411{
1412 static const VMProcPriority_T aVMProcPriorities[] =
1413 {
1414 VMProcPriority_Default,
1415 VMProcPriority_Flat,
1416 VMProcPriority_Low,
1417 VMProcPriority_Normal,
1418 VMProcPriority_High,
1419 };
1420 aSupportedVMProcPriorities.assign(aVMProcPriorities,
1421 aVMProcPriorities + RT_ELEMENTS(aVMProcPriorities));
1422 return S_OK;
1423}
1424
1425HRESULT SystemProperties::getSupportedNetworkAttachmentTypes(std::vector<NetworkAttachmentType_T> &aSupportedNetworkAttachmentTypes)
1426{
1427 static const NetworkAttachmentType_T aNetworkAttachmentTypes[] =
1428 {
1429 NetworkAttachmentType_NAT,
1430 NetworkAttachmentType_Bridged,
1431 NetworkAttachmentType_Internal,
1432 NetworkAttachmentType_HostOnly,
1433 NetworkAttachmentType_Generic,
1434 NetworkAttachmentType_NATNetwork,
1435#ifdef VBOX_WITH_CLOUD_NET
1436 NetworkAttachmentType_Cloud,
1437#endif
1438 NetworkAttachmentType_Null,
1439 };
1440 aSupportedNetworkAttachmentTypes.assign(aNetworkAttachmentTypes,
1441 aNetworkAttachmentTypes + RT_ELEMENTS(aNetworkAttachmentTypes));
1442 return S_OK;
1443}
1444
1445HRESULT SystemProperties::getSupportedNetworkAdapterTypes(std::vector<NetworkAdapterType_T> &aSupportedNetworkAdapterTypes)
1446{
1447 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
1448 {
1449 NetworkAdapterType_Am79C970A,
1450 NetworkAdapterType_Am79C973,
1451 NetworkAdapterType_I82540EM,
1452 NetworkAdapterType_I82543GC,
1453 NetworkAdapterType_I82545EM,
1454 NetworkAdapterType_Virtio,
1455#ifdef VBOX_WITH_VIRTIO_NET_1_0
1456 NetworkAdapterType_Virtio_1_0,
1457#endif
1458 };
1459 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes,
1460 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
1461 return S_OK;
1462}
1463
1464HRESULT SystemProperties::getSupportedPortModes(std::vector<PortMode_T> &aSupportedPortModes)
1465{
1466 static const PortMode_T aPortModes[] =
1467 {
1468 PortMode_Disconnected,
1469 PortMode_HostPipe,
1470 PortMode_HostDevice,
1471 PortMode_RawFile,
1472 PortMode_TCP,
1473 };
1474 aSupportedPortModes.assign(aPortModes,
1475 aPortModes + RT_ELEMENTS(aPortModes));
1476 return S_OK;
1477}
1478
1479HRESULT SystemProperties::getSupportedUartTypes(std::vector<UartType_T> &aSupportedUartTypes)
1480{
1481 static const UartType_T aUartTypes[] =
1482 {
1483 UartType_U16450,
1484 UartType_U16550A,
1485 UartType_U16750,
1486 };
1487 aSupportedUartTypes.assign(aUartTypes,
1488 aUartTypes + RT_ELEMENTS(aUartTypes));
1489 return S_OK;
1490}
1491
1492HRESULT SystemProperties::getSupportedUSBControllerTypes(std::vector<USBControllerType_T> &aSupportedUSBControllerTypes)
1493{
1494 static const USBControllerType_T aUSBControllerTypesWithoutExtPack[] =
1495 {
1496 USBControllerType_OHCI,
1497 };
1498 static const USBControllerType_T aUSBControllerTypesWithExtPack[] =
1499 {
1500 USBControllerType_OHCI,
1501 USBControllerType_EHCI,
1502 USBControllerType_XHCI,
1503 };
1504 bool fExtPack = false;
1505# ifdef VBOX_WITH_EXTPACK
1506 static const char *s_pszUsbExtPackName = "Oracle VM VirtualBox Extension Pack";
1507 if (mParent->i_getExtPackManager()->i_isExtPackUsable(s_pszUsbExtPackName))
1508# endif
1509 {
1510 fExtPack = true;
1511 }
1512
1513 if (fExtPack)
1514 aSupportedUSBControllerTypes.assign(aUSBControllerTypesWithExtPack,
1515 aUSBControllerTypesWithExtPack + RT_ELEMENTS(aUSBControllerTypesWithExtPack));
1516 else
1517 aSupportedUSBControllerTypes.assign(aUSBControllerTypesWithoutExtPack,
1518 aUSBControllerTypesWithoutExtPack + RT_ELEMENTS(aUSBControllerTypesWithoutExtPack));
1519 return S_OK;
1520}
1521
1522HRESULT SystemProperties::getSupportedAudioDriverTypes(std::vector<AudioDriverType_T> &aSupportedAudioDriverTypes)
1523{
1524 static const AudioDriverType_T aAudioDriverTypes[] =
1525 {
1526#ifdef RT_OS_WINDOWS
1527# if 0 /* deprecated for many years now */
1528 AudioDriverType_WinMM,
1529# endif
1530 AudioDriverType_DirectSound,
1531#endif
1532#ifdef RT_OS_DARWIN
1533 AudioDriverType_CoreAudio,
1534#endif
1535#ifdef RT_OS_OS2
1536 AudioDriverType_MMPM,
1537#endif
1538#ifdef RT_OS_SOLARIS
1539# if 0 /* deprecated for many years now */
1540 AudioDriverType_SolAudio,
1541# endif
1542#endif
1543#ifdef VBOX_WITH_AUDIO_ALSA
1544 AudioDriverType_ALSA,
1545#endif
1546#ifdef VBOX_WITH_AUDIO_OSS
1547 AudioDriverType_OSS,
1548#endif
1549#ifdef VBOX_WITH_AUDIO_PULSE
1550 AudioDriverType_Pulse,
1551#endif
1552 AudioDriverType_Null,
1553 };
1554 aSupportedAudioDriverTypes.assign(aAudioDriverTypes,
1555 aAudioDriverTypes + RT_ELEMENTS(aAudioDriverTypes));
1556 return S_OK;
1557}
1558
1559HRESULT SystemProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
1560{
1561 static const AudioControllerType_T aAudioControllerTypes[] =
1562 {
1563 AudioControllerType_AC97,
1564 AudioControllerType_SB16,
1565 AudioControllerType_HDA,
1566 };
1567 aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
1568 aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
1569 return S_OK;
1570}
1571
1572HRESULT SystemProperties::getSupportedStorageBuses(std::vector<StorageBus_T> &aSupportedStorageBuses)
1573{
1574 static const StorageBus_T aStorageBuses[] =
1575 {
1576 StorageBus_SATA,
1577 StorageBus_IDE,
1578 StorageBus_SCSI,
1579 StorageBus_Floppy,
1580 StorageBus_SAS,
1581 StorageBus_USB,
1582 StorageBus_PCIe,
1583 StorageBus_VirtioSCSI,
1584 };
1585 aSupportedStorageBuses.assign(aStorageBuses,
1586 aStorageBuses + RT_ELEMENTS(aStorageBuses));
1587 return S_OK;
1588}
1589
1590HRESULT SystemProperties::getSupportedStorageControllerTypes(std::vector<StorageControllerType_T> &aSupportedStorageControllerTypes)
1591{
1592 static const StorageControllerType_T aStorageControllerTypes[] =
1593 {
1594 StorageControllerType_IntelAhci,
1595 StorageControllerType_PIIX4,
1596 StorageControllerType_PIIX3,
1597 StorageControllerType_ICH6,
1598 StorageControllerType_LsiLogic,
1599 StorageControllerType_BusLogic,
1600 StorageControllerType_I82078,
1601 StorageControllerType_LsiLogicSas,
1602 StorageControllerType_USB,
1603 StorageControllerType_NVMe,
1604 StorageControllerType_VirtioSCSI,
1605 };
1606 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
1607 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
1608 return S_OK;
1609}
1610
1611HRESULT SystemProperties::getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes)
1612{
1613 static const ChipsetType_T aChipsetTypes[] =
1614 {
1615 ChipsetType_PIIX3,
1616 ChipsetType_ICH9,
1617 };
1618 aSupportedChipsetTypes.assign(aChipsetTypes,
1619 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
1620 return S_OK;
1621}
1622
1623
1624// public methods only for internal purposes
1625/////////////////////////////////////////////////////////////////////////////
1626
1627HRESULT SystemProperties::i_loadSettings(const settings::SystemProperties &data)
1628{
1629 AutoCaller autoCaller(this);
1630 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1631
1632 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1633 HRESULT rc = S_OK;
1634 rc = i_setDefaultMachineFolder(data.strDefaultMachineFolder);
1635 if (FAILED(rc)) return rc;
1636
1637 rc = i_setLoggingLevel(data.strLoggingLevel);
1638 if (FAILED(rc)) return rc;
1639
1640 rc = i_setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
1641 if (FAILED(rc)) return rc;
1642
1643 rc = i_setVRDEAuthLibrary(data.strVRDEAuthLibrary);
1644 if (FAILED(rc)) return rc;
1645
1646 rc = i_setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
1647 if (FAILED(rc)) return rc;
1648
1649 rc = i_setDefaultVRDEExtPack(data.strDefaultVRDEExtPack);
1650 if (FAILED(rc)) return rc;
1651
1652 m->uLogHistoryCount = data.uLogHistoryCount;
1653 m->fExclusiveHwVirt = data.fExclusiveHwVirt;
1654 m->uProxyMode = data.uProxyMode;
1655 m->strProxyUrl = data.strProxyUrl;
1656
1657 rc = i_setAutostartDatabasePath(data.strAutostartDatabasePath);
1658 if (FAILED(rc)) return rc;
1659
1660 {
1661 /* must ignore errors signalled here, because the guest additions
1662 * file may not exist, and in this case keep the empty string */
1663 ErrorInfoKeeper eik;
1664 (void)i_setDefaultAdditionsISO(data.strDefaultAdditionsISO);
1665 }
1666
1667 rc = i_setDefaultFrontend(data.strDefaultFrontend);
1668 if (FAILED(rc)) return rc;
1669
1670 return S_OK;
1671}
1672
1673HRESULT SystemProperties::i_saveSettings(settings::SystemProperties &data)
1674{
1675 AutoCaller autoCaller(this);
1676 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1677
1678 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1679
1680 data = *m;
1681
1682 return S_OK;
1683}
1684
1685/**
1686 * Returns a medium format object corresponding to the given format
1687 * identifier or null if no such format.
1688 *
1689 * @param aFormat Format identifier.
1690 *
1691 * @return ComObjPtr<MediumFormat>
1692 */
1693ComObjPtr<MediumFormat> SystemProperties::i_mediumFormat(const Utf8Str &aFormat)
1694{
1695 ComObjPtr<MediumFormat> format;
1696
1697 AutoCaller autoCaller(this);
1698 AssertComRCReturn (autoCaller.rc(), format);
1699
1700 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1701
1702 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1703 it != m_llMediumFormats.end();
1704 ++ it)
1705 {
1706 /* MediumFormat is all const, no need to lock */
1707
1708 if ((*it)->i_getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
1709 {
1710 format = *it;
1711 break;
1712 }
1713 }
1714
1715 return format;
1716}
1717
1718/**
1719 * Returns a medium format object corresponding to the given file extension or
1720 * null if no such format.
1721 *
1722 * @param aExt File extension.
1723 *
1724 * @return ComObjPtr<MediumFormat>
1725 */
1726ComObjPtr<MediumFormat> SystemProperties::i_mediumFormatFromExtension(const Utf8Str &aExt)
1727{
1728 ComObjPtr<MediumFormat> format;
1729
1730 AutoCaller autoCaller(this);
1731 AssertComRCReturn (autoCaller.rc(), format);
1732
1733 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1734
1735 bool fFound = false;
1736 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1737 it != m_llMediumFormats.end() && !fFound;
1738 ++it)
1739 {
1740 /* MediumFormat is all const, no need to lock */
1741 MediumFormat::StrArray aFileList = (*it)->i_getFileExtensions();
1742 for (MediumFormat::StrArray::const_iterator it1 = aFileList.begin();
1743 it1 != aFileList.end();
1744 ++it1)
1745 {
1746 if ((*it1).compare(aExt, Utf8Str::CaseInsensitive) == 0)
1747 {
1748 format = *it;
1749 fFound = true;
1750 break;
1751 }
1752 }
1753 }
1754
1755 return format;
1756}
1757
1758
1759/**
1760 * VD plugin load
1761 */
1762int SystemProperties::i_loadVDPlugin(const char *pszPluginLibrary)
1763{
1764 return VDPluginLoadFromFilename(pszPluginLibrary);
1765}
1766
1767/**
1768 * VD plugin unload
1769 */
1770int SystemProperties::i_unloadVDPlugin(const char *pszPluginLibrary)
1771{
1772 return VDPluginUnloadFromFilename(pszPluginLibrary);
1773}
1774
1775/**
1776 * Internally usable version of getDefaultAdditionsISO.
1777 */
1778HRESULT SystemProperties::i_getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO)
1779{
1780 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1781 if (m->strDefaultAdditionsISO.isNotEmpty())
1782 aDefaultAdditionsISO = m->strDefaultAdditionsISO;
1783 else
1784 {
1785 /* no guest additions, check if it showed up in the mean time */
1786 alock.release();
1787 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
1788 if (m->strDefaultAdditionsISO.isEmpty())
1789 {
1790 ErrorInfoKeeper eik;
1791 (void)setDefaultAdditionsISO("");
1792 }
1793 aDefaultAdditionsISO = m->strDefaultAdditionsISO;
1794 }
1795 return S_OK;
1796}
1797
1798// private methods
1799/////////////////////////////////////////////////////////////////////////////
1800
1801/**
1802 * Returns the user's home directory. Wrapper around RTPathUserHome().
1803 * @param strPath
1804 * @return
1805 */
1806HRESULT SystemProperties::i_getUserHomeDirectory(Utf8Str &strPath)
1807{
1808 char szHome[RTPATH_MAX];
1809 int vrc = RTPathUserHome(szHome, sizeof(szHome));
1810 if (RT_FAILURE(vrc))
1811 return setErrorBoth(E_FAIL, vrc,
1812 tr("Cannot determine user home directory (%Rrc)"),
1813 vrc);
1814 strPath = szHome;
1815 return S_OK;
1816}
1817
1818/**
1819 * Internal implementation to set the default machine folder. Gets called
1820 * from the public attribute setter as well as loadSettings(). With 4.0,
1821 * the "default default" machine folder has changed, and we now require
1822 * a full path always.
1823 * @param strPath
1824 * @return
1825 */
1826HRESULT SystemProperties::i_setDefaultMachineFolder(const Utf8Str &strPath)
1827{
1828 Utf8Str path(strPath); // make modifiable
1829 if ( path.isEmpty() // used by API calls to reset the default
1830 || path == "Machines" // this value (exactly like this, without path) is stored
1831 // in VirtualBox.xml if user upgrades from before 4.0 and
1832 // has not changed the default machine folder
1833 )
1834 {
1835 // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
1836 HRESULT rc = i_getUserHomeDirectory(path);
1837 if (FAILED(rc)) return rc;
1838 path += RTPATH_SLASH_STR "VirtualBox VMs";
1839 }
1840
1841 if (!RTPathStartsWithRoot(path.c_str()))
1842 return setError(E_INVALIDARG,
1843 tr("Given default machine folder '%s' is not fully qualified"),
1844 path.c_str());
1845
1846 m->strDefaultMachineFolder = path;
1847
1848 return S_OK;
1849}
1850
1851HRESULT SystemProperties::i_setLoggingLevel(const com::Utf8Str &aLoggingLevel)
1852{
1853 Utf8Str useLoggingLevel(aLoggingLevel);
1854 if (useLoggingLevel.isEmpty())
1855 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
1856 int rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), useLoggingLevel.c_str());
1857 // If failed and not the default logging level - try to use the default logging level.
1858 if (RT_FAILURE(rc))
1859 {
1860 // If failed write message to the release log.
1861 LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), rc));
1862 // If attempted logging level not the default one then try the default one.
1863 if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT))
1864 {
1865 rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), VBOXSVC_LOG_DEFAULT);
1866 // If failed report this to the release log.
1867 if (RT_FAILURE(rc))
1868 LogRel(("Cannot set default logging level Error=%Rrc \n", rc));
1869 }
1870 // On any failure - set default level as the one to be stored.
1871 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
1872 }
1873 // Set to passed value or if default used/attempted (even if error condition) use empty string.
1874 m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel);
1875 return RT_SUCCESS(rc) ? S_OK : E_FAIL;
1876}
1877
1878HRESULT SystemProperties::i_setDefaultHardDiskFormat(const com::Utf8Str &aFormat)
1879{
1880 if (!aFormat.isEmpty())
1881 m->strDefaultHardDiskFormat = aFormat;
1882 else
1883 m->strDefaultHardDiskFormat = "VDI";
1884
1885 return S_OK;
1886}
1887
1888HRESULT SystemProperties::i_setVRDEAuthLibrary(const com::Utf8Str &aPath)
1889{
1890 if (!aPath.isEmpty())
1891 m->strVRDEAuthLibrary = aPath;
1892 else
1893 m->strVRDEAuthLibrary = "VBoxAuth";
1894
1895 return S_OK;
1896}
1897
1898HRESULT SystemProperties::i_setWebServiceAuthLibrary(const com::Utf8Str &aPath)
1899{
1900 if (!aPath.isEmpty())
1901 m->strWebServiceAuthLibrary = aPath;
1902 else
1903 m->strWebServiceAuthLibrary = "VBoxAuth";
1904
1905 return S_OK;
1906}
1907
1908HRESULT SystemProperties::i_setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
1909{
1910 m->strDefaultVRDEExtPack = aExtPack;
1911
1912 return S_OK;
1913}
1914
1915HRESULT SystemProperties::i_setAutostartDatabasePath(const com::Utf8Str &aPath)
1916{
1917 HRESULT rc = S_OK;
1918 AutostartDb *autostartDb = this->mParent->i_getAutostartDb();
1919
1920 if (!aPath.isEmpty())
1921 {
1922 /* Update path in the autostart database. */
1923 int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
1924 if (RT_SUCCESS(vrc))
1925 m->strAutostartDatabasePath = aPath;
1926 else
1927 rc = setErrorBoth(E_FAIL, vrc,
1928 tr("Cannot set the autostart database path (%Rrc)"),
1929 vrc);
1930 }
1931 else
1932 {
1933 int vrc = autostartDb->setAutostartDbPath(NULL);
1934 if (RT_SUCCESS(vrc) || vrc == VERR_NOT_SUPPORTED)
1935 m->strAutostartDatabasePath = "";
1936 else
1937 rc = setErrorBoth(E_FAIL, vrc,
1938 tr("Deleting the autostart database path failed (%Rrc)"),
1939 vrc);
1940 }
1941
1942 return rc;
1943}
1944
1945HRESULT SystemProperties::i_setDefaultAdditionsISO(const com::Utf8Str &aPath)
1946{
1947 com::Utf8Str path(aPath);
1948 if (path.isEmpty())
1949 {
1950 char strTemp[RTPATH_MAX];
1951 int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
1952 AssertRC(vrc);
1953 Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
1954
1955 vrc = RTPathExecDir(strTemp, sizeof(strTemp));
1956 AssertRC(vrc);
1957 Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
1958
1959 vrc = RTPathUserHome(strTemp, sizeof(strTemp));
1960 AssertRC(vrc);
1961 Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%s.iso", strTemp, VirtualBox::i_getVersionNormalized().c_str());
1962
1963 /* Check the standard image locations */
1964 if (RTFileExists(strSrc1.c_str()))
1965 path = strSrc1;
1966 else if (RTFileExists(strSrc2.c_str()))
1967 path = strSrc2;
1968 else if (RTFileExists(strSrc3.c_str()))
1969 path = strSrc3;
1970 else
1971 return setError(E_FAIL,
1972 tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
1973 }
1974
1975 if (!RTPathStartsWithRoot(path.c_str()))
1976 return setError(E_INVALIDARG,
1977 tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
1978 path.c_str());
1979
1980 if (!RTFileExists(path.c_str()))
1981 return setError(E_INVALIDARG,
1982 tr("Given default machine Guest Additions ISO file '%s' does not exist"),
1983 path.c_str());
1984
1985 m->strDefaultAdditionsISO = path;
1986
1987 return S_OK;
1988}
1989
1990HRESULT SystemProperties::i_setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
1991{
1992 m->strDefaultFrontend = aDefaultFrontend;
1993
1994 return S_OK;
1995}
1996
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