1 | /* $Id: SystemPropertiesImpl.cpp 35368 2010-12-30 13:38:23Z 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 | #ifdef VBOX_WITH_EXTPACK
|
---|
24 | # include "ExtPackManagerImpl.h"
|
---|
25 | #endif
|
---|
26 | #include "AutoCaller.h"
|
---|
27 | #include "Global.h"
|
---|
28 | #include "Logging.h"
|
---|
29 |
|
---|
30 | // generated header
|
---|
31 | #include "SchemaDefs.h"
|
---|
32 |
|
---|
33 | #include <iprt/dir.h>
|
---|
34 | #include <iprt/ldr.h>
|
---|
35 | #include <iprt/path.h>
|
---|
36 | #include <iprt/string.h>
|
---|
37 | #include <iprt/cpp/utils.h>
|
---|
38 |
|
---|
39 | #include <VBox/err.h>
|
---|
40 | #include <VBox/param.h>
|
---|
41 | #include <VBox/settings.h>
|
---|
42 | #include <VBox/vd.h>
|
---|
43 |
|
---|
44 | // defines
|
---|
45 | /////////////////////////////////////////////////////////////////////////////
|
---|
46 |
|
---|
47 | // constructor / destructor
|
---|
48 | /////////////////////////////////////////////////////////////////////////////
|
---|
49 |
|
---|
50 | SystemProperties::SystemProperties()
|
---|
51 | : mParent(NULL),
|
---|
52 | m(new settings::SystemProperties)
|
---|
53 | {
|
---|
54 | }
|
---|
55 |
|
---|
56 | SystemProperties::~SystemProperties()
|
---|
57 | {
|
---|
58 | delete m;
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | HRESULT SystemProperties::FinalConstruct()
|
---|
63 | {
|
---|
64 | return S_OK;
|
---|
65 | }
|
---|
66 |
|
---|
67 | void SystemProperties::FinalRelease()
|
---|
68 | {
|
---|
69 | uninit();
|
---|
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 | setDefaultHardDiskFormat(Utf8Str::Empty);
|
---|
94 |
|
---|
95 | setVRDEAuthLibrary(Utf8Str::Empty);
|
---|
96 | setDefaultVRDEExtPack(Utf8Str::Empty);
|
---|
97 |
|
---|
98 | m->ulLogHistoryCount = 3;
|
---|
99 |
|
---|
100 | HRESULT rc = S_OK;
|
---|
101 |
|
---|
102 | /* Fetch info of all available hd backends. */
|
---|
103 |
|
---|
104 | /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
|
---|
105 | /// any number of backends
|
---|
106 |
|
---|
107 | VDBACKENDINFO aVDInfo[100];
|
---|
108 | unsigned cEntries;
|
---|
109 | int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
|
---|
110 | AssertRC(vrc);
|
---|
111 | if (RT_SUCCESS(vrc))
|
---|
112 | {
|
---|
113 | for (unsigned i = 0; i < cEntries; ++ i)
|
---|
114 | {
|
---|
115 | ComObjPtr<MediumFormat> hdf;
|
---|
116 | rc = hdf.createObject();
|
---|
117 | if (FAILED(rc)) break;
|
---|
118 |
|
---|
119 | rc = hdf->init(&aVDInfo[i]);
|
---|
120 | if (FAILED(rc)) break;
|
---|
121 |
|
---|
122 | m_llMediumFormats.push_back(hdf);
|
---|
123 | }
|
---|
124 | }
|
---|
125 |
|
---|
126 | /* Confirm a successful initialization */
|
---|
127 | if (SUCCEEDED(rc))
|
---|
128 | autoInitSpan.setSucceeded();
|
---|
129 |
|
---|
130 | return rc;
|
---|
131 | }
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
135 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
136 | */
|
---|
137 | void SystemProperties::uninit()
|
---|
138 | {
|
---|
139 | LogFlowThisFunc(("\n"));
|
---|
140 |
|
---|
141 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
142 | AutoUninitSpan autoUninitSpan(this);
|
---|
143 | if (autoUninitSpan.uninitDone())
|
---|
144 | return;
|
---|
145 |
|
---|
146 | unconst(mParent) = NULL;
|
---|
147 | }
|
---|
148 |
|
---|
149 | // ISystemProperties properties
|
---|
150 | /////////////////////////////////////////////////////////////////////////////
|
---|
151 |
|
---|
152 |
|
---|
153 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestRAM)(ULONG *minRAM)
|
---|
154 | {
|
---|
155 | CheckComArgOutPointerValid(minRAM);
|
---|
156 |
|
---|
157 | AutoCaller autoCaller(this);
|
---|
158 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
159 |
|
---|
160 | /* no need to lock, this is const */
|
---|
161 | AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
|
---|
162 | *minRAM = MM_RAM_MIN_IN_MB;
|
---|
163 |
|
---|
164 | return S_OK;
|
---|
165 | }
|
---|
166 |
|
---|
167 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestRAM)(ULONG *maxRAM)
|
---|
168 | {
|
---|
169 | CheckComArgOutPointerValid(maxRAM);
|
---|
170 |
|
---|
171 | AutoCaller autoCaller(this);
|
---|
172 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
173 |
|
---|
174 | /* no need to lock, this is const */
|
---|
175 | AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
|
---|
176 | ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
|
---|
177 | ULONG maxRAMArch = maxRAMSys;
|
---|
178 | *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
|
---|
179 |
|
---|
180 | return S_OK;
|
---|
181 | }
|
---|
182 |
|
---|
183 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestVRAM)(ULONG *minVRAM)
|
---|
184 | {
|
---|
185 | CheckComArgOutPointerValid(minVRAM);
|
---|
186 |
|
---|
187 | AutoCaller autoCaller(this);
|
---|
188 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
189 |
|
---|
190 | /* no need to lock, this is const */
|
---|
191 | *minVRAM = SchemaDefs::MinGuestVRAM;
|
---|
192 |
|
---|
193 | return S_OK;
|
---|
194 | }
|
---|
195 |
|
---|
196 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestVRAM)(ULONG *maxVRAM)
|
---|
197 | {
|
---|
198 | CheckComArgOutPointerValid(maxVRAM);
|
---|
199 |
|
---|
200 | AutoCaller autoCaller(this);
|
---|
201 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
202 |
|
---|
203 | /* no need to lock, this is const */
|
---|
204 | *maxVRAM = SchemaDefs::MaxGuestVRAM;
|
---|
205 |
|
---|
206 | return S_OK;
|
---|
207 | }
|
---|
208 |
|
---|
209 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestCPUCount)(ULONG *minCPUCount)
|
---|
210 | {
|
---|
211 | CheckComArgOutPointerValid(minCPUCount);
|
---|
212 |
|
---|
213 | AutoCaller autoCaller(this);
|
---|
214 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
215 |
|
---|
216 | /* no need to lock, this is const */
|
---|
217 | *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
|
---|
218 |
|
---|
219 | return S_OK;
|
---|
220 | }
|
---|
221 |
|
---|
222 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestCPUCount)(ULONG *maxCPUCount)
|
---|
223 | {
|
---|
224 | CheckComArgOutPointerValid(maxCPUCount);
|
---|
225 |
|
---|
226 | AutoCaller autoCaller(this);
|
---|
227 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
228 |
|
---|
229 | /* no need to lock, this is const */
|
---|
230 | *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
|
---|
231 |
|
---|
232 | return S_OK;
|
---|
233 | }
|
---|
234 |
|
---|
235 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestMonitors)(ULONG *maxMonitors)
|
---|
236 | {
|
---|
237 | CheckComArgOutPointerValid(maxMonitors);
|
---|
238 |
|
---|
239 | AutoCaller autoCaller(this);
|
---|
240 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
241 |
|
---|
242 | /* no need to lock, this is const */
|
---|
243 | *maxMonitors = SchemaDefs::MaxGuestMonitors;
|
---|
244 |
|
---|
245 | return S_OK;
|
---|
246 | }
|
---|
247 |
|
---|
248 | STDMETHODIMP SystemProperties::COMGETTER(InfoVDSize)(LONG64 *infoVDSize)
|
---|
249 | {
|
---|
250 | CheckComArgOutPointerValid(infoVDSize);
|
---|
251 |
|
---|
252 | AutoCaller autoCaller(this);
|
---|
253 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
254 |
|
---|
255 | /*
|
---|
256 | * The BIOS supports currently 32 bit LBA numbers (implementing the full
|
---|
257 | * 48 bit range is in theory trivial, but the crappy compiler makes things
|
---|
258 | * more difficult). This translates to almost 2 TiBytes (to be on the safe
|
---|
259 | * side, the reported limit is 1 MiByte less than that, as the total number
|
---|
260 | * of sectors should fit in 32 bits, too), which should be enough for the
|
---|
261 | * moment. Since the MBR partition tables support only 32bit sector numbers
|
---|
262 | * and thus the BIOS can only boot from disks smaller than 2T this is a
|
---|
263 | * rather hard limit.
|
---|
264 | *
|
---|
265 | * The virtual ATA/SATA disks support complete LBA48, and SCSI supports
|
---|
266 | * LBA64 (almost, more like LBA55 in practice), so the theoretical maximum
|
---|
267 | * disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6 orders
|
---|
268 | * of magnitude, but not with 11..13 orders of magnitude.
|
---|
269 | */
|
---|
270 | /* no need to lock, this is const */
|
---|
271 | *infoVDSize = 2 * _1T - _1M;
|
---|
272 |
|
---|
273 | return S_OK;
|
---|
274 | }
|
---|
275 |
|
---|
276 | STDMETHODIMP SystemProperties::COMGETTER(NetworkAdapterCount)(ULONG *count)
|
---|
277 | {
|
---|
278 | CheckComArgOutPointerValid(count);
|
---|
279 |
|
---|
280 | AutoCaller autoCaller(this);
|
---|
281 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
282 |
|
---|
283 | /* no need to lock, this is const */
|
---|
284 | *count = SchemaDefs::NetworkAdapterCount;
|
---|
285 |
|
---|
286 | return S_OK;
|
---|
287 | }
|
---|
288 |
|
---|
289 | STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
|
---|
290 | {
|
---|
291 | CheckComArgOutPointerValid(count);
|
---|
292 |
|
---|
293 | AutoCaller autoCaller(this);
|
---|
294 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
295 |
|
---|
296 | /* no need to lock, this is const */
|
---|
297 | *count = SchemaDefs::SerialPortCount;
|
---|
298 |
|
---|
299 | return S_OK;
|
---|
300 | }
|
---|
301 |
|
---|
302 | STDMETHODIMP SystemProperties::COMGETTER(ParallelPortCount)(ULONG *count)
|
---|
303 | {
|
---|
304 | CheckComArgOutPointerValid(count);
|
---|
305 |
|
---|
306 | AutoCaller autoCaller(this);
|
---|
307 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
308 |
|
---|
309 | /* no need to lock, this is const */
|
---|
310 | *count = SchemaDefs::ParallelPortCount;
|
---|
311 |
|
---|
312 | return S_OK;
|
---|
313 | }
|
---|
314 |
|
---|
315 | STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
|
---|
316 | {
|
---|
317 | CheckComArgOutPointerValid(aMaxBootPosition);
|
---|
318 |
|
---|
319 | AutoCaller autoCaller(this);
|
---|
320 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
321 |
|
---|
322 | /* no need to lock, this is const */
|
---|
323 | *aMaxBootPosition = SchemaDefs::MaxBootPosition;
|
---|
324 |
|
---|
325 | return S_OK;
|
---|
326 | }
|
---|
327 |
|
---|
328 | STDMETHODIMP SystemProperties::GetMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
|
---|
329 | ULONG *aMaxDevicesPerPort)
|
---|
330 | {
|
---|
331 | CheckComArgOutPointerValid(aMaxDevicesPerPort);
|
---|
332 |
|
---|
333 | AutoCaller autoCaller(this);
|
---|
334 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
335 |
|
---|
336 | /* no need to lock, this is const */
|
---|
337 | switch (aBus)
|
---|
338 | {
|
---|
339 | case StorageBus_SATA:
|
---|
340 | case StorageBus_SCSI:
|
---|
341 | case StorageBus_SAS:
|
---|
342 | {
|
---|
343 | /* SATA and both SCSI controllers only support one device per port. */
|
---|
344 | *aMaxDevicesPerPort = 1;
|
---|
345 | break;
|
---|
346 | }
|
---|
347 | case StorageBus_IDE:
|
---|
348 | case StorageBus_Floppy:
|
---|
349 | {
|
---|
350 | /* The IDE and Floppy controllers support 2 devices. One as master
|
---|
351 | * and one as slave (or floppy drive 0 and 1). */
|
---|
352 | *aMaxDevicesPerPort = 2;
|
---|
353 | break;
|
---|
354 | }
|
---|
355 | default:
|
---|
356 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
357 | }
|
---|
358 |
|
---|
359 | return S_OK;
|
---|
360 | }
|
---|
361 |
|
---|
362 | STDMETHODIMP SystemProperties::GetMinPortCountForStorageBus(StorageBus_T aBus,
|
---|
363 | ULONG *aMinPortCount)
|
---|
364 | {
|
---|
365 | CheckComArgOutPointerValid(aMinPortCount);
|
---|
366 |
|
---|
367 | AutoCaller autoCaller(this);
|
---|
368 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
369 |
|
---|
370 | /* no need to lock, this is const */
|
---|
371 | switch (aBus)
|
---|
372 | {
|
---|
373 | case StorageBus_SATA:
|
---|
374 | {
|
---|
375 | *aMinPortCount = 1;
|
---|
376 | break;
|
---|
377 | }
|
---|
378 | case StorageBus_SCSI:
|
---|
379 | {
|
---|
380 | *aMinPortCount = 16;
|
---|
381 | break;
|
---|
382 | }
|
---|
383 | case StorageBus_IDE:
|
---|
384 | {
|
---|
385 | *aMinPortCount = 2;
|
---|
386 | break;
|
---|
387 | }
|
---|
388 | case StorageBus_Floppy:
|
---|
389 | {
|
---|
390 | *aMinPortCount = 1;
|
---|
391 | break;
|
---|
392 | }
|
---|
393 | case StorageBus_SAS:
|
---|
394 | {
|
---|
395 | *aMinPortCount = 8;
|
---|
396 | break;
|
---|
397 | }
|
---|
398 | default:
|
---|
399 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
400 | }
|
---|
401 |
|
---|
402 | return S_OK;
|
---|
403 | }
|
---|
404 |
|
---|
405 | STDMETHODIMP SystemProperties::GetMaxPortCountForStorageBus(StorageBus_T aBus,
|
---|
406 | ULONG *aMaxPortCount)
|
---|
407 | {
|
---|
408 | CheckComArgOutPointerValid(aMaxPortCount);
|
---|
409 |
|
---|
410 | AutoCaller autoCaller(this);
|
---|
411 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
412 |
|
---|
413 | /* no need to lock, this is const */
|
---|
414 | switch (aBus)
|
---|
415 | {
|
---|
416 | case StorageBus_SATA:
|
---|
417 | {
|
---|
418 | *aMaxPortCount = 30;
|
---|
419 | break;
|
---|
420 | }
|
---|
421 | case StorageBus_SCSI:
|
---|
422 | {
|
---|
423 | *aMaxPortCount = 16;
|
---|
424 | break;
|
---|
425 | }
|
---|
426 | case StorageBus_IDE:
|
---|
427 | {
|
---|
428 | *aMaxPortCount = 2;
|
---|
429 | break;
|
---|
430 | }
|
---|
431 | case StorageBus_Floppy:
|
---|
432 | {
|
---|
433 | *aMaxPortCount = 1;
|
---|
434 | break;
|
---|
435 | }
|
---|
436 | case StorageBus_SAS:
|
---|
437 | {
|
---|
438 | *aMaxPortCount = 8;
|
---|
439 | break;
|
---|
440 | }
|
---|
441 | default:
|
---|
442 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
443 | }
|
---|
444 |
|
---|
445 | return S_OK;
|
---|
446 | }
|
---|
447 |
|
---|
448 | STDMETHODIMP SystemProperties::GetMaxInstancesOfStorageBus(ChipsetType_T aChipset,
|
---|
449 | StorageBus_T aBus,
|
---|
450 | ULONG *aMaxInstances)
|
---|
451 | {
|
---|
452 | CheckComArgOutPointerValid(aMaxInstances);
|
---|
453 |
|
---|
454 | AutoCaller autoCaller(this);
|
---|
455 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
456 |
|
---|
457 | ULONG cCtrs = 0;
|
---|
458 |
|
---|
459 | /* no need to lock, this is const */
|
---|
460 | switch (aBus)
|
---|
461 | {
|
---|
462 | case StorageBus_SATA:
|
---|
463 | case StorageBus_SCSI:
|
---|
464 | case StorageBus_SAS:
|
---|
465 | cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
|
---|
466 | break;
|
---|
467 | case StorageBus_IDE:
|
---|
468 | case StorageBus_Floppy:
|
---|
469 | {
|
---|
470 | cCtrs = 1;
|
---|
471 | break;
|
---|
472 | }
|
---|
473 | default:
|
---|
474 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
475 | }
|
---|
476 |
|
---|
477 | *aMaxInstances = cCtrs;
|
---|
478 |
|
---|
479 | return S_OK;
|
---|
480 | }
|
---|
481 |
|
---|
482 | STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
|
---|
483 | ComSafeArrayOut(DeviceType_T, aDeviceTypes))
|
---|
484 | {
|
---|
485 | CheckComArgOutSafeArrayPointerValid(aDeviceTypes);
|
---|
486 |
|
---|
487 | AutoCaller autoCaller(this);
|
---|
488 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
489 |
|
---|
490 | /* no need to lock, this is const */
|
---|
491 | switch (aBus)
|
---|
492 | {
|
---|
493 | case StorageBus_IDE:
|
---|
494 | case StorageBus_SATA:
|
---|
495 | {
|
---|
496 | com::SafeArray<DeviceType_T> saDeviceTypes(2);
|
---|
497 | saDeviceTypes[0] = DeviceType_DVD;
|
---|
498 | saDeviceTypes[1] = DeviceType_HardDisk;
|
---|
499 | saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
|
---|
500 | break;
|
---|
501 | }
|
---|
502 | case StorageBus_SCSI:
|
---|
503 | case StorageBus_SAS:
|
---|
504 | {
|
---|
505 | com::SafeArray<DeviceType_T> saDeviceTypes(1);
|
---|
506 | saDeviceTypes[0] = DeviceType_HardDisk;
|
---|
507 | saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
|
---|
508 | break;
|
---|
509 | }
|
---|
510 | case StorageBus_Floppy:
|
---|
511 | {
|
---|
512 | com::SafeArray<DeviceType_T> saDeviceTypes(1);
|
---|
513 | saDeviceTypes[0] = DeviceType_Floppy;
|
---|
514 | saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
|
---|
515 | break;
|
---|
516 | }
|
---|
517 | default:
|
---|
518 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
519 | }
|
---|
520 |
|
---|
521 | return S_OK;
|
---|
522 | }
|
---|
523 |
|
---|
524 | STDMETHODIMP SystemProperties::GetDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType, BOOL *aEnabled)
|
---|
525 | {
|
---|
526 | CheckComArgOutPointerValid(aEnabled);
|
---|
527 |
|
---|
528 | AutoCaller autoCaller(this);
|
---|
529 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
530 |
|
---|
531 | /* no need to lock, this is const */
|
---|
532 | switch (aControllerType)
|
---|
533 | {
|
---|
534 | case StorageControllerType_LsiLogic:
|
---|
535 | case StorageControllerType_BusLogic:
|
---|
536 | case StorageControllerType_IntelAhci:
|
---|
537 | case StorageControllerType_LsiLogicSas:
|
---|
538 | *aEnabled = false;
|
---|
539 | break;
|
---|
540 | case StorageControllerType_PIIX3:
|
---|
541 | case StorageControllerType_PIIX4:
|
---|
542 | case StorageControllerType_ICH6:
|
---|
543 | case StorageControllerType_I82078:
|
---|
544 | *aEnabled = true;
|
---|
545 | break;
|
---|
546 | default:
|
---|
547 | AssertMsgFailed(("Invalid controller type %d\n", aControllerType));
|
---|
548 | }
|
---|
549 | return S_OK;
|
---|
550 | }
|
---|
551 |
|
---|
552 | STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder)(BSTR *aDefaultMachineFolder)
|
---|
553 | {
|
---|
554 | CheckComArgOutPointerValid(aDefaultMachineFolder);
|
---|
555 |
|
---|
556 | AutoCaller autoCaller(this);
|
---|
557 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
558 |
|
---|
559 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
560 |
|
---|
561 | m->strDefaultMachineFolder.cloneTo(aDefaultMachineFolder);
|
---|
562 |
|
---|
563 | return S_OK;
|
---|
564 | }
|
---|
565 |
|
---|
566 | STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder)(IN_BSTR aDefaultMachineFolder)
|
---|
567 | {
|
---|
568 | AutoCaller autoCaller(this);
|
---|
569 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
570 |
|
---|
571 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
572 | HRESULT rc = setDefaultMachineFolder(aDefaultMachineFolder);
|
---|
573 | alock.release();
|
---|
574 |
|
---|
575 | if (SUCCEEDED(rc))
|
---|
576 | {
|
---|
577 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
578 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
579 | rc = mParent->saveSettings();
|
---|
580 | }
|
---|
581 |
|
---|
582 | return rc;
|
---|
583 | }
|
---|
584 |
|
---|
585 | STDMETHODIMP SystemProperties::COMGETTER(MediumFormats)(ComSafeArrayOut(IMediumFormat *, aMediumFormats))
|
---|
586 | {
|
---|
587 | CheckComArgOutSafeArrayPointerValid(aMediumFormats);
|
---|
588 |
|
---|
589 | AutoCaller autoCaller(this);
|
---|
590 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
591 |
|
---|
592 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
593 |
|
---|
594 | SafeIfaceArray<IMediumFormat> mediumFormats(m_llMediumFormats);
|
---|
595 | mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats));
|
---|
596 |
|
---|
597 | return S_OK;
|
---|
598 | }
|
---|
599 |
|
---|
600 | STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat)(BSTR *aDefaultHardDiskFormat)
|
---|
601 | {
|
---|
602 | CheckComArgOutPointerValid(aDefaultHardDiskFormat);
|
---|
603 |
|
---|
604 | AutoCaller autoCaller(this);
|
---|
605 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
606 |
|
---|
607 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
608 |
|
---|
609 | m->strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
|
---|
610 |
|
---|
611 | return S_OK;
|
---|
612 | }
|
---|
613 |
|
---|
614 | STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat)(IN_BSTR aDefaultHardDiskFormat)
|
---|
615 | {
|
---|
616 | AutoCaller autoCaller(this);
|
---|
617 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
618 |
|
---|
619 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
620 | HRESULT rc = setDefaultHardDiskFormat(aDefaultHardDiskFormat);
|
---|
621 | alock.release();
|
---|
622 |
|
---|
623 | if (SUCCEEDED(rc))
|
---|
624 | {
|
---|
625 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
626 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
627 | rc = mParent->saveSettings();
|
---|
628 | }
|
---|
629 |
|
---|
630 | return rc;
|
---|
631 | }
|
---|
632 |
|
---|
633 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceWarning)(LONG64 *aFreeSpace)
|
---|
634 | {
|
---|
635 | CheckComArgOutPointerValid(aFreeSpace);
|
---|
636 |
|
---|
637 | ReturnComNotImplemented();
|
---|
638 | }
|
---|
639 |
|
---|
640 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceWarning)(LONG64 /* aFreeSpace */)
|
---|
641 | {
|
---|
642 | ReturnComNotImplemented();
|
---|
643 | }
|
---|
644 |
|
---|
645 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentWarning)(ULONG *aFreeSpacePercent)
|
---|
646 | {
|
---|
647 | CheckComArgOutPointerValid(aFreeSpacePercent);
|
---|
648 |
|
---|
649 | ReturnComNotImplemented();
|
---|
650 | }
|
---|
651 |
|
---|
652 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentWarning)(ULONG /* aFreeSpacePercent */)
|
---|
653 | {
|
---|
654 | ReturnComNotImplemented();
|
---|
655 | }
|
---|
656 |
|
---|
657 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpaceError)(LONG64 *aFreeSpace)
|
---|
658 | {
|
---|
659 | CheckComArgOutPointerValid(aFreeSpace);
|
---|
660 |
|
---|
661 | ReturnComNotImplemented();
|
---|
662 | }
|
---|
663 |
|
---|
664 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpaceError)(LONG64 /* aFreeSpace */)
|
---|
665 | {
|
---|
666 | ReturnComNotImplemented();
|
---|
667 | }
|
---|
668 |
|
---|
669 | STDMETHODIMP SystemProperties::COMGETTER(FreeDiskSpacePercentError)(ULONG *aFreeSpacePercent)
|
---|
670 | {
|
---|
671 | CheckComArgOutPointerValid(aFreeSpacePercent);
|
---|
672 |
|
---|
673 | ReturnComNotImplemented();
|
---|
674 | }
|
---|
675 |
|
---|
676 | STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentError)(ULONG /* aFreeSpacePercent */)
|
---|
677 | {
|
---|
678 | ReturnComNotImplemented();
|
---|
679 | }
|
---|
680 |
|
---|
681 | STDMETHODIMP SystemProperties::COMGETTER(VRDEAuthLibrary)(BSTR *aVRDEAuthLibrary)
|
---|
682 | {
|
---|
683 | CheckComArgOutPointerValid(aVRDEAuthLibrary);
|
---|
684 |
|
---|
685 | AutoCaller autoCaller(this);
|
---|
686 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
687 |
|
---|
688 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
689 |
|
---|
690 | m->strVRDEAuthLibrary.cloneTo(aVRDEAuthLibrary);
|
---|
691 |
|
---|
692 | return S_OK;
|
---|
693 | }
|
---|
694 |
|
---|
695 | STDMETHODIMP SystemProperties::COMSETTER(VRDEAuthLibrary)(IN_BSTR aVRDEAuthLibrary)
|
---|
696 | {
|
---|
697 | AutoCaller autoCaller(this);
|
---|
698 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
699 |
|
---|
700 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
701 | HRESULT rc = setVRDEAuthLibrary(aVRDEAuthLibrary);
|
---|
702 | alock.release();
|
---|
703 |
|
---|
704 | if (SUCCEEDED(rc))
|
---|
705 | {
|
---|
706 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
707 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
708 | rc = mParent->saveSettings();
|
---|
709 | }
|
---|
710 |
|
---|
711 | return rc;
|
---|
712 | }
|
---|
713 |
|
---|
714 | STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary)(BSTR *aWebServiceAuthLibrary)
|
---|
715 | {
|
---|
716 | CheckComArgOutPointerValid(aWebServiceAuthLibrary);
|
---|
717 |
|
---|
718 | AutoCaller autoCaller(this);
|
---|
719 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
720 |
|
---|
721 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
722 |
|
---|
723 | m->strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
|
---|
724 |
|
---|
725 | return S_OK;
|
---|
726 | }
|
---|
727 |
|
---|
728 | STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary)(IN_BSTR aWebServiceAuthLibrary)
|
---|
729 | {
|
---|
730 | AutoCaller autoCaller(this);
|
---|
731 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
732 |
|
---|
733 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
734 | HRESULT rc = setWebServiceAuthLibrary(aWebServiceAuthLibrary);
|
---|
735 | alock.release();
|
---|
736 |
|
---|
737 | if (SUCCEEDED(rc))
|
---|
738 | {
|
---|
739 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
740 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
741 | rc = mParent->saveSettings();
|
---|
742 | }
|
---|
743 |
|
---|
744 | return rc;
|
---|
745 | }
|
---|
746 |
|
---|
747 | STDMETHODIMP SystemProperties::COMGETTER(DefaultVRDEExtPack)(BSTR *aExtPack)
|
---|
748 | {
|
---|
749 | CheckComArgOutPointerValid(aExtPack);
|
---|
750 |
|
---|
751 | AutoCaller autoCaller(this);
|
---|
752 | HRESULT hrc = autoCaller.rc();
|
---|
753 | if (SUCCEEDED(hrc))
|
---|
754 | {
|
---|
755 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
756 | Utf8Str strExtPack(m->strDefaultVRDEExtPack);
|
---|
757 | if (strExtPack.isNotEmpty())
|
---|
758 | {
|
---|
759 | if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
|
---|
760 | hrc = S_OK;
|
---|
761 | else
|
---|
762 | #ifdef VBOX_WITH_EXTPACK
|
---|
763 | hrc = mParent->getExtPackManager()->checkVrdeExtPack(&strExtPack);
|
---|
764 | #else
|
---|
765 | hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
|
---|
766 | #endif
|
---|
767 | }
|
---|
768 | else
|
---|
769 | {
|
---|
770 | #ifdef VBOX_WITH_EXTPACK
|
---|
771 | hrc = mParent->getExtPackManager()->getDefaultVrdeExtPack(&strExtPack);
|
---|
772 | #endif
|
---|
773 | if (strExtPack.isEmpty())
|
---|
774 | {
|
---|
775 | /*
|
---|
776 | * Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
|
---|
777 | * This is hardcoded uglyness, sorry.
|
---|
778 | */
|
---|
779 | char szPath[RTPATH_MAX];
|
---|
780 | int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
|
---|
781 | if (RT_SUCCESS(vrc))
|
---|
782 | vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxVRDP");
|
---|
783 | if (RT_SUCCESS(vrc))
|
---|
784 | vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
|
---|
785 | if (RT_SUCCESS(vrc) && RTFileExists(szPath))
|
---|
786 | {
|
---|
787 | /* Illegal extpack name, so no conflict. */
|
---|
788 | strExtPack = VBOXVRDP_KLUDGE_EXTPACK_NAME;
|
---|
789 | }
|
---|
790 | }
|
---|
791 | }
|
---|
792 |
|
---|
793 | if (SUCCEEDED(hrc))
|
---|
794 | strExtPack.cloneTo(aExtPack);
|
---|
795 | }
|
---|
796 |
|
---|
797 | return S_OK;
|
---|
798 | }
|
---|
799 |
|
---|
800 | STDMETHODIMP SystemProperties::COMSETTER(DefaultVRDEExtPack)(IN_BSTR aExtPack)
|
---|
801 | {
|
---|
802 | CheckComArgNotNull(aExtPack);
|
---|
803 | Utf8Str strExtPack(aExtPack);
|
---|
804 |
|
---|
805 | AutoCaller autoCaller(this);
|
---|
806 | HRESULT hrc = autoCaller.rc();
|
---|
807 | if (SUCCEEDED(hrc))
|
---|
808 | {
|
---|
809 | if (strExtPack.isNotEmpty())
|
---|
810 | {
|
---|
811 | if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
|
---|
812 | hrc = S_OK;
|
---|
813 | else
|
---|
814 | #ifdef VBOX_WITH_EXTPACK
|
---|
815 | hrc = mParent->getExtPackManager()->checkVrdeExtPack(&strExtPack);
|
---|
816 | #else
|
---|
817 | hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
|
---|
818 | #endif
|
---|
819 | }
|
---|
820 | if (SUCCEEDED(hrc))
|
---|
821 | {
|
---|
822 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
823 | hrc = setDefaultVRDEExtPack(aExtPack);
|
---|
824 | if (SUCCEEDED(hrc))
|
---|
825 | {
|
---|
826 | /* VirtualBox::saveSettings() needs the VirtualBox write lock. */
|
---|
827 | alock.release();
|
---|
828 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
829 | hrc = mParent->saveSettings();
|
---|
830 | }
|
---|
831 | }
|
---|
832 | }
|
---|
833 |
|
---|
834 | return hrc;
|
---|
835 | }
|
---|
836 |
|
---|
837 | STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount)(ULONG *count)
|
---|
838 | {
|
---|
839 | CheckComArgOutPointerValid(count);
|
---|
840 |
|
---|
841 | AutoCaller autoCaller(this);
|
---|
842 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
843 |
|
---|
844 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
845 |
|
---|
846 | *count = m->ulLogHistoryCount;
|
---|
847 |
|
---|
848 | return S_OK;
|
---|
849 | }
|
---|
850 |
|
---|
851 | STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount)(ULONG count)
|
---|
852 | {
|
---|
853 | AutoCaller autoCaller(this);
|
---|
854 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
855 |
|
---|
856 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
857 | m->ulLogHistoryCount = count;
|
---|
858 | alock.release();
|
---|
859 |
|
---|
860 | // VirtualBox::saveSettings() needs vbox write lock
|
---|
861 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
862 | HRESULT rc = mParent->saveSettings();
|
---|
863 |
|
---|
864 | return rc;
|
---|
865 | }
|
---|
866 |
|
---|
867 | STDMETHODIMP SystemProperties::COMGETTER(DefaultAudioDriver)(AudioDriverType_T *aAudioDriver)
|
---|
868 | {
|
---|
869 | CheckComArgOutPointerValid(aAudioDriver);
|
---|
870 |
|
---|
871 | AutoCaller autoCaller(this);
|
---|
872 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
873 |
|
---|
874 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
875 |
|
---|
876 | *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
|
---|
877 |
|
---|
878 | return S_OK;
|
---|
879 | }
|
---|
880 |
|
---|
881 | // public methods only for internal purposes
|
---|
882 | /////////////////////////////////////////////////////////////////////////////
|
---|
883 |
|
---|
884 | HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
|
---|
885 | {
|
---|
886 | AutoCaller autoCaller(this);
|
---|
887 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
888 |
|
---|
889 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
890 |
|
---|
891 | HRESULT rc = S_OK;
|
---|
892 |
|
---|
893 | rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
|
---|
894 | if (FAILED(rc)) return rc;
|
---|
895 |
|
---|
896 | rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
|
---|
897 | if (FAILED(rc)) return rc;
|
---|
898 |
|
---|
899 | rc = setVRDEAuthLibrary(data.strVRDEAuthLibrary);
|
---|
900 | if (FAILED(rc)) return rc;
|
---|
901 |
|
---|
902 | rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
|
---|
903 | if (FAILED(rc)) return rc;
|
---|
904 |
|
---|
905 | rc = setDefaultVRDEExtPack(data.strDefaultVRDEExtPack);
|
---|
906 | if (FAILED(rc)) return rc;
|
---|
907 |
|
---|
908 | m->ulLogHistoryCount = data.ulLogHistoryCount;
|
---|
909 |
|
---|
910 | return S_OK;
|
---|
911 | }
|
---|
912 |
|
---|
913 | HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
|
---|
914 | {
|
---|
915 | AutoCaller autoCaller(this);
|
---|
916 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
917 |
|
---|
918 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
919 |
|
---|
920 | data = *m;
|
---|
921 |
|
---|
922 | return S_OK;
|
---|
923 | }
|
---|
924 |
|
---|
925 | /**
|
---|
926 | * Returns a medium format object corresponding to the given format
|
---|
927 | * identifier or null if no such format.
|
---|
928 | *
|
---|
929 | * @param aFormat Format identifier.
|
---|
930 | *
|
---|
931 | * @return ComObjPtr<MediumFormat>
|
---|
932 | */
|
---|
933 | ComObjPtr<MediumFormat> SystemProperties::mediumFormat(const Utf8Str &aFormat)
|
---|
934 | {
|
---|
935 | ComObjPtr<MediumFormat> format;
|
---|
936 |
|
---|
937 | AutoCaller autoCaller(this);
|
---|
938 | AssertComRCReturn (autoCaller.rc(), format);
|
---|
939 |
|
---|
940 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
941 |
|
---|
942 | for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
|
---|
943 | it != m_llMediumFormats.end();
|
---|
944 | ++ it)
|
---|
945 | {
|
---|
946 | /* MediumFormat is all const, no need to lock */
|
---|
947 |
|
---|
948 | if ((*it)->getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
|
---|
949 | {
|
---|
950 | format = *it;
|
---|
951 | break;
|
---|
952 | }
|
---|
953 | }
|
---|
954 |
|
---|
955 | return format;
|
---|
956 | }
|
---|
957 |
|
---|
958 | /**
|
---|
959 | * Returns a medium format object corresponding to the given file extension or
|
---|
960 | * null if no such format.
|
---|
961 | *
|
---|
962 | * @param aExt File extension.
|
---|
963 | *
|
---|
964 | * @return ComObjPtr<MediumFormat>
|
---|
965 | */
|
---|
966 | ComObjPtr<MediumFormat> SystemProperties::mediumFormatFromExtension(const Utf8Str &aExt)
|
---|
967 | {
|
---|
968 | ComObjPtr<MediumFormat> format;
|
---|
969 |
|
---|
970 | AutoCaller autoCaller(this);
|
---|
971 | AssertComRCReturn (autoCaller.rc(), format);
|
---|
972 |
|
---|
973 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
974 |
|
---|
975 | bool fFound = false;
|
---|
976 | for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
|
---|
977 | it != m_llMediumFormats.end() && !fFound;
|
---|
978 | ++it)
|
---|
979 | {
|
---|
980 | /* MediumFormat is all const, no need to lock */
|
---|
981 | MediumFormat::StrList aFileList = (*it)->getFileExtensions();
|
---|
982 | for (MediumFormat::StrList::const_iterator it1 = aFileList.begin();
|
---|
983 | it1 != aFileList.end();
|
---|
984 | ++it1)
|
---|
985 | {
|
---|
986 | if ((*it1).compare(aExt, Utf8Str::CaseInsensitive) == 0)
|
---|
987 | {
|
---|
988 | format = *it;
|
---|
989 | fFound = true;
|
---|
990 | break;
|
---|
991 | }
|
---|
992 | }
|
---|
993 | }
|
---|
994 |
|
---|
995 | return format;
|
---|
996 | }
|
---|
997 |
|
---|
998 | // private methods
|
---|
999 | /////////////////////////////////////////////////////////////////////////////
|
---|
1000 |
|
---|
1001 | /**
|
---|
1002 | * Returns the user's home directory. Wrapper around RTPathUserHome().
|
---|
1003 | * @param strPath
|
---|
1004 | * @return
|
---|
1005 | */
|
---|
1006 | HRESULT SystemProperties::getUserHomeDirectory(Utf8Str &strPath)
|
---|
1007 | {
|
---|
1008 | char szHome[RTPATH_MAX];
|
---|
1009 | int vrc = RTPathUserHome(szHome, sizeof(szHome));
|
---|
1010 | if (RT_FAILURE(vrc))
|
---|
1011 | return setError(E_FAIL,
|
---|
1012 | tr("Cannot determine user home directory (%Rrc)"),
|
---|
1013 | vrc);
|
---|
1014 | strPath = szHome;
|
---|
1015 | return S_OK;
|
---|
1016 | }
|
---|
1017 |
|
---|
1018 | /**
|
---|
1019 | * Internal implementation to set the default machine folder. Gets called
|
---|
1020 | * from the public attribute setter as well as loadSettings(). With 4.0,
|
---|
1021 | * the "default default" machine folder has changed, and we now require
|
---|
1022 | * a full path always.
|
---|
1023 | * @param aPath
|
---|
1024 | * @return
|
---|
1025 | */
|
---|
1026 | HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &strPath)
|
---|
1027 | {
|
---|
1028 | Utf8Str path(strPath); // make modifiable
|
---|
1029 | if ( path.isEmpty() // used by API calls to reset the default
|
---|
1030 | || path == "Machines" // this value (exactly like this, without path) is stored
|
---|
1031 | // in VirtualBox.xml if user upgrades from before 4.0 and
|
---|
1032 | // has not changed the default machine folder
|
---|
1033 | )
|
---|
1034 | {
|
---|
1035 | // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
|
---|
1036 | HRESULT rc = getUserHomeDirectory(path);
|
---|
1037 | if (FAILED(rc)) return rc;
|
---|
1038 | path += RTPATH_SLASH_STR "VirtualBox VMs";
|
---|
1039 | }
|
---|
1040 |
|
---|
1041 | if (!RTPathStartsWithRoot(path.c_str()))
|
---|
1042 | return setError(E_INVALIDARG,
|
---|
1043 | tr("Given default machine folder '%s' is not fully qualified"),
|
---|
1044 | path.c_str());
|
---|
1045 |
|
---|
1046 | m->strDefaultMachineFolder = path;
|
---|
1047 |
|
---|
1048 | return S_OK;
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
|
---|
1052 | {
|
---|
1053 | if (!aFormat.isEmpty())
|
---|
1054 | m->strDefaultHardDiskFormat = aFormat;
|
---|
1055 | else
|
---|
1056 | m->strDefaultHardDiskFormat = "VDI";
|
---|
1057 |
|
---|
1058 | return S_OK;
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | HRESULT SystemProperties::setVRDEAuthLibrary(const Utf8Str &aPath)
|
---|
1062 | {
|
---|
1063 | if (!aPath.isEmpty())
|
---|
1064 | m->strVRDEAuthLibrary = aPath;
|
---|
1065 | else
|
---|
1066 | m->strVRDEAuthLibrary = "VBoxAuth";
|
---|
1067 |
|
---|
1068 | return S_OK;
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
|
---|
1072 | {
|
---|
1073 | if (!aPath.isEmpty())
|
---|
1074 | m->strWebServiceAuthLibrary = aPath;
|
---|
1075 | else
|
---|
1076 | m->strWebServiceAuthLibrary = "VBoxAuth";
|
---|
1077 |
|
---|
1078 | return S_OK;
|
---|
1079 | }
|
---|
1080 |
|
---|
1081 | HRESULT SystemProperties::setDefaultVRDEExtPack(const Utf8Str &aExtPack)
|
---|
1082 | {
|
---|
1083 | m->strDefaultVRDEExtPack = aExtPack;
|
---|
1084 |
|
---|
1085 | return S_OK;
|
---|
1086 | }
|
---|
1087 |
|
---|