1 | /* $Id: SystemPropertiesImpl.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #include "SystemPropertiesImpl.h"
|
---|
21 | #include "VirtualBoxImpl.h"
|
---|
22 | #include "MachineImpl.h"
|
---|
23 | #include "AutoCaller.h"
|
---|
24 | #include "Logging.h"
|
---|
25 |
|
---|
26 | // generated header
|
---|
27 | #include "SchemaDefs.h"
|
---|
28 |
|
---|
29 | #include <iprt/path.h>
|
---|
30 | #include <iprt/dir.h>
|
---|
31 | #include <iprt/process.h>
|
---|
32 | #include <iprt/ldr.h>
|
---|
33 |
|
---|
34 | #include <VBox/err.h>
|
---|
35 | #include <VBox/param.h>
|
---|
36 | #include <VBox/settings.h>
|
---|
37 | #include <VBox/VBoxHDD.h>
|
---|
38 |
|
---|
39 | // defines
|
---|
40 | /////////////////////////////////////////////////////////////////////////////
|
---|
41 |
|
---|
42 | // constructor / destructor
|
---|
43 | /////////////////////////////////////////////////////////////////////////////
|
---|
44 |
|
---|
45 | SystemProperties::SystemProperties()
|
---|
46 | : mParent(NULL)
|
---|
47 | {
|
---|
48 | }
|
---|
49 |
|
---|
50 | SystemProperties::~SystemProperties()
|
---|
51 | {
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | HRESULT SystemProperties::FinalConstruct()
|
---|
56 | {
|
---|
57 | return S_OK;
|
---|
58 | }
|
---|
59 |
|
---|
60 | void SystemProperties::FinalRelease()
|
---|
61 | {
|
---|
62 | uninit();
|
---|
63 | }
|
---|
64 |
|
---|
65 | // public methods only for internal purposes
|
---|
66 | /////////////////////////////////////////////////////////////////////////////
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Initializes the system information object.
|
---|
70 | *
|
---|
71 | * @returns COM result indicator
|
---|
72 | */
|
---|
73 | HRESULT SystemProperties::init(VirtualBox *aParent)
|
---|
74 | {
|
---|
75 | LogFlowThisFunc(("aParent=%p\n", aParent));
|
---|
76 |
|
---|
77 | ComAssertRet(aParent, E_FAIL);
|
---|
78 |
|
---|
79 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
80 | AutoInitSpan autoInitSpan(this);
|
---|
81 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
82 |
|
---|
83 | unconst(mParent) = aParent;
|
---|
84 |
|
---|
85 | setDefaultMachineFolder(Utf8Str::Null);
|
---|
86 | setDefaultHardDiskFolder(Utf8Str::Null);
|
---|
87 | setDefaultHardDiskFormat(Utf8Str::Null);
|
---|
88 |
|
---|
89 | setRemoteDisplayAuthLibrary(Utf8Str::Null);
|
---|
90 |
|
---|
91 | mLogHistoryCount = 3;
|
---|
92 |
|
---|
93 | HRESULT rc = S_OK;
|
---|
94 |
|
---|
95 | /* Fetch info of all available hd backends. */
|
---|
96 |
|
---|
97 | /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
|
---|
98 | /// any number of backends
|
---|
99 |
|
---|
100 | VDBACKENDINFO aVDInfo[100];
|
---|
101 | unsigned cEntries;
|
---|
102 | int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
|
---|
103 | AssertRC(vrc);
|
---|
104 | if (RT_SUCCESS(vrc))
|
---|
105 | {
|
---|
106 | for (unsigned i = 0; i < cEntries; ++ i)
|
---|
107 | {
|
---|
108 | ComObjPtr<MediumFormat> hdf;
|
---|
109 | rc = hdf.createObject();
|
---|
110 | if (FAILED(rc)) break;
|
---|
111 |
|
---|
112 | rc = hdf->init(&aVDInfo[i]);
|
---|
113 | if (FAILED(rc)) break;
|
---|
114 |
|
---|
115 | mMediumFormats.push_back(hdf);
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | /* Driver defaults which are OS specific */
|
---|
120 | #if defined(RT_OS_WINDOWS)
|
---|
121 | # ifdef VBOX_WITH_WINMM
|
---|
122 | mDefaultAudioDriver = AudioDriverType_WinMM;
|
---|
123 | # else /* VBOX_WITH_WINMM */
|
---|
124 | mDefaultAudioDriver = AudioDriverType_DirectSound;
|
---|
125 | # endif /* !VBOX_WITH_WINMM */
|
---|
126 | #elif defined(RT_OS_SOLARIS)
|
---|
127 | mDefaultAudioDriver = AudioDriverType_SolAudio;
|
---|
128 | #elif defined(RT_OS_LINUX)
|
---|
129 | # if defined(VBOX_WITH_PULSE)
|
---|
130 | /* Check for the pulse library & that the pulse audio daemon is running. */
|
---|
131 | if (RTProcIsRunningByName("pulseaudio") &&
|
---|
132 | RTLdrIsLoadable("libpulse.so.0"))
|
---|
133 | mDefaultAudioDriver = AudioDriverType_Pulse;
|
---|
134 | else
|
---|
135 | # endif /* VBOX_WITH_PULSE */
|
---|
136 | # if defined(VBOX_WITH_ALSA)
|
---|
137 | /* Check if we can load the ALSA library */
|
---|
138 | if (RTLdrIsLoadable("libasound.so.2"))
|
---|
139 | mDefaultAudioDriver = AudioDriverType_ALSA;
|
---|
140 | else
|
---|
141 | # endif /* VBOX_WITH_ALSA */
|
---|
142 | mDefaultAudioDriver = AudioDriverType_OSS;
|
---|
143 | #elif defined(RT_OS_DARWIN)
|
---|
144 | mDefaultAudioDriver = AudioDriverType_CoreAudio;
|
---|
145 | #elif defined(RT_OS_OS2)
|
---|
146 | mDefaultAudioDriver = AudioDriverType_MMP;
|
---|
147 | #elif defined(RT_OS_FREEBSD)
|
---|
148 | mDefaultAudioDriver = AudioDriverType_OSS;
|
---|
149 | #else
|
---|
150 | mDefaultAudioDriver = AudioDriverType_Null;
|
---|
151 | #endif
|
---|
152 |
|
---|
153 | /* Confirm a successful initialization */
|
---|
154 | if (SUCCEEDED(rc))
|
---|
155 | autoInitSpan.setSucceeded();
|
---|
156 |
|
---|
157 | return rc;
|
---|
158 | }
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
162 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
163 | */
|
---|
164 | void SystemProperties::uninit()
|
---|
165 | {
|
---|
166 | LogFlowThisFunc(("\n"));
|
---|
167 |
|
---|
168 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
169 | AutoUninitSpan autoUninitSpan(this);
|
---|
170 | if (autoUninitSpan.uninitDone())
|
---|
171 | return;
|
---|
172 |
|
---|
173 | unconst(mParent) = NULL;
|
---|
174 | }
|
---|
175 |
|
---|
176 | // ISystemProperties properties
|
---|
177 | /////////////////////////////////////////////////////////////////////////////
|
---|
178 |
|
---|
179 |
|
---|
180 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestRAM)(ULONG *minRAM)
|
---|
181 | {
|
---|
182 | CheckComArgOutPointerValid(minRAM);
|
---|
183 |
|
---|
184 | AutoCaller autoCaller(this);
|
---|
185 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
186 |
|
---|
187 | /* no need to lock, this is const */
|
---|
188 | AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
|
---|
189 | *minRAM = MM_RAM_MIN_IN_MB;
|
---|
190 |
|
---|
191 | return S_OK;
|
---|
192 | }
|
---|
193 |
|
---|
194 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestRAM)(ULONG *maxRAM)
|
---|
195 | {
|
---|
196 | CheckComArgOutPointerValid(maxRAM);
|
---|
197 |
|
---|
198 | AutoCaller autoCaller(this);
|
---|
199 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
200 |
|
---|
201 | /* no need to lock, this is const */
|
---|
202 | AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
|
---|
203 | ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
|
---|
204 | ULONG maxRAMArch = maxRAMSys;
|
---|
205 | #if HC_ARCH_BITS == 32 && !defined(RT_OS_DARWIN)
|
---|
206 | # ifdef RT_OS_WINDOWS
|
---|
207 | maxRAMArch = UINT32_C(1500);
|
---|
208 | # else
|
---|
209 | maxRAMArch = UINT32_C(2560);
|
---|
210 | # endif
|
---|
211 | #endif
|
---|
212 | *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
|
---|
213 |
|
---|
214 | return S_OK;
|
---|
215 | }
|
---|
216 |
|
---|
217 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestVRAM)(ULONG *minVRAM)
|
---|
218 | {
|
---|
219 | CheckComArgOutPointerValid(minVRAM);
|
---|
220 |
|
---|
221 | AutoCaller autoCaller(this);
|
---|
222 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
223 |
|
---|
224 | /* no need to lock, this is const */
|
---|
225 | *minVRAM = SchemaDefs::MinGuestVRAM;
|
---|
226 |
|
---|
227 | return S_OK;
|
---|
228 | }
|
---|
229 |
|
---|
230 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestVRAM)(ULONG *maxVRAM)
|
---|
231 | {
|
---|
232 | CheckComArgOutPointerValid(maxVRAM);
|
---|
233 |
|
---|
234 | AutoCaller autoCaller(this);
|
---|
235 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
236 |
|
---|
237 | /* no need to lock, this is const */
|
---|
238 | *maxVRAM = SchemaDefs::MaxGuestVRAM;
|
---|
239 |
|
---|
240 | return S_OK;
|
---|
241 | }
|
---|
242 |
|
---|
243 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestCPUCount)(ULONG *minCPUCount)
|
---|
244 | {
|
---|
245 | CheckComArgOutPointerValid(minCPUCount);
|
---|
246 |
|
---|
247 | AutoCaller autoCaller(this);
|
---|
248 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
249 |
|
---|
250 | /* no need to lock, this is const */
|
---|
251 | *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
|
---|
252 |
|
---|
253 | return S_OK;
|
---|
254 | }
|
---|
255 |
|
---|
256 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestCPUCount)(ULONG *maxCPUCount)
|
---|
257 | {
|
---|
258 | CheckComArgOutPointerValid(maxCPUCount);
|
---|
259 |
|
---|
260 | AutoCaller autoCaller(this);
|
---|
261 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
262 |
|
---|
263 | /* no need to lock, this is const */
|
---|
264 | *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
|
---|
265 |
|
---|
266 | return S_OK;
|
---|
267 | }
|
---|
268 |
|
---|
269 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestMonitors)(ULONG *maxMonitors)
|
---|
270 | {
|
---|
271 | CheckComArgOutPointerValid(maxMonitors);
|
---|
272 |
|
---|
273 | AutoCaller autoCaller(this);
|
---|
274 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
275 |
|
---|
276 | /* no need to lock, this is const */
|
---|
277 | *maxMonitors = SchemaDefs::MaxGuestMonitors;
|
---|
278 |
|
---|
279 | return S_OK;
|
---|
280 | }
|
---|
281 |
|
---|
282 | STDMETHODIMP SystemProperties::COMGETTER(MaxVDISize)(ULONG64 *maxVDISize)
|
---|
283 | {
|
---|
284 | CheckComArgOutPointerValid(maxVDISize);
|
---|
285 |
|
---|
286 | AutoCaller autoCaller(this);
|
---|
287 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
288 |
|
---|
289 | /** The BIOS supports currently 32 bit LBA numbers (implementing the full
|
---|
290 | * 48 bit range is in theory trivial, but the crappy compiler makes things
|
---|
291 | * more difficult). This translates to almost 2 TBytes (to be on the safe
|
---|
292 | * side, the reported limit is 1 MiByte less than that, as the total number
|
---|
293 | * of sectors should fit in 32 bits, too), which should bei enough for
|
---|
294 | * the moment. The virtual ATA disks support complete LBA48 (although for
|
---|
295 | * example iSCSI is also currently limited to 32 bit LBA), so the
|
---|
296 | * theoretical maximum disk size is 128 PiByte. The user interface cannot
|
---|
297 | * cope with this in a reasonable way yet. */
|
---|
298 | /* no need to lock, this is const */
|
---|
299 | *maxVDISize = 2048 * 1024 - 1;
|
---|
300 |
|
---|
301 | return S_OK;
|
---|
302 | }
|
---|
303 |
|
---|
304 | STDMETHODIMP SystemProperties::COMGETTER(NetworkAdapterCount)(ULONG *count)
|
---|
305 | {
|
---|
306 | CheckComArgOutPointerValid(count);
|
---|
307 |
|
---|
308 | AutoCaller autoCaller(this);
|
---|
309 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
310 |
|
---|
311 | /* no need to lock, this is const */
|
---|
312 | *count = SchemaDefs::NetworkAdapterCount;
|
---|
313 |
|
---|
314 | return S_OK;
|
---|
315 | }
|
---|
316 |
|
---|
317 | STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
|
---|
318 | {
|
---|
319 | CheckComArgOutPointerValid(count);
|
---|
320 |
|
---|
321 | AutoCaller autoCaller(this);
|
---|
322 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
323 |
|
---|
324 | /* no need to lock, this is const */
|
---|
325 | *count = SchemaDefs::SerialPortCount;
|
---|
326 |
|
---|
327 | return S_OK;
|
---|
328 | }
|
---|
329 |
|
---|
330 | STDMETHODIMP SystemProperties::COMGETTER(ParallelPortCount)(ULONG *count)
|
---|
331 | {
|
---|
332 | CheckComArgOutPointerValid(count);
|
---|
333 |
|
---|
334 | AutoCaller autoCaller(this);
|
---|
335 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
336 |
|
---|
337 | /* no need to lock, this is const */
|
---|
338 | *count = SchemaDefs::ParallelPortCount;
|
---|
339 |
|
---|
340 | return S_OK;
|
---|
341 | }
|
---|
342 |
|
---|
343 | STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
|
---|
344 | {
|
---|
345 | CheckComArgOutPointerValid(aMaxBootPosition);
|
---|
346 |
|
---|
347 | AutoCaller autoCaller(this);
|
---|
348 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
349 |
|
---|
350 | /* no need to lock, this is const */
|
---|
351 | *aMaxBootPosition = SchemaDefs::MaxBootPosition;
|
---|
352 |
|
---|
353 | return S_OK;
|
---|
354 | }
|
---|
355 |
|
---|
356 | STDMETHODIMP SystemProperties::GetMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
|
---|
357 | ULONG *aMaxDevicesPerPort)
|
---|
358 | {
|
---|
359 | CheckComArgOutPointerValid(aMaxDevicesPerPort);
|
---|
360 |
|
---|
361 | AutoCaller autoCaller(this);
|
---|
362 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
363 |
|
---|
364 | /* no need to lock, this is const */
|
---|
365 | switch (aBus)
|
---|
366 | {
|
---|
367 | case StorageBus_SATA:
|
---|
368 | case StorageBus_SCSI:
|
---|
369 | case StorageBus_SAS:
|
---|
370 | {
|
---|
371 | /* SATA and both SCSI controllers only support one device per port. */
|
---|
372 | *aMaxDevicesPerPort = 1;
|
---|
373 | break;
|
---|
374 | }
|
---|
375 | case StorageBus_IDE:
|
---|
376 | case StorageBus_Floppy:
|
---|
377 | {
|
---|
378 | /* The IDE and Floppy controllers support 2 devices. One as master
|
---|
379 | * and one as slave (or floppy drive 0 and 1). */
|
---|
380 | *aMaxDevicesPerPort = 2;
|
---|
381 | break;
|
---|
382 | }
|
---|
383 | default:
|
---|
384 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
385 | }
|
---|
386 |
|
---|
387 | return S_OK;
|
---|
388 | }
|
---|
389 |
|
---|
390 | STDMETHODIMP SystemProperties::GetMinPortCountForStorageBus(StorageBus_T aBus,
|
---|
391 | ULONG *aMinPortCount)
|
---|
392 | {
|
---|
393 | CheckComArgOutPointerValid(aMinPortCount);
|
---|
394 |
|
---|
395 | AutoCaller autoCaller(this);
|
---|
396 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
397 |
|
---|
398 | /* no need to lock, this is const */
|
---|
399 | switch (aBus)
|
---|
400 | {
|
---|
401 | case StorageBus_SATA:
|
---|
402 | {
|
---|
403 | *aMinPortCount = 1;
|
---|
404 | break;
|
---|
405 | }
|
---|
406 | case StorageBus_SCSI:
|
---|
407 | {
|
---|
408 | *aMinPortCount = 16;
|
---|
409 | break;
|
---|
410 | }
|
---|
411 | case StorageBus_IDE:
|
---|
412 | {
|
---|
413 | *aMinPortCount = 2;
|
---|
414 | break;
|
---|
415 | }
|
---|
416 | case StorageBus_Floppy:
|
---|
417 | {
|
---|
418 | *aMinPortCount = 1;
|
---|
419 | break;
|
---|
420 | }
|
---|
421 | case StorageBus_SAS:
|
---|
422 | {
|
---|
423 | *aMinPortCount = 8;
|
---|
424 | break;
|
---|
425 | }
|
---|
426 | default:
|
---|
427 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
428 | }
|
---|
429 |
|
---|
430 | return S_OK;
|
---|
431 | }
|
---|
432 |
|
---|
433 | STDMETHODIMP SystemProperties::GetMaxPortCountForStorageBus(StorageBus_T aBus,
|
---|
434 | ULONG *aMaxPortCount)
|
---|
435 | {
|
---|
436 | CheckComArgOutPointerValid(aMaxPortCount);
|
---|
437 |
|
---|
438 | AutoCaller autoCaller(this);
|
---|
439 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
440 |
|
---|
441 | /* no need to lock, this is const */
|
---|
442 | switch (aBus)
|
---|
443 | {
|
---|
444 | case StorageBus_SATA:
|
---|
445 | {
|
---|
446 | *aMaxPortCount = 30;
|
---|
447 | break;
|
---|
448 | }
|
---|
449 | case StorageBus_SCSI:
|
---|
450 | {
|
---|
451 | *aMaxPortCount = 16;
|
---|
452 | break;
|
---|
453 | }
|
---|
454 | case StorageBus_IDE:
|
---|
455 | {
|
---|
456 | *aMaxPortCount = 2;
|
---|
457 | break;
|
---|
458 | }
|
---|
459 | case StorageBus_Floppy:
|
---|
460 | {
|
---|
461 | *aMaxPortCount = 1;
|
---|
462 | break;
|
---|
463 | }
|
---|
464 | case StorageBus_SAS:
|
---|
465 | {
|
---|
466 | *aMaxPortCount = 8;
|
---|
467 | break;
|
---|
468 | }
|
---|
469 | default:
|
---|
470 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
471 | }
|
---|
472 |
|
---|
473 | return S_OK;
|
---|
474 | }
|
---|
475 |
|
---|
476 | STDMETHODIMP SystemProperties::GetMaxInstancesOfStorageBus(StorageBus_T aBus,
|
---|
477 | ULONG *aMaxInstances)
|
---|
478 | {
|
---|
479 | CheckComArgOutPointerValid(aMaxInstances);
|
---|
480 |
|
---|
481 | AutoCaller autoCaller(this);
|
---|
482 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
483 |
|
---|
484 | /* no need to lock, this is const */
|
---|
485 | switch (aBus)
|
---|
486 | {
|
---|
487 | case StorageBus_SATA:
|
---|
488 | case StorageBus_SCSI:
|
---|
489 | case StorageBus_IDE:
|
---|
490 | case StorageBus_SAS:
|
---|
491 | case StorageBus_Floppy:
|
---|
492 | {
|
---|
493 | /** @todo raise the limits ASAP, per bus type */
|
---|
494 | *aMaxInstances = 1;
|
---|
495 | break;
|
---|
496 | }
|
---|
497 | default:
|
---|
498 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
499 | }
|
---|
500 |
|
---|
501 | return S_OK;
|
---|
502 | }
|
---|
503 |
|
---|
504 | STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
|
---|
505 | ComSafeArrayOut(DeviceType_T, aDeviceTypes))
|
---|
506 | {
|
---|
507 | CheckComArgOutSafeArrayPointerValid(aDeviceTypes);
|
---|
508 |
|
---|
509 | AutoCaller autoCaller(this);
|
---|
510 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
511 |
|
---|
512 | /* no need to lock, this is const */
|
---|
513 | switch (aBus)
|
---|
514 | {
|
---|
515 | case StorageBus_IDE:
|
---|
516 | {
|
---|
517 | com::SafeArray<DeviceType_T> saDeviceTypes(2);
|
---|
518 | saDeviceTypes[0] = DeviceType_DVD;
|
---|
519 | saDeviceTypes[1] = DeviceType_HardDisk;
|
---|
520 | saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
|
---|
521 | break;
|
---|
522 | }
|
---|
523 | case StorageBus_SATA:
|
---|
524 | case StorageBus_SCSI:
|
---|
525 | case StorageBus_SAS:
|
---|
526 | {
|
---|
527 | com::SafeArray<DeviceType_T> saDeviceTypes(1);
|
---|
528 | saDeviceTypes[0] = DeviceType_HardDisk;
|
---|
529 | saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
|
---|
530 | break;
|
---|
531 | }
|
---|
532 | case StorageBus_Floppy:
|
---|
533 | {
|
---|
534 | com::SafeArray<DeviceType_T> saDeviceTypes(1);
|
---|
535 | saDeviceTypes[0] = DeviceType_Floppy;
|
---|
536 | saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
|
---|
537 | break;
|
---|
538 | }
|
---|
539 | default:
|
---|
540 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
541 | }
|
---|
542 |
|
---|
543 | return S_OK;
|
---|
544 | }
|
---|
545 |
|
---|
546 | STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder)(BSTR *aDefaultMachineFolder)
|
---|
547 | {
|
---|
548 | CheckComArgOutPointerValid(aDefaultMachineFolder);
|
---|
549 |
|
---|
550 | AutoCaller autoCaller(this);
|
---|
551 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
552 |
|
---|
553 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
554 |
|
---|
555 | m_strDefaultMachineFolderFull.cloneTo(aDefaultMachineFolder);
|
---|
556 |
|
---|
557 | return S_OK;
|
---|
558 | }
|
---|
559 |
|
---|
560 | STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder)(IN_BSTR aDefaultMachineFolder)
|
---|
561 | {
|
---|
562 | AutoCaller autoCaller(this);
|
---|
563 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
564 |
|
---|
565 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
566 | HRESULT rc = setDefaultMachineFolder(aDefaultMachineFolder);
|
---|
567 | alock.release();
|
---|
568 |
|
---|
569 | if (SUCCEEDED(rc))
|
---|
570 | {
|
---|
571 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
572 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
573 | rc = mParent->saveSettings();
|
---|
574 | }
|
---|
575 |
|
---|
576 | return rc;
|
---|
577 | }
|
---|
578 |
|
---|
579 | STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFolder)(BSTR *aDefaultHardDiskFolder)
|
---|
580 | {
|
---|
581 | CheckComArgOutPointerValid(aDefaultHardDiskFolder);
|
---|
582 |
|
---|
583 | AutoCaller autoCaller(this);
|
---|
584 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
585 |
|
---|
586 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
587 |
|
---|
588 | m_strDefaultHardDiskFolderFull.cloneTo(aDefaultHardDiskFolder);
|
---|
589 |
|
---|
590 | return S_OK;
|
---|
591 | }
|
---|
592 |
|
---|
593 | STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFolder)(IN_BSTR aDefaultHardDiskFolder)
|
---|
594 | {
|
---|
595 | AutoCaller autoCaller(this);
|
---|
596 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
597 |
|
---|
598 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
599 | HRESULT rc = setDefaultHardDiskFolder(aDefaultHardDiskFolder);
|
---|
600 | alock.release();
|
---|
601 |
|
---|
602 | if (SUCCEEDED(rc))
|
---|
603 | {
|
---|
604 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
605 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
606 | rc = mParent->saveSettings();
|
---|
607 | }
|
---|
608 |
|
---|
609 | return rc;
|
---|
610 | }
|
---|
611 |
|
---|
612 | STDMETHODIMP SystemProperties::COMGETTER(MediumFormats)(ComSafeArrayOut(IMediumFormat *, aMediumFormats))
|
---|
613 | {
|
---|
614 | CheckComArgOutSafeArrayPointerValid(aMediumFormats);
|
---|
615 |
|
---|
616 | AutoCaller autoCaller(this);
|
---|
617 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
618 |
|
---|
619 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
620 |
|
---|
621 | SafeIfaceArray<IMediumFormat> mediumFormats(mMediumFormats);
|
---|
622 | mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats));
|
---|
623 |
|
---|
624 | return S_OK;
|
---|
625 | }
|
---|
626 |
|
---|
627 | STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat)(BSTR *aDefaultHardDiskFormat)
|
---|
628 | {
|
---|
629 | CheckComArgOutPointerValid(aDefaultHardDiskFormat);
|
---|
630 |
|
---|
631 | AutoCaller autoCaller(this);
|
---|
632 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
633 |
|
---|
634 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
635 |
|
---|
636 | m_strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
|
---|
637 |
|
---|
638 | return S_OK;
|
---|
639 | }
|
---|
640 |
|
---|
641 | STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat)(IN_BSTR aDefaultHardDiskFormat)
|
---|
642 | {
|
---|
643 | AutoCaller autoCaller(this);
|
---|
644 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
645 |
|
---|
646 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
647 | HRESULT rc = setDefaultHardDiskFormat(aDefaultHardDiskFormat);
|
---|
648 | alock.release();
|
---|
649 |
|
---|
650 | if (SUCCEEDED(rc))
|
---|
651 | {
|
---|
652 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
653 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
654 | rc = mParent->saveSettings();
|
---|
655 | }
|
---|
656 |
|
---|
657 | return rc;
|
---|
658 | }
|
---|
659 |
|
---|
660 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceWarning)(ULONG64 *aFreeSpace)
|
---|
661 | {
|
---|
662 | CheckComArgOutPointerValid(aFreeSpace);
|
---|
663 |
|
---|
664 | ReturnComNotImplemented();
|
---|
665 | }
|
---|
666 |
|
---|
667 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceWarning)(ULONG64 /* aFreeSpace */)
|
---|
668 | {
|
---|
669 | ReturnComNotImplemented();
|
---|
670 | }
|
---|
671 |
|
---|
672 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentWarning)(ULONG *aFreeSpacePercent)
|
---|
673 | {
|
---|
674 | CheckComArgOutPointerValid(aFreeSpacePercent);
|
---|
675 |
|
---|
676 | ReturnComNotImplemented();
|
---|
677 | }
|
---|
678 |
|
---|
679 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentWarning)(ULONG /* aFreeSpacePercent */)
|
---|
680 | {
|
---|
681 | ReturnComNotImplemented();
|
---|
682 | }
|
---|
683 |
|
---|
684 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceError)(ULONG64 *aFreeSpace)
|
---|
685 | {
|
---|
686 | CheckComArgOutPointerValid(aFreeSpace);
|
---|
687 |
|
---|
688 | ReturnComNotImplemented();
|
---|
689 | }
|
---|
690 |
|
---|
691 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceError)(ULONG64 /* aFreeSpace */)
|
---|
692 | {
|
---|
693 | ReturnComNotImplemented();
|
---|
694 | }
|
---|
695 |
|
---|
696 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentError)(ULONG *aFreeSpacePercent)
|
---|
697 | {
|
---|
698 | CheckComArgOutPointerValid(aFreeSpacePercent);
|
---|
699 |
|
---|
700 | ReturnComNotImplemented();
|
---|
701 | }
|
---|
702 |
|
---|
703 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentError)(ULONG /* aFreeSpacePercent */)
|
---|
704 | {
|
---|
705 | ReturnComNotImplemented();
|
---|
706 | }
|
---|
707 |
|
---|
708 | STDMETHODIMP SystemProperties::COMGETTER(RemoteDisplayAuthLibrary)(BSTR *aRemoteDisplayAuthLibrary)
|
---|
709 | {
|
---|
710 | CheckComArgOutPointerValid(aRemoteDisplayAuthLibrary);
|
---|
711 |
|
---|
712 | AutoCaller autoCaller(this);
|
---|
713 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
714 |
|
---|
715 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
716 |
|
---|
717 | m_strRemoteDisplayAuthLibrary.cloneTo(aRemoteDisplayAuthLibrary);
|
---|
718 |
|
---|
719 | return S_OK;
|
---|
720 | }
|
---|
721 |
|
---|
722 | STDMETHODIMP SystemProperties::COMSETTER(RemoteDisplayAuthLibrary)(IN_BSTR aRemoteDisplayAuthLibrary)
|
---|
723 | {
|
---|
724 | AutoCaller autoCaller(this);
|
---|
725 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
726 |
|
---|
727 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
728 | HRESULT rc = setRemoteDisplayAuthLibrary(aRemoteDisplayAuthLibrary);
|
---|
729 | alock.release();
|
---|
730 |
|
---|
731 | if (SUCCEEDED(rc))
|
---|
732 | {
|
---|
733 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
734 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
735 | rc = mParent->saveSettings();
|
---|
736 | }
|
---|
737 |
|
---|
738 | return rc;
|
---|
739 | }
|
---|
740 |
|
---|
741 | STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary)(BSTR *aWebServiceAuthLibrary)
|
---|
742 | {
|
---|
743 | CheckComArgOutPointerValid(aWebServiceAuthLibrary);
|
---|
744 |
|
---|
745 | AutoCaller autoCaller(this);
|
---|
746 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
747 |
|
---|
748 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
749 |
|
---|
750 | m_strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
|
---|
751 |
|
---|
752 | return S_OK;
|
---|
753 | }
|
---|
754 |
|
---|
755 | STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary)(IN_BSTR aWebServiceAuthLibrary)
|
---|
756 | {
|
---|
757 | AutoCaller autoCaller(this);
|
---|
758 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
759 |
|
---|
760 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
761 | HRESULT rc = setWebServiceAuthLibrary(aWebServiceAuthLibrary);
|
---|
762 | alock.release();
|
---|
763 |
|
---|
764 | if (SUCCEEDED(rc))
|
---|
765 | {
|
---|
766 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
767 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
768 | rc = mParent->saveSettings();
|
---|
769 | }
|
---|
770 |
|
---|
771 | return rc;
|
---|
772 | }
|
---|
773 |
|
---|
774 | STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount)(ULONG *count)
|
---|
775 | {
|
---|
776 | CheckComArgOutPointerValid(count);
|
---|
777 |
|
---|
778 | AutoCaller autoCaller(this);
|
---|
779 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
780 |
|
---|
781 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
782 |
|
---|
783 | *count = mLogHistoryCount;
|
---|
784 |
|
---|
785 | return S_OK;
|
---|
786 | }
|
---|
787 |
|
---|
788 | STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount)(ULONG count)
|
---|
789 | {
|
---|
790 | AutoCaller autoCaller(this);
|
---|
791 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
792 |
|
---|
793 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
794 | mLogHistoryCount = count;
|
---|
795 | alock.release();
|
---|
796 |
|
---|
797 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
798 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
799 | HRESULT rc = mParent->saveSettings();
|
---|
800 |
|
---|
801 | return rc;
|
---|
802 | }
|
---|
803 |
|
---|
804 | STDMETHODIMP SystemProperties::COMGETTER(DefaultAudioDriver)(AudioDriverType_T *aAudioDriver)
|
---|
805 | {
|
---|
806 | CheckComArgOutPointerValid(aAudioDriver);
|
---|
807 |
|
---|
808 | AutoCaller autoCaller(this);
|
---|
809 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
810 |
|
---|
811 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
812 |
|
---|
813 | *aAudioDriver = mDefaultAudioDriver;
|
---|
814 |
|
---|
815 | return S_OK;
|
---|
816 | }
|
---|
817 |
|
---|
818 | // public methods only for internal purposes
|
---|
819 | /////////////////////////////////////////////////////////////////////////////
|
---|
820 |
|
---|
821 | HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
|
---|
822 | {
|
---|
823 | AutoCaller autoCaller(this);
|
---|
824 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
825 |
|
---|
826 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
827 |
|
---|
828 | HRESULT rc = S_OK;
|
---|
829 |
|
---|
830 | rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
|
---|
831 | if (FAILED(rc)) return rc;
|
---|
832 |
|
---|
833 | rc = setDefaultHardDiskFolder(data.strDefaultHardDiskFolder);
|
---|
834 | if (FAILED(rc)) return rc;
|
---|
835 |
|
---|
836 | rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
|
---|
837 | if (FAILED(rc)) return rc;
|
---|
838 |
|
---|
839 | rc = setRemoteDisplayAuthLibrary(data.strRemoteDisplayAuthLibrary);
|
---|
840 | if (FAILED(rc)) return rc;
|
---|
841 |
|
---|
842 | rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
|
---|
843 | if (FAILED(rc)) return rc;
|
---|
844 |
|
---|
845 | mLogHistoryCount = data.ulLogHistoryCount;
|
---|
846 |
|
---|
847 | return S_OK;
|
---|
848 | }
|
---|
849 |
|
---|
850 | HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
|
---|
851 | {
|
---|
852 | AutoCaller autoCaller(this);
|
---|
853 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
854 |
|
---|
855 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
856 |
|
---|
857 | data.strDefaultMachineFolder = m_strDefaultMachineFolder;
|
---|
858 | data.strDefaultHardDiskFolder = m_strDefaultHardDiskFolder;
|
---|
859 | data.strDefaultHardDiskFormat = m_strDefaultHardDiskFormat;
|
---|
860 | data.strRemoteDisplayAuthLibrary = m_strRemoteDisplayAuthLibrary;
|
---|
861 | data.strWebServiceAuthLibrary = m_strWebServiceAuthLibrary;
|
---|
862 | data.ulLogHistoryCount = mLogHistoryCount;
|
---|
863 |
|
---|
864 | return S_OK;
|
---|
865 | }
|
---|
866 |
|
---|
867 | /**
|
---|
868 | * Returns a medium format object corresponding to the given format
|
---|
869 | * identifier or null if no such format.
|
---|
870 | *
|
---|
871 | * @param aFormat Format identifier.
|
---|
872 | *
|
---|
873 | * @return ComObjPtr<MediumFormat>
|
---|
874 | */
|
---|
875 | ComObjPtr<MediumFormat> SystemProperties::mediumFormat (CBSTR aFormat)
|
---|
876 | {
|
---|
877 | ComObjPtr<MediumFormat> format;
|
---|
878 |
|
---|
879 | AutoCaller autoCaller(this);
|
---|
880 | AssertComRCReturn (autoCaller.rc(), format);
|
---|
881 |
|
---|
882 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
883 |
|
---|
884 | for (MediumFormatList::const_iterator it = mMediumFormats.begin();
|
---|
885 | it != mMediumFormats.end(); ++ it)
|
---|
886 | {
|
---|
887 | /* MediumFormat is all const, no need to lock */
|
---|
888 |
|
---|
889 | if ((*it)->id().compare(aFormat, Bstr::CaseInsensitive) == 0)
|
---|
890 | {
|
---|
891 | format = *it;
|
---|
892 | break;
|
---|
893 | }
|
---|
894 | }
|
---|
895 |
|
---|
896 | return format;
|
---|
897 | }
|
---|
898 |
|
---|
899 | // private methods
|
---|
900 | /////////////////////////////////////////////////////////////////////////////
|
---|
901 |
|
---|
902 | HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &aPath)
|
---|
903 | {
|
---|
904 | Utf8Str path(aPath);
|
---|
905 | if (path.isEmpty())
|
---|
906 | path = "Machines";
|
---|
907 |
|
---|
908 | /* get the full file name */
|
---|
909 | Utf8Str folder;
|
---|
910 | int vrc = mParent->calculateFullPath(path, folder);
|
---|
911 | if (RT_FAILURE(vrc))
|
---|
912 | return setError(E_FAIL,
|
---|
913 | tr("Invalid default machine folder '%s' (%Rrc)"),
|
---|
914 | path.raw(),
|
---|
915 | vrc);
|
---|
916 |
|
---|
917 | m_strDefaultMachineFolder = path;
|
---|
918 | m_strDefaultMachineFolderFull = folder;
|
---|
919 |
|
---|
920 | return S_OK;
|
---|
921 | }
|
---|
922 |
|
---|
923 | HRESULT SystemProperties::setDefaultHardDiskFolder(const Utf8Str &aPath)
|
---|
924 | {
|
---|
925 | Utf8Str path(aPath);
|
---|
926 | if (path.isEmpty())
|
---|
927 | path = "HardDisks";
|
---|
928 |
|
---|
929 | /* get the full file name */
|
---|
930 | Utf8Str folder;
|
---|
931 | int vrc = mParent->calculateFullPath(path, folder);
|
---|
932 | if (RT_FAILURE(vrc))
|
---|
933 | return setError(E_FAIL,
|
---|
934 | tr("Invalid default hard disk folder '%s' (%Rrc)"),
|
---|
935 | path.raw(),
|
---|
936 | vrc);
|
---|
937 |
|
---|
938 | m_strDefaultHardDiskFolder = path;
|
---|
939 | m_strDefaultHardDiskFolderFull = folder;
|
---|
940 |
|
---|
941 | return S_OK;
|
---|
942 | }
|
---|
943 |
|
---|
944 | HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
|
---|
945 | {
|
---|
946 | if (!aFormat.isEmpty())
|
---|
947 | m_strDefaultHardDiskFormat = aFormat;
|
---|
948 | else
|
---|
949 | m_strDefaultHardDiskFormat = "VDI";
|
---|
950 |
|
---|
951 | return S_OK;
|
---|
952 | }
|
---|
953 |
|
---|
954 | HRESULT SystemProperties::setRemoteDisplayAuthLibrary(const Utf8Str &aPath)
|
---|
955 | {
|
---|
956 | if (!aPath.isEmpty())
|
---|
957 | m_strRemoteDisplayAuthLibrary = aPath;
|
---|
958 | else
|
---|
959 | m_strRemoteDisplayAuthLibrary = "VRDPAuth";
|
---|
960 |
|
---|
961 | return S_OK;
|
---|
962 | }
|
---|
963 |
|
---|
964 | HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
|
---|
965 | {
|
---|
966 | if (!aPath.isEmpty())
|
---|
967 | m_strWebServiceAuthLibrary = aPath;
|
---|
968 | else
|
---|
969 | m_strWebServiceAuthLibrary = "VRDPAuth";
|
---|
970 |
|
---|
971 | return S_OK;
|
---|
972 | }
|
---|
973 |
|
---|