~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to src/VBox/Main/SystemPropertiesImpl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <VBox/err.h>
38
38
#include <VBox/param.h>
39
39
#include <VBox/settings.h>
 
40
#include <VBox/VBoxHDD.h>
40
41
 
41
42
// defines
42
43
/////////////////////////////////////////////////////////////////////////////
66
67
 */
67
68
HRESULT SystemProperties::init (VirtualBox *aParent)
68
69
{
69
 
    LogFlowThisFunc (("aParent=%p\n", aParent));
 
70
    LogFlowThisFunc(("aParent=%p\n", aParent));
70
71
 
71
72
    ComAssertRet (aParent, E_FAIL);
72
73
 
73
74
    /* 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 (NULL);
80
 
    setDefaultHardDiskFolder (NULL);
81
 
    setDefaultHardDiskFormat (NULL);
82
 
 
83
 
    setRemoteDisplayAuthLibrary (NULL);
 
75
    AutoInitSpan autoInitSpan(this);
 
76
    AssertReturn(autoInitSpan.isOk(), E_FAIL);
 
77
 
 
78
    unconst(mParent) = aParent;
 
79
 
 
80
    setDefaultMachineFolder(Utf8Str::Null);
 
81
    setDefaultHardDiskFolder(Utf8Str::Null);
 
82
    setDefaultHardDiskFormat(Utf8Str::Null);
 
83
 
 
84
    setRemoteDisplayAuthLibrary(Utf8Str::Null);
84
85
 
85
86
    mLogHistoryCount = 3;
86
87
 
98
99
    unsigned cEntries;
99
100
    int vrc = VDBackendInfo (RT_ELEMENTS (aVDInfo), aVDInfo, &cEntries);
100
101
    AssertRC (vrc);
101
 
    if (RT_SUCCESS (vrc))
 
102
    if (RT_SUCCESS(vrc))
102
103
    {
103
104
        for (unsigned i = 0; i < cEntries; ++ i)
104
105
        {
105
 
            ComObjPtr <HardDiskFormat> hdf;
 
106
            ComObjPtr<MediumFormat> hdf;
106
107
            rc = hdf.createObject();
107
108
            CheckComRCBreakRC (rc);
108
109
 
109
110
            rc = hdf->init (&aVDInfo [i]);
110
111
            CheckComRCBreakRC (rc);
111
112
 
112
 
            mHardDiskFormats.push_back (hdf);
 
113
            mMediumFormats.push_back (hdf);
113
114
        }
114
115
    }
115
116
 
148
149
#endif
149
150
 
150
151
    /* Confirm a successful initialization */
151
 
    if (SUCCEEDED (rc))
 
152
    if (SUCCEEDED(rc))
152
153
        autoInitSpan.setSucceeded();
153
154
 
154
155
    return rc;
160
161
 */
161
162
void SystemProperties::uninit()
162
163
{
163
 
    LogFlowThisFunc (("\n"));
 
164
    LogFlowThisFunc(("\n"));
164
165
 
165
166
    /* Enclose the state transition Ready->InUninit->NotReady */
166
 
    AutoUninitSpan autoUninitSpan (this);
 
167
    AutoUninitSpan autoUninitSpan(this);
167
168
    if (autoUninitSpan.uninitDone())
168
169
        return;
169
170
 
170
 
    unconst (mParent).setNull();
 
171
    unconst(mParent).setNull();
171
172
}
172
173
 
173
174
// ISystemProperties properties
179
180
    if (!minRAM)
180
181
        return E_POINTER;
181
182
 
182
 
    AutoCaller autoCaller (this);
183
 
    CheckComRCReturnRC (autoCaller.rc());
 
183
    AutoCaller autoCaller(this);
 
184
    CheckComRCReturnRC(autoCaller.rc());
184
185
 
185
186
    /* no need to lock, this is const */
186
187
    AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
194
195
    if (!maxRAM)
195
196
        return E_POINTER;
196
197
 
197
 
    AutoCaller autoCaller (this);
198
 
    CheckComRCReturnRC (autoCaller.rc());
 
198
    AutoCaller autoCaller(this);
 
199
    CheckComRCReturnRC(autoCaller.rc());
199
200
 
200
201
    /* no need to lock, this is const */
201
202
    AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
218
219
    if (!minVRAM)
219
220
        return E_POINTER;
220
221
 
221
 
    AutoCaller autoCaller (this);
222
 
    CheckComRCReturnRC (autoCaller.rc());
 
222
    AutoCaller autoCaller(this);
 
223
    CheckComRCReturnRC(autoCaller.rc());
223
224
 
224
225
    /* no need to lock, this is const */
225
226
    *minVRAM = SchemaDefs::MinGuestVRAM;
232
233
    if (!maxVRAM)
233
234
        return E_POINTER;
234
235
 
235
 
    AutoCaller autoCaller (this);
236
 
    CheckComRCReturnRC (autoCaller.rc());
 
236
    AutoCaller autoCaller(this);
 
237
    CheckComRCReturnRC(autoCaller.rc());
237
238
 
238
239
    /* no need to lock, this is const */
239
240
    *maxVRAM = SchemaDefs::MaxGuestVRAM;
246
247
    if (!minCPUCount)
247
248
        return E_POINTER;
248
249
 
249
 
    AutoCaller autoCaller (this);
250
 
    CheckComRCReturnRC (autoCaller.rc());
 
250
    AutoCaller autoCaller(this);
 
251
    CheckComRCReturnRC(autoCaller.rc());
251
252
 
252
253
    /* no need to lock, this is const */
253
254
    *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
260
261
    if (!maxCPUCount)
261
262
        return E_POINTER;
262
263
 
263
 
    AutoCaller autoCaller (this);
264
 
    CheckComRCReturnRC (autoCaller.rc());
 
264
    AutoCaller autoCaller(this);
 
265
    CheckComRCReturnRC(autoCaller.rc());
265
266
 
266
267
    /* no need to lock, this is const */
267
268
    *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
274
275
    if (!maxMonitors)
275
276
        return E_POINTER;
276
277
 
277
 
    AutoCaller autoCaller (this);
278
 
    CheckComRCReturnRC (autoCaller.rc());
 
278
    AutoCaller autoCaller(this);
 
279
    CheckComRCReturnRC(autoCaller.rc());
279
280
 
280
281
    /* no need to lock, this is const */
281
282
    *maxMonitors = SchemaDefs::MaxGuestMonitors;
288
289
    if (!maxVDISize)
289
290
        return E_POINTER;
290
291
 
291
 
    AutoCaller autoCaller (this);
292
 
    CheckComRCReturnRC (autoCaller.rc());
 
292
    AutoCaller autoCaller(this);
 
293
    CheckComRCReturnRC(autoCaller.rc());
293
294
 
294
295
    /** The BIOS supports currently 32 bit LBA numbers (implementing the full
295
296
     * 48 bit range is in theory trivial, but the crappy compiler makes things
311
312
    if (!count)
312
313
        return E_POINTER;
313
314
 
314
 
    AutoCaller autoCaller (this);
315
 
    CheckComRCReturnRC (autoCaller.rc());
 
315
    AutoCaller autoCaller(this);
 
316
    CheckComRCReturnRC(autoCaller.rc());
316
317
 
317
318
    /* no need to lock, this is const */
318
319
    *count = SchemaDefs::NetworkAdapterCount;
325
326
    if (!count)
326
327
        return E_POINTER;
327
328
 
328
 
    AutoCaller autoCaller (this);
329
 
    CheckComRCReturnRC (autoCaller.rc());
 
329
    AutoCaller autoCaller(this);
 
330
    CheckComRCReturnRC(autoCaller.rc());
330
331
 
331
332
    /* no need to lock, this is const */
332
333
    *count = SchemaDefs::SerialPortCount;
339
340
    if (!count)
340
341
        return E_POINTER;
341
342
 
342
 
    AutoCaller autoCaller (this);
343
 
    CheckComRCReturnRC (autoCaller.rc());
 
343
    AutoCaller autoCaller(this);
 
344
    CheckComRCReturnRC(autoCaller.rc());
344
345
 
345
346
    /* no need to lock, this is const */
346
347
    *count = SchemaDefs::ParallelPortCount;
352
353
{
353
354
    CheckComArgOutPointerValid(aMaxBootPosition);
354
355
 
355
 
    AutoCaller autoCaller (this);
356
 
    CheckComRCReturnRC (autoCaller.rc());
 
356
    AutoCaller autoCaller(this);
 
357
    CheckComRCReturnRC(autoCaller.rc());
357
358
 
358
359
    /* no need to lock, this is const */
359
360
    *aMaxBootPosition = SchemaDefs::MaxBootPosition;
361
362
    return S_OK;
362
363
}
363
364
 
 
365
STDMETHODIMP SystemProperties::GetMaxDevicesPerPortForStorageBus (StorageBus_T aBus, ULONG *aMaxDevicesPerPort)
 
366
{
 
367
    CheckComArgOutPointerValid(aMaxDevicesPerPort);
 
368
 
 
369
    AutoCaller autoCaller(this);
 
370
    CheckComRCReturnRC(autoCaller.rc());
 
371
 
 
372
    /* no need to lock, this is const */
 
373
    switch (aBus)
 
374
    {
 
375
        case StorageBus_SATA:
 
376
        case StorageBus_SCSI:
 
377
        {
 
378
            /* SATA and both SCSI controllers only support one device per port. */
 
379
            *aMaxDevicesPerPort = 1;
 
380
            break;
 
381
        }
 
382
        case StorageBus_IDE:
 
383
        case StorageBus_Floppy:
 
384
        {
 
385
            /* The IDE and Floppy controllers support 2 devices. One as master
 
386
             * and one as slave (or floppy drive 0 and 1). */
 
387
            *aMaxDevicesPerPort = 2;
 
388
            break;
 
389
        }
 
390
        default:
 
391
            AssertMsgFailed(("Invalid bus type %d\n", aBus));
 
392
    }
 
393
 
 
394
    return S_OK;
 
395
}
 
396
 
 
397
STDMETHODIMP SystemProperties::GetMinPortCountForStorageBus (StorageBus_T aBus, ULONG *aMinPortCount)
 
398
{
 
399
    CheckComArgOutPointerValid(aMinPortCount);
 
400
 
 
401
    AutoCaller autoCaller(this);
 
402
    CheckComRCReturnRC(autoCaller.rc());
 
403
 
 
404
    /* no need to lock, this is const */
 
405
    switch (aBus)
 
406
    {
 
407
        case StorageBus_SATA:
 
408
        {
 
409
            *aMinPortCount = 1;
 
410
            break;
 
411
        }
 
412
        case StorageBus_SCSI:
 
413
        {
 
414
            *aMinPortCount = 16;
 
415
            break;
 
416
        }
 
417
        case StorageBus_IDE:
 
418
        {
 
419
            *aMinPortCount = 2;
 
420
            break;
 
421
        }
 
422
        case StorageBus_Floppy:
 
423
        {
 
424
            *aMinPortCount = 1;
 
425
            break;
 
426
        }
 
427
        default:
 
428
            AssertMsgFailed(("Invalid bus type %d\n", aBus));
 
429
    }
 
430
 
 
431
    return S_OK;
 
432
}
 
433
 
 
434
STDMETHODIMP SystemProperties::GetMaxPortCountForStorageBus (StorageBus_T aBus, ULONG *aMaxPortCount)
 
435
{
 
436
    CheckComArgOutPointerValid(aMaxPortCount);
 
437
 
 
438
    AutoCaller autoCaller(this);
 
439
    CheckComRCReturnRC(autoCaller.rc());
 
440
 
 
441
    /* no need to lock, this is const */
 
442
    switch (aBus)
 
443
    {
 
444
        case StorageBus_SATA:
 
445
        {
 
446
            *aMaxPortCount = 30;
 
447
            break;
 
448
        }
 
449
        case StorageBus_SCSI:
 
450
        {
 
451
            *aMaxPortCount = 16;
 
452
            break;
 
453
        }
 
454
        case StorageBus_IDE:
 
455
        {
 
456
            *aMaxPortCount = 2;
 
457
            break;
 
458
        }
 
459
        case StorageBus_Floppy:
 
460
        {
 
461
            *aMaxPortCount = 1;
 
462
            break;
 
463
        }
 
464
        default:
 
465
            AssertMsgFailed(("Invalid bus type %d\n", aBus));
 
466
    }
 
467
 
 
468
    return S_OK;
 
469
}
 
470
 
 
471
STDMETHODIMP SystemProperties::GetMaxInstancesOfStorageBus(StorageBus_T aBus, ULONG *aMaxInstances)
 
472
{
 
473
    CheckComArgOutPointerValid(aMaxInstances);
 
474
 
 
475
    AutoCaller autoCaller(this);
 
476
    CheckComRCReturnRC(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_Floppy:
 
485
        {
 
486
            /** @todo raise the limits ASAP, per bus type */
 
487
            *aMaxInstances = 1;
 
488
            break;
 
489
        }
 
490
        default:
 
491
            AssertMsgFailed(("Invalid bus type %d\n", aBus));
 
492
    }
 
493
 
 
494
    return S_OK;
 
495
}
 
496
 
 
497
STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
 
498
                                 ComSafeArrayOut(DeviceType_T, aDeviceTypes))
 
