VirtualBox

Changeset 13606 in vbox


Ignore:
Timestamp:
Oct 28, 2008 10:36:13 AM (16 years ago)
Author:
vboxsync
Message:

Main: First bulk of classes transfered to the new locking scheme.

Location:
trunk/src/VBox/Main
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r12423 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    20092011/////////////////////////////////////////////////////////////////////////////
    20102012
     2013DEFINE_EMPTY_CTOR_DTOR (RemoteDisplayInfo)
     2014
    20112015HRESULT RemoteDisplayInfo::FinalConstruct()
    20122016{
     
    20162020void RemoteDisplayInfo::FinalRelease()
    20172021{
    2018     if (isReady())
    2019         uninit ();
     2022    uninit ();
    20202023}
    20212024
     
    20282031HRESULT RemoteDisplayInfo::init (Console *aParent)
    20292032{
    2030     LogFlowMember (("RemoteDisplayInfo::init (%p)\n", aParent));
     2033    LogFlowThisFunc (("aParent=%p\n", aParent));
    20312034
    20322035    ComAssertRet (aParent, E_INVALIDARG);
    20332036
    2034     AutoWriteLock alock (this);
    2035     ComAssertRet (!isReady(), E_UNEXPECTED);
    2036 
    2037     mParent = aParent;
    2038 
    2039     setReady (true);
     2037    /* Enclose the state transition NotReady->InInit->Ready */
     2038    AutoInitSpan autoInitSpan (this);
     2039    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     2040
     2041    unconst (mParent) = aParent;
     2042
    20402043    return S_OK;
    20412044}
     
    20472050void RemoteDisplayInfo::uninit()
    20482051{
    2049     LogFlowMember (("RemoteDisplayInfo::uninit()\n"));
    2050 
    2051     AutoWriteLock alock (this);
    2052     AssertReturn (isReady(), (void) 0);
    2053 
    2054     mParent.setNull();
    2055 
    2056     setReady (false);
     2052    LogFlowThisFunc (("\n"));
     2053
     2054    /* Enclose the state transition Ready->InUninit->NotReady */
     2055    AutoUninitSpan autoUninitSpan (this);
     2056    if (autoUninitSpan.uninitDone())
     2057        return;
     2058
     2059    unconst (mParent).setNull();
    20572060}
    20582061
     
    20662069            return E_POINTER;                                             \
    20672070                                                                          \
    2068         AutoWriteLock alock (this);                                            \
    2069         CHECK_READY();                                                    \
     2071        AutoCaller autoCaller (this);                                     \
     2072        CheckComRCReturnRC (autoCaller.rc());                             \
     2073                                                                          \
     2074        /* todo: Not sure if a AutoReadLock would be sufficient. */       \
     2075        AutoWriteLock alock (this);                                       \
    20702076                                                                          \
    20712077        uint32_t value;                                                   \
     
    20862092            return E_POINTER;                                             \
    20872093                                                                          \
    2088         AutoWriteLock alock (this);                                            \
    2089         CHECK_READY();                                                    \
     2094        AutoCaller autoCaller (this);                                     \
     2095        CheckComRCReturnRC (autoCaller.rc());                             \
     2096                                                                          \
     2097        /* todo: Not sure if a AutoReadLock would be sufficient. */       \
     2098        AutoWriteLock alock (this);                                       \
    20902099                                                                          \
    20912100        _aType value;                                                     \
     
    21062115            return E_POINTER;                                             \
    21072116                                                                          \
    2108         AutoWriteLock alock (this);                                            \
    2109         CHECK_READY();                                                    \
     2117        AutoCaller autoCaller (this);                                     \
     2118        CheckComRCReturnRC (autoCaller.rc());                             \
     2119                                                                          \
     2120        /* todo: Not sure if a AutoReadLock would be sufficient. */       \
     2121        AutoWriteLock alock (this);                                       \
    21102122                                                                          \
    21112123        uint32_t cbOut = 0;                                               \
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r12925 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6365/////////////////////////////////////////////////////////////////////////////
    6466
     67DEFINE_EMPTY_CTOR_DTOR (Display)
     68
    6569HRESULT Display::FinalConstruct()
    6670{
     
    7983    mcbVbvaPartial = 0;
    8084
    81     mParent = NULL;
    8285    mpDrv = NULL;
    8386    mpVMMDev = NULL;
     
    9699void Display::FinalRelease()
    97100{
    98     if (isReady())
    99         uninit();
     101    uninit();
    100102}
    101103
     
    110112 * @param qemuConsoleData address of common console data structure
    111113 */
    112 HRESULT Display::init (Console *parent)
    113 {
    114     LogFlowFunc (("isReady=%d", isReady()));
    115 
    116     ComAssertRet (parent, E_INVALIDARG);
    117 
    118     AutoWriteLock alock (this);
    119     ComAssertRet (!isReady(), E_UNEXPECTED);
    120 
    121     mParent = parent;
     114HRESULT Display::init (Console *aParent)
     115{
     116    LogFlowThisFunc (("aParent=%p\n", aParent));
     117
     118    ComAssertRet (aParent, E_INVALIDARG);
     119
     120    /* Enclose the state transition NotReady->InInit->Ready */
     121    AutoInitSpan autoInitSpan (this);
     122    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     123
     124    unconst (mParent) = aParent;
    122125
    123126    /* reset the event sems */
    124     RTSemEventMultiReset(mUpdateSem);
     127    RTSemEventMultiReset (mUpdateSem);
    125128
    126129    // by default, we have an internal framebuffer which is
     
    157160    }
    158161
    159     mParent->RegisterCallback(this);
    160 
    161     setReady (true);
     162    mParent->RegisterCallback (this);
     163
     164    /* Confirm a successful initialization */
     165    autoInitSpan.setSucceeded();
     166
    162167    return S_OK;
    163168}
     
    169174void Display::uninit()
    170175{
    171     LogFlowFunc (("isReady=%d\n", isReady()));
    172 
    173     AutoWriteLock alock (this);
    174     AssertReturn (isReady(), (void) 0);
     176    LogFlowThisFunc (("\n"));
     177
     178    /* Enclose the state transition Ready->InUninit->NotReady */
     179    AutoUninitSpan autoUninitSpan (this);
     180    if (autoUninitSpan.uninitDone())
     181        return;
    175182
    176183    ULONG ul;
    177184    for (ul = 0; ul < mcMonitors; ul++)
    178     {
    179185        maFramebuffers[ul].pFramebuffer = NULL;
    180     }
    181 
    182     RTSemEventMultiDestroy(mUpdateSem);
     186
     187    RTSemEventMultiDestroy (mUpdateSem);
    183188
    184189    if (mParent)
    185     {
    186         mParent->UnregisterCallback(this);
    187     }
     190        mParent->UnregisterCallback (this);
     191
     192    unconst (mParent).setNull();
    188193
    189194    if (mpDrv)
    190195        mpDrv->pDisplay = NULL;
     196
    191197    mpDrv = NULL;
    192198    mpVMMDev = NULL;
    193199    mfVMMDevInited = true;
    194 
    195     setReady (false);
    196200}
    197201
     
    206210    }
    207211    else
    208     {
    209212        mfMachineRunning = false;
    210     }
     213
    211214    return S_OK;
    212215}
     
    12501253        return E_POINTER;
    12511254
     1255    AutoCaller autoCaller (this);
     1256    CheckComRCReturnRC (autoCaller.rc());
     1257
    12521258    AutoWriteLock alock (this);
    1253     CHECK_READY();
    12541259
    12551260    CHECK_CONSOLE_DRV (mpDrv);
    12561261
    12571262    *width = mpDrv->Connector.cx;
     1263
    12581264    return S_OK;
    12591265}
     
    12701276        return E_POINTER;
    12711277
     1278    AutoCaller autoCaller (this);
     1279    CheckComRCReturnRC (autoCaller.rc());
     1280
    12721281    AutoWriteLock alock (this);
    1273     CHECK_READY();
    12741282
    12751283    CHECK_CONSOLE_DRV (mpDrv);
    12761284
    12771285    *height = mpDrv->Connector.cy;
     1286
    12781287    return S_OK;
    12791288}
     
    12901299        return E_INVALIDARG;
    12911300
     1301    AutoCaller autoCaller (this);
     1302    CheckComRCReturnRC (autoCaller.rc());
     1303
    12921304    AutoWriteLock alock (this);
    1293     CHECK_READY();
    12941305
    12951306    CHECK_CONSOLE_DRV (mpDrv);
     
    12991310    AssertRC(rc);
    13001311    *bitsPerPixel = cBits;
     1312
    13011313    return S_OK;
    13021314}
     
    13101322    LogFlowFunc (("\n"));
    13111323
     1324    AutoCaller autoCaller (this);
     1325    CheckComRCReturnRC (autoCaller.rc());
     1326
    13121327    AutoWriteLock alock (this);
    1313     CHECK_READY();
    13141328
    13151329    /*
     
    13611375        return E_POINTER;
    13621376
     1377    AutoCaller autoCaller (this);
     1378    CheckComRCReturnRC (autoCaller.rc());
     1379
    13631380    AutoWriteLock alock (this);
    1364     CHECK_READY();
    13651381
    13661382    /* only allowed for internal framebuffers */
     
    13761392
    13771393    return setError (E_FAIL,
    1378         tr ("Framebuffer locking is allowed only for the internal framebuffer"));
     1394                     tr ("Framebuffer locking is allowed only for the internal framebuffer"));
    13791395}
    13801396
    13811397STDMETHODIMP Display::UnlockFramebuffer()
    13821398{
     1399    AutoCaller autoCaller (this);
     1400    CheckComRCReturnRC (autoCaller.rc());
     1401
    13831402    AutoWriteLock alock (this);
    1384     CHECK_READY();
    13851403
    13861404    if (mFramebufferOpened)
     
    13941412
    13951413    return setError (E_FAIL,
    1396         tr ("Framebuffer locking is allowed only for the internal framebuffer"));
     1414                     tr ("Framebuffer locking is allowed only for the internal framebuffer"));
    13971415}
    13981416
     
    14041422        return E_POINTER;
    14051423
     1424    AutoCaller autoCaller (this);
     1425    CheckComRCReturnRC (autoCaller.rc());
     1426
    14061427    AutoWriteLock alock (this);
    1407     CHECK_READY();
    14081428
    14091429    Console::SafeVMPtrQuiet pVM (mParent);
     
    14431463        return E_POINTER;
    14441464
     1465    AutoCaller autoCaller (this);
     1466    CheckComRCReturnRC (autoCaller.rc());
     1467
    14451468    AutoWriteLock alock (this);
    1446     CHECK_READY();
    14471469
    14481470    Console::SafeVMPtrQuiet pVM (mParent);
     
    14821504        return E_POINTER;
    14831505
     1506    AutoCaller autoCaller (this);
     1507    CheckComRCReturnRC (autoCaller.rc());
     1508
    14841509    AutoWriteLock alock (this);
    1485     CHECK_READY();
    14861510
    14871511    /* @todo this should be actually done on EMT. */
     
    15011525STDMETHODIMP Display::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aBitsPerPixel, ULONG aDisplay)
    15021526{
     1527    AutoCaller autoCaller (this);
     1528    CheckComRCReturnRC (autoCaller.rc());
     1529
    15031530    AutoWriteLock alock (this);
    1504     CHECK_READY();
    15051531
    15061532    CHECK_CONSOLE_DRV (mpDrv);
     
    15481574STDMETHODIMP Display::SetSeamlessMode (BOOL enabled)
    15491575{
     1576    AutoCaller autoCaller (this);
     1577    CheckComRCReturnRC (autoCaller.rc());
     1578
    15501579    AutoWriteLock alock (this);
    1551     CHECK_READY();
    15521580
    15531581    /* Have to leave the lock because the pfnRequestSeamlessChange will call EMT.  */
     
    15771605        return E_INVALIDARG;
    15781606
     1607    AutoCaller autoCaller (this);
     1608    CheckComRCReturnRC (autoCaller.rc());
     1609
    15791610    AutoWriteLock alock (this);
    1580     CHECK_READY();
    15811611
    15821612    CHECK_CONSOLE_DRV (mpDrv);
     
    15911621    /*
    15921622     * First try use the graphics device features for making a snapshot.
    1593      * This does not support streatching, is an optional feature (returns not supported).
     1623     * This does not support stretching, is an optional feature (returns not supported).
    15941624     *
    15951625     * Note: It may cause a display resize. Watch out for deadlocks.
     
    16121642
    16131643    /*
    1614      * If the function returns not supported, or if streaching is requested,
     1644     * If the function returns not supported, or if stretching is requested,
    16151645     * we'll have to do all the work ourselves using the framebuffer data.
    16161646     */
    16171647    if (rcVBox == VERR_NOT_SUPPORTED || rcVBox == VERR_NOT_IMPLEMENTED)
    16181648    {
    1619         /** @todo implement snapshot streching and generic snapshot fallback. */
     1649        /** @todo implement snapshot stretching and generic snapshot fallback. */
    16201650        rc = setError (E_NOTIMPL, tr ("This feature is not implemented"));
    16211651    }
     
    16471677        return E_INVALIDARG;
    16481678
     1679    AutoCaller autoCaller (this);
     1680    CheckComRCReturnRC (autoCaller.rc());
     1681
    16491682    AutoWriteLock alock (this);
    1650     CHECK_READY();
    16511683
    16521684    CHECK_CONSOLE_DRV (mpDrv);
     
    16571689    /*
    16581690     * Again we're lazy and make the graphics device do all the
    1659      * dirty convertion work.
     1691     * dirty conversion work.
    16601692     */
    16611693    PVMREQ pReq;
     
    17041736    LogFlowFuncEnter();
    17051737
     1738    AutoCaller autoCaller (this);
     1739    CheckComRCReturnRC (autoCaller.rc());
     1740
    17061741    AutoWriteLock alock (this);
    1707     CHECK_READY();
    17081742
    17091743    CHECK_CONSOLE_DRV (mpDrv);
     
    17501784    //  (and therefore don't use Display lock at all here to save some
    17511785    //  milliseconds).
    1752     CHECK_READY();
     1786    AutoCaller autoCaller (this);
     1787    CheckComRCReturnRC (autoCaller.rc());
    17531788
    17541789    /* this is only valid for external framebuffers */
     
    17831818    //  (and therefore don't use Display lock at all here to save some
    17841819    //  milliseconds).
    1785     CHECK_READY();
     1820    AutoCaller autoCaller (this);
     1821    CheckComRCReturnRC (autoCaller.rc());
    17861822
    17871823    /* this is only valid for external framebuffers */
     
    19071943    AssertReturn (uScreenId < that->mcMonitors, VERR_INVALID_PARAMETER);
    19081944
    1909     /// @todo (r=dmik) AutoCaller
     1945    AutoCaller autoCaller (that);
     1946    CheckComRCReturnRC (autoCaller.rc());
    19101947
    19111948    AutoWriteLock alock (that);
     
    22642301    }
    22652302
    2266     /* Get the display information strcuture. */
     2303    /* Get the display information structure. */
    22672304    DISPLAYFBINFO *pFBInfo = &pDrv->pDisplay->maFramebuffers[uScreenId];
    22682305
  • trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp

    r8155 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2123
    2224#include "HostNetworkInterfaceImpl.h"
     25#include "Logging.h"
    2326
    2427// constructor / destructor
    2528/////////////////////////////////////////////////////////////////////////////
    2629
    27 HostNetworkInterface::HostNetworkInterface()
     30DEFINE_EMPTY_CTOR_DTOR (HostNetworkInterface)
     31
     32HRESULT HostNetworkInterface::FinalConstruct()
    2833{
     34    return S_OK;
    2935}
    3036
    31 HostNetworkInterface::~HostNetworkInterface()
     37void HostNetworkInterface::FinalRelease()
    3238{
     39    uninit ();
    3340}
    3441
     
    4047 *
    4148 * @returns COM result indicator
    42  * @param   interfaceName name of the network interface
     49 * @param   aInterfaceName name of the network interface
     50 * @param   aGuid GUID of the host network interface
    4351 */
    44 HRESULT HostNetworkInterface::init (Bstr interfaceName, Guid guid)
     52HRESULT HostNetworkInterface::init (Bstr aInterfaceName, Guid aGuid)
    4553{
    46     ComAssertRet (interfaceName, E_INVALIDARG);
    47     ComAssertRet (!guid.isEmpty(), E_INVALIDARG);
     54    LogFlowThisFunc (("aInterfaceName={%ls}, aGuid={%s}\n",
     55                      aInterfaceName.raw(), aGuid.toString().raw()));
    4856
    49     AutoWriteLock alock (this);
    50     mInterfaceName = interfaceName;
    51     mGuid = guid;
    52     setReady(true);
     57    ComAssertRet (aInterfaceName, E_INVALIDARG);
     58    ComAssertRet (!aGuid.isEmpty(), E_INVALIDARG);
     59
     60    /* Enclose the state transition NotReady->InInit->Ready */
     61    AutoInitSpan autoInitSpan (this);
     62    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     63
     64    unconst (mInterfaceName) = aInterfaceName;
     65    unconst (mGuid) = aGuid;
     66
     67    /* Confirm a successful initialization */
     68    autoInitSpan.setSucceeded();
     69
    5370    return S_OK;
    5471}
     
    6178 *
    6279 * @returns COM status code
    63  * @param   interfaceName address of result pointer
     80 * @param   aInterfaceName address of result pointer
    6481 */
    65 STDMETHODIMP HostNetworkInterface::COMGETTER(Name) (BSTR *interfaceName)
     82STDMETHODIMP HostNetworkInterface::COMGETTER(Name) (BSTR *aInterfaceName)
    6683{
    67     if (!interfaceName)
     84    if (!aInterfaceName)
    6885        return E_POINTER;
    69     AutoWriteLock alock (this);
    70     CHECK_READY();
    71     mInterfaceName.cloneTo(interfaceName);
     86
     87    AutoCaller autoCaller (this);
     88    CheckComRCReturnRC (autoCaller.rc());
     89
     90    mInterfaceName.cloneTo (aInterfaceName);
     91
    7292    return S_OK;
    7393}
     
    7797 *
    7898 * @returns COM status code
    79  * @param   guid address of result pointer
     99 * @param   aGuid address of result pointer
    80100 */
    81 STDMETHODIMP HostNetworkInterface::COMGETTER(Id) (GUIDPARAMOUT guid)
     101STDMETHODIMP HostNetworkInterface::COMGETTER(Id) (GUIDPARAMOUT aGuid)
    82102{
    83     if (!guid)
     103    if (!aGuid)
    84104        return E_POINTER;
    85     AutoWriteLock alock (this);
    86     CHECK_READY();
    87     mGuid.cloneTo(guid);
     105
     106    AutoCaller autoCaller (this);
     107    CheckComRCReturnRC (autoCaller.rc());
     108
     109    mGuid.cloneTo (aGuid);
     110
    88111    return S_OK;
    89112}
     113
  • trunk/src/VBox/Main/KeyboardImpl.cpp

    r11661 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5759////////////////////////////////////////////////////////////////////////////////
    5860
     61DEFINE_EMPTY_CTOR_DTOR (Keyboard)
     62
    5963HRESULT Keyboard::FinalConstruct()
    6064{
    61     mParent = NULL;
    6265    mpDrv = NULL;
    6366    mpVMMDev = NULL;
     
    6871void Keyboard::FinalRelease()
    6972{
    70     if (isReady())
    71         uninit();
     73    uninit();
    7274}
    7375
     
    8183 * @param parent handle of our parent object
    8284 */
    83 HRESULT Keyboard::init (Console *parent)
    84 {
    85     LogFlow(("Keyboard::init(): isReady=%d\n", isReady()));
    86 
    87     ComAssertRet (parent, E_INVALIDARG);
    88 
    89     AutoWriteLock alock (this);
    90     ComAssertRet (!isReady(), E_UNEXPECTED);
    91 
    92     mParent = parent;
    93 
    94     setReady (true);
     85HRESULT Keyboard::init (Console *aParent)
     86{
     87    LogFlowThisFunc (("aParent=%p\n", aParent));
     88
     89    ComAssertRet (aParent, E_INVALIDARG);
     90
     91    /* Enclose the state transition NotReady->InInit->Ready */
     92    AutoInitSpan autoInitSpan (this);
     93    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     94
     95    unconst (mParent) = aParent;
     96
     97    /* Confirm a successful initialization */
     98    autoInitSpan.setSucceeded();
     99
    95100    return S_OK;
    96101}
     
    102107void Keyboard::uninit()
    103108{
    104     LogFlow(("Keyboard::uninit(): isReady=%d\n", isReady()));
    105 
    106     AutoWriteLock alock (this);
    107     AssertReturn (isReady(), (void) 0);
     109    LogFlowThisFunc (("\n"));
     110
     111    /* Enclose the state transition Ready->InUninit->NotReady */
     112    AutoUninitSpan autoUninitSpan (this);
     113    if (autoUninitSpan.uninitDone())
     114        return;
    108115
    109116    if (mpDrv)
    110117        mpDrv->pKeyboard = NULL;
     118
    111119    mpDrv = NULL;
    112120    mpVMMDev = NULL;
    113121    mfVMMDevInited = true;
    114122
    115     setReady (false);
     123    unconst (mParent).setNull();
    116124}
    117125
     
    122130 * @param scancode The scancode to send
    123131 */
    124 STDMETHODIMP Keyboard::PutScancode(LONG scancode)
    125 {
     132STDMETHODIMP Keyboard::PutScancode (LONG scancode)
     133{
     134    HRESULT rc = S_OK;
     135
     136    AutoCaller autoCaller (this);
     137    CheckComRCReturnRC (autoCaller.rc());
     138
    126139    AutoWriteLock alock (this);
    127     CHECK_READY();
    128140
    129141    CHECK_CONSOLE_DRV (mpDrv);
    130142
    131     int rcVBox = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, (uint8_t)scancode);
    132 
    133     if (VBOX_FAILURE (rcVBox))
    134         return setError (E_FAIL,
    135             tr ("Could not send scan code 0x%08X to the virtual keyboard (%Vrc)"),
    136                 scancode, rcVBox);
    137 
    138     return S_OK;
     143    int vrc = mpDrv->pUpPort->pfnPutEvent (mpDrv->pUpPort, (uint8_t)scancode);
     144
     145    if (VBOX_FAILURE (vrc))
     146        rc = setError (E_FAIL, tr ("Could not send scan code 0x%08X to the virtual keyboard (%Vrc)"),
     147                       scancode, vrc);
     148
     149    return rc;
    139150}
    140151
     
    149160                      This value can be NULL.
    150161 */
    151 STDMETHODIMP Keyboard::PutScancodes(ComSafeArrayIn (LONG, scancodes),
    152                                     ULONG *codesStored)
    153 {
    154     if (ComSafeArrayInIsNull(scancodes))
     162STDMETHODIMP Keyboard::PutScancodes (ComSafeArrayIn (LONG, scancodes),
     163                                     ULONG *codesStored)
     164{
     165    HRESULT rc = S_OK;
     166
     167    if (ComSafeArrayInIsNull (scancodes))
    155168        return E_INVALIDARG;
    156169
     170    AutoCaller autoCaller (this);
     171    CheckComRCReturnRC (autoCaller.rc());
     172
    157173    AutoWriteLock alock (this);
    158     CHECK_READY();
    159174
    160175    CHECK_CONSOLE_DRV (mpDrv);
    161176
    162     com::SafeArray <LONG> keys(ComSafeArrayInArg(scancodes));
    163     int rcVBox = VINF_SUCCESS;
    164 
    165     for (uint32_t i = 0; (i < keys.size()) && VBOX_SUCCESS(rcVBox); i++)
    166     {
    167         rcVBox = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, (uint8_t)keys[i]);
    168     }
    169 
    170     if (VBOX_FAILURE (rcVBox))
    171         return setError (E_FAIL,
    172             tr ("Could not send all scan codes to the virtual keyboard (%Vrc)"), rcVBox);
     177    com::SafeArray <LONG> keys (ComSafeArrayInArg (scancodes));
     178    int vrc = VINF_SUCCESS;
     179
     180    for (uint32_t i = 0; (i < keys.size()) && VBOX_SUCCESS (vrc); i++)
     181        vrc = mpDrv->pUpPort->pfnPutEvent (mpDrv->pUpPort, (uint8_t)keys [i]);
     182
     183    if (VBOX_FAILURE (vrc))
     184        return setError (E_FAIL, tr ("Could not send all scan codes to the virtual keyboard (%Vrc)"),
     185                         vrc);
    173186
    174187    /// @todo is it actually possible that not all scancodes can be transmitted?
     
    176189        *codesStored = keys.size();
    177190
    178     return S_OK;
     191    return rc;
    179192}
    180193
     
    188201STDMETHODIMP Keyboard::PutCAD()
    189202{
    190     static com::SafeArray<LONG> cadSequence(6);
    191    
    192     cadSequence[0] = 0x1d; // Ctrl down
    193     cadSequence[1] = 0x38; // Alt down
    194     cadSequence[2] = 0x53; // Del down
    195     cadSequence[3] = 0xd3; // Del up
    196     cadSequence[4] = 0xb8; // Alt up
    197     cadSequence[5] = 0x9d; // Ctrl up
    198 
    199     return PutScancodes (ComSafeArrayAsInParam(cadSequence), NULL);
     203    static com::SafeArray<LONG> cadSequence (6);
     204
     205    cadSequence [0] = 0x1d; // Ctrl down
     206    cadSequence [1] = 0x38; // Alt down
     207    cadSequence [2] = 0x53; // Del down
     208    cadSequence [3] = 0xd3; // Del up
     209    cadSequence [4] = 0xb8; // Alt up
     210    cadSequence [5] = 0x9d; // Ctrl up
     211
     212    return PutScancodes (ComSafeArrayAsInParam (cadSequence), NULL);
    200213}
    201214
     
    212225 * @param   enmInterface        The requested interface identification.
    213226 */
    214 DECLCALLBACK(void *)  Keyboard::drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
    215 {
    216     PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
    217     PDRVMAINKEYBOARD pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINKEYBOARD);
     227DECLCALLBACK(void *) Keyboard::drvQueryInterface (PPDMIBASE pInterface, PDMINTERFACE enmInterface)
     228{
     229    PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV (pInterface);
     230    PDRVMAINKEYBOARD pDrv = PDMINS_2_DATA (pDrvIns, PDRVMAINKEYBOARD);
    218231    switch (enmInterface)
    219232    {
     
    234247 * @param   pDrvIns     The driver instance data.
    235248 */
    236 DECLCALLBACK(void) Keyboard::drvDestruct(PPDMDRVINS pDrvIns)
     249DECLCALLBACK(void) Keyboard::drvDestruct (PPDMDRVINS pDrvIns)
    237250{
    238251    PDRVMAINKEYBOARD pData = PDMINS_2_DATA(pDrvIns, PDRVMAINKEYBOARD);
     
    246259}
    247260
    248 DECLCALLBACK(void) keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds)
    249 {
    250     PDRVMAINKEYBOARD pDrv = PPDMIKEYBOARDCONNECTOR_2_MAINKEYBOARD(pInterface);
    251     pDrv->pKeyboard->getParent()->onKeyboardLedsChange(!!(enmLeds & PDMKEYBLEDS_NUMLOCK),
    252                                                        !!(enmLeds & PDMKEYBLEDS_CAPSLOCK),
    253                                                        !!(enmLeds & PDMKEYBLEDS_SCROLLLOCK));
     261DECLCALLBACK(void) keyboardLedStatusChange (PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds)
     262{
     263    PDRVMAINKEYBOARD pDrv = PPDMIKEYBOARDCONNECTOR_2_MAINKEYBOARD (pInterface);
     264    pDrv->pKeyboard->getParent()->onKeyboardLedsChange (!!(enmLeds & PDMKEYBLEDS_NUMLOCK),
     265                                                        !!(enmLeds & PDMKEYBLEDS_CAPSLOCK),
     266                                                        !!(enmLeds & PDMKEYBLEDS_SCROLLLOCK));
    254267}
    255268
     
    264277 *                      iInstance it's expected to be used a bit in this function.
    265278 */
    266 DECLCALLBACK(int) Keyboard::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
    267 {
    268     PDRVMAINKEYBOARD pData = PDMINS_2_DATA(pDrvIns, PDRVMAINKEYBOARD);
     279DECLCALLBACK(int) Keyboard::drvConstruct (PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
     280{
     281    PDRVMAINKEYBOARD pData = PDMINS_2_DATA (pDrvIns, PDRVMAINKEYBOARD);
    269282    LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
    270283
     
    272285     * Validate configuration.
    273286     */
    274     if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
     287    if (!CFGMR3AreValuesValid (pCfgHandle, "Object\0"))
    275288        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    276289    PPDMIBASE pBaseIgnore;
    277     int rc = pDrvIns->pDrvHlp->pfnAttach(pDrvIns, &pBaseIgnore);
     290    int rc = pDrvIns->pDrvHlp->pfnAttach (pDrvIns, &pBaseIgnore);
    278291    if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
    279292    {
    280         AssertMsgFailed(("Configuration error: Not possible to attach anything to this driver!\n"));
     293        AssertMsgFailed (("Configuration error: Not possible to attach anything to this driver!\n"));
    281294        return VERR_PDM_DRVINS_NO_ATTACH;
    282295    }
     
    292305     * Get the IKeyboardPort interface of the above driver/device.
    293306     */
    294     pData->pUpPort = (PPDMIKEYBOARDPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_KEYBOARD_PORT);
     307    pData->pUpPort = (PPDMIKEYBOARDPORT)pDrvIns->pUpBase->pfnQueryInterface (pDrvIns->pUpBase, PDMINTERFACE_KEYBOARD_PORT);
    295308    if (!pData->pUpPort)
    296309    {
    297         AssertMsgFailed(("Configuration error: No keyboard port interface above!\n"));
     310        AssertMsgFailed (("Configuration error: No keyboard port interface above!\n"));
    298311        return VERR_PDM_MISSING_INTERFACE_ABOVE;
    299312    }
     
    303316     */
    304317    void *pv;
    305     rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
    306     if (VBOX_FAILURE(rc))
    307     {
    308         AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Vrc\n", rc));
     318    rc = CFGMR3QueryPtr (pCfgHandle, "Object", &pv);
     319    if (VBOX_FAILURE (rc))
     320    {
     321        AssertMsgFailed (("Configuration error: No/bad \"Object\" value! rc=%Vrc\n", rc));
    309322        return rc;
    310323    }
  • trunk/src/VBox/Main/MouseImpl.cpp

    r11296 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5254/////////////////////////////////////////////////////////////////////////////
    5355
     56DEFINE_EMPTY_CTOR_DTOR (Mouse)
     57
    5458HRESULT Mouse::FinalConstruct()
    5559{
    56     mParent = NULL;
    5760    mpDrv = NULL;
    5861    return S_OK;
     
    6164void Mouse::FinalRelease()
    6265{
    63     if (isReady())
    64         uninit();
     66    uninit();
    6567}
    6668
     
    7678HRESULT Mouse::init (Console *parent)
    7779{
    78     LogFlow(("Mouse::init(): isReady=%d\n", isReady()));
     80    LogFlow(("Mouse::init()\n"));
    7981
    8082    ComAssertRet (parent, E_INVALIDARG);
    8183
    82     AutoWriteLock alock (this);
    83     ComAssertRet (!isReady(), E_UNEXPECTED);
    84 
    85     mParent = parent;
     84    /* Enclose the state transition NotReady->InInit->Ready */
     85    AutoInitSpan autoInitSpan (this);
     86    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     87
     88    unconst(mParent) = parent;
    8689
    8790#ifdef RT_OS_L4
     
    9295#endif
    9396
    94     setReady (true);
     97    /* Confirm a successful initialization */
     98    autoInitSpan.setSucceeded();
     99
    95100    return S_OK;
    96101}
     
    102107void Mouse::uninit()
    103108{
    104     LogFlow(("Mouse::uninit(): isReady=%d\n", isReady()));
    105 
    106     AutoWriteLock alock (this);
    107     AssertReturn (isReady(), (void) 0);
     109    LogFlowThisFunc (("\n"));
     110
     111    /* Enclose the state transition Ready->InUninit->NotReady */
     112    AutoUninitSpan autoUninitSpan (this);
     113    if (autoUninitSpan.uninitDone())
     114        return;
    108115
    109116    if (mpDrv)
     
    111118    mpDrv = NULL;
    112119
    113     setReady (false);
     120    unconst (mParent).setNull();
    114121}
    115122
     
    129136        return E_POINTER;
    130137
     138    AutoCaller autoCaller (this);
     139    CheckComRCReturnRC (autoCaller.rc());
     140
    131141    AutoWriteLock alock (this);
    132     CHECK_READY();
    133142
    134143    CHECK_CONSOLE_DRV (mpDrv);
     
    141150    mParent->getVMMDev()->getVMMDevPort()->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(), &mouseCaps);
    142151    *absoluteSupported = mouseCaps & VMMDEV_MOUSEGUESTWANTSABS;
     152
    143153    return S_OK;
    144154}
     
    156166        return E_POINTER;
    157167
     168    AutoCaller autoCaller (this);
     169    CheckComRCReturnRC (autoCaller.rc());
     170
    158171    AutoWriteLock alock (this);
    159     CHECK_READY();
    160172
    161173    CHECK_CONSOLE_DRV (mpDrv);
     
    168180    mParent->getVMMDev()->getVMMDevPort()->pfnQueryMouseCapabilities(mParent->getVMMDev()->getVMMDevPort(), &mouseCaps);
    169181    *needsHostCursor = mouseCaps & VMMDEV_MOUSEGUESTNEEDSHOSTCUR;
     182
    170183    return S_OK;
    171184}
     
    185198STDMETHODIMP Mouse::PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG buttonState)
    186199{
     200    HRESULT rc = S_OK;
     201
     202    AutoCaller autoCaller (this);
     203    CheckComRCReturnRC (autoCaller.rc());
     204
    187205    AutoWriteLock alock (this);
    188     CHECK_READY();
    189206
    190207    CHECK_CONSOLE_DRV (mpDrv);
     
    218235    int vrc = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, dx, dy, dz, fButtons);
    219236    if (VBOX_FAILURE (vrc))
    220         return setError (E_FAIL,
    221             tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
    222             vrc);
    223 
    224     return S_OK;
     237        rc = setError (E_FAIL, tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
     238                       vrc);
     239
     240    return rc;
    225241}
    226242
     
    238254                                          LONG buttonState)
    239255{
     256    HRESULT rc = S_OK;
     257
     258    AutoCaller autoCaller (this);
     259    CheckComRCReturnRC (autoCaller.rc());
     260
    240261    AutoWriteLock alock (this);
    241     CHECK_READY();
    242262
    243263    CHECK_CONSOLE_DRV (mpDrv);
     
    267287    ULONG displayWidth;
    268288    ULONG displayHeight;
    269     HRESULT rc = pDisplay->COMGETTER(Width)(&displayWidth);
     289    rc = pDisplay->COMGETTER(Width)(&displayWidth);
    270290    ComAssertComRCRet (rc, rc);
    271291    rc = pDisplay->COMGETTER(Height)(&displayHeight);
     
    297317                                          fButtons);
    298318        if (VBOX_FAILURE (vrc))
    299             return setError (E_FAIL,
    300                 tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
    301                 vrc);
    302     }
    303 
    304     return S_OK;
     319            rc = setError (E_FAIL, tr ("Could not send the mouse event to the virtual mouse (%Vrc)"),
     320                           vrc);
     321    }
     322
     323    return rc;
    305324}
    306325
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r13580 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3941/////////////////////////////////////////////////////////////////////////////
    4042
     43DEFINE_EMPTY_CTOR_DTOR (SystemProperties)
     44
    4145HRESULT SystemProperties::FinalConstruct()
    4246{
     
    4650void SystemProperties::FinalRelease()
    4751{
    48     if (isReady())
    49         uninit ();
     52    uninit ();
    5053}
    5154
     
    6063HRESULT SystemProperties::init (VirtualBox *aParent)
    6164{
    62     LogFlowMember (("SystemProperties::init()\n"));
     65    LogFlowThisFunc (("aParent=%p\n", aParent));
    6366
    6467    ComAssertRet (aParent, E_FAIL);
    6568
    66     AutoWriteLock alock (this);
    67     ComAssertRet (!isReady(), E_UNEXPECTED);
    68 
    69     mParent = aParent;
     69    /* Enclose the state transition NotReady->InInit->Ready */
     70    AutoInitSpan autoInitSpan (this);
     71    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     72
     73    unconst (mParent) = aParent;
    7074
    7175    setDefaultMachineFolder (NULL);
     
    105109    }
    106110
    107     setReady (SUCCEEDED (rc));
     111    /* Confirm a successful initialization */
     112    if (SUCCEEDED (rc))
     113        autoInitSpan.setSucceeded();
    108114
    109115    return rc;
     
    116122void SystemProperties::uninit()
    117123{
    118     LogFlowMember (("SystemProperties::uninit()\n"));
    119 
    120     AutoWriteLock alock (this);
    121     AssertReturn (isReady(), (void) 0);
    122 
    123     setReady (false);
     124    LogFlowThisFunc (("\n"));
     125
     126    /* Enclose the state transition Ready->InUninit->NotReady */
     127    AutoUninitSpan autoUninitSpan (this);
     128    if (autoUninitSpan.uninitDone())
     129        return;
     130
     131    unconst (mParent).setNull();
    124132}
    125133
     
    132140    if (!minRAM)
    133141        return E_POINTER;
    134     AutoWriteLock alock (this);
    135     CHECK_READY();
    136 
     142
     143    AutoCaller autoCaller (this);
     144    CheckComRCReturnRC (autoCaller.rc());
     145
     146    /* no need to lock, this is const */
    137147    *minRAM = SchemaDefs::MinGuestRAM;
    138148
     
    144154    if (!maxRAM)
    145155        return E_POINTER;
    146     AutoWriteLock alock (this);
    147     CHECK_READY();
    148 
     156
     157    AutoCaller autoCaller (this);
     158    CheckComRCReturnRC (autoCaller.rc());
     159
     160    /* no need to lock, this is const */
    149161    *maxRAM = SchemaDefs::MaxGuestRAM;
    150162
     
    156168    if (!minVRAM)
    157169        return E_POINTER;
    158     AutoWriteLock alock (this);
    159     CHECK_READY();
    160 
     170
     171    AutoCaller autoCaller (this);
     172    CheckComRCReturnRC (autoCaller.rc());
     173
     174    /* no need to lock, this is const */
    161175    *minVRAM = SchemaDefs::MinGuestVRAM;
    162176
     
    168182    if (!maxVRAM)
    169183        return E_POINTER;
    170     AutoWriteLock alock (this);
    171     CHECK_READY();
    172 
     184
     185    AutoCaller autoCaller (this);
     186    CheckComRCReturnRC (autoCaller.rc());
     187
     188    /* no need to lock, this is const */
    173189    *maxVRAM = SchemaDefs::MaxGuestVRAM;
    174190
     
    180196    if (!maxMonitors)
    181197        return E_POINTER;
    182     AutoWriteLock alock (this);
    183     CHECK_READY();
    184 
     198
     199    AutoCaller autoCaller (this);
     200    CheckComRCReturnRC (autoCaller.rc());
     201
     202    /* no need to lock, this is const */
    185203    *maxMonitors = SchemaDefs::MaxGuestMonitors;
    186204
     
    192210    if (!maxVDISize)
    193211        return E_POINTER;
    194     AutoWriteLock alock (this);
    195     CHECK_READY();
     212
     213    AutoCaller autoCaller (this);
     214    CheckComRCReturnRC (autoCaller.rc());
    196215
    197216    /** The BIOS supports currently 32 bit LBA numbers (implementing the full
     
    204223     * theoretical maximum disk size is 128 PiByte. The user interface cannot
    205224     * cope with this in a reasonable way yet. */
     225    /* no need to lock, this is const */
    206226    *maxVDISize = 2048 * 1024 - 1;
    207227
     
    213233    if (!count)
    214234        return E_POINTER;
    215     AutoWriteLock alock (this);
    216     CHECK_READY();
    217 
     235
     236    AutoCaller autoCaller (this);
     237    CheckComRCReturnRC (autoCaller.rc());
     238
     239    /* no need to lock, this is const */
    218240    *count = SchemaDefs::NetworkAdapterCount;
    219241
     
    225247    if (!count)
    226248        return E_POINTER;
    227     AutoWriteLock alock (this);
    228     CHECK_READY();
    229 
     249
     250    AutoCaller autoCaller (this);
     251    CheckComRCReturnRC (autoCaller.rc());
     252
     253    /* no need to lock, this is const */
    230254    *count = SchemaDefs::SerialPortCount;
    231255
     
    237261    if (!count)
    238262        return E_POINTER;
    239     AutoWriteLock alock (this);
    240     CHECK_READY();
    241 
     263
     264    AutoCaller autoCaller (this);
     265    CheckComRCReturnRC (autoCaller.rc());
     266
     267    /* no need to lock, this is const */
    242268    *count = SchemaDefs::ParallelPortCount;
    243269
     
    249275    if (!aMaxBootPosition)
    250276        return E_POINTER;
    251     AutoWriteLock alock (this);
    252     CHECK_READY();
    253 
     277
     278    AutoCaller autoCaller (this);
     279    CheckComRCReturnRC (autoCaller.rc());
     280
     281    /* no need to lock, this is const */
    254282    *aMaxBootPosition = SchemaDefs::MaxBootPosition;
    255283
     
    262290        return E_POINTER;
    263291
    264     AutoWriteLock alock (this);
    265     CHECK_READY();
     292    AutoCaller autoCaller (this);
     293    CheckComRCReturnRC (autoCaller.rc());
     294
     295    AutoReadLock alock (this);
    266296
    267297    mDefaultMachineFolderFull.cloneTo (aDefaultMachineFolder);
     
    272302STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder) (INPTR BSTR aDefaultMachineFolder)
    273303{
    274     AutoWriteLock alock (this);
    275     CHECK_READY();
     304    AutoCaller autoCaller (this);
     305    CheckComRCReturnRC (autoCaller.rc());
     306
     307    /* VirtualBox::saveSettings() needs a write lock */
     308    AutoMultiWriteLock2 alock (mParent, this);
    276309
    277310    HRESULT rc = setDefaultMachineFolder (aDefaultMachineFolder);
    278     if (FAILED (rc))
    279         return rc;
    280 
    281     alock.unlock();
    282     return mParent->saveSettings();
     311    if (SUCCEEDED (rc))
     312        rc = mParent->saveSettings();
     313
     314    return rc;
    283315}
    284316
     
    288320        return E_POINTER;
    289321
    290     AutoWriteLock alock (this);
    291     CHECK_READY();
     322    AutoCaller autoCaller (this);
     323    CheckComRCReturnRC (autoCaller.rc());
     324
     325    AutoReadLock alock (this);
    292326
    293327    mDefaultHardDiskFolderFull.cloneTo (aDefaultHardDiskFolder);
     
    298332STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFolder) (INPTR BSTR aDefaultHardDiskFolder)
    299333{
    300     AutoWriteLock alock (this);
    301     CHECK_READY();
     334    AutoCaller autoCaller (this);
     335    CheckComRCReturnRC (autoCaller.rc());
     336
     337    /* VirtualBox::saveSettings() needs a write lock */
     338    AutoMultiWriteLock2 alock (mParent, this);
    302339
    303340    HRESULT rc = setDefaultHardDiskFolder (aDefaultHardDiskFolder);
    304     if (FAILED (rc))
    305         return rc;
    306 
    307     alock.unlock();
    308     return mParent->saveSettings();
     341    if (SUCCEEDED (rc))
     342        rc = mParent->saveSettings();
     343
     344    return rc;
    309345}
    310346
     
    315351        return E_POINTER;
    316352
    317     AutoWriteLock alock (this);
    318     CHECK_READY();
     353    AutoCaller autoCaller (this);
     354    CheckComRCReturnRC (autoCaller.rc());
     355
     356    AutoReadLock alock (this);
    319357
    320358    SafeIfaceArray <IHardDiskFormat> hardDiskFormats (mHardDiskFormats);
     
    329367        return E_POINTER;
    330368
    331     AutoWriteLock alock (this);
    332     CHECK_READY();
     369    AutoCaller autoCaller (this);
     370    CheckComRCReturnRC (autoCaller.rc());
     371
     372    AutoReadLock alock (this);
    333373
    334374    mRemoteDisplayAuthLibrary.cloneTo (aRemoteDisplayAuthLibrary);
     
    339379STDMETHODIMP SystemProperties::COMSETTER(RemoteDisplayAuthLibrary) (INPTR BSTR aRemoteDisplayAuthLibrary)
    340380{
    341     AutoWriteLock alock (this);
    342     CHECK_READY();
     381    AutoCaller autoCaller (this);
     382    CheckComRCReturnRC (autoCaller.rc());
     383
     384    /* VirtualBox::saveSettings() needs a write lock */
     385    AutoMultiWriteLock2 alock (mParent, this);
    343386
    344387    HRESULT rc = setRemoteDisplayAuthLibrary (aRemoteDisplayAuthLibrary);
    345     if (FAILED (rc))
    346         return rc;
    347 
    348     alock.unlock();
    349     return mParent->saveSettings();
     388    if (SUCCEEDED (rc))
     389        rc = mParent->saveSettings();
     390
     391    return rc;
    350392}
    351393
     
    355397        return E_POINTER;
    356398
    357     AutoWriteLock alock (this);
    358     CHECK_READY();
     399    AutoCaller autoCaller (this);
     400    CheckComRCReturnRC (autoCaller.rc());
     401
     402    AutoReadLock alock (this);
    359403
    360404    mWebServiceAuthLibrary.cloneTo (aWebServiceAuthLibrary);
     
    365409STDMETHODIMP SystemProperties::COMSETTER(WebServiceAuthLibrary) (INPTR BSTR aWebServiceAuthLibrary)
    366410{
    367     AutoWriteLock alock (this);
    368     CHECK_READY();
     411    AutoCaller autoCaller (this);
     412    CheckComRCReturnRC (autoCaller.rc());
     413
     414    /* VirtualBox::saveSettings() needs a write lock */
     415    AutoMultiWriteLock2 alock (mParent, this);
    369416
    370417    HRESULT rc = setWebServiceAuthLibrary (aWebServiceAuthLibrary);
    371     if (FAILED (rc))
    372         return rc;
    373 
    374     alock.unlock();
    375     return mParent->saveSettings();
     418    if (SUCCEEDED (rc))
     419        rc = mParent->saveSettings();
     420
     421    return rc;
    376422}
    377423
     
    381427        return E_POINTER;
    382428
    383     AutoWriteLock alock (this);
    384     CHECK_READY();
     429    AutoCaller autoCaller (this);
     430    CheckComRCReturnRC (autoCaller.rc());
     431
     432    AutoReadLock alock (this);
    385433
    386434    *enabled = mHWVirtExEnabled;
     
    391439STDMETHODIMP SystemProperties::COMSETTER(HWVirtExEnabled) (BOOL enabled)
    392440{
    393     AutoWriteLock alock (this);
    394     CHECK_READY();
     441    AutoCaller autoCaller (this);
     442    CheckComRCReturnRC (autoCaller.rc());
     443
     444    /* VirtualBox::saveSettings() needs a write lock */
     445    AutoMultiWriteLock2 alock (mParent, this);
    395446
    396447    mHWVirtExEnabled = enabled;
    397448
    398     alock.unlock();
    399     return mParent->saveSettings();
     449    HRESULT rc = mParent->saveSettings();
     450
     451    return rc;
    400452}
    401453
     
    405457        return E_POINTER;
    406458
    407     AutoWriteLock alock (this);
    408     CHECK_READY();
     459    AutoCaller autoCaller (this);
     460    CheckComRCReturnRC (autoCaller.rc());
     461
     462    AutoReadLock alock (this);
    409463
    410464    *count = mLogHistoryCount;
     
    415469STDMETHODIMP SystemProperties::COMSETTER(LogHistoryCount) (ULONG count)
    416470{
    417     AutoWriteLock alock (this);
    418     CHECK_READY();
     471    AutoCaller autoCaller (this);
     472    CheckComRCReturnRC (autoCaller.rc());
     473
     474    /* VirtualBox::saveSettings() needs a write lock */
     475    AutoMultiWriteLock2 alock (mParent, this);
    419476
    420477    mLogHistoryCount = count;
    421478
    422     alock.unlock();
    423     return mParent->saveSettings();
     479    HRESULT rc = mParent->saveSettings();
     480
     481    return rc;
    424482}
    425483
     
    431489    using namespace settings;
    432490
     491    AutoCaller autoCaller (this);
     492    CheckComRCReturnRC (autoCaller.rc());
     493
    433494    AutoWriteLock alock (this);
    434     CHECK_READY();
    435495
    436496    AssertReturn (!aGlobal.isNull(), E_FAIL);
     
    470530    using namespace settings;
    471531
    472     AutoWriteLock alock (this);
    473     CHECK_READY();
     532    AutoCaller autoCaller (this);
     533    CheckComRCReturnRC (autoCaller.rc());
     534
     535    AutoReadLock alock (this);
    474536
    475537    ComAssertRet (!aGlobal.isNull(), E_FAIL);
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r13580 r13606  
    164164     */
    165165
    166     Guest *getGuest() { return mGuest; }
    167     Keyboard *getKeyboard() { return mKeyboard; }
    168     Mouse *getMouse() { return mMouse; }
    169     Display *getDisplay() { return mDisplay; }
    170     MachineDebugger *getMachineDebugger() { return mDebugger; }
    171 
    172     const ComPtr <IMachine> &machine() { return mMachine; }
     166    Guest *getGuest() const { return mGuest; }
     167    Keyboard *getKeyboard() const { return mKeyboard; }
     168    Mouse *getMouse() const { return mMouse; }
     169    Display *getDisplay() const { return mDisplay; }
     170    MachineDebugger *getMachineDebugger() const { return mDebugger; }
     171
     172    const ComPtr <IMachine> &machine() const { return mMachine; }
    173173
    174174    /** Method is called only from ConsoleVRDPServer */
    175     IVRDPServer *getVRDPServer() { return mVRDPServer; }
    176 
    177     ConsoleVRDPServer *consoleVRDPServer() { return mConsoleVRDPServer; }
     175    IVRDPServer *getVRDPServer() const { return mVRDPServer; }
     176
     177    ConsoleVRDPServer *consoleVRDPServer() const { return mConsoleVRDPServer; }
    178178
    179179    HRESULT updateMachineState (MachineState_T aMachineState);
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r12126 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4951    bool fClientScrollLock;
    5052} VRDPInputSynch;
    51 #endif /* VBOX_WITH_VRDP */       
     53#endif /* VBOX_WITH_VRDP */
    5254
    5355/* Member of Console. Helper class for VRDP server management. Not a COM class. */
     
    6668#else
    6769        NOREF(fGuestWantsAbsolute);
    68 #endif /* VBOX_WITH_VRDP */       
     70#endif /* VBOX_WITH_VRDP */
    6971    }
    7072
     
    9496        NOREF(fCapsLock);
    9597        NOREF(fScrollLock);
    96 #endif /* VBOX_WITH_VRDP */       
     98#endif /* VBOX_WITH_VRDP */
    9799    }
    98100
     
    112114    void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
    113115    void USBBackendDelete (uint32_t u32ClientId);
    114    
     116
    115117    void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
    116118    void USBBackendReleasePointer (const Guid *pGuid);
    117    
     119
    118120    /* Private interface for the RemoteUSBBackend destructor. */
    119121    void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
    120    
     122
    121123    /* Private methods for the Remote USB thread. */
    122124    RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
    123    
     125
    124126    void notifyRemoteUSBThreadRunning (RTTHREAD thread);
    125127    bool isRemoteUSBThreadRunning (void);
    126128    void waitRemoteUSBThreadEvent (unsigned cMillies);
    127    
     129
    128130    void ClipboardCreate (uint32_t u32ClientId);
    129131    void ClipboardDelete (uint32_t u32ClientId);
     
    157159
    158160    static PFNVRDPCREATESERVER mpfnVRDPCreateServer;
    159    
     161
    160162    static VRDPENTRYPOINTS_1 *mpEntryPoints;
    161163    static VRDPCALLBACKS_1 mCallbacks;
     
    173175    static DECLCALLBACK(void) VRDPCallbackInput             (void *pvCallback, int type, const void *pvInput, unsigned cbInput);
    174176    static DECLCALLBACK(void) VRDPCallbackVideoModeHint     (void *pvCallback, unsigned cWidth, unsigned cHeight,  unsigned cBitsPerPixel, unsigned uScreenId);
    175    
     177
    176178    bool m_fGuestWantsAbsolute;
    177179    int m_mousex;
    178180    int m_mousey;
    179    
     181
    180182    IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
    181    
     183
    182184    IConsoleCallback *mConsoleCallback;
    183185
     
    189191    int lockConsoleVRDPServer (void);
    190192    void unlockConsoleVRDPServer (void);
    191    
     193
    192194    int mcClipboardRefs;
    193195    HGCMSVCEXTHANDLE mhClipboard;
     
    196198    static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
    197199    static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
    198    
     200
    199201#ifdef VBOX_WITH_USB
    200202    RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
     
    205207        RemoteUSBBackend *pHead;
    206208        RemoteUSBBackend *pTail;
    207        
     209
    208210        RTTHREAD thread;
    209        
     211
    210212        bool fThreadRunning;
    211        
     213
    212214        RTSEMEVENT event;
    213215    } USBBackends;
     
    231233
    232234class ATL_NO_VTABLE RemoteDisplayInfo :
     235    public VirtualBoxBaseNEXT,
    233236    public VirtualBoxSupportErrorInfoImpl <RemoteDisplayInfo, IRemoteDisplayInfo>,
    234237    public VirtualBoxSupportTranslation <RemoteDisplayInfo>,
    235     public VirtualBoxBase,
    236238    public IRemoteDisplayInfo
    237239{
    238240public:
     241
     242    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (RemoteDisplayInfo)
    239243
    240244    DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo)
     
    248252
    249253    NS_DECL_ISUPPORTS
     254
     255    DECLARE_EMPTY_CTOR_DTOR (RemoteDisplayInfo)
    250256
    251257    HRESULT FinalConstruct();
     
    279285private:
    280286
    281     ComObjPtr <Console, ComWeakRef> mParent;
     287    const ComObjPtr <Console, ComWeakRef> mParent;
    282288};
    283289
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r11820 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2527#include "VirtualBoxBase.h"
    2628#include "SchemaDefs.h"
     29
    2730#include <iprt/semaphore.h>
    2831#include <VBox/pdmdrv.h>
     
    5558
    5659    volatile uint32_t u32ResizeStatus;
    57    
     60
    5861    /* The Framebuffer has default format and must be updates immediately. */
    5962    bool fDefaultFormat;
    60    
     63
    6164    struct {
    6265        /* The rectangle that includes all dirty rectangles. */
     
    7073
    7174class ATL_NO_VTABLE Display :
     75    public VirtualBoxBaseNEXT,
    7276    public IConsoleCallback,
    7377    public VirtualBoxSupportErrorInfoImpl <Display, IDisplay>,
    7478    public VirtualBoxSupportTranslation <Display>,
    75     public VirtualBoxBase,
    7679    public IDisplay
    7780{
    7881
    7982public:
     83
     84    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Display)
    8085
    8186    DECLARE_NOT_AGGREGATABLE(Display)
     
    9095    NS_DECL_ISUPPORTS
    9196
     97    DECLARE_EMPTY_CTOR_DTOR (Display)
     98
    9299    HRESULT FinalConstruct();
    93100    void FinalRelease();
    94101
    95102    // public initializer/uninitializer for internal purposes only
    96     HRESULT init (Console *parent);
     103    HRESULT init (Console *aParent);
    97104    void uninit();
    98105
     
    247254    static DECLCALLBACK(void)  displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
    248255
    249     ComObjPtr <Console, ComWeakRef> mParent;
     256    const ComObjPtr <Console, ComWeakRef> mParent;
    250257    /** Pointer to the associated display driver. */
    251258    struct DRVMAINDISPLAY  *mpDrv;
     
    275282    bool        mfVideoAccelVRDP;
    276283    uint32_t    mfu32SupportedOrders;
    277    
     284
    278285    int32_t volatile mcVideoAccelVRDPRefs;
    279286
  • trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h

    r10896 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2729
    2830class ATL_NO_VTABLE HostNetworkInterface :
     31    public VirtualBoxBaseNEXT,
    2932    public VirtualBoxSupportErrorInfoImpl <HostNetworkInterface, IHostNetworkInterface>,
    3033    public VirtualBoxSupportTranslation <HostNetworkInterface>,
    31     public VirtualBoxBase,
    3234    public IHostNetworkInterface
    3335{
    3436public:
    35     HostNetworkInterface();
    36     virtual ~HostNetworkInterface();
    3737
    38     DECLARE_NOT_AGGREGATABLE(HostNetworkInterface)
     38    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostNetworkInterface)
     39
     40    DECLARE_NOT_AGGREGATABLE (HostNetworkInterface)
    3941
    4042    DECLARE_PROTECT_FINAL_CONSTRUCT()
    4143
    42     BEGIN_COM_MAP(HostNetworkInterface)
    43         COM_INTERFACE_ENTRY(ISupportErrorInfo)
    44         COM_INTERFACE_ENTRY(IHostNetworkInterface)
     44    BEGIN_COM_MAP (HostNetworkInterface)
     45        COM_INTERFACE_ENTRY (ISupportErrorInfo)
     46        COM_INTERFACE_ENTRY (IHostNetworkInterface)
    4547    END_COM_MAP()
    4648
    4749    NS_DECL_ISUPPORTS
     50
     51    DECLARE_EMPTY_CTOR_DTOR (HostNetworkInterface)
     52
     53    HRESULT FinalConstruct();
     54    void FinalRelease();
    4855
    4956    // public initializer/uninitializer for internal purposes only
     
    5158
    5259    // IHostNetworkInterface properties
    53     STDMETHOD(COMGETTER(Name)) (BSTR *interfaceName);
    54     STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT guid);
     60    STDMETHOD(COMGETTER(Name)) (BSTR *aInterfaceName);
     61    STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT aGuid);
    5562
    5663    // for VirtualBoxSupportErrorInfoImpl
     
    5865
    5966private:
    60     Bstr mInterfaceName;
    61     Guid mGuid;
     67    const Bstr mInterfaceName;
     68    const Guid mGuid;
    6269};
    6370
  • trunk/src/VBox/Main/include/KeyboardImpl.h

    r11661 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2527#include "VirtualBoxBase.h"
    2628#include "ConsoleEvents.h"
     29
    2730#include <VBox/pdmdrv.h>
    2831
     
    4548
    4649class ATL_NO_VTABLE Keyboard :
     50    public VirtualBoxBaseNEXT,
    4751    public VirtualBoxSupportErrorInfoImpl <Keyboard, IKeyboard>,
    4852    public VirtualBoxSupportTranslation <Keyboard>,
    49     public VirtualBoxBase,
    5053    public IKeyboard
    5154{
    5255
    5356public:
     57
     58    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Keyboard)
    5459
    5560    DECLARE_NOT_AGGREGATABLE(Keyboard)
     
    6469    NS_DECL_ISUPPORTS
    6570
     71    DECLARE_EMPTY_CTOR_DTOR (Keyboard)
     72
    6673    HRESULT FinalConstruct();
    6774    void FinalRelease();
    6875
    69     // public methods only for internal purposes
    70     HRESULT init (Console *parent);
     76    // public initializer/uninitializer for internal purposes only
     77    HRESULT init (Console *aParent);
    7178    void uninit();
    7279
     
    8188    static const PDMDRVREG  DrvReg;
    8289
    83     Console *getParent()
     90    Console *getParent() const
    8491    {
    8592        return mParent;
     
    9299    static DECLCALLBACK(void)   drvDestruct(PPDMDRVINS pDrvIns);
    93100
    94     ComObjPtr <Console, ComWeakRef> mParent;
     101    const ComObjPtr <Console, ComWeakRef> mParent;
    95102    /** Pointer to the associated keyboard driver. */
    96103    struct DRVMAINKEYBOARD *mpDrv;
  • trunk/src/VBox/Main/include/MouseImpl.h

    r8155 r13606  
     1/* $Id $ */
     2
    13/** @file
    24 *
     
    57
    68/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4850
    4951class ATL_NO_VTABLE Mouse :
     52    public VirtualBoxBaseNEXT,
    5053    public VirtualBoxSupportErrorInfoImpl <Mouse, IMouse>,
    5154    public VirtualBoxSupportTranslation <Mouse>,
    52     public VirtualBoxBase,
    5355    public IMouse
    5456{
    5557public:
     58
     59    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
    5660
    5761    DECLARE_NOT_AGGREGATABLE(Mouse)
     
    6670    NS_DECL_ISUPPORTS
    6771
     72    DECLARE_EMPTY_CTOR_DTOR (Mouse)
     73
    6874    HRESULT FinalConstruct();
    6975    void FinalRelease();
    7076
    71     // public methods only for internal purposes
     77    // public initializer/uninitializer for internal purposes only
    7278    HRESULT init(Console *parent);
    7379    void uninit();
     
    94100    static DECLCALLBACK(void)   drvDestruct(PPDMDRVINS pDrvIns);
    95101
    96     ComObjPtr <Console, ComWeakRef> mParent;
     102    const ComObjPtr <Console, ComWeakRef> mParent;
    97103    /** Pointer to the associated mouse driver. */
    98104    struct DRVMAINMOUSE    *mpDrv;
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r13580 r13606  
    77
    88/*
    9  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3535
    3636class ATL_NO_VTABLE SystemProperties :
     37    public VirtualBoxBaseNEXT,
    3738    public VirtualBoxSupportErrorInfoImpl <SystemProperties, ISystemProperties>,
    3839    public VirtualBoxSupportTranslation <SystemProperties>,
    39     public VirtualBoxBase,
    4040    public ISystemProperties
    4141{
    4242public:
     43
     44    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SystemProperties)
    4345
    4446    DECLARE_NOT_AGGREGATABLE(SystemProperties)
     
    5254
    5355    NS_DECL_ISUPPORTS
     56
     57    DECLARE_EMPTY_CTOR_DTOR (SystemProperties)
    5458
    5559    HRESULT FinalConstruct();
     
    9195
    9296    /** Default Machine path (as is, not full). Not thread safe (use object lock). */
    93     const Bstr &defaultMachineFolder() { return mDefaultMachineFolder; }
     97    const Bstr &defaultMachineFolder() const { return mDefaultMachineFolder; }
    9498    /** Default Machine path (full). Not thread safe (use object lock). */
    95     const Bstr &defaultMachineFolderFull() { return mDefaultMachineFolderFull; }
     99    const Bstr &defaultMachineFolderFull() const { return mDefaultMachineFolderFull; }
    96100    /** Default hard disk path (as is, not full). Not thread safe (use object lock). */
    97     const Bstr &defaultHardDiskFolder() { return mDefaultHardDiskFolder; }
     101    const Bstr &defaultHardDiskFolder() const { return mDefaultHardDiskFolder; }
    98102    /** Default hard disk path (full). Not thread safe (use object lock). */
    99     const Bstr &defaultHardDiskFolderFull() { return mDefaultHardDiskFolderFull; }
     103    const Bstr &defaultHardDiskFolderFull() const { return mDefaultHardDiskFolderFull; }
    100104
    101105    // for VirtualBoxSupportErrorInfoImpl
     
    111115    HRESULT setWebServiceAuthLibrary (const BSTR aPath);
    112116
    113     ComObjPtr <VirtualBox, ComWeakRef> mParent;
     117    const ComObjPtr <VirtualBox, ComWeakRef> mParent;
    114118
    115119    Bstr mDefaultMachineFolder;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette