VirtualBox

Changeset 15834 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jan 7, 2009 2:17:56 PM (16 years ago)
Author:
vboxsync
Message:

#3285: Improve error handling API to include unique error numbers
Document InternalSessionControl's

  • getRemoteConsole
  • assignMachine
  • assignRemoteMachine
  • updateMachineState
  • uninitialize
  • onDVDDriveChange
  • onFloppyDriveChange
  • onNetworkAdapterChange
  • onSerialPortChange
  • onParallelPortChange
  • onVRDPServerChange
  • onUSBControllerChange
  • onSharedFolderChange
  • onUSBDeviceAttach
  • onUSBDeviceDetach
  • onShowWindow
  • accessGuestProperty
  • enumerateGuestProperties
Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

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

    r15140 r15834  
    266266    AutoReadLock alock (this);
    267267
    268     AssertReturn (mState != SessionState_Closed, E_FAIL);
     268    AssertReturn (mState != SessionState_Closed, VBOX_E_INVALID_VM_STATE);
    269269
    270270    AssertMsgReturn (mType == SessionType_Direct && !!mConsole,
    271                      ("This is not a direct session!\n"), E_FAIL);
     271      ("This is not a direct session!\n"), VBOX_E_INVALID_OBJECT_STATE);
    272272
    273273    /* return a failure if the session already transitioned to Closing
    274274     * but the server hasn't processed Machine::OnSessionEnd() yet. */
    275275    if (mState != SessionState_Open)
    276         return E_UNEXPECTED;
     276        return VBOX_E_INVALID_VM_STATE;
    277277
    278278    mConsole.queryInterfaceTo (aConsole);
     
    291291    AutoWriteLock alock (this);
    292292
    293     AssertReturn (mState == SessionState_Closed, E_FAIL);
     293    AssertReturn (mState == SessionState_Closed, VBOX_E_INVALID_VM_STATE);
    294294
    295295    if (!aMachine)
     
    302302         */
    303303
    304         AssertReturn (mType == SessionType_Null, E_FAIL);
     304        AssertReturn (mType == SessionType_Null, VBOX_E_INVALID_OBJECT_STATE);
    305305        mType = SessionType_Remote;
    306306        mState = SessionState_Spawning;
     
    363363
    364364    AssertReturn (mState == SessionState_Closed ||
    365                   mState == SessionState_Spawning, E_FAIL);
     365                  mState == SessionState_Spawning, VBOX_E_INVALID_VM_STATE);
    366366
    367367    HRESULT rc = E_FAIL;
     
    369369    /* query IInternalMachineControl interface */
    370370    mControl = aMachine;
    371     AssertReturn (!!mControl, E_FAIL);
     371    AssertReturn (!!mControl, E_FAIL); // This test appears to be redundant --JS
    372372
    373373    /// @todo (dmik)
     
    445445    }
    446446
    447     AssertReturn (mState == SessionState_Open &&
    448                   mType == SessionType_Direct, E_FAIL);
     447    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     448    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    449449
    450450    AssertReturn (!mControl.isNull(), E_FAIL);
     
    476476
    477477        AssertReturn (mState == SessionState_Open ||
    478                       mState == SessionState_Spawning, E_FAIL);
     478                      mState == SessionState_Spawning, VBOX_E_INVALID_VM_STATE);
    479479
    480480        /* close ourselves */
     
    509509
    510510    AutoReadLock alock (this);
    511     AssertReturn (mState == SessionState_Open &&
    512                   mType == SessionType_Direct, E_FAIL);
     511    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     512    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    513513
    514514    return mConsole->onDVDDriveChange();
     
    523523
    524524    AutoReadLock alock (this);
    525     AssertReturn (mState == SessionState_Open &&
    526                   mType == SessionType_Direct, E_FAIL);
     525    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     526    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    527527
    528528    return mConsole->onFloppyDriveChange();
     
    537537
    538538    AutoReadLock alock (this);
    539     AssertReturn (mState == SessionState_Open &&
    540                   mType == SessionType_Direct, E_FAIL);
     539    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     540    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    541541
    542542    return mConsole->onNetworkAdapterChange(networkAdapter);
     
    551551
    552552    AutoReadLock alock (this);
    553     AssertReturn (mState == SessionState_Open &&
    554                   mType == SessionType_Direct, E_FAIL);
     553    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     554    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    555555
    556556    return mConsole->onSerialPortChange(serialPort);
     
    565565
    566566    AutoReadLock alock (this);
    567     AssertReturn (mState == SessionState_Open &&
    568                   mType == SessionType_Direct, E_FAIL);
     567    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     568    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    569569
    570570    return mConsole->onParallelPortChange(parallelPort);
     
    579579
    580580    AutoReadLock alock (this);
    581     AssertReturn (mState == SessionState_Open &&
    582                   mType == SessionType_Direct, E_FAIL);
     581    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     582    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    583583
    584584    return mConsole->onVRDPServerChange();
     
    593593
    594594    AutoReadLock alock (this);
    595     AssertReturn (mState == SessionState_Open &&
    596                   mType == SessionType_Direct, E_FAIL);
     595    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     596    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    597597
    598598    return mConsole->onUSBControllerChange();
     
    607607
    608608    AutoReadLock alock (this);
    609     AssertReturn (mState == SessionState_Open &&
    610                   mType == SessionType_Direct, E_FAIL);
     609    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     610    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    611611
    612612    return mConsole->onSharedFolderChange (aGlobal);
     
    623623
    624624    AutoReadLock alock (this);
    625     AssertReturn (mState == SessionState_Open &&
    626                   mType == SessionType_Direct, E_FAIL);
     625    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     626    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    627627
    628628    return mConsole->onUSBDeviceAttach (aDevice, aError, aMaskedIfs);
     
    638638
    639639    AutoReadLock alock (this);
    640     AssertReturn (mState == SessionState_Open &&
    641                   mType == SessionType_Direct, E_FAIL);
     640    AssertReturn (mState == SessionState_Open, VBOX_E_INVALID_VM_STATE);
     641    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    642642
    643643    return mConsole->onUSBDeviceDetach (aId, aError);
     
    651651    AutoReadLock alock (this);
    652652
    653     AssertReturn (mType == SessionType_Direct, E_FAIL);
     653    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    654654
    655655    if (mState != SessionState_Open)
     
    678678            tr ("Machine session is not open (session state: %d)."),
    679679            mState);
    680     AssertReturn (mType == SessionType_Direct, E_UNEXPECTED);
     680    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    681681    CheckComArgNotNull(aName);
    682682    if (!aIsSetter && !VALID_PTR (aRetValue))
     
    712712
    713713    if (mState != SessionState_Open)
    714         return setError (E_FAIL,
     714        return setError (VBOX_E_INVALID_VM_STATE,
    715715            tr ("Machine session is not open (session state: %d)."),
    716716            mState);
    717     AssertReturn (mType == SessionType_Direct, E_UNEXPECTED);
     717    AssertReturn (mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    718718    if (!VALID_PTR (aPatterns) && (aPatterns != NULL))
    719719        return E_POINTER;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r15828 r15834  
    1114411144
    1114511145    <method name="getRemoteConsole">
    11146       <desc>Returns the console object suitable for remote control.</desc>
     11146      <desc>
     11147        Returns the console object suitable for remote control.
     11148
     11149        <result name="VBOX_E_INVALID_VM_STATE">
     11150          Session state prevents operation.
     11151        </result>
     11152        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11153          Session type prevents operation.
     11154        </result>
     11155
     11156      </desc>
    1114711157      <param name="console" type="IConsole" dir="return"/>
    1114811158    </method>
     
    1115211162        Assigns the machine object associated with this direct-type
    1115311163        session or informs the session that it will be a remote one
    11154         (if machine = NULL).
     11164        (if @a machine == NULL).
     11165
     11166        <result name="VBOX_E_INVALID_VM_STATE">
     11167          Session state prevents operation.
     11168        </result>
     11169        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11170          Session type prevents operation.
     11171        </result>
     11172
    1115511173      </desc>
    1115611174      <param name="machine" type="IMachine" dir="in"/>
     
    1116111179        Assigns the machine and the (remote) console object associated with
    1116211180        this remote-type session.
     11181
     11182        <result name="VBOX_E_INVALID_VM_STATE">
     11183          Session state prevents operation.
     11184        </result>
     11185
    1116311186      </desc>
    1116411187      <param name="machine" type="IMachine" dir="in"/>
     
    1117111194        Must be called only in certain cases
    1117211195        (see the method implementation).
     11196
     11197        <result name="VBOX_E_INVALID_VM_STATE">
     11198          Session state prevents operation.
     11199        </result>
     11200        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11201          Session type prevents operation.
     11202        </result>
     11203
    1117311204      </desc>
    1117411205      <param name="aMachineState" type="MachineState" dir="in"/>
     
    1118011211        the corresponding remote session when the direct session dies
    1118111212        or gets closed.
     11213
     11214        <result name="VBOX_E_INVALID_VM_STATE">
     11215          Session state prevents operation.
     11216        </result>
     11217
    1118211218      </desc>
    1118311219    </method>
     
    1118711223        Triggered when settings of the DVD drive object of the
    1118811224        associated virtual machine have changed.
     11225
     11226        <result name="VBOX_E_INVALID_VM_STATE">
     11227          Session state prevents operation.
     11228        </result>
     11229        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11230          Session type prevents operation.
     11231        </result>
     11232
    1118911233      </desc>
    1119011234    </method>
     
    1119411238        Triggered when settings of the floppy drive object of the
    1119511239        associated virtual machine have changed.
     11240
     11241        <result name="VBOX_E_INVALID_VM_STATE">
     11242          Session state prevents operation.
     11243        </result>
     11244        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11245          Session type prevents operation.
     11246        </result>
     11247
    1119611248      </desc>
    1119711249    </method>
     
    1120111253        Triggered when settings of a network adapter of the
    1120211254        associated virtual machine have changed.
     11255
     11256        <result name="VBOX_E_INVALID_VM_STATE">
     11257          Session state prevents operation.
     11258        </result>
     11259        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11260          Session type prevents operation.
     11261        </result>
     11262
    1120311263      </desc>
    1120411264      <param name="networkAdapter" type="INetworkAdapter" dir="in"/>
     
    1120911269        Triggered when settings of a serial port of the
    1121011270        associated virtual machine have changed.
     11271
     11272        <result name="VBOX_E_INVALID_VM_STATE">
     11273          Session state prevents operation.
     11274        </result>
     11275        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11276          Session type prevents operation.
     11277        </result>
     11278
    1121111279      </desc>
    1121211280      <param name="serialPort" type="ISerialPort" dir="in"/>
     
    1121711285        Triggered when settings of a parallel port of the
    1121811286        associated virtual machine have changed.
     11287
     11288        <result name="VBOX_E_INVALID_VM_STATE">
     11289          Session state prevents operation.
     11290        </result>
     11291        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11292          Session type prevents operation.
     11293        </result>
     11294
    1121911295      </desc>
    1122011296      <param name="parallelPort" type="IParallelPort" dir="in"/>
     
    1122511301        Triggered when settings of the VRDP server object of the
    1122611302        associated virtual machine have changed.
     11303
     11304        <result name="VBOX_E_INVALID_VM_STATE">
     11305          Session state prevents operation.
     11306        </result>
     11307        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11308          Session type prevents operation.
     11309        </result>
     11310
    1122711311      </desc>
    1122811312    </method>
     
    1123211316        Triggered when settings of the USB controller object of the
    1123311317        associated virtual machine have changed.
     11318
     11319        <result name="VBOX_E_INVALID_VM_STATE">
     11320          Session state prevents operation.
     11321        </result>
     11322        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11323          Session type prevents operation.
     11324        </result>
     11325
    1123411326      </desc>
    1123511327    </method>
     
    1124511337          time of processing this notification.
    1124611338        </note>
     11339
     11340        <result name="VBOX_E_INVALID_VM_STATE">
     11341          Session state prevents operation.
     11342        </result>
     11343        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11344          Session type prevents operation.
     11345        </result>
     11346
    1124711347      </desc>
    1124811348      <param name="global" type="boolean" dir="in"/>
     
    1125611356        A @c null @a error object means success, otherwise it
    1125711357        describes a failure.
     11358
     11359        <result name="VBOX_E_INVALID_VM_STATE">
     11360          Session state prevents operation.
     11361        </result>
     11362        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11363          Session type prevents operation.
     11364        </result>
     11365
    1125811366      </desc>
    1125911367      <param name="device" type="IUSBDevice" dir="in"/>
     
    1126811376        <link to="IConsole::detachUSBDevice"/>) has completed.
    1126911377        A @c null @a error object means success, otherwise it
     11378
     11379        <result name="VBOX_E_INVALID_VM_STATE">
     11380          Session state prevents operation.
     11381        </result>
     11382        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11383          Session type prevents operation.
     11384        </result>
     11385
    1127011386      </desc>
    1127111387      <param name="id" type="uuid" dir="in"/>
     
    1128011396        <link to="IConsoleCallback::onCanShowWindow()"/>
    1128111397        and <link to="IConsoleCallback::onShowWindow()"/>.
     11398
     11399        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11400          Session type prevents operation.
     11401        </result>
     11402
    1128211403      </desc>
    1128311404      <param name="check" type="boolean" dir="in"/>
     
    1129111412        <link to="IMachine::setGuestProperty()"/> in order to read and
    1129211413        modify guest properties.
     11414
     11415        <result name="VBOX_E_INVALID_VM_STATE">
     11416          Machine session is not open.
     11417        </result>
     11418        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11419          Session type is not direct.
     11420        </result>
     11421
    1129311422      </desc>
    1129411423      <param name="name" type="wstring" dir="in"/>
     
    1130511434        Return a list of the guest properties matching a set of patterns along
    1130611435        with their values, time stamps and flags.
     11436
     11437        <result name="VBOX_E_INVALID_VM_STATE">
     11438          Machine session is not open.
     11439        </result>
     11440        <result name="VBOX_E_INVALID_OBJECT_STATE">
     11441          Session type is not direct.
     11442        </result>
     11443
    1130711444      </desc>
    1130811445      <param name="patterns" type="wstring" dir="in">
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