VirtualBox

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

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

Small changes 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 47592 2013-08-07 13:58:24Z 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 if (useLoggingLevel.isEmpty())
660 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
661
662 useLoggingLevel.cloneTo(aLoggingLevel);
663 return S_OK;
664}
665
666
667STDMETHODIMP SystemProperties::COMSETTER(LoggingLevel)(IN_BSTR aLoggingLevel)
668{
669 AutoCaller autoCaller(this);
670 if (FAILED(autoCaller.rc())) return autoCaller.rc();
671
672 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
673 HRESULT rc = setLoggingLevel(aLoggingLevel);
674 alock.release();
675
676 if (SUCCEEDED(rc))
677 {
678 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
679 rc = mParent->saveSettings();
680 }
681 else
682 LogRel(("Cannot set passed logging level=%ls, or the default one - Error=%Rhrc \n", aLoggingLevel, rc));
683
684 return rc;
685}
686
687STDMETHODIMP SystemProperties::COMGETTER(MediumFormats)(ComSafeArrayOut(IMediumFormat *, aMediumFormats))
688{
689 CheckComArgOutSafeArrayPointerValid(aMediumFormats);
690
691 AutoCaller autoCaller(this);
692 if (FAILED(autoCaller.rc())) return autoCaller.rc();
693
694 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
695
696 SafeIfaceArray<IMediumFormat> mediumFormats(m_llMediumFormats);
697 mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats));
698
699 return S_OK;
700}
701
702STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat)(BSTR *aDefaultHardDiskFormat)
703{
704 CheckComArgOutPointerValid(aDefaultHardDiskFormat);
705
706 AutoCaller autoCaller(this);
707 if (FAILED(autoCaller.rc())) return autoCaller.rc();
708
709 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
710
711 m->strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
712
713 return S_OK;
714}
715
716STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat)(IN_BSTR aDefaultHardDiskFormat)
717{
718 AutoCaller autoCaller(this);
719 if (FAILED(autoCaller.rc())) return autoCaller.rc();
720
721 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
722 HRESULT rc = setDefaultHardDiskFormat(aDefaultHardDiskFormat);
723 alock.release();
724
725 if (SUCCEEDED(rc))
726 {
727 // VirtualBox::saveSettings() needs vbox write lock
728 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
729 rc = mParent->saveSettings();
730 }
731
732 return rc;
733}
734
735STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceWarning)(LONG64 *aFreeSpace)
736{
737 CheckComArgOutPointerValid(aFreeSpace);
738
739 ReturnComNotImplemented();
740}
741
742STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceWarning)(LONG64 /* aFreeSpace */)
743{
744 ReturnComNotImplemented();
745}
746
747STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentWarning)(ULONG *aFreeSpacePercent)
748{
749 CheckComArgOutPointerValid(aFreeSpacePercent);
750
751 ReturnComNotImplemented();
752}
753
754STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentWarning)(ULONG /* aFreeSpacePercent */)
755{
756 ReturnComNotImplemented();
757}
758
759STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceError)(LONG64 *aFreeSpace)
760{
761 CheckComArgOutPointerValid(aFreeSpace);
762
763 ReturnComNotImplemented();
764}
765
766STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceError)(LONG64 /* aFreeSpace */)
767{
768 ReturnComNotImplemented();
769}
770
771STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentError)(ULONG *aFreeSpacePercent)
772{
773 CheckComArgOutPointerValid(aFreeSpacePercent);
774
775 ReturnComNotImplemented();
776}
777
778STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentError)(ULONG /* aFreeSpacePercent */)
779{
780 ReturnComNotImplemented();
781}
782
783STDMETHODIMP SystemProperties::COMGETTER(VRDEAuthLibrary)(BSTR *aVRDEAuthLibrary)
784{
785 CheckComArgOutPointerValid(aVRDEAuthLibrary);
786
787 AutoCaller autoCaller(this);
788 if (FAILED(autoCaller.rc())) return autoCaller.rc();
789
790 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
791
792 m->strVRDEAuthLibrary.cloneTo(aVRDEAuthLibrary);
793
794 return S_OK;
795}
796
797STDMETHODIMP SystemProperties::COMSETTER(VRDEAuthLibrary)(IN_BSTR aVRDEAuthLibrary)
798{
799 AutoCaller autoCaller(this);
800 if (FAILED(autoCaller.rc())) return autoCaller.rc();
801
802 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
803 HRESULT rc = setVRDEAuthLibrary(aVRDEAuthLibrary);
804 alock.release();
805
806 if (SUCCEEDED(rc))
807 {
808 // VirtualBox::saveSettings() needs vbox write lock
809 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
810 rc = mParent->saveSettings();
811 }
812
813 return rc;
814}
815
816STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary)(BSTR *aWebServiceAuthLibrary)
817{
818 CheckComArgOutPointerValid(aWebServiceAuthLibrary);
819
820 AutoCaller autoCaller(this);
821 if (FAILED(autoCaller.rc())) return autoCaller.rc();
822
823 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
824
825 m->strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
826
827 return S_OK;
828}
829
830STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary)(IN_BSTR aWebServiceAuthLibrary)
831{
832 AutoCaller autoCaller(this);
833 if (FAILED(autoCaller.rc())) return autoCaller.rc();
834
835 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
836 HRESULT rc = setWebServiceAuthLibrary(aWebServiceAuthLibrary);
837 alock.release();
838
839 if (SUCCEEDED(rc))
840 {
841 // VirtualBox::saveSettings() needs vbox write lock
842 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
843 rc = mParent->saveSettings();
844 }
845
846 return rc;
847}
848
849STDMETHODIMP SystemProperties::COMGETTER(DefaultVRDEExtPack)(BSTR *aExtPack)
850{
851 CheckComArgOutPointerValid(aExtPack);
852
853 AutoCaller autoCaller(this);
854 HRESULT hrc = autoCaller.rc();
855 if (SUCCEEDED(hrc))
856 {
857 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
858 Utf8Str strExtPack(m->strDefaultVRDEExtPack);
859 if (strExtPack.isNotEmpty())
860 {
861 if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
862 hrc = S_OK;
863 else
864#ifdef VBOX_WITH_EXTPACK
865 hrc = mParent->getExtPackManager()->checkVrdeExtPack(&strExtPack);
866#else
867 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
868#endif
869 }
870 else
871 {
872#ifdef VBOX_WITH_EXTPACK
873 hrc = mParent->getExtPackManager()->getDefaultVrdeExtPack(&strExtPack);
874#endif
875 if (strExtPack.isEmpty())
876 {
877 /*
878 * Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
879 * This is hardcoded uglyness, sorry.
880 */
881 char szPath[RTPATH_MAX];
882 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
883 if (RT_SUCCESS(vrc))
884 vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxVRDP");
885 if (RT_SUCCESS(vrc))
886 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
887 if (RT_SUCCESS(vrc) && RTFileExists(szPath))
888 {
889 /* Illegal extpack name, so no conflict. */
890 strExtPack = VBOXVRDP_KLUDGE_EXTPACK_NAME;
891 }
892 }
893 }
894
895 if (SUCCEEDED(hrc))
896 strExtPack.cloneTo(aExtPack);
897 }
898
899 return S_OK;
900}
901
902STDMETHODIMP SystemProperties::COMSETTER(DefaultVRDEExtPack)(IN_BSTR aExtPack)
903{
904 CheckComArgNotNull(aExtPack);
905 Utf8Str strExtPack(aExtPack);
906
907 AutoCaller autoCaller(this);
908 HRESULT hrc = autoCaller.rc();
909 if (SUCCEEDED(hrc))
910 {
911 if (strExtPack.isNotEmpty())
912 {
913 if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
914 hrc = S_OK;
915 else
916#ifdef VBOX_WITH_EXTPACK
917 hrc = mParent->getExtPackManager()->checkVrdeExtPack(&strExtPack);
918#else
919 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
920#endif
921 }
922 if (SUCCEEDED(hrc))
923 {
924 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
925 hrc = setDefaultVRDEExtPack(aExtPack);
926 if (SUCCEEDED(hrc))
927 {
928 /* VirtualBox::saveSettings() needs the VirtualBox write lock. */
929 alock.release();
930 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
931 hrc = mParent->saveSettings();
932 }
933 }
934 }
935
936 return hrc;
937}
938
939STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount)(ULONG *count)
940{
941 CheckComArgOutPointerValid(count);
942
943 AutoCaller autoCaller(this);
944 if (FAILED(autoCaller.rc())) return autoCaller.rc();
945
946 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
947
948 *count = m->ulLogHistoryCount;
949
950 return S_OK;
951}
952
953STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount)(ULONG count)
954{
955 AutoCaller autoCaller(this);
956 if (FAILED(autoCaller.rc())) return autoCaller.rc();
957
958 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
959 m->ulLogHistoryCount = count;
960 alock.release();
961
962 // VirtualBox::saveSettings() needs vbox write lock
963 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
964 HRESULT rc = mParent->saveSettings();
965
966 return rc;
967}
968
969STDMETHODIMP SystemProperties::COMGETTER(DefaultAudioDriver)(AudioDriverType_T *aAudioDriver)
970{
971 CheckComArgOutPointerValid(aAudioDriver);
972
973 AutoCaller autoCaller(this);
974 if (FAILED(autoCaller.rc())) return autoCaller.rc();
975
976 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
977
978 *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
979
980 return S_OK;
981}
982
983STDMETHODIMP SystemProperties::COMGETTER(AutostartDatabasePath)(BSTR *aAutostartDbPath)
984{
985 CheckComArgOutPointerValid(aAutostartDbPath);
986
987 AutoCaller autoCaller(this);
988 if (FAILED(autoCaller.rc())) return autoCaller.rc();
989
990 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
991
992 m->strAutostartDatabasePath.cloneTo(aAutostartDbPath);
993
994 return S_OK;
995}
996
997STDMETHODIMP SystemProperties::COMSETTER(AutostartDatabasePath)(IN_BSTR aAutostartDbPath)
998{
999 AutoCaller autoCaller(this);
1000 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1001
1002 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1003 HRESULT rc = setAutostartDatabasePath(aAutostartDbPath);
1004 alock.release();
1005
1006 if (SUCCEEDED(rc))
1007 {
1008 // VirtualBox::saveSettings() needs vbox write lock
1009 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1010 rc = mParent->saveSettings();
1011 }
1012
1013 return rc;
1014}
1015
1016STDMETHODIMP SystemProperties::COMGETTER(DefaultAdditionsISO)(BSTR *aDefaultAdditionsISO)
1017{
1018 CheckComArgOutPointerValid(aDefaultAdditionsISO);
1019
1020 AutoCaller autoCaller(this);
1021 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1022
1023 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1024
1025 if (m->strDefaultAdditionsISO.isEmpty())
1026 {
1027 /* no guest additions, check if it showed up in the mean time */
1028 alock.release();
1029 {
1030 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
1031 ErrorInfoKeeper eik;
1032 (void)setDefaultAdditionsISO("");
1033 }
1034 alock.acquire();
1035 }
1036 m->strDefaultAdditionsISO.cloneTo(aDefaultAdditionsISO);
1037
1038 return S_OK;
1039}
1040
1041STDMETHODIMP SystemProperties::COMSETTER(DefaultAdditionsISO)(IN_BSTR aDefaultAdditionsISO)
1042{
1043 AutoCaller autoCaller(this);
1044 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1045
1046 /** @todo not yet implemented, settings handling is missing */
1047 ReturnComNotImplemented();
1048
1049 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1050 HRESULT rc = setDefaultAdditionsISO(aDefaultAdditionsISO);
1051 alock.release();
1052
1053 if (SUCCEEDED(rc))
1054 {
1055 // VirtualBox::saveSettings() needs vbox write lock
1056 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1057 rc = mParent->saveSettings();
1058 }
1059
1060 return rc;
1061}
1062
1063STDMETHODIMP SystemProperties::COMGETTER(DefaultFrontend)(BSTR *aDefaultFrontend)
1064{
1065 CheckComArgOutPointerValid(aDefaultFrontend);
1066
1067 AutoCaller autoCaller(this);
1068 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1069
1070 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1071 m->strDefaultFrontend.cloneTo(aDefaultFrontend);
1072
1073 return S_OK;
1074}
1075
1076STDMETHODIMP SystemProperties::COMSETTER(DefaultFrontend)(IN_BSTR aDefaultFrontend)
1077{
1078 AutoCaller autoCaller(this);
1079 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1080
1081 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1082 if (m->strDefaultFrontend == Utf8Str(aDefaultFrontend))
1083 return S_OK;
1084 HRESULT rc = setDefaultFrontend(aDefaultFrontend);
1085 alock.release();
1086
1087 if (SUCCEEDED(rc))
1088 {
1089 // VirtualBox::saveSettings() needs vbox write lock
1090 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1091 rc = mParent->saveSettings();
1092 }
1093
1094 return rc;
1095}
1096
1097// public methods only for internal purposes
1098/////////////////////////////////////////////////////////////////////////////
1099
1100HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
1101{
1102 AutoCaller autoCaller(this);
1103 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1104
1105 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1106
1107 HRESULT rc = S_OK;
1108
1109 rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
1110 if (FAILED(rc)) return rc;
1111
1112 rc = setLoggingLevel(data.strLoggingLevel);
1113 if (FAILED(rc)) return rc;
1114
1115 rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
1116 if (FAILED(rc)) return rc;
1117
1118 rc = setVRDEAuthLibrary(data.strVRDEAuthLibrary);
1119 if (FAILED(rc)) return rc;
1120
1121 rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
1122 if (FAILED(rc)) return rc;
1123
1124 rc = setDefaultVRDEExtPack(data.strDefaultVRDEExtPack);
1125 if (FAILED(rc)) return rc;
1126
1127 m->ulLogHistoryCount = data.ulLogHistoryCount;
1128
1129 rc = setAutostartDatabasePath(data.strAutostartDatabasePath);
1130 if (FAILED(rc)) return rc;
1131
1132 {
1133 /* must ignore errors signalled here, because the guest additions
1134 * file may not exist, and in this case keep the empty string */
1135 ErrorInfoKeeper eik;
1136 (void)setDefaultAdditionsISO(data.strDefaultAdditionsISO);
1137 }
1138
1139 rc = setDefaultFrontend(data.strDefaultFrontend);
1140 if (FAILED(rc)) return rc;
1141
1142 return S_OK;
1143}
1144
1145HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
1146{
1147 AutoCaller autoCaller(this);
1148 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1149
1150 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1151
1152 data = *m;
1153
1154 return S_OK;
1155}
1156
1157/**
1158 * Returns a medium format object corresponding to the given format
1159 * identifier or null if no such format.
1160 *
1161 * @param aFormat Format identifier.
1162 *
1163 * @return ComObjPtr<MediumFormat>
1164 */
1165ComObjPtr<MediumFormat> SystemProperties::mediumFormat(const Utf8Str &aFormat)
1166{
1167 ComObjPtr<MediumFormat> format;
1168
1169 AutoCaller autoCaller(this);
1170 AssertComRCReturn (autoCaller.rc(), format);
1171
1172 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1173
1174 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1175 it != m_llMediumFormats.end();
1176 ++ it)
1177 {
1178 /* MediumFormat is all const, no need to lock */
1179
1180 if ((*it)->i_getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
1181 {
1182 format = *it;
1183 break;
1184 }
1185 }
1186
1187 return format;
1188}
1189
1190/**
1191 * Returns a medium format object corresponding to the given file extension or
1192 * null if no such format.
1193 *
1194 * @param aExt File extension.
1195 *
1196 * @return ComObjPtr<MediumFormat>
1197 */
1198ComObjPtr<MediumFormat> SystemProperties::mediumFormatFromExtension(const Utf8Str &aExt)
1199{
1200 ComObjPtr<MediumFormat> format;
1201
1202 AutoCaller autoCaller(this);
1203 AssertComRCReturn (autoCaller.rc(), format);
1204
1205 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1206
1207 bool fFound = false;
1208 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1209 it != m_llMediumFormats.end() && !fFound;
1210 ++it)
1211 {
1212 /* MediumFormat is all const, no need to lock */
1213 MediumFormat::StrArray aFileList = (*it)->i_getFileExtensions();
1214 for (MediumFormat::StrArray::const_iterator it1 = aFileList.begin();
1215 it1 != aFileList.end();
1216 ++it1)
1217 {
1218 if ((*it1).compare(aExt, Utf8Str::CaseInsensitive) == 0)
1219 {
1220 format = *it;
1221 fFound = true;
1222 break;
1223 }
1224 }
1225 }
1226
1227 return format;
1228}
1229
1230// private methods
1231/////////////////////////////////////////////////////////////////////////////
1232
1233/**
1234 * Returns the user's home directory. Wrapper around RTPathUserHome().
1235 * @param strPath
1236 * @return
1237 */
1238HRESULT SystemProperties::getUserHomeDirectory(Utf8Str &strPath)
1239{
1240 char szHome[RTPATH_MAX];
1241 int vrc = RTPathUserHome(szHome, sizeof(szHome));
1242 if (RT_FAILURE(vrc))
1243 return setError(E_FAIL,
1244 tr("Cannot determine user home directory (%Rrc)"),
1245 vrc);
1246 strPath = szHome;
1247 return S_OK;
1248}
1249
1250/**
1251 * Internal implementation to set the default machine folder. Gets called
1252 * from the public attribute setter as well as loadSettings(). With 4.0,
1253 * the "default default" machine folder has changed, and we now require
1254 * a full path always.
1255 * @param aPath
1256 * @return
1257 */
1258HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &strPath)
1259{
1260 Utf8Str path(strPath); // make modifiable
1261 if ( path.isEmpty() // used by API calls to reset the default
1262 || path == "Machines" // this value (exactly like this, without path) is stored
1263 // in VirtualBox.xml if user upgrades from before 4.0 and
1264 // has not changed the default machine folder
1265 )
1266 {
1267 // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
1268 HRESULT rc = getUserHomeDirectory(path);
1269 if (FAILED(rc)) return rc;
1270 path += RTPATH_SLASH_STR "VirtualBox VMs";
1271 }
1272
1273 if (!RTPathStartsWithRoot(path.c_str()))
1274 return setError(E_INVALIDARG,
1275 tr("Given default machine folder '%s' is not fully qualified"),
1276 path.c_str());
1277
1278 m->strDefaultMachineFolder = path;
1279
1280 return S_OK;
1281}
1282
1283HRESULT SystemProperties::setLoggingLevel(const Utf8Str &aLoggingLevel)
1284{
1285 int rc;
1286 Utf8Str useLoggingLevel(aLoggingLevel);
1287 rc = RTLogGroupSettings(RTLogRelDefaultInstance(), useLoggingLevel.c_str());
1288 // If failed and not the default logging level - try to use the default logging level.
1289 if (RT_FAILURE(rc))
1290 {
1291 // If failed write message to the release log.
1292 LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), rc));
1293 // If attempted logging level not the default one then try the default one.
1294 if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT))
1295 {
1296 rc = RTLogGroupSettings(RTLogRelDefaultInstance(), VBOXSVC_LOG_DEFAULT);
1297 // If failed report this to the release log.
1298 if (RT_FAILURE(rc))
1299 LogRel(("Cannot set default logging level Error=%Rrc \n", rc));
1300 }
1301 // On any failure - set default level as the one to be stored.
1302 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
1303 }
1304 // Set to passed value or if default used/attempted (even if error condition) use empty string.
1305 m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel);
1306 return RT_SUCCESS(rc) ? S_OK : E_FAIL;
1307}
1308
1309HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
1310{
1311 if (!aFormat.isEmpty())
1312 m->strDefaultHardDiskFormat = aFormat;
1313 else
1314 m->strDefaultHardDiskFormat = "VDI";
1315
1316 return S_OK;
1317}
1318
1319HRESULT SystemProperties::setVRDEAuthLibrary(const Utf8Str &aPath)
1320{
1321 if (!aPath.isEmpty())
1322 m->strVRDEAuthLibrary = aPath;
1323 else
1324 m->strVRDEAuthLibrary = "VBoxAuth";
1325
1326 return S_OK;
1327}
1328
1329HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
1330{
1331 if (!aPath.isEmpty())
1332 m->strWebServiceAuthLibrary = aPath;
1333 else
1334 m->strWebServiceAuthLibrary = "VBoxAuth";
1335
1336 return S_OK;
1337}
1338
1339HRESULT SystemProperties::setDefaultVRDEExtPack(const Utf8Str &aExtPack)
1340{
1341 m->strDefaultVRDEExtPack = aExtPack;
1342
1343 return S_OK;
1344}
1345
1346HRESULT SystemProperties::setAutostartDatabasePath(const Utf8Str &aPath)
1347{
1348 HRESULT rc = S_OK;
1349 AutostartDb *autostartDb = this->mParent->getAutostartDb();
1350
1351 if (!aPath.isEmpty())
1352 {
1353 /* Update path in the autostart database. */
1354 int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
1355 if (RT_SUCCESS(vrc))
1356 m->strAutostartDatabasePath = aPath;
1357 else
1358 rc = setError(E_FAIL,
1359 tr("Cannot set the autostart database path (%Rrc)"),
1360 vrc);
1361 }
1362 else
1363 {
1364 int vrc = autostartDb->setAutostartDbPath(NULL);
1365 if (RT_SUCCESS(vrc) || vrc == VERR_NOT_SUPPORTED)
1366 m->strAutostartDatabasePath = "";
1367 else
1368 rc = setError(E_FAIL,
1369 tr("Deleting the autostart database path failed (%Rrc)"),
1370 vrc);
1371 }
1372
1373 return rc;
1374}
1375
1376HRESULT SystemProperties::setDefaultAdditionsISO(const Utf8Str &aPath)
1377{
1378 Utf8Str path(aPath);
1379 if (path.isEmpty())
1380 {
1381 char strTemp[RTPATH_MAX];
1382 int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
1383 AssertRC(vrc);
1384 Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
1385
1386 vrc = RTPathExecDir(strTemp, sizeof(strTemp));
1387 AssertRC(vrc);
1388 Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
1389
1390 vrc = RTPathUserHome(strTemp, sizeof(strTemp));
1391 AssertRC(vrc);
1392 Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%ls.iso", strTemp, VirtualBox::getVersionNormalized().raw());
1393
1394 /* Check the standard image locations */
1395 if (RTFileExists(strSrc1.c_str()))
1396 path = strSrc1;
1397 else if (RTFileExists(strSrc2.c_str()))
1398 path = strSrc2;
1399 else if (RTFileExists(strSrc3.c_str()))
1400 path = strSrc3;
1401 else
1402 return setError(E_FAIL,
1403 tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
1404 }
1405
1406 if (!RTPathStartsWithRoot(path.c_str()))
1407 return setError(E_INVALIDARG,
1408 tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
1409 path.c_str());
1410
1411 if (!RTFileExists(path.c_str()))
1412 return setError(E_INVALIDARG,
1413 tr("Given default machine Guest Additions ISO file '%s' does not exist"),
1414 path.c_str());
1415
1416 m->strDefaultAdditionsISO = path;
1417
1418 return S_OK;
1419}
1420
1421HRESULT SystemProperties::setDefaultFrontend(const Utf8Str &aDefaultFrontend)
1422{
1423 m->strDefaultFrontend = aDefaultFrontend;
1424
1425 return S_OK;
1426}
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