VirtualBox

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

Last change on this file since 48429 was 48004, checked in by vboxsync, 11 years ago

Fixed initialization.

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