499
{
 
500
    CheckComArgOutSafeArrayPointerValid(aDeviceTypes);
 
501
 
 
502
    AutoCaller autoCaller(this);
 
503
    CheckComRCReturnRC(autoCaller.rc());
 
504
 
 
505
    /* no need to lock, this is const */
 
506
    switch (aBus)
 
507
    {
 
508
        case StorageBus_IDE:
 
509
        {
 
510
            com::SafeArray<DeviceType_T> saDeviceTypes(2);
 
511
            saDeviceTypes[0] = DeviceType_DVD;
 
512
            saDeviceTypes[1] = DeviceType_HardDisk;
 
513
            saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
 
514
            break;
 
515
        }
 
516
        case StorageBus_SATA:
 
517
        case StorageBus_SCSI:
 
518
        {
 
519
            com::SafeArray<DeviceType_T> saDeviceTypes(1);
 
520
            saDeviceTypes[0] = DeviceType_HardDisk;
 
521
            saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
 
522
            break;
 
523
        }
 
524
        case StorageBus_Floppy:
 
525
        {
 
526
            com::SafeArray<DeviceType_T> saDeviceTypes(1);
 
527
            saDeviceTypes[0] = DeviceType_Floppy;
 
528
            saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
 
529
            break;
 
530
        }
 
531
        default:
 
532
            AssertMsgFailed(("Invalid bus type %d\n", aBus));
 
533
    }
 
534
 
 
535
    return S_OK;
 
536
}
 
