VirtualBox

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


Ignore:
Timestamp:
Dec 21, 2007 2:38:19 PM (17 years ago)
Author:
vboxsync
Message:

Main: Return errors when the parallel port is enabled but the path is null.

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

Legend:

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

    r6076 r6168  
    196196    /* IRQ (required) */
    197197    mData->mIRQ = aPortNode.value <ULONG> ("IRQ");
    198     /* device path (may be null) */
    199     /// @todo report an error if enabled is true and path is empty or null!
    200     //  The same applies to COMSETTER(Path).
    201     mData->mPath = aPortNode.stringValue ("path");
     198    /* device path (optional, defaults to null) */
     199    Bstr path = aPortNode.stringValue ("path");
     200
     201    HRESULT rc = checkSetPath (path);
     202    CheckComRCReturnRC (rc);
     203    mData->mPath = path;
    202204
    203205    return S_OK;
     
    343345    if (mData->mEnabled != aEnabled)
    344346    {
     347        if (aEnabled &&
     348            mData->mPath.isEmpty())
     349            return setError (E_INVALIDARG,
     350                        tr ("Cannot enable the parallel port %d "
     351                            "because the port path is empty or null"),
     352                        mData->mSlot);
     353
    345354        mData.backup();
    346355        mData->mEnabled = aEnabled;
     
    495504}
    496505
     506/**
     507 *  Validates COMSETTER(Path) arguments.
     508 */
     509HRESULT ParallelPort::checkSetPath (const BSTR aPath)
     510{
     511    AssertReturn (isLockedOnCurrentThread(), E_FAIL);
     512
     513    if (mData->mEnabled &&
     514        (aPath == NULL || *aPath == '\0'))
     515        return setError (E_INVALIDARG,
     516            tr ("Path of the parallel port %d may not be empty or null "
     517                "when the port is enabled"),
     518            mData->mSlot);
     519
     520    return S_OK;
     521}
     522
    497523STDMETHODIMP ParallelPort::COMSETTER(Path) (INPTR BSTR aPath)
    498524{
    499     if (!aPath)
    500         return E_POINTER;
    501 
    502     if (!*aPath)
    503         return setError (E_INVALIDARG,
    504             tr ("Path of the parallel port %d may not be empty"),
    505             mData->mSlot);
    506 
    507525    AutoCaller autoCaller (this);
    508526    CheckComRCReturnRC (autoCaller.rc());
     
    516534    if (mData->mPath != aPath)
    517535    {
     536        HRESULT rc = checkSetPath (aPath);
     537        CheckComRCReturnRC (rc);
     538
    518539        mData.backup();
    519540        mData->mPath = aPath;
  • trunk/src/VBox/Main/SerialPortImpl.cpp

    r6076 r6168  
    621621STDMETHODIMP SerialPort::COMSETTER(Path) (INPTR BSTR aPath)
    622622{
    623     if (!aPath)
    624         return E_POINTER;
    625 
    626623    AutoCaller autoCaller (this);
    627624    CheckComRCReturnRC (autoCaller.rc());
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r6156 r6168  
    77747774      and all port read operations will return no data.
    77757775
    7776       <see>IMachine::getSerial</see>
     7776      <see>IMachine::getSerialPort</see>
    77777777    </desc>
    77787778
     
    78187818        is PortMode::HostDevicePort. In either of the above cases, setting a
    78197819        @c null or an empty string as the attribute's value will result into
    7820         an error.
     7820        an error. Otherwise, the value of this property is ignored.
    78217821      </desc>
    78227822    </attribute>
     
    78757875    <attribute name="path" type="wstring">
    78767876      <desc>
    7877         Host parallel device name. Setting a null or an empty string as this
    7878         attribute's value will result into an error.
     7877        Host parallel device name. If this parallel port is enabled, setting a
     7878        @c null or an empty string as this attribute's value will result into
     7879        an error.
    78797880      </desc>
    78807881    </attribute>
  • trunk/src/VBox/Main/include/ParallelPortImpl.h

    r6076 r6168  
    3636        Data()
    3737            : mSlot (0)
    38             , mEnabled(FALSE)
     38            , mEnabled (FALSE)
    3939            , mIRQ (4)
    4040            , mIOBase (0x378)
     
    112112private:
    113113
     114    HRESULT checkSetPath (const BSTR aPath);
     115
    114116    const ComObjPtr <Machine, ComWeakRef> mParent;
    115117    const ComObjPtr <ParallelPort> mPeer;
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