VirtualBox

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

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

Small change to tidy up 6787 Contrl VboxSV release logging

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