537
 
364
538
STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder) (BSTR *aDefaultMachineFolder)
365
539
{
366
540
    CheckComArgOutPointerValid(aDefaultMachineFolder);
367
541
 
368
 
    AutoCaller autoCaller (this);
369
 
    CheckComRCReturnRC (autoCaller.rc());
370
 
 
371
 
    AutoReadLock alock (this);
372
 
 
373
 
    mDefaultMachineFolderFull.cloneTo (aDefaultMachineFolder);
 
542
    AutoCaller autoCaller(this);
 
543
    CheckComRCReturnRC(autoCaller.rc());
 
544
 
 
545
    AutoReadLock alock(this);
 
546
 
 
547
    m_strDefaultMachineFolderFull.cloneTo(aDefaultMachineFolder);
374
548
 
375
549
    return S_OK;
376
550
}
377
551
 
378
552
STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder) (IN_BSTR aDefaultMachineFolder)
379
553
{
380
 
    AutoCaller autoCaller (this);
381
 
    CheckComRCReturnRC (autoCaller.rc());
 
554
    AutoCaller autoCaller(this);
 
555
    CheckComRCReturnRC(autoCaller.rc());
382
556
 
383
557
    /* VirtualBox::saveSettings() needs a write lock */
384
558
    AutoMultiWriteLock2 alock (mParent, this);
385
559
 
386
560
    HRESULT rc = setDefaultMachineFolder (aDefaultMachineFolder);
387
 
    if (SUCCEEDED (rc))
 
561
    if (SUCCEEDED(rc))
388
562
        rc = mParent->saveSettings();
389
563
 
390
564
    return rc;
394
568
{
395
569
    CheckComArgOutPointerValid(aDefaultHardDiskFolder);
396
570
 
397
 
    AutoCaller autoCaller (this);
398
 
    CheckComRCReturnRC (autoCaller.rc());
399
 
 
400
 
    AutoReadLock alock (this);
401
 
 
402
 
    mDefaultHardDiskFolderFull.cloneTo (aDefaultHardDiskFolder);
 
571
    AutoCaller autoCaller(this);
 
572
    CheckComRCReturnRC(autoCaller.rc());
 
573
 
 
574
    AutoReadLock alock(this);
 
575
 
 
576
    m_strDefaultHardDiskFolderFull.cloneTo(aDefaultHardDiskFolder);
403
577
 
404
578
    return S_OK;
405
579
}
406
580
 
407
581
STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFolder) (IN_BSTR aDefaultHardDiskFolder)
408
582
{
409
 
    AutoCaller autoCaller (this);
410
 
    CheckComRCReturnRC (autoCaller.rc());
 
583
    AutoCaller autoCaller(this);
 
584
    CheckComRCReturnRC(autoCaller.rc());
411
585
 
412
586
    /* VirtualBox::saveSettings() needs a write lock */
413
587
    AutoMultiWriteLock2 alock (mParent, this);
414
588
 
415
589
    HRESULT rc = setDefaultHardDiskFolder (aDefaultHardDiskFolder);
416
 
    if (SUCCEEDED (rc))
 
590
    if (SUCCEEDED(rc))
417
591
        rc = mParent->saveSettings();
418
592
 
419
593
    return rc;
420
594
}
421
595
 
