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