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