422
596
STDMETHODIMP SystemProperties::
423
 
COMGETTER(HardDiskFormats) (ComSafeArrayOut (IHardDiskFormat *, aHardDiskFormats))
 
597
COMGETTER(MediumFormats) (ComSafeArrayOut(IMediumFormat *, aMediumFormats))
424
598
{
425
 
    if (ComSafeArrayOutIsNull (aHardDiskFormats))
 
599
    if (ComSafeArrayOutIsNull(aMediumFormats))
426
600
        return E_POINTER;
427
601
 
428
 
    AutoCaller autoCaller (this);
429
 
    CheckComRCReturnRC (autoCaller.rc());
430
 
 
431
 
    AutoReadLock alock (this);
432
 
 
433
 
    SafeIfaceArray <IHardDiskFormat> hardDiskFormats (mHardDiskFormats);
434
 
    hardDiskFormats.detachTo (ComSafeArrayOutArg (aHardDiskFormats));
 
602
    AutoCaller autoCaller(this);
 
603
    CheckComRCReturnRC(autoCaller.rc());
 
604
 
 
605
    AutoReadLock alock(this);
 
606
 
 
607
    SafeIfaceArray<IMediumFormat> mediumFormats (mMediumFormats);
 
608
    mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats));
435
609
 
436
610
    return S_OK;
