1 | /* $Id: SystemPropertiesImpl.cpp 22173 2009-08-11 15:38:59Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include "SystemPropertiesImpl.h"
|
---|
25 | #include "VirtualBoxImpl.h"
|
---|
26 | #include "MachineImpl.h"
|
---|
27 | #include "Logging.h"
|
---|
28 |
|
---|
29 | // generated header
|
---|
30 | #include "SchemaDefs.h"
|
---|
31 |
|
---|
32 | #include <iprt/path.h>
|
---|
33 | #include <iprt/dir.h>
|
---|
34 | #include <iprt/process.h>
|
---|
35 | #include <iprt/ldr.h>
|
---|
36 |
|
---|
37 | #include <VBox/err.h>
|
---|
38 | #include <VBox/param.h>
|
---|
39 | #include <VBox/settings.h>
|
---|
40 |
|
---|
41 | // defines
|
---|
42 | /////////////////////////////////////////////////////////////////////////////
|
---|
43 |
|
---|
44 | // constructor / destructor
|
---|
45 | /////////////////////////////////////////////////////////////////////////////
|
---|
46 |
|
---|
47 | DEFINE_EMPTY_CTOR_DTOR (SystemProperties)
|
---|
48 |
|
---|
49 | HRESULT SystemProperties::FinalConstruct()
|
---|
50 | {
|
---|
51 | return S_OK;
|
---|
52 | }
|
---|
53 |
|
---|
54 | void SystemProperties::FinalRelease()
|
---|
55 | {
|
---|
56 | uninit ();
|
---|
57 | }
|
---|
58 |
|
---|
59 | // public methods only for internal purposes
|
---|
60 | /////////////////////////////////////////////////////////////////////////////
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Initializes the system information object.
|
---|
64 | *
|
---|
65 | * @returns COM result indicator
|
---|
66 | */
|
---|
67 | HRESULT SystemProperties::init (VirtualBox *aParent)
|
---|
68 | {
|
---|
69 | LogFlowThisFunc(("aParent=%p\n", aParent));
|
---|
70 |
|
---|
71 | ComAssertRet (aParent, E_FAIL);
|
---|
72 |
|
---|
73 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
74 | AutoInitSpan autoInitSpan(this);
|
---|
75 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
76 |
|
---|
77 | unconst(mParent) = aParent;
|
---|
78 |
|
---|
79 | setDefaultMachineFolder(Utf8Str::Null);
|
---|
80 | setDefaultHardDiskFolder(Utf8Str::Null);
|
---|
81 | setDefaultHardDiskFormat(Utf8Str::Null);
|
---|
82 |
|
---|
83 | setRemoteDisplayAuthLibrary(Utf8Str::Null);
|
---|
84 |
|
---|
85 | mLogHistoryCount = 3;
|
---|
86 |
|
---|
87 | HRESULT rc = S_OK;
|
---|
88 |
|
---|
89 | /* Fetch info of all available hd backends. */
|
---|
90 |
|
---|
91 | /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
|
---|
92 | /// any number of backends
|
---|
93 |
|
---|
94 | /// @todo We currently leak memory because it's not actually clear what to
|
---|
95 | /// free in structures returned by VDBackendInfo. Must be fixed ASAP!
|
---|
96 |
|
---|
97 | VDBACKENDINFO aVDInfo [100];
|
---|
98 | unsigned cEntries;
|
---|
99 | int vrc = VDBackendInfo (RT_ELEMENTS (aVDInfo), aVDInfo, &cEntries);
|
---|
100 | AssertRC (vrc);
|
---|
101 | if (RT_SUCCESS(vrc))
|
---|
102 | {
|
---|
103 | for (unsigned i = 0; i < cEntries; ++ i)
|
---|
104 | {
|
---|
105 | ComObjPtr<HardDiskFormat> hdf;
|
---|
106 | rc = hdf.createObject();
|
---|
107 | CheckComRCBreakRC (rc);
|
---|
108 |
|
---|
109 | rc = hdf->init (&aVDInfo [i]);
|
---|
110 | CheckComRCBreakRC (rc);
|
---|
111 |
|
---|
112 | mHardDiskFormats.push_back (hdf);
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | /* Driver defaults which are OS specific */
|
---|
117 | #if defined (RT_OS_WINDOWS)
|
---|
118 | # ifdef VBOX_WITH_WINMM
|
---|
119 | mDefaultAudioDriver = AudioDriverType_WinMM;
|
---|
120 | # else /* VBOX_WITH_WINMM */
|
---|
121 | mDefaultAudioDriver = AudioDriverType_DirectSound;
|
---|
122 | # endif /* !VBOX_WITH_WINMM */
|
---|
123 | #elif defined (RT_OS_SOLARIS)
|
---|
124 | mDefaultAudioDriver = AudioDriverType_SolAudio;
|
---|
125 | #elif defined (RT_OS_LINUX)
|
---|
126 | # if defined (VBOX_WITH_PULSE)
|
---|
127 | /* Check for the pulse library & that the pulse audio daemon is running. */
|
---|
128 | if (RTProcIsRunningByName ("pulseaudio") &&
|
---|
129 | RTLdrIsLoadable ("libpulse.so.0"))
|
---|
130 | mDefaultAudioDriver = AudioDriverType_Pulse;
|
---|
131 | else
|
---|
132 | # endif /* VBOX_WITH_PULSE */
|
---|
133 | # if defined (VBOX_WITH_ALSA)
|
---|
134 | /* Check if we can load the ALSA library */
|
---|
135 | if (RTLdrIsLoadable ("libasound.so.2"))
|
---|
136 | mDefaultAudioDriver = AudioDriverType_ALSA;
|
---|
137 | else
|
---|
138 | # endif /* VBOX_WITH_ALSA */
|
---|
139 | mDefaultAudioDriver = AudioDriverType_OSS;
|
---|
140 | #elif defined (RT_OS_DARWIN)
|
---|
141 | mDefaultAudioDriver = AudioDriverType_CoreAudio;
|
---|
142 | #elif defined (RT_OS_OS2)
|
---|
143 | mDefaultAudioDriver = AudioDriverType_MMP;
|
---|
144 | #elif defined (RT_OS_FREEBSD)
|
---|
145 | mDefaultAudioDriver = AudioDriverType_OSS;
|
---|
146 | #else
|
---|
147 | mDefaultAudioDriver = AudioDriverType_Null;
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | /* Confirm a successful initialization */
|
---|
151 | if (SUCCEEDED(rc))
|
---|
152 | autoInitSpan.setSucceeded();
|
---|
153 |
|
---|
154 | return rc;
|
---|
155 | }
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
159 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
160 | */
|
---|
161 | void SystemProperties::uninit()
|
---|
162 | {
|
---|
163 | LogFlowThisFunc(("\n"));
|
---|
164 |
|
---|
165 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
166 | AutoUninitSpan autoUninitSpan(this);
|
---|
167 | if (autoUninitSpan.uninitDone())
|
---|
168 | return;
|
---|
169 |
|
---|
170 | unconst(mParent).setNull();
|
---|
171 | }
|
---|
172 |
|
---|
173 | // ISystemProperties properties
|
---|
174 | /////////////////////////////////////////////////////////////////////////////
|
---|
175 |
|
---|
176 |
|
---|
177 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestRAM)(ULONG *minRAM)
|
---|
178 | {
|
---|
179 | if (!minRAM)
|
---|
180 | return E_POINTER;
|
---|
181 |
|
---|
182 | AutoCaller autoCaller(this);
|
---|
183 | CheckComRCReturnRC(autoCaller.rc());
|
---|
184 |
|
---|
185 | /* no need to lock, this is const */
|
---|
186 | AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
|
---|
187 | *minRAM = MM_RAM_MIN_IN_MB;
|
---|
188 |
|
---|
189 | return S_OK;
|
---|
190 | }
|
---|
191 |
|
---|
192 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestRAM)(ULONG *maxRAM)
|
---|
193 | {
|
---|
194 | if (!maxRAM)
|
---|
195 | return E_POINTER;
|
---|
196 |
|
---|
197 | AutoCaller autoCaller(this);
|
---|
198 | CheckComRCReturnRC(autoCaller.rc());
|
---|
199 |
|
---|
200 | /* no need to lock, this is const */
|
---|
201 | AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
|
---|
202 | *maxRAM = MM_RAM_MAX_IN_MB;
|
---|
203 |
|
---|
204 | return S_OK;
|
---|
205 | }
|
---|
206 |
|
---|
207 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestVRAM)(ULONG *minVRAM)
|
---|
208 | {
|
---|
209 | if (!minVRAM)
|
---|
210 | return E_POINTER;
|
---|
211 |
|
---|
212 | AutoCaller autoCaller(this);
|
---|
213 | CheckComRCReturnRC(autoCaller.rc());
|
---|
214 |
|
---|
215 | /* no need to lock, this is const */
|
---|
216 | *minVRAM = SchemaDefs::MinGuestVRAM;
|
---|
217 |
|
---|
218 | return S_OK;
|
---|
219 | }
|
---|
220 |
|
---|
221 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestVRAM)(ULONG *maxVRAM)
|
---|
222 | {
|
---|
223 | if (!maxVRAM)
|
---|
224 | return E_POINTER;
|
---|
225 |
|
---|
226 | AutoCaller autoCaller(this);
|
---|
227 | CheckComRCReturnRC(autoCaller.rc());
|
---|
228 |
|
---|
229 | /* no need to lock, this is const */
|
---|
230 | *maxVRAM = SchemaDefs::MaxGuestVRAM;
|
---|
231 |
|
---|
232 | return S_OK;
|
---|
233 | }
|
---|
234 |
|
---|
235 | STDMETHODIMP SystemProperties::COMGETTER(MinGuestCPUCount)(ULONG *minCPUCount)
|
---|
236 | {
|
---|
237 | if (!minCPUCount)
|
---|
238 | return E_POINTER;
|
---|
239 |
|
---|
240 | AutoCaller autoCaller(this);
|
---|
241 | CheckComRCReturnRC(autoCaller.rc());
|
---|
242 |
|
---|
243 | /* no need to lock, this is const */
|
---|
244 | *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
|
---|
245 |
|
---|
246 | return S_OK;
|
---|
247 | }
|
---|
248 |
|
---|
249 | STDMETHODIMP SystemProperties::COMGETTER(MaxGuestCPUCount)(ULONG *maxCPUCount)
|
---|
250 | {
|
---|
251 | if (!maxCPUCount)
|
---|
252 | return E_POINTER;
|
---|
253 |
|
---|
254 | AutoCaller autoCaller(this);
|
---|
255 | CheckComRCReturnRC(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 | if (!maxMonitors)
|
---|
266 | return E_POINTER;
|
---|
267 |
|
---|
268 | AutoCaller autoCaller(this);
|
---|
269 | CheckComRCReturnRC(autoCaller.rc());
|
---|
270 |
|
---|
271 | /* no need to lock, this is const */
|
---|
272 | *maxMonitors = SchemaDefs::MaxGuestMonitors;
|
---|
273 |
|
---|
274 | return S_OK;
|
---|
275 | }
|
---|
276 |
|
---|
277 | STDMETHODIMP SystemProperties::COMGETTER(MaxVDISize)(ULONG64 *maxVDISize)
|
---|
278 | {
|
---|
279 | if (!maxVDISize)
|
---|
280 | return E_POINTER;
|
---|
281 |
|
---|
282 | AutoCaller autoCaller(this);
|
---|
283 | CheckComRCReturnRC(autoCaller.rc());
|
---|
284 |
|
---|
285 | /** The BIOS supports currently 32 bit LBA numbers (implementing the full
|
---|
286 | * 48 bit range is in theory trivial, but the crappy compiler makes things
|
---|
287 | * more difficult). This translates to almost 2 TBytes (to be on the safe
|
---|
288 | * side, the reported limit is 1 MiByte less than that, as the total number
|
---|
289 | * of sectors should fit in 32 bits, too), which should bei enough for
|
---|
290 | * the moment. The virtual ATA disks support complete LBA48 (although for
|
---|
291 | * example iSCSI is also currently limited to 32 bit LBA), so the
|
---|
292 | * theoretical maximum disk size is 128 PiByte. The user interface cannot
|
---|
293 | * cope with this in a reasonable way yet. */
|
---|
294 | /* no need to lock, this is const */
|
---|
295 | *maxVDISize = 2048 * 1024 - 1;
|
---|
296 |
|
---|
297 | return S_OK;
|
---|
298 | }
|
---|
299 |
|
---|
300 | STDMETHODIMP SystemProperties::COMGETTER(NetworkAdapterCount)(ULONG *count)
|
---|
301 | {
|
---|
302 | if (!count)
|
---|
303 | return E_POINTER;
|
---|
304 |
|
---|
305 | AutoCaller autoCaller(this);
|
---|
306 | CheckComRCReturnRC(autoCaller.rc());
|
---|
307 |
|
---|
308 | /* no need to lock, this is const */
|
---|
309 | *count = SchemaDefs::NetworkAdapterCount;
|
---|
310 |
|
---|
311 | return S_OK;
|
---|
312 | }
|
---|
313 |
|
---|
314 | STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
|
---|
315 | {
|
---|
316 | if (!count)
|
---|
317 | return E_POINTER;
|
---|
318 |
|
---|
319 | AutoCaller autoCaller(this);
|
---|
320 | CheckComRCReturnRC(autoCaller.rc());
|
---|
321 |
|
---|
322 | /* no need to lock, this is const */
|
---|
323 | *count = SchemaDefs::SerialPortCount;
|
---|
324 |
|
---|
325 | return S_OK;
|
---|
326 | }
|
---|
327 |
|
---|
328 | STDMETHODIMP SystemProperties::COMGETTER(ParallelPortCount)(ULONG *count)
|
---|
329 | {
|
---|
330 | if (!count)
|
---|
331 | return E_POINTER;
|
---|
332 |
|
---|
333 | AutoCaller autoCaller(this);
|
---|
334 | CheckComRCReturnRC(autoCaller.rc());
|
---|
335 |
|
---|
336 | /* no need to lock, this is const */
|
---|
337 | *count = SchemaDefs::ParallelPortCount;
|
---|
338 |
|
---|
339 | return S_OK;
|
---|
340 | }
|
---|
341 |
|
---|
342 | STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
|
---|
343 | {
|
---|
344 | CheckComArgOutPointerValid(aMaxBootPosition);
|
---|
345 |
|
---|
346 | AutoCaller autoCaller(this);
|
---|
347 | CheckComRCReturnRC(autoCaller.rc());
|
---|
348 |
|
---|
349 | /* no need to lock, this is const */
|
---|
350 | *aMaxBootPosition = SchemaDefs::MaxBootPosition;
|
---|
351 |
|
---|
352 | return S_OK;
|
---|
353 | }
|
---|
354 |
|
---|
355 | STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder) (BSTR *aDefaultMachineFolder)
|
---|
356 | {
|
---|
357 | CheckComArgOutPointerValid(aDefaultMachineFolder);
|
---|
358 |
|
---|
359 | AutoCaller autoCaller(this);
|
---|
360 | CheckComRCReturnRC(autoCaller.rc());
|
---|
361 |
|
---|
362 | AutoReadLock alock(this);
|
---|
363 |
|
---|
364 | m_strDefaultMachineFolderFull.cloneTo(aDefaultMachineFolder);
|
---|
365 |
|
---|
366 | return S_OK;
|
---|
367 | }
|
---|
368 |
|
---|
369 | STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder) (IN_BSTR aDefaultMachineFolder)
|
---|
370 | {
|
---|
371 | AutoCaller autoCaller(this);
|
---|
372 | CheckComRCReturnRC(autoCaller.rc());
|
---|
373 |
|
---|
374 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
375 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
376 |
|
---|
377 | HRESULT rc = setDefaultMachineFolder (aDefaultMachineFolder);
|
---|
378 | if (SUCCEEDED(rc))
|
---|
379 | rc = mParent->saveSettings();
|
---|
380 |
|
---|
381 | return rc;
|
---|
382 | }
|
---|
383 |
|
---|
384 | STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFolder) (BSTR *aDefaultHardDiskFolder)
|
---|
385 | {
|
---|
386 | CheckComArgOutPointerValid(aDefaultHardDiskFolder);
|
---|
387 |
|
---|
388 | AutoCaller autoCaller(this);
|
---|
389 | CheckComRCReturnRC(autoCaller.rc());
|
---|
390 |
|
---|
391 | AutoReadLock alock(this);
|
---|
392 |
|
---|
393 | m_strDefaultHardDiskFolderFull.cloneTo(aDefaultHardDiskFolder);
|
---|
394 |
|
---|
395 | return S_OK;
|
---|
396 | }
|
---|
397 |
|
---|
398 | STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFolder) (IN_BSTR aDefaultHardDiskFolder)
|
---|
399 | {
|
---|
400 | AutoCaller autoCaller(this);
|
---|
401 | CheckComRCReturnRC(autoCaller.rc());
|
---|
402 |
|
---|
403 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
404 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
405 |
|
---|
406 | HRESULT rc = setDefaultHardDiskFolder (aDefaultHardDiskFolder);
|
---|
407 | if (SUCCEEDED(rc))
|
---|
408 | rc = mParent->saveSettings();
|
---|
409 |
|
---|
410 | return rc;
|
---|
411 | }
|
---|
412 |
|
---|
413 | STDMETHODIMP SystemProperties::
|
---|
414 | COMGETTER(HardDiskFormats) (ComSafeArrayOut(IHardDiskFormat *, aHardDiskFormats))
|
---|
415 | {
|
---|
416 | if (ComSafeArrayOutIsNull(aHardDiskFormats))
|
---|
417 | return E_POINTER;
|
---|
418 |
|
---|
419 | AutoCaller autoCaller(this);
|
---|
420 | CheckComRCReturnRC(autoCaller.rc());
|
---|
421 |
|
---|
422 | AutoReadLock alock(this);
|
---|
423 |
|
---|
424 | SafeIfaceArray<IHardDiskFormat> hardDiskFormats (mHardDiskFormats);
|
---|
425 | hardDiskFormats.detachTo(ComSafeArrayOutArg(aHardDiskFormats));
|
---|
426 |
|
---|
427 | return S_OK;
|
---|
428 | }
|
---|
429 |
|
---|
430 | STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat) (BSTR *aDefaultHardDiskFormat)
|
---|
431 | {
|
---|
432 | CheckComArgOutPointerValid(aDefaultHardDiskFormat);
|
---|
433 |
|
---|
434 | AutoCaller autoCaller(this);
|
---|
435 | CheckComRCReturnRC(autoCaller.rc());
|
---|
436 |
|
---|
437 | AutoReadLock alock(this);
|
---|
438 |
|
---|
439 | m_strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
|
---|
440 |
|
---|
441 | return S_OK;
|
---|
442 | }
|
---|
443 |
|
---|
444 | STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat) (IN_BSTR aDefaultHardDiskFormat)
|
---|
445 | {
|
---|
446 | AutoCaller autoCaller(this);
|
---|
447 | CheckComRCReturnRC(autoCaller.rc());
|
---|
448 |
|
---|
449 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
450 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
451 |
|
---|
452 | HRESULT rc = setDefaultHardDiskFormat (aDefaultHardDiskFormat);
|
---|
453 | if (SUCCEEDED(rc))
|
---|
454 | rc = mParent->saveSettings();
|
---|
455 |
|
---|
456 | return rc;
|
---|
457 | }
|
---|
458 |
|
---|
459 | STDMETHODIMP SystemProperties::COMGETTER(RemoteDisplayAuthLibrary) (BSTR *aRemoteDisplayAuthLibrary)
|
---|
460 | {
|
---|
461 | CheckComArgOutPointerValid(aRemoteDisplayAuthLibrary);
|
---|
462 |
|
---|
463 | AutoCaller autoCaller(this);
|
---|
464 | CheckComRCReturnRC(autoCaller.rc());
|
---|
465 |
|
---|
466 | AutoReadLock alock(this);
|
---|
467 |
|
---|
468 | m_strRemoteDisplayAuthLibrary.cloneTo(aRemoteDisplayAuthLibrary);
|
---|
469 |
|
---|
470 | return S_OK;
|
---|
471 | }
|
---|
472 |
|
---|
473 | STDMETHODIMP SystemProperties::COMSETTER(RemoteDisplayAuthLibrary) (IN_BSTR aRemoteDisplayAuthLibrary)
|
---|
474 | {
|
---|
475 | AutoCaller autoCaller(this);
|
---|
476 | CheckComRCReturnRC(autoCaller.rc());
|
---|
477 |
|
---|
478 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
479 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
480 |
|
---|
481 | HRESULT rc = setRemoteDisplayAuthLibrary (aRemoteDisplayAuthLibrary);
|
---|
482 | if (SUCCEEDED(rc))
|
---|
483 | rc = mParent->saveSettings();
|
---|
484 |
|
---|
485 | return rc;
|
---|
486 | }
|
---|
487 |
|
---|
488 | STDMETHODIMP SystemProperties::COMGETTER(WebServiceAuthLibrary) (BSTR *aWebServiceAuthLibrary)
|
---|
489 | {
|
---|
490 | CheckComArgOutPointerValid(aWebServiceAuthLibrary);
|
---|
491 |
|
---|
492 | AutoCaller autoCaller(this);
|
---|
493 | CheckComRCReturnRC(autoCaller.rc());
|
---|
494 |
|
---|
495 | AutoReadLock alock(this);
|
---|
496 |
|
---|
497 | m_strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
|
---|
498 |
|
---|
499 | return S_OK;
|
---|
500 | }
|
---|
501 |
|
---|
502 | STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary) (IN_BSTR aWebServiceAuthLibrary)
|
---|
503 | {
|
---|
504 | AutoCaller autoCaller(this);
|
---|
505 | CheckComRCReturnRC(autoCaller.rc());
|
---|
506 |
|
---|
507 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
508 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
509 |
|
---|
510 | HRESULT rc = setWebServiceAuthLibrary (aWebServiceAuthLibrary);
|
---|
511 | if (SUCCEEDED(rc))
|
---|
512 | rc = mParent->saveSettings();
|
---|
513 |
|
---|
514 | return rc;
|
---|
515 | }
|
---|
516 |
|
---|
517 | STDMETHODIMP SystemProperties::COMGETTER(LogHistoryCount) (ULONG *count)
|
---|
518 | {
|
---|
519 | if (!count)
|
---|
520 | return E_POINTER;
|
---|
521 |
|
---|
522 | AutoCaller autoCaller(this);
|
---|
523 | CheckComRCReturnRC(autoCaller.rc());
|
---|
524 |
|
---|
525 | AutoReadLock alock(this);
|
---|
526 |
|
---|
527 | *count = mLogHistoryCount;
|
---|
528 |
|
---|
529 | return S_OK;
|
---|
530 | }
|
---|
531 |
|
---|
532 | STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount) (ULONG count)
|
---|
533 | {
|
---|
534 | AutoCaller autoCaller(this);
|
---|
535 | CheckComRCReturnRC(autoCaller.rc());
|
---|
536 |
|
---|
537 | /* VirtualBox::saveSettings() needs a write lock */
|
---|
538 | AutoMultiWriteLock2 alock (mParent, this);
|
---|
539 |
|
---|
540 | mLogHistoryCount = count;
|
---|
541 |
|
---|
542 | HRESULT rc = mParent->saveSettings();
|
---|
543 |
|
---|
544 | return rc;
|
---|
545 | }
|
---|
546 |
|
---|
547 | STDMETHODIMP SystemProperties::COMGETTER(DefaultAudioDriver) (AudioDriverType_T *aAudioDriver)
|
---|
548 | {
|
---|
549 | if (!aAudioDriver)
|
---|
550 | return E_POINTER;
|
---|
551 |
|
---|
552 | AutoCaller autoCaller(this);
|
---|
553 | CheckComRCReturnRC(autoCaller.rc());
|
---|
554 |
|
---|
555 | AutoReadLock alock(this);
|
---|
556 |
|
---|
557 | *aAudioDriver = mDefaultAudioDriver;
|
---|
558 |
|
---|
559 | return S_OK;
|
---|
560 | }
|
---|
561 |
|
---|
562 | // public methods only for internal purposes
|
---|
563 | /////////////////////////////////////////////////////////////////////////////
|
---|
564 |
|
---|
565 | HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
|
---|
566 | {
|
---|
567 | AutoCaller autoCaller(this);
|
---|
568 | CheckComRCReturnRC(autoCaller.rc());
|
---|
569 |
|
---|
570 | AutoWriteLock alock(this);
|
---|
571 |
|
---|
572 | HRESULT rc = S_OK;
|
---|
573 |
|
---|
574 | rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
|
---|
575 | CheckComRCReturnRC(rc);
|
---|
576 |
|
---|
577 | rc = setDefaultHardDiskFolder(data.strDefaultHardDiskFolder);
|
---|
578 | CheckComRCReturnRC(rc);
|
---|
579 |
|
---|
580 | rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
|
---|
581 | CheckComRCReturnRC(rc);
|
---|
582 |
|
---|
583 | rc = setRemoteDisplayAuthLibrary(data.strRemoteDisplayAuthLibrary);
|
---|
584 | CheckComRCReturnRC(rc);
|
---|
585 |
|
---|
586 | rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
|
---|
587 | CheckComRCReturnRC(rc);
|
---|
588 |
|
---|
589 | mLogHistoryCount = data.ulLogHistoryCount;
|
---|
590 |
|
---|
591 | return S_OK;
|
---|
592 | }
|
---|
593 |
|
---|
594 | HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
|
---|
595 | {
|
---|
596 | AutoCaller autoCaller(this);
|
---|
597 | CheckComRCReturnRC(autoCaller.rc());
|
---|
598 |
|
---|
599 | AutoReadLock alock(this);
|
---|
600 |
|
---|
601 | data.strDefaultMachineFolder = m_strDefaultMachineFolder;
|
---|
602 | data.strDefaultHardDiskFolder = m_strDefaultHardDiskFolder;
|
---|
603 | data.strDefaultHardDiskFormat = m_strDefaultHardDiskFormat;
|
---|
604 | data.strRemoteDisplayAuthLibrary = m_strRemoteDisplayAuthLibrary;
|
---|
605 | data.strWebServiceAuthLibrary = m_strWebServiceAuthLibrary;
|
---|
606 | data.ulLogHistoryCount = mLogHistoryCount;
|
---|
607 |
|
---|
608 | return S_OK;
|
---|
609 | }
|
---|
610 |
|
---|
611 | /**
|
---|
612 | * Rerurns a hard disk format object corresponding to the given format
|
---|
613 | * identifier or null if no such format.
|
---|
614 | *
|
---|
615 | * @param aFormat Format identifier.
|
---|
616 | *
|
---|
617 | * @return ComObjPtr<HardDiskFormat>
|
---|
618 | */
|
---|
619 | ComObjPtr<HardDiskFormat> SystemProperties::hardDiskFormat (CBSTR aFormat)
|
---|
620 | {
|
---|
621 | ComObjPtr<HardDiskFormat> format;
|
---|
622 |
|
---|
623 | AutoCaller autoCaller(this);
|
---|
624 | AssertComRCReturn (autoCaller.rc(), format);
|
---|
625 |
|
---|
626 | AutoReadLock alock(this);
|
---|
627 |
|
---|
628 | for (HardDiskFormatList::const_iterator it = mHardDiskFormats.begin();
|
---|
629 | it != mHardDiskFormats.end(); ++ it)
|
---|
630 | {
|
---|
631 | /* HardDiskFormat is all const, no need to lock */
|
---|
632 |
|
---|
633 | if ((*it)->id().compareIgnoreCase (aFormat) == 0)
|
---|
634 | {
|
---|
635 | format = *it;
|
---|
636 | break;
|
---|
637 | }
|
---|
638 | }
|
---|
639 |
|
---|
640 | return format;
|
---|
641 | }
|
---|
642 |
|
---|
643 | // private methods
|
---|
644 | /////////////////////////////////////////////////////////////////////////////
|
---|
645 |
|
---|
646 | HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &aPath)
|
---|
647 | {
|
---|
648 | Utf8Str path(aPath);
|
---|
649 | if (path.isEmpty())
|
---|
650 | path = "Machines";
|
---|
651 |
|
---|
652 | /* get the full file name */
|
---|
653 | Utf8Str folder;
|
---|
654 | int vrc = mParent->calculateFullPath(path, folder);
|
---|
655 | if (RT_FAILURE(vrc))
|
---|
656 | return setError(E_FAIL,
|
---|
657 | tr("Invalid default machine folder '%s' (%Rrc)"),
|
---|
658 | path.raw(),
|
---|
659 | vrc);
|
---|
660 |
|
---|
661 | m_strDefaultMachineFolder = path;
|
---|
662 | m_strDefaultMachineFolderFull = folder;
|
---|
663 |
|
---|
664 | return S_OK;
|
---|
665 | }
|
---|
666 |
|
---|
667 | HRESULT SystemProperties::setDefaultHardDiskFolder(const Utf8Str &aPath)
|
---|
668 | {
|
---|
669 | Utf8Str path(aPath);
|
---|
670 | if (path.isEmpty())
|
---|
671 | path = "HardDisks";
|
---|
672 |
|
---|
673 | /* get the full file name */
|
---|
674 | Utf8Str folder;
|
---|
675 | int vrc = mParent->calculateFullPath(path, folder);
|
---|
676 | if (RT_FAILURE(vrc))
|
---|
677 | return setError(E_FAIL,
|
---|
678 | tr("Invalid default hard disk folder '%s' (%Rrc)"),
|
---|
679 | path.raw(),
|
---|
680 | vrc);
|
---|
681 |
|
---|
682 | m_strDefaultHardDiskFolder = path;
|
---|
683 | m_strDefaultHardDiskFolderFull = folder;
|
---|
684 |
|
---|
685 | return S_OK;
|
---|
686 | }
|
---|
687 |
|
---|
688 | HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
|
---|
689 | {
|
---|
690 | if (!aFormat.isEmpty())
|
---|
691 | m_strDefaultHardDiskFormat = aFormat;
|
---|
692 | else
|
---|
693 | m_strDefaultHardDiskFormat = "VDI";
|
---|
694 |
|
---|
695 | return S_OK;
|
---|
696 | }
|
---|
697 |
|
---|
698 | HRESULT SystemProperties::setRemoteDisplayAuthLibrary(const Utf8Str &aPath)
|
---|
699 | {
|
---|
700 | if (!aPath.isEmpty())
|
---|
701 | m_strRemoteDisplayAuthLibrary = aPath;
|
---|
702 | else
|
---|
703 | m_strRemoteDisplayAuthLibrary = "VRDPAuth";
|
---|
704 |
|
---|
705 | return S_OK;
|
---|
706 | }
|
---|
707 |
|
---|
708 | HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
|
---|
709 | {
|
---|
710 | if (!aPath.isEmpty())
|
---|
711 | m_strWebServiceAuthLibrary = aPath;
|
---|
712 | else
|
---|
713 | m_strWebServiceAuthLibrary = "VRDPAuth";
|
---|
714 |
|
---|
715 | return S_OK;
|
---|
716 | }
|
---|
717 |
|
---|