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