VirtualBox

Changeset 3348 in vbox for trunk/src


Ignore:
Timestamp:
Jul 2, 2007 12:44:39 PM (18 years ago)
Author:
vboxsync
Message:

Main: Converted AudioAdapter and NetworkAdapter to the new locking scheme.

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

Legend:

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

    r3191 r3348  
    2424#include "Logging.h"
    2525
     26#include <iprt/cpputils.h>
     27
    2628// constructor / destructor
    2729/////////////////////////////////////////////////////////////////////////////
    2830
     31DEFINE_EMPTY_CTOR_DTOR (AudioAdapter)
     32
    2933HRESULT AudioAdapter::FinalConstruct()
    3034{
     
    3438void AudioAdapter::FinalRelease()
    3539{
    36     if (isReady())
    37         uninit ();
     40    uninit ();
    3841}
    3942
     
    4245
    4346/**
    44  * Initializes the audio adapter object.
    45  *
    46  * @returns COM result indicator
    47  */
    48 HRESULT AudioAdapter::init (Machine *parent)
    49 {
    50     LogFlowMember (("AudioAdapter::init (%p)\n", parent));
    51 
    52     ComAssertRet (parent, E_INVALIDARG);
    53 
    54     AutoLock alock (this);
    55     ComAssertRet (!isReady(), E_UNEXPECTED);
    56 
    57     mParent = parent;
    58     // mPeer is left null
     47 *  Initializes the audio adapter object.
     48 *
     49 *  @param aParent  Handle of the parent object.
     50 */
     51HRESULT AudioAdapter::init (Machine *aParent)
     52{
     53    LogFlowThisFunc (("aParent=%p\n", aParent));
     54
     55    ComAssertRet (aParent, E_INVALIDARG);
     56
     57    /* Enclose the state transition NotReady->InInit->Ready */
     58    AutoInitSpan autoInitSpan (this);
     59    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     60
     61    unconst (mParent) = aParent;
     62    /* mPeer is left null */
    5963
    6064    mData.allocate();
    6165
    62     setReady (true);
     66    /* Confirm a successful initialization */
     67    autoInitSpan.setSucceeded();
     68
    6369    return S_OK;
    6470}
     
    7177 *  @note This object must be destroyed before the original object
    7278 *  it shares data with is destroyed.
    73  */
    74 HRESULT AudioAdapter::init (Machine *parent, AudioAdapter *that)
    75 {
    76     LogFlowMember (("AudioAdapter::init (%p, %p)\n", parent, that));
    77 
    78     ComAssertRet (parent && that, E_INVALIDARG);
    79 
    80     AutoLock alock (this);
    81     ComAssertRet (!isReady(), E_UNEXPECTED);
    82 
    83     mParent = parent;
    84     mPeer = that;
    85 
    86     AutoLock thatlock (that);
    87     mData.share (that->mData);
    88 
    89     setReady (true);
     79 *
     80 *  @note Locks @a aThat object for reading.
     81 */
     82HRESULT AudioAdapter::init (Machine *aParent, AudioAdapter *aThat)
     83{
     84    LogFlowThisFunc (("aParent=%p, aThat=%p\n", aParent, aThat));
     85
     86    ComAssertRet (aParent && aThat, E_INVALIDARG);
     87
     88    /* Enclose the state transition NotReady->InInit->Ready */
     89    AutoInitSpan autoInitSpan (this);
     90    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     91
     92    unconst (mParent) = aParent;
     93    unconst (mPeer) = aThat;
     94
     95    AutoCaller thatCaller (aThat);
     96    AssertComRCReturnRC (thatCaller.rc());
     97
     98    AutoReaderLock thatLock (aThat);
     99    mData.share (aThat->mData);
     100
     101    /* Confirm a successful initialization */
     102    autoInitSpan.setSucceeded();
     103
    90104    return S_OK;
    91105}
     
    95109 *  (a kind of copy constructor). This object makes a private copy of data
    96110 *  of the original object passed as an argument.
    97  */
    98 HRESULT AudioAdapter::initCopy (Machine *parent, AudioAdapter *that)
    99 {
    100     LogFlowMember (("AudioAdapter::initCopy (%p, %p)\n", parent, that));
    101 
    102     ComAssertRet (parent && that, E_INVALIDARG);
    103 
    104     AutoLock alock (this);
    105     ComAssertRet (!isReady(), E_UNEXPECTED);
    106 
    107     mParent = parent;
    108     // mPeer is left null
    109 
    110     AutoLock thatlock (that);
    111     mData.attachCopy (that->mData);
    112 
    113     setReady (true);
     111 *
     112 *  @note Locks @a aThat object for reading.
     113 */
     114HRESULT AudioAdapter::initCopy (Machine *aParent, AudioAdapter *aThat)
     115{
     116    LogFlowThisFunc (("aParent=%p, aThat=%p\n", aParent, aThat));
     117
     118    ComAssertRet (aParent && aThat, 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;
     125    /* mPeer is left null */
     126
     127    AutoCaller thatCaller (aThat);
     128    AssertComRCReturnRC (thatCaller.rc());
     129
     130    AutoReaderLock thatLock (aThat);
     131    mData.attachCopy (aThat->mData);
     132
     133    /* Confirm a successful initialization */
     134    autoInitSpan.setSucceeded();
     135
    114136    return S_OK;
    115137}
     
    121143void AudioAdapter::uninit()
    122144{
    123     LogFlowMember (("AudioAdapter::uninit()\n"));
     145    LogFlowThisFunc (("\n"));
     146
     147    /* Enclose the state transition Ready->InUninit->NotReady */
     148    AutoUninitSpan autoUninitSpan (this);
     149    if (autoUninitSpan.uninitDone())
     150        return;
     151
     152    mData.free();
     153
     154    unconst (mPeer).setNull();
     155    unconst (mParent).setNull();
     156}
     157
     158// IAudioAdapter properties
     159/////////////////////////////////////////////////////////////////////////////
     160
     161STDMETHODIMP AudioAdapter::COMGETTER(Enabled)(BOOL *aEnabled)
     162{
     163    if (!aEnabled)
     164        return E_POINTER;
     165
     166    AutoCaller autoCaller (this);
     167    CheckComRCReturnRC (autoCaller.rc());
     168
     169    AutoReaderLock alock (this);
     170
     171    *aEnabled = mData->mEnabled;
     172
     173    return S_OK;
     174}
     175
     176STDMETHODIMP AudioAdapter::COMSETTER(Enabled)(BOOL aEnabled)
     177{
     178    AutoCaller autoCaller (this);
     179    CheckComRCReturnRC (autoCaller.rc());
     180
     181    /* the machine needs to be mutable */
     182    Machine::AutoMutableStateDependency adep (mParent);
     183    CheckComRCReturnRC (adep.rc());
    124184
    125185    AutoLock alock (this);
    126     AssertReturn (isReady(), (void) 0);
    127 
    128     mData.free();
    129 
    130     mPeer.setNull();
    131     mParent.setNull();
    132 
    133     setReady(false);
    134 }
    135 
    136 // IAudioAdapter properties
    137 /////////////////////////////////////////////////////////////////////////////
    138 
    139 /**
    140  * Returns the enabled status
    141  *
    142  * @returns COM status code
    143  * @param enabled address of result variable
    144  */
    145 STDMETHODIMP AudioAdapter::COMGETTER(Enabled)(BOOL *enabled)
    146 {
    147     if (!enabled)
    148         return E_POINTER;
    149 
    150     AutoLock lock(this);
    151     CHECK_READY();
    152 
    153     *enabled = mData->mEnabled;
    154     return S_OK;
    155 }
    156 
    157 /**
    158  * Sets the enabled state
    159  *
    160  * @returns COM status code
    161  * @param enabled address of result variable
    162  */
    163 STDMETHODIMP AudioAdapter::COMSETTER(Enabled)(BOOL enabled)
    164 {
    165     AutoLock lock(this);
    166     CHECK_READY();
    167 
    168     CHECK_MACHINE_MUTABILITY (mParent);
    169 
    170     if (mData->mEnabled != enabled)
     186
     187    if (mData->mEnabled != aEnabled)
    171188    {
    172189        mData.backup();
    173         mData->mEnabled = enabled;
     190        mData->mEnabled = aEnabled;
    174191    }
    175192
     
    177194}
    178195
    179 /**
    180  * Returns the current audio driver type
    181  *
    182  * @returns COM status code
    183  * @param audioDriver address of result variable
    184  */
    185 STDMETHODIMP AudioAdapter::COMGETTER(AudioDriver)(AudioDriverType_T *audioDriver)
    186 {
    187     if (!audioDriver)
     196STDMETHODIMP AudioAdapter::COMGETTER(AudioDriver)(AudioDriverType_T *aAudioDriver)
     197{
     198    if (!aAudioDriver)
    188199        return E_POINTER;
    189200
    190     AutoLock lock(this);
    191     CHECK_READY();
    192 
    193     *audioDriver = mData->mAudioDriver;
    194     return S_OK;
    195 }
    196 
    197 /**
    198  * Sets the audio driver type
    199  *
    200  * @returns COM status code
    201  * @param audioDriver audio driver type to use
    202  */
    203 STDMETHODIMP AudioAdapter::COMSETTER(AudioDriver)(AudioDriverType_T audioDriver)
    204 {
    205     AutoLock lock(this);
    206     CHECK_READY();
    207 
    208     CHECK_MACHINE_MUTABILITY (mParent);
     201    AutoCaller autoCaller (this);
     202    CheckComRCReturnRC (autoCaller.rc());
     203
     204    AutoReaderLock alock (this);
     205
     206    *aAudioDriver = mData->mAudioDriver;
     207
     208    return S_OK;
     209}
     210
     211STDMETHODIMP AudioAdapter::COMSETTER(AudioDriver)(AudioDriverType_T aAudioDriver)
     212{
     213    AutoCaller autoCaller (this);
     214    CheckComRCReturnRC (autoCaller.rc());
     215
     216    /* the machine needs to be mutable */
     217    Machine::AutoMutableStateDependency adep (mParent);
     218    CheckComRCReturnRC (adep.rc());
     219
     220    AutoLock alock (this);
    209221
    210222    HRESULT rc = S_OK;
    211223
    212     if (mData->mAudioDriver != audioDriver)
     224    if (mData->mAudioDriver != aAudioDriver)
    213225    {
    214226        /*
    215227         * which audio driver type are we supposed to use?
    216228         */
    217         switch (audioDriver)
     229        switch (aAudioDriver)
    218230        {
    219231            case AudioDriverType_NullAudioDriver:
     
    238250            {
    239251                mData.backup();
    240                 mData->mAudioDriver = audioDriver;
     252                mData->mAudioDriver = aAudioDriver;
    241253                break;
    242254            }
     
    244256            default:
    245257            {
    246                 Log(("wrong audio driver type specified!\n"));
     258                AssertMsgFailed (("Wrong audio driver type %d\n",
     259                                  aAudioDriver));
    247260                rc = E_FAIL;
    248261            }
     
    259272/////////////////////////////////////////////////////////////////////////////
    260273
     274/**
     275 *  @note Locks this object for writing.
     276 */
     277bool AudioAdapter::rollback()
     278{
     279    /* sanity */
     280    AutoCaller autoCaller (this);
     281    AssertComRCReturn (autoCaller.rc(), false);
     282
     283    AutoLock alock (this);
     284
     285    bool changed = false;
     286
     287    if (mData.isBackedUp())
     288    {
     289        /* we need to check all data to see whether anything will be changed
     290         * after rollback */
     291        changed = mData.hasActualChanges();
     292        mData.rollback();
     293    }
     294
     295    return changed;
     296}
     297
     298/**
     299 *  @note Locks this object for writing, together with the peer object (also
     300 *  for writing) if there is one.
     301 */
    261302void AudioAdapter::commit()
    262303{
    263     AutoLock alock (this);
     304    /* sanity */
     305    AutoCaller autoCaller (this);
     306    AssertComRCReturnVoid (autoCaller.rc());
     307
     308    /* sanity too */
     309    AutoCaller thatCaller (mPeer);
     310    AssertComRCReturnVoid (thatCaller.rc());
     311
     312    /* lock both for writing since we modify both */
     313    AutoMultiLock <2> alock (this->wlock(), AutoLock::maybeWlock (mPeer));
     314
    264315    if (mData.isBackedUp())
    265316    {
     
    267318        if (mPeer)
    268319        {
    269             // attach new data to the peer and reshare it
    270             AutoLock peerlock (mPeer);
     320            /* attach new data to the peer and reshare it */
    271321            mPeer->mData.attach (mData);
    272322        }
     
    274324}
    275325
     326/**
     327 *  @note Locks this object for writing, together with the peer object
     328 *  represented by @a aThat (locked for reading).
     329 */
    276330void AudioAdapter::copyFrom (AudioAdapter *aThat)
    277331{
    278     AutoLock alock (this);
    279 
    280     // this will back up current data
     332    AssertReturnVoid (aThat != NULL);
     333
     334    /* sanity */
     335    AutoCaller autoCaller (this);
     336    AssertComRCReturnVoid (autoCaller.rc());
     337
     338    /* sanity too */
     339    AutoCaller thatCaller (mPeer);
     340    AssertComRCReturnVoid (thatCaller.rc());
     341
     342    /* peer is not modified, lock it for reading */
     343    AutoMultiLock <2> alock (this->wlock(), aThat->rlock());
     344
     345    /* this will back up current data */
    281346    mData.assignCopy (aThat->mData);
    282347}
    283 
  • trunk/src/VBox/Main/DVDDriveImpl.cpp

    r3330 r3348  
    4747
    4848/**
    49  * Initializes the DVD drive object.
    50  *
    51  * @param   aParent  Handle of our parent object.
    52  * @return  COM result indicator
     49 *  Initializes the DVD drive object.
     50 *
     51 *  @param aParent  Handle of the parent object.
    5352 */
    5453HRESULT DVDDrive::init (Machine *aParent)
     
    155154    mData.free();
    156155
    157     unconst (mParent).setNull();
     156    unconst (mPeer).setNull();
    158157    unconst (mParent).setNull();
    159158}
     
    249248            mData->mDriveState = DriveState_ImageMounted;
    250249
    251             /* leave the lock before informing callbacks*/
     250            /* leave the lock before informing callbacks */
    252251            alock.unlock();
    253252
     
    283282        mData->mDriveState = DriveState_HostDriveCaptured;
    284283
    285         /* leave the lock before informing callbacks*/
     284        /* leave the lock before informing callbacks */
    286285        alock.unlock();
    287286
     
    311310        mData->mDriveState = DriveState_NotMounted;
    312311
    313         /* leave the lock before informing callbacks*/
     312        /* leave the lock before informing callbacks */
    314313        alock.unlock();
    315314
     
    406405
    407406/**
    408  *  @note Locks this object for writing, together with the peer object (locked
    409  *  for reading) if there is one.
     407 *  @note Locks this object for writing, together with the peer object
     408 *  represented by @a aThat (locked for reading).
    410409 */
    411410void DVDDrive::copyFrom (DVDDrive *aThat)
    412411{
     412    AssertReturnVoid (aThat != NULL);
     413
    413414    /* sanity */
    414415    AutoCaller autoCaller (this);
     
    420421
    421422    /* peer is not modified, lock it for reading */
    422     AutoMultiLock <2> alock (this->wlock(), AutoLock::maybeRlock (mPeer));
     423    AutoMultiLock <2> alock (this->wlock(), aThat->rlock());
    423424
    424425    /* this will back up current data */
  • trunk/src/VBox/Main/FloppyDriveImpl.cpp

    r3330 r3348  
    4747
    4848/**
    49  * Initializes the Floppy drive object.
    50  *
    51  * @param   aParent  Handle of our parent object.
    52  * @return  COM result indicator
     49 *  Initializes the Floppy drive object.
     50 *
     51 *  @param aParent  Handle of the parent object.
    5352 */
    5453HRESULT FloppyDrive::init (Machine *aParent)
     
    155154    mData.free();
    156155
    157     unconst (mParent).setNull();
     156    unconst (mPeer).setNull();
    158157    unconst (mParent).setNull();
    159158}
     
    195194        mData->mEnabled = aEnabled;
    196195
    197         /* leave the lock before informing callbacks*/
     196        /* leave the lock before informing callbacks */
    198197        alock.unlock();
    199198
     
    256255            mData->mDriveState = DriveState_ImageMounted;
    257256
    258             /* leave the lock before informing callbacks*/
     257            /* leave the lock before informing callbacks */
    259258            alock.unlock();
    260259
     
    290289        mData->mDriveState = DriveState_HostDriveCaptured;
    291290
    292         /* leave the lock before informing callbacks*/
     291        /* leave the lock before informing callbacks */
    293292        alock.unlock();
    294293
     
    318317        mData->mDriveState = DriveState_NotMounted;
    319318
    320         /* leave the lock before informing callbacks*/
     319        /* leave the lock before informing callbacks */
    321320        alock.unlock();
    322321
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r2981 r3348  
    2424#include "MachineImpl.h"
    2525
     26#include <iprt/string.h>
     27#include <iprt/cpputils.h>
     28
    2629#include <VBox/err.h>
    27 #include <iprt/string.h>
    28 
    29 // defines
    30 ////////////////////////////////////////////////////////////////////////////////
    3130
    3231// constructor / destructor
    3332////////////////////////////////////////////////////////////////////////////////
    3433
     34DEFINE_EMPTY_CTOR_DTOR (NetworkAdapter)
     35
    3536HRESULT NetworkAdapter::FinalConstruct()
    3637{
     
    4041void NetworkAdapter::FinalRelease()
    4142{
    42     if (isReady())
    43         uninit ();
     43    uninit ();
    4444}
    4545
     
    4848
    4949/**
    50  * Initializes the network adapter object.
     50 *  Initializes the network adapter object.
    5151 *
    52  * @param   parent  handle of our parent object
    53  * @return  COM result indicator
     52 *  @param aParent  Handle of the parent object.
    5453 */
    55 HRESULT NetworkAdapter::init (Machine *parent, ULONG slot)
    56 {
    57     LogFlowMember (("NetworkAdapter::init (%p): slot=%d\n", parent, slot));
    58 
    59     ComAssertRet (parent, E_INVALIDARG);
    60     ComAssertRet (slot < SchemaDefs::NetworkAdapterCount, E_INVALIDARG);
    61 
    62     AutoLock alock (this);
    63     ComAssertRet (!isReady(), E_UNEXPECTED);
    64 
    65     mParent = parent;
    66     // mPeer is left null
     54HRESULT NetworkAdapter::init (Machine *aParent, ULONG aSlot)
     55{
     56    LogFlowThisFunc (("aParent=%p, aSlot=%d\n", aParent, aSlot));
     57
     58    ComAssertRet (aParent, E_INVALIDARG);
     59    ComAssertRet (aSlot < SchemaDefs::NetworkAdapterCount, E_INVALIDARG);
     60
     61    /* Enclose the state transition NotReady->InInit->Ready */
     62    AutoInitSpan autoInitSpan (this);
     63    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     64
     65    unconst (mParent) = aParent;
     66    /* mPeer is left null */
    6767
    6868    mData.allocate();
    6969
    70     // initialize data
    71     mData->mSlot = slot;
    72 
    73     // default to Am79C973
     70    /* initialize data */
     71    mData->mSlot = aSlot;
     72
     73    /* default to Am79C973 */
    7474    mData->mAdapterType = NetworkAdapterType_NetworkAdapterAm79C973;
    7575
    76     // generate the MAC address early to guarantee it is the same both after
    77     // changing some other property (i.e. after mData.backup()) and after the
    78     // subsequent mData.rollback().
     76    /* generate the MAC address early to guarantee it is the same both after
     77     * changing some other property (i.e. after mData.backup()) and after the
     78     * subsequent mData.rollback(). */
    7979    generateMACAddress();
    8080
    81     setReady (true);
     81    /* Confirm a successful initialization */
     82    autoInitSpan.setSucceeded();
     83
    8284    return S_OK;
    8385}
     
    9092 *  @note This object must be destroyed before the original object
    9193 *  it shares data with is destroyed.
     94 *
     95 *  @note Locks @a aThat object for reading.
    9296 */
    93 HRESULT NetworkAdapter::init (Machine *parent, NetworkAdapter *that)
    94 {
    95     LogFlowMember (("NetworkAdapter::init (%p, %p)\n", parent, that));
    96 
    97     ComAssertRet (parent && that, E_INVALIDARG);
    98 
    99     AutoLock alock (this);
    100     ComAssertRet (!isReady(), E_UNEXPECTED);
    101 
    102     mParent = parent;
    103     mPeer = that;
    104 
    105     AutoLock thatlock (that);
    106     mData.share (that->mData);
    107 
    108     setReady (true);
     97HRESULT NetworkAdapter::init (Machine *aParent, NetworkAdapter *aThat)
     98{
     99    LogFlowThisFunc (("aParent=%p, aThat=%p\n", aParent, aThat));
     100
     101    ComAssertRet (aParent && aThat, E_INVALIDARG);
     102
     103    /* Enclose the state transition NotReady->InInit->Ready */
     104    AutoInitSpan autoInitSpan (this);
     105    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     106
     107    unconst (mParent) = aParent;
     108    unconst (mPeer) = aThat;
     109
     110    AutoCaller thatCaller (aThat);
     111    AssertComRCReturnRC (thatCaller.rc());
     112
     113    AutoReaderLock thatLock (aThat);
     114    mData.share (aThat->mData);
     115
     116    /* Confirm a successful initialization */
     117    autoInitSpan.setSucceeded();
     118
    109119    return S_OK;
    110120}
     
    114124 *  (a kind of copy constructor). This object makes a private copy of data
    115125 *  of the original object passed as an argument.
     126 *
     127 *  @note Locks @a aThat object for reading.
    116128 */
    117 HRESULT NetworkAdapter::initCopy (Machine *parent, NetworkAdapter *that)
    118 {
    119     LogFlowMember (("NetworkAdapter::initCopy (%p, %p)\n", parent, that));
    120 
    121     ComAssertRet (parent && that, E_INVALIDARG);
    122 
    123     AutoLock alock (this);
    124     ComAssertRet (!isReady(), E_UNEXPECTED);
    125 
    126     mParent = parent;
    127     // mPeer is left null
    128 
    129     AutoLock thatlock (that);
    130     mData.attachCopy (that->mData);
    131 
    132     setReady (true);
     129HRESULT NetworkAdapter::initCopy (Machine *aParent, NetworkAdapter *aThat)
     130{
     131    LogFlowThisFunc (("aParent=%p, aThat=%p\n", aParent, aThat));
     132
     133    ComAssertRet (aParent && aThat, E_INVALIDARG);
     134
     135    /* Enclose the state transition NotReady->InInit->Ready */
     136    AutoInitSpan autoInitSpan (this);
     137    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
     138
     139    unconst (mParent) = aParent;
     140    /* mPeer is left null */
     141
     142    AutoCaller thatCaller (aThat);
     143    AssertComRCReturnRC (thatCaller.rc());
     144
     145    AutoReaderLock thatLock (aThat);
     146    mData.attachCopy (aThat->mData);
     147
     148    /* Confirm a successful initialization */
     149    autoInitSpan.setSucceeded();
     150
    133151    return S_OK;
    134152}
     
    140158void NetworkAdapter::uninit()
    141159{
    142     LogFlowMember (("INetworkAdapter::uninit()\n"));
    143 
    144     AutoLock alock (this);
    145     AssertReturn (isReady(), (void) 0);
     160    LogFlowThisFunc (("\n"));
     161
     162    /* Enclose the state transition Ready->InUninit->NotReady */
     163    AutoUninitSpan autoUninitSpan (this);
     164    if (autoUninitSpan.uninitDone())
     165        return;
    146166
    147167    mData.free();
    148168
    149     mPeer.setNull();
    150     mParent.setNull();
    151 
    152     setReady (false);
     169    unconst (mPeer).setNull();
     170    unconst (mParent).setNull();
    153171}
    154172
     
    156174////////////////////////////////////////////////////////////////////////////////
    157175
    158 STDMETHODIMP NetworkAdapter::COMGETTER(AdapterType) (NetworkAdapterType_T *adapterType)
    159 {
    160     if (!adapterType)
    161         return E_POINTER;
    162 
    163     AutoLock alock (this);
    164     CHECK_READY();
    165 
    166     *adapterType = mData->mAdapterType;
    167     return S_OK;
    168 }
    169 
    170 STDMETHODIMP NetworkAdapter::COMSETTER(AdapterType) (NetworkAdapterType_T adapterType)
    171 {
    172     AutoLock alock(this);
    173     CHECK_READY();
    174 
    175     CHECK_MACHINE_MUTABILITY (mParent);
     176STDMETHODIMP NetworkAdapter::COMGETTER(AdapterType) (NetworkAdapterType_T *aAdapterType)
     177{
     178    if (!aAdapterType)
     179        return E_POINTER;
     180
     181    AutoCaller autoCaller (this);
     182    CheckComRCReturnRC (autoCaller.rc());
     183
     184    AutoReaderLock alock (this);
     185
     186    *aAdapterType = mData->mAdapterType;
     187
     188    return S_OK;
     189}
     190
     191STDMETHODIMP NetworkAdapter::COMSETTER(AdapterType) (NetworkAdapterType_T aAdapterType)
     192{
     193    AutoCaller autoCaller (this);
     194    CheckComRCReturnRC (autoCaller.rc());
     195
     196    /* the machine needs to be mutable */
     197    Machine::AutoMutableStateDependency adep (mParent);
     198    CheckComRCReturnRC (adep.rc());
     199
     200    AutoLock alock (this);
    176201
    177202    /* make sure the value is allowed */
    178     switch (adapterType)
     203    switch (aAdapterType)
    179204    {
    180205        case NetworkAdapterType_NetworkAdapterAm79C970A:
     
    182207            break;
    183208        default:
    184             return setError(E_FAIL, tr("Invalid network adapter type '%d'"), adapterType);
    185     }
    186 
    187     if (mData->mAdapterType != adapterType)
    188     {
    189         mData.backup();
    190         mData->mAdapterType = adapterType;
    191 
    192         /* notify parent */
    193         alock.unlock();
    194         mParent->onNetworkAdapterChange (this);
    195     }
    196 
    197     return S_OK;
    198 }
    199 
    200 STDMETHODIMP NetworkAdapter::COMGETTER(Slot) (ULONG *slot)
    201 {
    202     if (!slot)
    203         return E_POINTER;
    204 
    205     AutoLock alock (this);
    206     CHECK_READY();
    207 
    208     *slot = mData->mSlot;
    209     return S_OK;
    210 }
    211 
    212 STDMETHODIMP NetworkAdapter::COMGETTER(Enabled) (BOOL *enabled)
    213 {
    214     if (!enabled)
    215         return E_POINTER;
    216 
    217     AutoLock alock (this);
    218     CHECK_READY();
    219 
    220     *enabled = mData->mEnabled;
    221     return S_OK;
    222 }
    223 
    224 STDMETHODIMP NetworkAdapter::COMSETTER(Enabled) (BOOL enabled)
    225 {
    226     AutoLock alock(this);
    227     CHECK_READY();
    228 
    229     CHECK_MACHINE_MUTABILITY (mParent);
    230 
    231     if (mData->mEnabled != enabled)
    232     {
    233         mData.backup();
    234         mData->mEnabled = enabled;
    235 
    236         /* notify parent */
    237         alock.unlock();
    238         mParent->onNetworkAdapterChange (this);
    239     }
    240 
    241     return S_OK;
    242 }
    243 
    244 /**
    245  * Returns the MAC address string
    246  *
    247  * @returns COM status code
    248  * @param macAddress address of result variable
    249  */
    250 STDMETHODIMP NetworkAdapter::COMGETTER(MACAddress)(BSTR *macAddress)
    251 {
    252     if (!macAddress)
    253         return E_POINTER;
    254 
    255     AutoLock alock(this);
    256     CHECK_READY();
     209            return setError (E_FAIL,
     210                tr("Invalid network adapter type '%d'"),
     211                aAdapterType);
     212    }
     213
     214    if (mData->mAdapterType != aAdapterType)
     215    {
     216        mData.backup();
     217        mData->mAdapterType = aAdapterType;
     218
     219        /* leave the lock before informing callbacks */
     220        alock.unlock();
     221
     222        mParent->onNetworkAdapterChange (this);
     223    }
     224
     225    return S_OK;
     226}
     227
     228STDMETHODIMP NetworkAdapter::COMGETTER(Slot) (ULONG *aSlot)
     229{
     230    if (!aSlot)
     231        return E_POINTER;
     232
     233    AutoCaller autoCaller (this);
     234    CheckComRCReturnRC (autoCaller.rc());
     235
     236    AutoReaderLock alock (this);
     237
     238    *aSlot = mData->mSlot;
     239
     240    return S_OK;
     241}
     242
     243STDMETHODIMP NetworkAdapter::COMGETTER(Enabled) (BOOL *aEnabled)
     244{
     245    if (!aEnabled)
     246        return E_POINTER;
     247
     248    AutoCaller autoCaller (this);
     249    CheckComRCReturnRC (autoCaller.rc());
     250
     251    AutoReaderLock alock (this);
     252
     253    *aEnabled = mData->mEnabled;
     254
     255    return S_OK;
     256}
     257
     258STDMETHODIMP NetworkAdapter::COMSETTER(Enabled) (BOOL aEnabled)
     259{
     260    AutoCaller autoCaller (this);
     261    CheckComRCReturnRC (autoCaller.rc());
     262
     263    /* the machine needs to be mutable */
     264    Machine::AutoMutableStateDependency adep (mParent);
     265    CheckComRCReturnRC (adep.rc());
     266
     267    AutoLock alock (this);
     268
     269    if (mData->mEnabled != aEnabled)
     270    {
     271        mData.backup();
     272        mData->mEnabled = aEnabled;
     273
     274        /* leave the lock before informing callbacks */
     275        alock.unlock();
     276
     277        mParent->onNetworkAdapterChange (this);
     278    }
     279
     280    return S_OK;
     281}
     282
     283STDMETHODIMP NetworkAdapter::COMGETTER(MACAddress)(BSTR *aMACAddress)
     284{
     285    if (!aMACAddress)
     286        return E_POINTER;
     287
     288    AutoCaller autoCaller (this);
     289    CheckComRCReturnRC (autoCaller.rc());
     290
     291    AutoReaderLock alock (this);
    257292
    258293    ComAssertRet (!!mData->mMACAddress, E_FAIL);
    259294
    260     mData->mMACAddress.cloneTo (macAddress);
    261 
    262     return S_OK;
    263 }
    264 
    265 /**
    266  * Sets the MAC address
    267  *
    268  * @returns COM status code
    269  * @param   macAddress 12-digit hexadecimal MAC address string with
    270  *                     capital letters. Can be NULL to generate a MAC
    271  */
    272 STDMETHODIMP NetworkAdapter::COMSETTER(MACAddress)(INPTR BSTR macAddress)
    273 {
    274     AutoLock alock(this);
    275     CHECK_READY();
    276 
    277     CHECK_MACHINE_MUTABILITY (mParent);
     295    mData->mMACAddress.cloneTo (aMACAddress);
     296
     297    return S_OK;
     298}
     299
     300STDMETHODIMP NetworkAdapter::COMSETTER(MACAddress)(INPTR BSTR aMACAddress)
     301{
     302    AutoCaller autoCaller (this);
     303    CheckComRCReturnRC (autoCaller.rc());
     304
     305    /* the machine needs to be mutable */
     306    Machine::AutoMutableStateDependency adep (mParent);
     307    CheckComRCReturnRC (adep.rc());
     308
     309    AutoLock alock (this);
    278310
    279311    HRESULT rc = S_OK;
     
    283315     * Are we supposed to generate a MAC?
    284316     */
    285     if (!macAddress)
    286     {
    287         mData.backup();
     317    if (!aMACAddress)
     318    {
     319        mData.backup();
     320
    288321        generateMACAddress();
    289322        emitChangeEvent = true;
     
    291324    else
    292325    {
    293         if (mData->mMACAddress != macAddress)
     326        if (mData->mMACAddress != aMACAddress)
    294327        {
    295328            /*
    296329             * Verify given MAC address
    297330             */
    298             Utf8Str macAddressUtf = macAddress;
     331            Utf8Str macAddressUtf = aMACAddress;
    299332            char *macAddressStr = (char*)macAddressUtf.raw();
    300333            int i = 0;
     
    316349            {
    317350                mData.backup();
    318                 mData->mMACAddress = macAddress;
     351
     352                mData->mMACAddress = aMACAddress;
    319353                emitChangeEvent = true;
    320354            }
     
    324358    if (emitChangeEvent)
    325359    {
    326         /* notify parent */
    327         alock.unlock();
     360        /* leave the lock before informing callbacks */
     361        alock.unlock();
     362
    328363        mParent->onNetworkAdapterChange (this);
    329364    }
     
    332367}
    333368
    334 /**
    335  * Returns the attachment type
    336  *
    337  * @returns COM status code
    338  * @param   attachmentType address of result variable
    339  */
    340 STDMETHODIMP NetworkAdapter::COMGETTER(AttachmentType)(NetworkAttachmentType_T *attachmentType)
    341 {
    342     if (!attachmentType)
    343         return E_POINTER;
    344     AutoLock alock(this);
    345     CHECK_READY();
    346 
    347     *attachmentType = mData->mAttachmentType;
    348 
    349     return S_OK;
    350 }
    351 
    352 /**
    353  * Returns the host interface the adapter is attached to
    354  *
    355  * @returns COM status code
    356  * @param   hostInterface address of result string
    357  */
    358 STDMETHODIMP NetworkAdapter::COMGETTER(HostInterface)(BSTR *hostInterface)
    359 {
    360     if (!hostInterface)
    361         return E_POINTER;
    362     AutoLock alock(this);
    363     CHECK_READY();
    364 
    365     mData->mHostInterface.cloneTo(hostInterface);
    366 
    367     return S_OK;
    368 }
    369 
    370 /**
    371  * Sets the host interface device name.
    372  *
    373  * @returns COM status code
    374  * @param   hostInterface name of the host interface device in use
    375  */
    376 STDMETHODIMP NetworkAdapter::COMSETTER(HostInterface)(INPTR BSTR hostInterface)
     369STDMETHODIMP NetworkAdapter::COMGETTER(AttachmentType)(
     370    NetworkAttachmentType_T *aAttachmentType)
     371{
     372    if (!aAttachmentType)
     373        return E_POINTER;
     374
     375    AutoCaller autoCaller (this);
     376    CheckComRCReturnRC (autoCaller.rc());
     377
     378    AutoReaderLock alock (this);
     379
     380    *aAttachmentType = mData->mAttachmentType;
     381
     382    return S_OK;
     383}
     384
     385STDMETHODIMP NetworkAdapter::COMGETTER(HostInterface)(BSTR *aHostInterface)
     386{
     387    if (!aHostInterface)
     388        return E_POINTER;
     389
     390    AutoCaller autoCaller (this);
     391    CheckComRCReturnRC (autoCaller.rc());
     392
     393    AutoReaderLock alock (this);
     394
     395    mData->mHostInterface.cloneTo (aHostInterface);
     396
     397    return S_OK;
     398}
     399
     400STDMETHODIMP NetworkAdapter::COMSETTER(HostInterface)(INPTR BSTR aHostInterface)
    377401{
    378402    /** @todo Validate input string length. r=dmik: do it in XML schema?*/
     
    382406    // (because the @name attribute of <HostInerface> must be always present,
    383407    // but can be empty).
    384     if (!hostInterface)
     408    if (!aHostInterface)
    385409        return E_INVALIDARG;
    386410#endif
    387411#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
    388412    // empty strings are not allowed as path names
    389     if (hostInterface && !(*hostInterface))
     413    if (aHostInterface && !(*aHostInterface))
    390414        return E_INVALIDARG;
    391415#endif
    392416
    393     AutoLock alock(this);
    394     CHECK_READY();
    395 
    396     CHECK_MACHINE_MUTABILITY (mParent);
    397 
    398     if (mData->mHostInterface != hostInterface)
    399     {
    400         mData.backup();
    401         mData->mHostInterface = hostInterface;
    402 
    403         /* notify parent */
    404         alock.unlock();
    405         mParent->onNetworkAdapterChange(this);
     417     AutoCaller autoCaller (this);
     418    CheckComRCReturnRC (autoCaller.rc());
     419
     420    /* the machine needs to be mutable */
     421    Machine::AutoMutableStateDependency adep (mParent);
     422    CheckComRCReturnRC (adep.rc());
     423
     424    AutoLock alock (this);
     425
     426    if (mData->mHostInterface != aHostInterface)
     427    {
     428        mData.backup();
     429        mData->mHostInterface = aHostInterface;
     430
     431        /* leave the lock before informing callbacks */
     432        alock.unlock();
     433
     434        mParent->onNetworkAdapterChange (this);
    406435    }
    407436
     
    410439
    411440#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
    412 /**
    413  * Returns the TAP file descriptor the adapter is attached to
    414  *
    415  * @returns COM status code
    416  * @param   tapFileDescriptor address of result string
    417  */
    418 STDMETHODIMP NetworkAdapter::COMGETTER(TAPFileDescriptor)(LONG *tapFileDescriptor)
    419 {
    420     if (!tapFileDescriptor)
    421         return E_POINTER;
    422 
    423     AutoLock alock(this);
    424     CHECK_READY();
    425 
    426     *tapFileDescriptor = mData->mTAPFD;
    427 
    428     return S_OK;
    429 }
    430 
    431 /**
    432  * Sets the TAP file descriptor the adapter is attached to
    433  *
    434  * @returns COM status code
    435  * @param   tapFileDescriptor file descriptor of existing TAP interface
    436  */
    437 STDMETHODIMP NetworkAdapter::COMSETTER(TAPFileDescriptor)(LONG tapFileDescriptor)
     441
     442STDMETHODIMP NetworkAdapter::COMGETTER(TAPFileDescriptor)(LONG *aTAPFileDescriptor)
     443{
     444    if (!aTAPFileDescriptor)
     445        return E_POINTER;
     446
     447    AutoCaller autoCaller (this);
     448    CheckComRCReturnRC (autoCaller.rc());
     449
     450    AutoReaderLock alock (this);
     451
     452    *aTAPFileDescriptor = mData->mTAPFD;
     453
     454    return S_OK;
     455}
     456
     457STDMETHODIMP NetworkAdapter::COMSETTER(TAPFileDescriptor)(LONG aTAPFileDescriptor)
    438458{
    439459    /*
    440460     * Validate input.
    441461     */
    442     RTFILE tapFD = tapFileDescriptor;
    443     if (tapFD != NIL_RTFILE && (LONG)tapFD != tapFileDescriptor)
    444     {
    445         AssertMsgFailed(("Invalid file descriptor: %ld.\n", tapFileDescriptor));
     462    RTFILE tapFD = aTAPFileDescriptor;
     463    if (tapFD != NIL_RTFILE && (LONG)tapFD != aTAPFileDescriptor)
     464    {
     465        AssertMsgFailed(("Invalid file descriptor: %ld.\n", aTAPFileDescriptor));
    446466        return setError (E_INVALIDARG,
    447             tr ("Invalid file descriptor: %ld"), tapFileDescriptor);
    448     }
    449 
    450     AutoLock alock(this);
    451     CHECK_READY();
    452 
    453     CHECK_MACHINE_MUTABILITY (mParent);
    454 
    455     if (mData->mTAPFD != (RTFILE) tapFileDescriptor)
    456     {
    457         mData.backup();
    458         mData->mTAPFD = tapFileDescriptor;
    459 
    460         /* notify parent */
    461         alock.unlock();
     467            tr ("Invalid file descriptor: %ld"), aTAPFileDescriptor);
     468    }
     469
     470    AutoCaller autoCaller (this);
     471    CheckComRCReturnRC (autoCaller.rc());
     472
     473    /* the machine needs to be mutable */
     474    Machine::AutoMutableStateDependency adep (mParent);
     475    CheckComRCReturnRC (adep.rc());
     476
     477    AutoLock alock (this);
     478
     479    if (mData->mTAPFD != (RTFILE) aTAPFileDescriptor)
     480    {
     481        mData.backup();
     482        mData->mTAPFD = aTAPFileDescriptor;
     483
     484        /* leave the lock before informing callbacks */
     485        alock.unlock();
     486
     487        mParent->onNetworkAdapterChange (this);
     488    }
     489
     490    return S_OK;
     491}
     492
     493STDMETHODIMP NetworkAdapter::COMGETTER(TAPSetupApplication) (
     494    BSTR *aTAPSetupApplication)
     495{
     496    if (!aTAPSetupApplication)
     497        return E_POINTER;
     498
     499    AutoCaller autoCaller (this);
     500    CheckComRCReturnRC (autoCaller.rc());
     501
     502    AutoReaderLock alock (this);
     503
     504    /* we don't have to be in TAP mode to support this call */
     505    mData->mTAPSetupApplication.cloneTo (aTAPSetupApplication);
     506
     507    return S_OK;
     508}
     509
     510STDMETHODIMP NetworkAdapter::COMSETTER(TAPSetupApplication) (
     511    INPTR BSTR aTAPSetupApplication)
     512{
     513    /* empty strings are not allowed as path names */
     514    if (aTAPSetupApplication && !(*aTAPSetupApplication))
     515        return E_INVALIDARG;
     516
     517    AutoCaller autoCaller (this);
     518    CheckComRCReturnRC (autoCaller.rc());
     519
     520    /* the machine needs to be mutable */
     521    Machine::AutoMutableStateDependency adep (mParent);
     522    CheckComRCReturnRC (adep.rc());
     523
     524    AutoLock alock (this);
     525
     526    if (mData->mTAPSetupApplication != aTAPSetupApplication)
     527    {
     528        mData.backup();
     529        mData->mTAPSetupApplication = aTAPSetupApplication;
     530
     531        /* leave the lock before informing callbacks */
     532        alock.unlock();
     533
     534        mParent->onNetworkAdapterChange (this);
     535    }
     536
     537    return S_OK;
     538}
     539
     540STDMETHODIMP NetworkAdapter::COMGETTER(TAPTerminateApplication) (
     541    BSTR *aTAPTerminateApplication)
     542{
     543    if (!aTAPTerminateApplication)
     544        return E_POINTER;
     545
     546    AutoCaller autoCaller (this);
     547    CheckComRCReturnRC (autoCaller.rc());
     548
     549    AutoReaderLock alock (this);
     550
     551    /* we don't have to be in TAP mode to support this call */
     552    mData->mTAPTerminateApplication.cloneTo(aTAPTerminateApplication);
     553
     554    return S_OK;
     555}
     556
     557STDMETHODIMP NetworkAdapter::COMSETTER(TAPTerminateApplication) (
     558    INPTR BSTR aTAPTerminateApplication)
     559{
     560    /* empty strings are not allowed as path names */
     561    if (aTAPTerminateApplication && !(*aTAPTerminateApplication))
     562        return E_INVALIDARG;
     563
     564    AutoCaller autoCaller (this);
     565    CheckComRCReturnRC (autoCaller.rc());
     566
     567    /* the machine needs to be mutable */
     568    Machine::AutoMutableStateDependency adep (mParent);
     569    CheckComRCReturnRC (adep.rc());
     570
     571    AutoLock alock (this);
     572
     573    if (mData->mTAPTerminateApplication != aTAPTerminateApplication)
     574    {
     575        mData.backup();
     576        mData->mTAPTerminateApplication = aTAPTerminateApplication;
     577
     578        /* leave the lock before informing callbacks */
     579        alock.unlock();
     580
    462581        mParent->onNetworkAdapterChange(this);
    463582    }
     
    466585}
    467586
    468 
    469 /**
    470  * Returns the current TAP setup application path
    471  *
    472  * @returns COM status code
    473  * @param   tapSetupApplication address of result buffer
    474  */
    475 STDMETHODIMP NetworkAdapter::COMGETTER(TAPSetupApplication)(BSTR *tapSetupApplication)
    476 {
    477     if (!tapSetupApplication)
    478         return E_POINTER;
    479     AutoLock alock(this);
    480     CHECK_READY();
    481 
    482     /* we don't have to be in TAP mode to support this call */
    483     mData->mTAPSetupApplication.cloneTo(tapSetupApplication);
    484 
    485     return S_OK;
    486 }
    487 
    488 /**
    489  * Stores a new TAP setup application
    490  *
    491  * @returns COM status code
    492  * @param   tapSetupApplication new TAP setup application path
    493  */
    494 STDMETHODIMP NetworkAdapter::COMSETTER(TAPSetupApplication)(INPTR BSTR tapSetupApplication)
    495 {
    496     // empty strings are not allowed as path names
    497     if (tapSetupApplication && !(*tapSetupApplication))
     587#endif /* VBOX_WITH_UNIXY_TAP_NETWORKING */
     588
     589STDMETHODIMP NetworkAdapter::COMGETTER(InternalNetwork) (BSTR *aInternalNetwork)
     590{
     591    /* we don't allow null strings */
     592    if (!aInternalNetwork)
     593        return E_POINTER;
     594
     595    AutoCaller autoCaller (this);
     596    CheckComRCReturnRC (autoCaller.rc());
     597
     598    AutoReaderLock alock (this);
     599
     600    mData->mInternalNetwork.cloneTo (aInternalNetwork);
     601
     602    return S_OK;
     603}
     604
     605STDMETHODIMP NetworkAdapter::COMSETTER(InternalNetwork) (INPTR BSTR aInternalNetwork)
     606{
     607    if (!aInternalNetwork)
    498608        return E_INVALIDARG;
    499609
    500     AutoLock alock(this);
    501     CHECK_READY();
    502 
    503     CHECK_MACHINE_MUTABILITY (mParent);
    504 
    505     if (mData->mTAPSetupApplication != tapSetupApplication)
    506     {
    507         mData.backup();
    508         mData->mTAPSetupApplication = tapSetupApplication;
    509 
    510         /* notify parent */
    511         alock.unlock();
    512         mParent->onNetworkAdapterChange(this);
    513     }
    514 
    515     return S_OK;
    516 }
    517 
    518 /**
    519  * Returns the current TAP terminate application path
    520  *
    521  * @returns COM status code
    522  * @param   tapTerminateApplication address of result buffer
    523  */
    524 STDMETHODIMP NetworkAdapter::COMGETTER(TAPTerminateApplication)(BSTR *tapTerminateApplication)
    525 {
    526     if (!tapTerminateApplication)
    527         return E_POINTER;
    528     AutoLock alock(this);
    529     CHECK_READY();
    530 
    531     /* we don't have to be in TAP mode to support this call */
    532     mData->mTAPTerminateApplication.cloneTo(tapTerminateApplication);
    533 
    534     return S_OK;
    535 }
    536 
    537 /**
    538  * Stores a new TAP terminate application
    539  *
    540  * @returns COM status code
    541  * @param   tapTerminateApplication new TAP terminate application path
    542  */
    543 STDMETHODIMP NetworkAdapter::COMSETTER(TAPTerminateApplication)(INPTR BSTR tapTerminateApplication)
    544 {
    545     // empty strings are not allowed as path names
    546     if (tapTerminateApplication && !(*tapTerminateApplication))
    547         return E_INVALIDARG;
    548 
    549     AutoLock alock(this);
    550     CHECK_READY();
    551 
    552     CHECK_MACHINE_MUTABILITY (mParent);
    553 
    554     if (mData->mTAPTerminateApplication != tapTerminateApplication)
    555     {
    556         mData.backup();
    557         mData->mTAPTerminateApplication = tapTerminateApplication;
    558 
    559         /* notify parent */
    560         alock.unlock();
    561         mParent->onNetworkAdapterChange(this);
    562     }
    563 
    564     return S_OK;
    565 }
    566 
    567 #endif /* VBOX_WITH_UNIXY_TAP_NETWORKING */
    568 
    569 /**
    570  * Returns the internal network the adapter is attached to
    571  *
    572  * @returns COM status code
    573  * @param   internalNetwork address of result variable
    574  */
    575 STDMETHODIMP NetworkAdapter::COMGETTER(InternalNetwork)(BSTR *internalNetwork)
    576 {
    577     // we don't allow null strings
    578     if (!internalNetwork)
    579         return E_POINTER;
    580     AutoLock alock(this);
    581     CHECK_READY();
    582 
    583     mData->mInternalNetwork.cloneTo(internalNetwork);
    584 
    585     return S_OK;
    586 }
    587 
    588 /**
    589  * Sets the internal network for attachment.
    590  *
    591  * @returns COM status code
    592  * @param   internalNetwork internal network name
    593  */
    594 STDMETHODIMP NetworkAdapter::COMSETTER(InternalNetwork)(INPTR BSTR internalNetwork)
    595 {
    596     if (!internalNetwork)
    597         return E_INVALIDARG;
    598 
    599     AutoLock alock(this);
    600     CHECK_READY();
    601 
    602     CHECK_MACHINE_MUTABILITY (mParent);
    603 
    604     if (mData->mInternalNetwork != internalNetwork)
     610    AutoCaller autoCaller (this);
     611    CheckComRCReturnRC (autoCaller.rc());
     612
     613    /* the machine needs to be mutable */
     614    Machine::AutoMutableStateDependency adep (mParent);
     615    CheckComRCReturnRC (adep.rc());
     616
     617    AutoLock alock (this);
     618
     619    if (mData->mInternalNetwork != aInternalNetwork)
    605620    {
    606621        /* if an empty string is to be set, internal networking must be turned off */
    607         if (   (internalNetwork == Bstr(""))
     622        if (   (aInternalNetwork == Bstr(""))
    608623            && (mData->mAttachmentType = NetworkAttachmentType_InternalNetworkAttachment))
    609624        {
    610             return setError(E_FAIL, tr("A valid internal network name must be set"));
     625            return setError (E_FAIL, tr ("Empty internal network name is not valid"));
    611626        }
    612627
    613628        mData.backup();
    614         mData->mInternalNetwork = internalNetwork;
    615 
    616         /* notify parent */
    617         alock.unlock();
    618         mParent->onNetworkAdapterChange(this);
    619     }
    620 
    621     return S_OK;
    622 }
    623 
    624 
    625 /**
    626  * Return the current cable status
    627  *
    628  * @returns COM status code
    629  * @param   connected address of result variable
    630  */
    631 STDMETHODIMP NetworkAdapter::COMGETTER(CableConnected)(BOOL *connected)
    632 {
    633     if (!connected)
    634         return E_POINTER;
    635 
    636     AutoLock alock(this);
    637     CHECK_READY();
    638 
    639     *connected = mData->mCableConnected;
    640     return S_OK;
    641 }
    642 
    643 /**
    644  * Set the cable status flag.
    645  *
    646  * @returns COM status code
    647  * @param   connected new trace flag
    648  */
    649 STDMETHODIMP NetworkAdapter::COMSETTER(CableConnected)(BOOL connected)
    650 {
    651     AutoLock alock(this);
    652     CHECK_READY();
    653 
    654     CHECK_MACHINE_MUTABILITY (mParent);
    655 
    656     if (connected != mData->mCableConnected)
    657     {
    658         mData.backup();
    659         mData->mCableConnected = connected;
    660 
    661         /* notify parent */
    662         alock.unlock();
    663         mParent->onNetworkAdapterChange(this);
    664     }
    665 
    666     return S_OK;
    667 }
    668 
    669 /**
    670  * Return the current trace status
    671  *
    672  * @returns COM status code
    673  * @param   enabled address of result variable
    674  */
    675 STDMETHODIMP NetworkAdapter::COMGETTER(TraceEnabled)(BOOL *enabled)
    676 {
    677     if (!enabled)
    678         return E_POINTER;
    679 
    680     AutoLock alock(this);
    681     CHECK_READY();
    682 
    683     *enabled = mData->mTraceEnabled;
    684     return S_OK;
    685 }
    686 
    687 /**
    688  * Set the trace flag.
    689  *
    690  * @returns COM status code
    691  * @param   enabled new trace flag
    692  */
    693 STDMETHODIMP NetworkAdapter::COMSETTER(TraceEnabled)(BOOL enabled)
    694 {
    695     AutoLock alock(this);
    696     CHECK_READY();
    697 
    698     CHECK_MACHINE_MUTABILITY (mParent);
    699 
    700     if (enabled != mData->mTraceEnabled)
    701     {
    702         mData.backup();
    703         mData->mTraceEnabled = enabled;
    704 
    705         /* notify parent */
    706         alock.unlock();
    707         mParent->onNetworkAdapterChange(this);
    708     }
    709 
    710     return S_OK;
    711 }
    712 
    713 /**
    714  * Return the current trace file name
    715  *
    716  * @returns COM status code
    717  * @param   address where to store result
    718  */
    719 STDMETHODIMP NetworkAdapter::COMGETTER(TraceFile)(BSTR *traceFile)
    720 {
    721     if (!traceFile)
    722         return E_POINTER;
    723 
    724     AutoLock alock(this);
    725     CHECK_READY();
    726 
    727     mData->mTraceFile.cloneTo(traceFile);
    728     return S_OK;
    729 }
    730 
    731 /**
    732  * Set the trace file name
    733  *
    734  * @returns COM status code
    735  * @param   New trace file name
    736  */
    737 STDMETHODIMP NetworkAdapter::COMSETTER(TraceFile)(INPTR BSTR traceFile)
    738 {
    739     if (!traceFile)
     629        mData->mInternalNetwork = aInternalNetwork;
     630
     631        /* leave the lock before informing callbacks */
     632        alock.unlock();
     633
     634        mParent->onNetworkAdapterChange (this);
     635    }
     636
     637    return S_OK;
     638}
     639
     640STDMETHODIMP NetworkAdapter::COMGETTER(CableConnected) (BOOL *aConnected)
     641{
     642    if (!aConnected)
     643        return E_POINTER;
     644
     645    AutoCaller autoCaller (this);
     646    CheckComRCReturnRC (autoCaller.rc());
     647
     648    AutoReaderLock alock (this);
     649
     650    *aConnected = mData->mCableConnected;
     651
     652    return S_OK;
     653}
     654
     655STDMETHODIMP NetworkAdapter::COMSETTER(CableConnected) (BOOL aConnected)
     656{
     657    AutoCaller autoCaller (this);
     658    CheckComRCReturnRC (autoCaller.rc());
     659
     660    /* the machine needs to be mutable */
     661    Machine::AutoMutableStateDependency adep (mParent);
     662    CheckComRCReturnRC (adep.rc());
     663
     664    AutoLock alock (this);
     665
     666    if (aConnected != mData->mCableConnected)
     667    {
     668        mData.backup();
     669        mData->mCableConnected = aConnected;
     670
     671        /* leave the lock before informing callbacks */
     672        alock.unlock();
     673
     674        mParent->onNetworkAdapterChange (this);
     675    }
     676
     677    return S_OK;
     678}
     679
     680STDMETHODIMP NetworkAdapter::COMGETTER(TraceEnabled) (BOOL *aEnabled)
     681{
     682    if (!aEnabled)
     683        return E_POINTER;
     684
     685    AutoCaller autoCaller (this);
     686    CheckComRCReturnRC (autoCaller.rc());
     687
     688    AutoReaderLock alock (this);
     689
     690    *aEnabled = mData->mTraceEnabled;
     691    return S_OK;
     692}
     693
     694STDMETHODIMP NetworkAdapter::COMSETTER(TraceEnabled) (BOOL aEnabled)
     695{
     696    AutoCaller autoCaller (this);
     697    CheckComRCReturnRC (autoCaller.rc());
     698
     699    /* the machine needs to be mutable */
     700    Machine::AutoMutableStateDependency adep (mParent);
     701    CheckComRCReturnRC (adep.rc());
     702
     703    AutoLock alock (this);
     704
     705    if (aEnabled != mData->mTraceEnabled)
     706    {
     707        mData.backup();
     708        mData->mTraceEnabled = aEnabled;
     709
     710        /* leave the lock before informing callbacks */
     711        alock.unlock();
     712
     713        mParent->onNetworkAdapterChange (this);
     714    }
     715
     716    return S_OK;
     717}
     718
     719STDMETHODIMP NetworkAdapter::COMGETTER(TraceFile) (BSTR *aTraceFile)
     720{
     721    if (!aTraceFile)
     722        return E_POINTER;
     723
     724    AutoCaller autoCaller (this);
     725    CheckComRCReturnRC (autoCaller.rc());
     726
     727    AutoReaderLock alock (this);
     728
     729    mData->mTraceFile.cloneTo (aTraceFile);
     730
     731    return S_OK;
     732}
     733
     734STDMETHODIMP NetworkAdapter::COMSETTER(TraceFile) (INPTR BSTR aTraceFile)
     735{
     736    if (!aTraceFile)
    740737        return E_INVALIDARG;
    741738
    742     AutoLock alock(this);
    743     CHECK_READY();
    744 
    745     CHECK_MACHINE_MUTABILITY(mParent);
    746 
    747     mData.backup();
    748     mData->mTraceFile = traceFile;
    749 
    750     /* notify parent */
    751     alock.unlock();
    752     mParent->onNetworkAdapterChange(this);
     739    AutoCaller autoCaller (this);
     740    CheckComRCReturnRC (autoCaller.rc());
     741
     742    /* the machine needs to be mutable */
     743    Machine::AutoMutableStateDependency adep (mParent);
     744    CheckComRCReturnRC (adep.rc());
     745
     746    AutoLock alock (this);
     747
     748    if (mData->mTraceFile != aTraceFile)
     749    {
     750        mData.backup();
     751        mData->mTraceFile = aTraceFile;
     752
     753        /* leave the lock before informing callbacks */
     754        alock.unlock();
     755
     756        mParent->onNetworkAdapterChange (this);
     757    }
    753758
    754759    return S_OK;
     
    758763////////////////////////////////////////////////////////////////////////////////
    759764
    760 /**
    761  * Attach the network card to the NAT interface.
    762  *
    763  * @returns COM status code
    764  */
    765765STDMETHODIMP NetworkAdapter::AttachToNAT()
    766766{
    767     AutoLock alock(this);
    768     CHECK_READY();
    769 
    770     CHECK_MACHINE_MUTABILITY (mParent);
     767    AutoCaller autoCaller (this);
     768    CheckComRCReturnRC (autoCaller.rc());
     769
     770    /* the machine needs to be mutable */
     771    Machine::AutoMutableStateDependency adep (mParent);
     772    CheckComRCReturnRC (adep.rc());
     773
     774    AutoLock alock (this);
    771775
    772776    if (mData->mAttachmentType != NetworkAttachmentType_NATNetworkAttachment)
    773777    {
    774778        mData.backup();
     779
    775780        detach();
     781
    776782        mData->mAttachmentType = NetworkAttachmentType_NATNetworkAttachment;
    777783
    778         /* notify parent */
    779         alock.unlock();
    780         mParent->onNetworkAdapterChange(this);
    781     }
    782 
    783     return S_OK;
    784 }
    785 
    786 /**
    787  * Attach the network card to the defined host interface.
    788  *
    789  * @returns COM status code
    790  */
     784        /* leave the lock before informing callbacks */
     785        alock.unlock();
     786
     787        mParent->onNetworkAdapterChange (this);
     788    }
     789
     790    return S_OK;
     791}
     792
    791793STDMETHODIMP NetworkAdapter::AttachToHostInterface()
    792794{
    793     AutoLock alock(this);
    794     CHECK_READY();
    795 
    796     CHECK_MACHINE_MUTABILITY (mParent);
     795    AutoCaller autoCaller (this);
     796    CheckComRCReturnRC (autoCaller.rc());
     797
     798    /* the machine needs to be mutable */
     799    Machine::AutoMutableStateDependency adep (mParent);
     800    CheckComRCReturnRC (adep.rc());
     801
     802    AutoLock alock (this);
    797803
    798804    /* don't do anything if we're already host interface attached */
     
    800806    {
    801807        mData.backup();
     808
    802809        /* first detach the current attachment */
    803         if (mData->mAttachmentType != NetworkAttachmentType_NoNetworkAttachment)
    804             detach();
     810        detach();
     811
    805812        mData->mAttachmentType = NetworkAttachmentType_HostInterfaceNetworkAttachment;
    806813
    807         /* notify parent */
    808         alock.unlock();
    809         mParent->onNetworkAdapterChange(this);
    810     }
    811 
    812     return S_OK;
    813 }
    814 
    815 /**
    816  * Attach the network card to the defined internal network.
    817  *
    818  * @returns COM status code
    819  */
     814        /* leave the lock before informing callbacks */
     815        alock.unlock();
     816
     817        mParent->onNetworkAdapterChange (this);
     818    }
     819
     820    return S_OK;
     821}
     822
    820823STDMETHODIMP NetworkAdapter::AttachToInternalNetwork()
    821824{
    822     AutoLock alock(this);
    823     CHECK_READY();
    824 
    825     CHECK_MACHINE_MUTABILITY (mParent);
     825    AutoCaller autoCaller (this);
     826    CheckComRCReturnRC (autoCaller.rc());
     827
     828    /* the machine needs to be mutable */
     829    Machine::AutoMutableStateDependency adep (mParent);
     830    CheckComRCReturnRC (adep.rc());
     831
     832    AutoLock alock (this);
    826833
    827834    /* don't do anything if we're already internal network attached */
    828835    if (mData->mAttachmentType != NetworkAttachmentType_InternalNetworkAttachment)
    829836    {
     837        mData.backup();
     838
     839        /* first detach the current attachment */
     840        detach();
     841
    830842        /* there must an internal network name */
    831843        if (   !mData->mInternalNetwork
    832             || (mData->mInternalNetwork == Bstr("")))
     844            || (mData->mInternalNetwork == Bstr ("")))
    833845        {
    834             LogRel(("Internal network name not defined, setting to default \"intnet\"\n"));
    835             HRESULT rc = COMSETTER(InternalNetwork)(Bstr("intnet"));
    836             if (FAILED(rc))
    837                 return rc;
     846            LogRel (("Internal network name not defined, "
     847                     "setting to default \"intnet\"\n"));
     848            mData->mInternalNetwork = Bstr ("intnet");
    838849        }
    839850
    840         mData.backup();
    841         /* first detach the current attachment */
     851        mData->mAttachmentType = NetworkAttachmentType_InternalNetworkAttachment;
     852
     853        /* leave the lock before informing callbacks */
     854        alock.unlock();
     855
     856        mParent->onNetworkAdapterChange (this);
     857    }
     858
     859    return S_OK;
     860}
     861
     862STDMETHODIMP NetworkAdapter::Detach()
     863{
     864    AutoCaller autoCaller (this);
     865    CheckComRCReturnRC (autoCaller.rc());
     866
     867    /* the machine needs to be mutable */
     868    Machine::AutoMutableStateDependency adep (mParent);
     869    CheckComRCReturnRC (adep.rc());
     870
     871    AutoLock alock (this);
     872
     873    if (mData->mAttachmentType != NetworkAttachmentType_NoNetworkAttachment)
     874    {
     875        mData.backup();
     876
    842877        detach();
    843         mData->mAttachmentType = NetworkAttachmentType_InternalNetworkAttachment;
    844 
    845         /* notify parent */
    846         alock.unlock();
    847         mParent->onNetworkAdapterChange(this);
    848     }
    849 
    850     return S_OK;
    851 }
    852 
    853 /**
    854  * Detach the network card from its interface
    855  *
    856  * @returns COM status code
    857  */
    858 STDMETHODIMP NetworkAdapter::Detach()
    859 {
    860     AutoLock alock(this);
    861     CHECK_READY();
    862 
    863     CHECK_MACHINE_MUTABILITY (mParent);
    864 
    865     if (mData->mAttachmentType != NetworkAttachmentType_NoNetworkAttachment)
    866     {
    867         mData.backup();
    868         detach();
    869 
    870         /* notify parent */
    871         alock.unlock();
    872         mParent->onNetworkAdapterChange(this);
     878
     879        /* leave the lock before informing callbacks */
     880        alock.unlock();
     881
     882        mParent->onNetworkAdapterChange (this);
    873883    }
    874884
     
    879889////////////////////////////////////////////////////////////////////////////////
    880890
     891/**
     892 *  @note Locks this object for writing.
     893 */
    881894bool NetworkAdapter::rollback()
    882895{
     896    /* sanity */
     897    AutoCaller autoCaller (this);
     898    AssertComRCReturn (autoCaller.rc(), false);
     899
    883900    AutoLock alock (this);
    884901
     
    887904    if (mData.isBackedUp())
    888905    {
    889         // we need to check all data to see whether anything will be changed
    890         // after rollback
     906        /* we need to check all data to see whether anything will be changed
     907         * after rollback */
    891908        changed = mData.hasActualChanges();
    892909        mData.rollback();
     
    896913}
    897914
     915/**
     916 *  @note Locks this object for writing, together with the peer object (also
     917 *  for writing) if there is one.
     918 */
    898919void NetworkAdapter::commit()
    899920{
    900     AutoLock alock (this);
     921    /* sanity */
     922    AutoCaller autoCaller (this);
     923    AssertComRCReturnVoid (autoCaller.rc());
     924
     925    /* sanity too */
     926    AutoCaller thatCaller (mPeer);
     927    AssertComRCReturnVoid (thatCaller.rc());
     928
     929    /* lock both for writing since we modify both */
     930    AutoMultiLock <2> alock (this->wlock(), AutoLock::maybeWlock (mPeer));
     931
    901932    if (mData.isBackedUp())
    902933    {
     
    904935        if (mPeer)
    905936        {
    906             // attach new data to the peer and reshare it
    907             AutoLock peerlock (mPeer);
     937            /* attach new data to the peer and reshare it */
    908938            mPeer->mData.attach (mData);
    909939        }
     
    911941}
    912942
     943/**
     944 *  @note Locks this object for writing, together with the peer object
     945 *  represented by @a aThat (locked for reading).
     946 */
    913947void NetworkAdapter::copyFrom (NetworkAdapter *aThat)
    914948{
    915     AutoLock alock (this);
    916 
    917     // this will back up current data
     949    AssertReturnVoid (aThat != NULL);
     950
     951    /* sanity */
     952    AutoCaller autoCaller (this);
     953    AssertComRCReturnVoid (autoCaller.rc());
     954
     955    /* sanity too */
     956    AutoCaller thatCaller (mPeer);
     957    AssertComRCReturnVoid (thatCaller.rc());
     958
     959    /* peer is not modified, lock it for reading */
     960    AutoMultiLock <2> alock (this->wlock(), aThat->rlock());
     961
     962    /* this will back up current data */
    918963    mData.assignCopy (aThat->mData);
    919964}
     
    923968
    924969/**
    925  * Worker routine for detach handling. No locking, no notifications.
     970 *  Worker routine for detach handling. No locking, no notifications.
     971
     972 *  @note Must be called from under the object's write lock.
    926973 */
    927974void NetworkAdapter::detach()
    928975{
     976    AssertReturnVoid (isLockedOnCurrentThread());
     977
    929978    switch (mData->mAttachmentType)
    930979    {
     
    9611010
    9621011/**
    963  * Generates a new unique MAC address based on our vendor ID and
    964  * parts of a GUID
     1012 *  Generates a new unique MAC address based on our vendor ID and
     1013 *  parts of a GUID.
     1014 *
     1015 *  @note Must be called from under the object's write lock or within the init
     1016 *  span.
    9651017 */
    9661018void NetworkAdapter::generateMACAddress()
     
    9741026    Guid guid;
    9751027    guid.create();
    976     RTStrPrintf(strMAC, sizeof(strMAC), "080027%02X%02X%02X", guid.ptr()->au8[0], guid.ptr()->au8[1], guid.ptr()->au8[2]);
    977     LogFlowThisFunc (("Generated '%s'\n", strMAC));
     1028    RTStrPrintf (strMAC, sizeof(strMAC), "080027%02X%02X%02X",
     1029                 guid.ptr()->au8[0], guid.ptr()->au8[1], guid.ptr()->au8[2]);
     1030    LogFlowThisFunc (("generated MAC: '%s'\n", strMAC));
    9781031    mData->mMACAddress = strMAC;
    9791032}
  • trunk/src/VBox/Main/include/AudioAdapterImpl.h

    r2981 r3348  
    2828
    2929class ATL_NO_VTABLE AudioAdapter :
     30    public VirtualBoxBaseNEXT,
    3031    public VirtualBoxSupportErrorInfoImpl <AudioAdapter, IAudioAdapter>,
    3132    public VirtualBoxSupportTranslation <AudioAdapter>,
    32     public VirtualBoxBase,
    3333    public IAudioAdapter
    3434{
     
    5353    };
    5454
     55    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (AudioAdapter)
     56
    5557    DECLARE_NOT_AGGREGATABLE(AudioAdapter)
    5658
     
    6466    NS_DECL_ISUPPORTS
    6567
     68    DECLARE_EMPTY_CTOR_DTOR (AudioAdapter)
     69
    6670    HRESULT FinalConstruct();
    6771    void FinalRelease();
    6872
    6973    // public initializer/uninitializer for internal purposes only
    70     HRESULT init (Machine *parent);
    71     HRESULT init (Machine *parent, AudioAdapter *that);
    72     HRESULT initCopy (Machine *parent, AudioAdapter *that);
     74    HRESULT init (Machine *aParent);
     75    HRESULT init (Machine *aParent, AudioAdapter *aThat);
     76    HRESULT initCopy (Machine *aParent, AudioAdapter *aThat);
    7377    void uninit();
    7478
    75     STDMETHOD(COMGETTER(Enabled))(BOOL *enabled);
    76     STDMETHOD(COMSETTER(Enabled))(BOOL enabled);
    77     STDMETHOD(COMGETTER(AudioDriver)) (AudioDriverType_T *audioDriverType);
    78     STDMETHOD(COMSETTER(AudioDriver)) (AudioDriverType_T audioDriverType);
     79    STDMETHOD(COMGETTER(Enabled))(BOOL *aEnabled);
     80    STDMETHOD(COMSETTER(Enabled))(BOOL aEnabled);
     81    STDMETHOD(COMGETTER(AudioDriver)) (AudioDriverType_T *aAudioDriverType);
     82    STDMETHOD(COMSETTER(AudioDriver)) (AudioDriverType_T aAudioDriverType);
    7983
    8084    // public methods only for internal purposes
    8185
    82     const Backupable <Data> &data() const { return mData; }
    83 
    8486    bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
    8587    bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
    86     void rollback() { AutoLock alock (this); mData.rollback(); }
     88    bool rollback();
    8789    void commit();
    8890    void copyFrom (AudioAdapter *aThat);
     91
     92    // public methods for internal purposes only
     93    // (ensure there is a caller and a read lock before calling them!)
     94
     95    const Backupable <Data> &data() const { return mData; }
    8996
    9097    // for VirtualBoxSupportErrorInfoImpl
     
    93100private:
    94101
    95     ComObjPtr <Machine, ComWeakRef> mParent;
    96     ComObjPtr <AudioAdapter> mPeer;
     102    const ComObjPtr <Machine, ComWeakRef> mParent;
     103    const ComObjPtr <AudioAdapter> mPeer;
     104
    97105    Backupable <Data> mData;
    98106};
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r2981 r3348  
    2929
    3030class ATL_NO_VTABLE NetworkAdapter :
    31     public VirtualBoxBase,
     31    public VirtualBoxBaseNEXT,
    3232    public VirtualBoxSupportErrorInfoImpl <NetworkAdapter, INetworkAdapter>,
    3333    public VirtualBoxSupportTranslation <NetworkAdapter>,
     
    8686    };
    8787
     88    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
     89
    8890    DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
    8991
     
    9799    NS_DECL_ISUPPORTS
    98100
     101    DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
     102
    99103    HRESULT FinalConstruct();
    100104    void FinalRelease();
    101105
    102106    // public initializer/uninitializer for internal purposes only
    103     HRESULT init (Machine *parent, ULONG slot);
    104     HRESULT init (Machine *parent, NetworkAdapter *that);
    105     HRESULT initCopy (Machine *parent, NetworkAdapter *that);
     107    HRESULT init (Machine *aParent, ULONG aSlot);
     108    HRESULT init (Machine *aParent, NetworkAdapter *aThat);
     109    HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
    106110    void uninit();
    107111
    108112    // INetworkAdapter properties
    109     STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *adapterType);
    110     STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T adapterType);
    111     STDMETHOD(COMGETTER(Slot)) (ULONG *slot);
    112     STDMETHOD(COMGETTER(Enabled)) (BOOL *enabled);
    113     STDMETHOD(COMSETTER(Enabled)) (BOOL enabled);
    114     STDMETHOD(COMGETTER(MACAddress))(BSTR *macAddress);
    115     STDMETHOD(COMSETTER(MACAddress))(INPTR BSTR macAddress);
    116     STDMETHOD(COMGETTER(AttachmentType))(NetworkAttachmentType_T *attachmentType);
    117     STDMETHOD(COMGETTER(HostInterface))(BSTR *hostInterface);
    118     STDMETHOD(COMSETTER(HostInterface))(INPTR BSTR hostInterface);
     113    STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
     114    STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
     115    STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
     116    STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
     117    STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
     118    STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
     119    STDMETHOD(COMSETTER(MACAddress)) (INPTR BSTR aMACAddress);
     120    STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
     121    STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
     122    STDMETHOD(COMSETTER(HostInterface)) (INPTR BSTR aHostInterface);
    119123#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
    120     STDMETHOD(COMGETTER(TAPFileDescriptor))(LONG *tapFileDescriptor);
    121     STDMETHOD(COMSETTER(TAPFileDescriptor))(LONG tapFileDescriptor);
    122     STDMETHOD(COMGETTER(TAPSetupApplication))(BSTR *tapSetupApplication);
    123     STDMETHOD(COMSETTER(TAPSetupApplication))(INPTR BSTR tapSetupApplication);
    124     STDMETHOD(COMGETTER(TAPTerminateApplication))(BSTR *tapTerminateApplication);
    125     STDMETHOD(COMSETTER(TAPTerminateApplication))(INPTR BSTR tapTerminateApplication);
     124    STDMETHOD(COMGETTER(TAPFileDescriptor)) (LONG *aTAPFileDescriptor);
     125    STDMETHOD(COMSETTER(TAPFileDescriptor)) (LONG aTAPFileDescriptor);
     126    STDMETHOD(COMGETTER(TAPSetupApplication)) (BSTR *aTAPSetupApplication);
     127    STDMETHOD(COMSETTER(TAPSetupApplication)) (INPTR BSTR aTAPSetupApplication);
     128    STDMETHOD(COMGETTER(TAPTerminateApplication)) (BSTR *aTAPTerminateApplication);
     129    STDMETHOD(COMSETTER(TAPTerminateApplication)) (INPTR BSTR aTAPTerminateApplication);
    126130#endif
    127     STDMETHOD(COMGETTER(InternalNetwork))(BSTR *internalNetwork);
    128     STDMETHOD(COMSETTER(InternalNetwork))(INPTR BSTR internalNetwork);
    129     STDMETHOD(COMGETTER(CableConnected))(BOOL *connected);
    130     STDMETHOD(COMSETTER(CableConnected))(BOOL connected);
    131     STDMETHOD(COMGETTER(TraceEnabled))(BOOL *enabled);
    132     STDMETHOD(COMSETTER(TraceEnabled))(BOOL enabled);
    133     STDMETHOD(COMGETTER(TraceFile))(BSTR *traceFile);
    134     STDMETHOD(COMSETTER(TraceFile))(INPTR BSTR traceFile);
     131    STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
     132    STDMETHOD(COMSETTER(InternalNetwork)) (INPTR BSTR aInternalNetwork);
     133    STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
     134    STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
     135    STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
     136    STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
     137    STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
     138    STDMETHOD(COMSETTER(TraceFile)) (INPTR BSTR aTraceFile);
    135139
    136140    // INetworkAdapter methods
     
    142146    // public methods only for internal purposes
    143147
    144     const Backupable <Data> &data() const { return mData; }
    145 
    146148    bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
    147149    bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
     
    149151    void commit();
    150152    void copyFrom (NetworkAdapter *aThat);
     153
     154    // public methods for internal purposes only
     155    // (ensure there is a caller and a read lock before calling them!)
     156
     157    const Backupable <Data> &data() const { return mData; }
    151158
    152159    // for VirtualBoxSupportErrorInfoImpl
     
    158165    void generateMACAddress();
    159166
    160     ComObjPtr <Machine, ComWeakRef> mParent;
    161     ComObjPtr <NetworkAdapter> mPeer;
     167    const ComObjPtr <Machine, ComWeakRef> mParent;
     168    const ComObjPtr <NetworkAdapter> mPeer;
     169
    162170    Backupable <Data> mData;
    163171};
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