437
611
}
440
614
{
441
615
    CheckComArgOutPointerValid(aDefaultHardDiskFormat);
442
616
 
443
 
    AutoCaller autoCaller (this);
444
 
    CheckComRCReturnRC (autoCaller.rc());
445
 
 
446
 
    AutoReadLock alock (this);
447
 
 
448
 
    mDefaultHardDiskFormat.cloneTo (aDefaultHardDiskFormat);
 
617
    AutoCaller autoCaller(this);
 
618
    CheckComRCReturnRC(autoCaller.rc());
 
619
 
 
620
    AutoReadLock alock(this);
 
621
 
 
622
    m_strDefaultHardDiskFormat.cloneTo(aDefaultHardDiskFormat);
449
623
 
450
624
    return S_OK;
451
625
}
452
626
 
453
627
STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat) (IN_BSTR aDefaultHardDiskFormat)
454
628
{
455
 
    AutoCaller autoCaller (this);
456
 
    CheckComRCReturnRC (autoCaller.rc());
 
629
    AutoCaller autoCaller(this);
 
630
    CheckComRCReturnRC(autoCaller.rc());
457
631
 
458
632
    /* VirtualBox::saveSettings() needs a write lock */
459
633
    AutoMultiWriteLock2 alock (mParent, this);
460
634
 
461
635
    HRESULT rc = setDefaultHardDiskFormat (aDefaultHardDiskFormat);
462
 
    if (SUCCEEDED (rc))
 
636
    if (SUCCEEDED(rc))
463
637
        rc = mParent->saveSettings();
464
638
 
465
639
    return rc;
469
643
{
470
644
    CheckComArgOutPointerValid(aRemoteDisplayAuthLibrary);
471
645
 
472
 
    AutoCaller autoCaller (this);
473
 
    CheckComRCReturnRC (autoCaller.rc());
474
 
 
475
 
    AutoReadLock alock (this);
476
 
 
477
 
    mRemoteDisplayAuthLibrary.cloneTo (aRemoteDisplayAuthLibrary);
 
646
    AutoCaller autoCaller(this);
 
647
    CheckComRCReturnRC(autoCaller.rc());
 
648
 
 
649
    AutoReadLock alock(this);
 
650
 
 
651
    m_strRemoteDisplayAuthLibrary.cloneTo(aRemoteDisplayAuthLibrary);
478
652
 
479
653
    return S_OK;
480
654
}
481
655
 
482
656
STDMETHODIMP SystemProperties::COMSETTER(RemoteDisplayAuthLibrary) (IN_BSTR aRemoteDisplayAuthLibrary)
483
657
{
484
 
    AutoCaller autoCaller (this);
485
 
    CheckComRCReturnRC (autoCaller.rc());
 
658
    AutoCaller autoCaller(this);
 
659
    CheckComRCReturnRC(autoCaller.rc());
486
660
 
487
661
    /* VirtualBox::saveSettings() needs a write lock */
488
662
    AutoMultiWriteLock2 alock (mParent, this);
489
663
 
490
664
    HRESULT rc = setRemoteDisplayAuthLibrary (aRemoteDisplayAuthLibrary);
491
 
    if (SUCCEEDED (rc))
 
665
    if (SUCCEEDED(rc))
492
666
        rc = mParent->saveSettings();
493
667
 
494
668
    return rc;
498
672
{
499
673
    CheckComArgOutPointerValid(aWebServiceAuthLibrary);
500
674
 
501
 
    AutoCaller autoCaller (this);
502
 
    CheckComRCReturnRC (autoCaller.rc());
503
 
 
504
 
    AutoReadLock alock (this);
505
 
 
506
 
    mWebServiceAuthLibrary.cloneTo (aWebServiceAuthLibrary);
 
675
    AutoCaller autoCaller(this);
 
676
    CheckComRCReturnRC(autoCaller.rc());
 
677
 
 
678
    AutoReadLock alock(this);
 
679
 
 
680
    m_strWebServiceAuthLibrary.cloneTo(aWebServiceAuthLibrary);
507
681
 
508
682
    return S_OK;
509
683
}
510
684
 
511
685
STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary) (IN_BSTR aWebServiceAuthLibrary)
512
686
{
513
 
    AutoCaller autoCaller (this);
514
 
    CheckComRCReturnRC (autoCaller.rc());
 
687
    AutoCaller autoCaller(this);
 
688
    CheckComRCReturnRC(autoCaller.rc());
515
689
 
516
690
    /* VirtualBox::saveSettings() needs a write lock */
517
691
    AutoMultiWriteLock2 alock (mParent, this);
518
692
 
519
693
    HRESULT rc = setWebServiceAuthLibrary (aWebServiceAuthLibrary);
520
 
    if (SUCCEEDED (rc))
 
694
    if (SUCCEEDED(rc))
521
695
        rc = mParent->saveSettings();
522
696
 
523
697
    return rc;
528
702
    if (!count)
529
703
        return E_POINTER;
530
704
 
531
 
    AutoCaller autoCaller (this);
532
 
    CheckComRCReturnRC (autoCaller.rc());
 
705
    AutoCaller autoCaller(this);
 
706
    CheckComRCReturnRC(autoCaller.rc());
533
707
 
534
 
    AutoReadLock alock (this);
 
708
    AutoReadLock alock(this);
535
709
 
536
710
    *count = mLogHistoryCount;
537
711
 
540
714
 
541
715
STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount) (ULONG count)
542
716
{
543
 
    AutoCaller autoCaller (this);
544
 
    CheckComRCReturnRC (autoCaller.rc());
 
717
    AutoCaller autoCaller(this);
 
718
    CheckComRCReturnRC(autoCaller.rc());
545
719
 
546
720
    /* VirtualBox::saveSettings() needs a write lock */
547
721
    AutoMultiWriteLock2 alock (mParent, this);
558
732
    if (!aAudioDriver)
559
733
        return E_POINTER;
560
734
 
561
 
    AutoCaller autoCaller (this);
562
 
    CheckComRCReturnRC (autoCaller.rc());
 
735
    AutoCaller autoCaller(this);
 
736
    CheckComRCReturnRC(autoCaller.rc());
563
737
 
564
 
    AutoReadLock alock (this);
 
738
    AutoReadLock alock(this);
565
739
 
566
740
    *aAudioDriver = mDefaultAudioDriver;
567
741
 
571
745
// public methods only for internal purposes
572
746
/////////////////////////////////////////////////////////////////////////////
573
747
 
574
 
HRESULT SystemProperties::loadSettings (const settings::Key &aGlobal)
 
748
HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
575
749
{
576
 
    using namespace settings;
577
 
 
578
 
    AutoCaller autoCaller (this);
579
 
    CheckComRCReturnRC (autoCaller.rc());
580
 
 
581
 
    AutoWriteLock alock (this);
582
 
 
583
 
    AssertReturn (!aGlobal.isNull(), E_FAIL);
 
750
    AutoCaller autoCaller(this);
 
751
    CheckComRCReturnRC(autoCaller.rc());
 
752
 
 
753
    AutoWriteLock alock(this);
584
754
 
585
755
    HRESULT rc = S_OK;
586
756
 
587
 
    Key properties = aGlobal.key ("SystemProperties");
588
 
 
589
 
    Bstr bstr;
590
 
 
591
 
    bstr = properties.stringValue ("defaultMachineFolder");
592
 
    rc = setDefaultMachineFolder (bstr);
593
 
    CheckComRCReturnRC (rc);
594
 
 
595
 
    bstr = properties.stringValue ("defaultHardDiskFolder");
596
 
    rc = setDefaultHardDiskFolder (bstr);
597
 
    CheckComRCReturnRC (rc);
598
 
 
599
 
    bstr = properties.stringValue ("defaultHardDiskFormat");
600
 
    rc = setDefaultHardDiskFormat (bstr);
601
 
    CheckComRCReturnRC (rc);
602
 
 
603
 
    bstr = properties.stringValue ("remoteDisplayAuthLibrary");
604
 
    rc = setRemoteDisplayAuthLibrary (bstr);
605
 
    CheckComRCReturnRC (rc);
606
 
 
607
 
    bstr = properties.stringValue ("webServiceAuthLibrary");
608
 
    rc = setWebServiceAuthLibrary (bstr);
609
 
    CheckComRCReturnRC (rc);
610
 
 
611
 
    mLogHistoryCount = properties.valueOr <ULONG> ("LogHistoryCount", 3);
 
757
    rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
 
758
    CheckComRCReturnRC(rc);
 
759
 
 
760
    rc = setDefaultHardDiskFolder(data.strDefaultHardDiskFolder);
 
761
    CheckComRCReturnRC(rc);
 
762
 
 
763
    rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
 
764
    CheckComRCReturnRC(rc);
 
765
 
 
766
    rc = setRemoteDisplayAuthLibrary(data.strRemoteDisplayAuthLibrary);
 
767
    CheckComRCReturnRC(rc);
 
768
 
 
769
    rc = setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
 
770
    CheckComRCReturnRC(rc);
 
771
 
 
772
    mLogHistoryCount = data.ulLogHistoryCount;
612
773
 
613
774
    return S_OK;
614
775
}
615
776
 
616
 
HRESULT SystemProperties::saveSettings (settings::Key &aGlobal)
 
777
HRESULT SystemProperties::saveSettings(settings::SystemProperties &data)
617
778
{
618
 
    using namespace settings;
619
 
 
620
 
    AutoCaller autoCaller (this);
621
 
    CheckComRCReturnRC (autoCaller.rc());
622
 
 
623
 
    AutoReadLock alock (this);
624
 
 
625
 
    ComAssertRet (!aGlobal.isNull(), E_FAIL);
626
 
 
627
 
    /* first, delete the entry */
628
 
    Key properties = aGlobal.findKey ("SystemProperties");
629
 
    if (!properties.isNull())
630
 
        properties.zap();
631
 
    /* then, recreate it */
632
 
    properties = aGlobal.createKey ("SystemProperties");
633
 
 
634
 
    if (mDefaultMachineFolder)
635
 
        properties.setValue <Bstr> ("defaultMachineFolder", mDefaultMachineFolder);
636
 
 
637
 
    if (mDefaultHardDiskFolder)
638
 
        properties.setValue <Bstr> ("defaultHardDiskFolder", mDefaultHardDiskFolder);
639
 
 
640
 
    if (mDefaultHardDiskFormat)
641
 
        properties.setValue <Bstr> ("defaultHardDiskFormat", mDefaultHardDiskFormat);
642
 
 
643
 
    if (mRemoteDisplayAuthLibrary)
644
 
        properties.setValue <Bstr> ("remoteDisplayAuthLibrary", mRemoteDisplayAuthLibrary);
645
 
 
646
 
    if (mWebServiceAuthLibrary)
647
 
        properties.setValue <Bstr> ("webServiceAuthLibrary", mWebServiceAuthLibrary);
648
 
 
649
 
    properties.setValue <ULONG> ("LogHistoryCount", mLogHistoryCount);
 
779
    AutoCaller autoCaller(this);
 
780
    CheckComRCReturnRC(autoCaller.rc());
 
781
 
 
782
    AutoReadLock alock(this);
 
783
 
 
784
    data.strDefaultMachineFolder = m_strDefaultMachineFolder;
 
785
    data.strDefaultHardDiskFolder = m_strDefaultHardDiskFolder;
 
786
    data.strDefaultHardDiskFormat = m_strDefaultHardDiskFormat;
 
787
    data.strRemoteDisplayAuthLibrary = m_strRemoteDisplayAuthLibrary;
 
788
    data.strWebServiceAuthLibrary = m_strWebServiceAuthLibrary;
 
789
    data.ulLogHistoryCount = mLogHistoryCount;
650
790
 
651
791
    return S_OK;
652
792
}
653
793
 
654
794
/**
655
 
 * Rerurns a hard disk format object corresponding to the given format
 
795
 * Returns a medium format object corresponding to the given format
656
796
 * identifier or null if no such format.
657
797
 *
658
798
 * @param aFormat   Format identifier.
659
799
 *
660
 
 * @return ComObjPtr<HardDiskFormat>
 
800
 * @return ComObjPtr<MediumFormat>
661
801
 */
662
 
ComObjPtr <HardDiskFormat> SystemProperties::hardDiskFormat (CBSTR aFormat)
 
802
ComObjPtr<MediumFormat> SystemProperties::mediumFormat (CBSTR aFormat)
663
803
{
664
 
    ComObjPtr <HardDiskFormat> format;
 
804
    ComObjPtr<MediumFormat> format;
665
805
 
666
 
    AutoCaller autoCaller (this);
 
806
    AutoCaller autoCaller(this);
667
807
    AssertComRCReturn (autoCaller.rc(), format);
668
808
 
669
 
    AutoReadLock alock (this);
 
809
    AutoReadLock alock(this);
670
810
 
671
 
    for (HardDiskFormatList::const_iterator it = mHardDiskFormats.begin();
672
 
         it != mHardDiskFormats.end(); ++ it)
 
811
    for (MediumFormatList::const_iterator it = mMediumFormats.begin();
 
812
         it != mMediumFormats.end(); ++ it)
673
813
    {
674
 
        /* HardDiskFormat is all const, no need to lock */
 
814
        /* MediumFormat is all const, no need to lock */
675
815
 
676
816
        if ((*it)->id().compareIgnoreCase (aFormat) == 0)
677
817
        {
686
826
// private methods
687
827
/////////////////////////////////////////////////////////////////////////////
688
828
 
689
 
HRESULT SystemProperties::setDefaultMachineFolder (CBSTR aPath)
 
829
HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &aPath)
690
830
{
691
 
    Utf8Str path;
692
 
    if (aPath && *aPath)
693
 
        path = aPath;
694
 
    else
 
831
    Utf8Str path(aPath);
 
832
    if (path.isEmpty())
695
833
        path = "Machines";
696
834
 
697
835
    /* get the full file name */
698
836
    Utf8Str folder;
699
 
    int vrc = mParent->calculateFullPath (path, folder);
700
 
    if (RT_FAILURE (vrc))
701
 
        return setError (E_FAIL,
702
 
            tr ("Invalid default machine folder '%ls' (%Rrc)"),
703
 
            path.raw(), vrc);
 
837
    int vrc = mParent->calculateFullPath(path, folder);
 
838
    if (RT_FAILURE(vrc))
 
839
        return setError(E_FAIL,
 
840
                        tr("Invalid default machine folder '%s' (%Rrc)"),
 
841
                        path.raw(),
 
842
                        vrc);
704
843
 
705
 
    mDefaultMachineFolder = path;
706
 
    mDefaultMachineFolderFull = folder;
 
844
    m_strDefaultMachineFolder = path;
 
845
    m_strDefaultMachineFolderFull = folder;
707
846
 
708
847
    return S_OK;
709
848
}
710
849
 
711
 
HRESULT SystemProperties::setDefaultHardDiskFolder (CBSTR aPath)
 
850
HRESULT SystemProperties::setDefaultHardDiskFolder(const Utf8Str &aPath)
712
851
{
713
 
    Utf8Str path;
714
 
    if (aPath && *aPath)
715
 
        path = aPath;
716
 
    else
 
852
    Utf8Str path(aPath);
 
853
    if (path.isEmpty())
717
854
        path = "HardDisks";
718
855
 
719
856
    /* get the full file name */
720
857
    Utf8Str folder;
721
 
    int vrc = mParent->calculateFullPath (path, folder);
722
 
    if (RT_FAILURE (vrc))
723
 
        return setError (E_FAIL,
724
 
            tr ("Invalid default hard disk folder '%ls' (%Rrc)"),
725
 
            path.raw(), vrc);
726
 
 
727
 
    mDefaultHardDiskFolder = path;
728
 
    mDefaultHardDiskFolderFull = folder;
729
 
 
730
 
    return S_OK;
731
 
}
732
 
 
733
 
HRESULT SystemProperties::setDefaultHardDiskFormat (CBSTR aFormat)
734
 
{
735
 
    if (aFormat && *aFormat)
736
 
        mDefaultHardDiskFormat = aFormat;
737
 
    else
738
 
        mDefaultHardDiskFormat = "VDI";
739
 
 
740
 
    return S_OK;
741
 
}
742
 
 
743
 
HRESULT SystemProperties::setRemoteDisplayAuthLibrary (CBSTR aPath)
744
 
{
745
 
    if (aPath && *aPath)
746
 
        mRemoteDisplayAuthLibrary = aPath;
747
 
    else
748
 
        mRemoteDisplayAuthLibrary = "VRDPAuth";
749
 
 
750
 
    return S_OK;
751
 
}
752
 
 
753
 
HRESULT SystemProperties::setWebServiceAuthLibrary (CBSTR aPath)
754
 
{
755
 
    if (aPath && *aPath)
756
 
        mWebServiceAuthLibrary = aPath;
757
 
    else
758
 
        mWebServiceAuthLibrary = "VRDPAuth";
759
 
 
760
 
    return S_OK;
761
 
}
762
 
/* vi: set tabstop=4 shiftwidth=4 expandtab: */
 
858
    int vrc = mParent->calculateFullPath(path, folder);
 
859
    if (RT_FAILURE(vrc))
 
860
        return setError(E_FAIL,
 
861
                        tr("Invalid default hard disk folder '%s' (%Rrc)"),
 
862
                        path.raw(),
 
863
                        vrc);
 
864
 
 
865
    m_strDefaultHardDiskFolder = path;
 
866
    m_strDefaultHardDiskFolderFull = folder;
 
867
 
 
868
    return S_OK;
 
869
}
 
870
 
 
871
HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
 
872
{
 
873
    if (!aFormat.isEmpty())
 
874
        m_strDefaultHardDiskFormat = aFormat;
 
875
    else
 
876
        m_strDefaultHardDiskFormat = "VDI";
 
877
 
 
878
    return S_OK;
 
879
}
 
880
 
 
881
HRESULT SystemProperties::setRemoteDisplayAuthLibrary(const Utf8Str &aPath)
 
882
{
 
883
    if (!aPath.isEmpty())
 
884
        m_strRemoteDisplayAuthLibrary = aPath;
 
885
    else
 
886
        m_strRemoteDisplayAuthLibrary = "VRDPAuth";
 
887
 
 
888
    return S_OK;
 
889
}
 
890
 
 
891
HRESULT SystemProperties::setWebServiceAuthLibrary(const Utf8Str &aPath)
 
892
{
 
893
    if (!aPath.isEmpty())
 
894
        m_strWebServiceAuthLibrary = aPath;
 
895
    else
 
896
        m_strWebServiceAuthLibrary = "VRDPAuth";
 
897
 
 
898
    return S_OK;
 
899
}
 
900