VirtualBox

Changeset 59381 in vbox


Ignore:
Timestamp:
Jan 18, 2016 5:17:24 PM (9 years ago)
Author:
vboxsync
Message:

Main,FE/Qt: Don't access the USB ID database for IHostUSBDevice::getManufacturer() and IHostUSBDevice::getProduct() because these attrtibutes might be used to initialize a filter. Ther filter won't work if the device doesn't expose a manufacturer or product and we pick one from the database and initialize the filter with bugref:7868

Location:
trunk/src/VBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r59032 r59381  
    884884    else
    885885    {
    886         QString m = aDevice.GetManufacturer().trimmed();
    887         QString p = aDevice.GetProduct().trimmed();
     886        QVector<QString> devInfoVector = aDevice.GetDeviceInfo();
     887        QString m;
     888        QString p;
     889
     890        if (devInfoVector.size() >= 1)
     891            m = devInfoVector[0].trimmed();
     892        if (devInfoVector.size() >= 2)
     893            p = devInfoVector[1].trimmed();
    888894
    889895        if (m.isEmpty() && p.isEmpty())
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r59117 r59381  
    1802118021    uuid="5915d179-83c7-4f2b-a323-9a97f46f4e29"
    1802218022    wsmap="managed"
    18023     reservedAttributes="3"
     18023    reservedAttributes="2"
    1802418024    >
    1802518025    <desc>
     
    1810818108      <desc>
    1810918109        The backend which will be used to communicate with this device.
     18110      </desc>
     18111    </attribute>
     18112
     18113    <attribute name="deviceInfo" type="wstring" readonly="yes" safearray="yes">
     18114      <desc>
     18115        Array of device attributes as single strings.
     18116
     18117        So far the following are used:
     18118          0: The manufacturer string, if the device doesn't expose the ID one is taken
     18119             from an internal database or an empty string if none is found.
     18120          1: The product string, if the device doesn't expose the ID one is taken
     18121             from an internal database or an empty string if none is found.
    1811018122      </desc>
    1811118123    </attribute>
  • trunk/src/VBox/Main/include/HostUSBDeviceImpl.h

    r59117 r59381  
    261261    HRESULT getSpeed(USBConnectionSpeed_T *aSpeed);
    262262    HRESULT getRemote(BOOL *aRemote);
    263     HRESULT getName(com::Utf8Str &aName);
    264263    HRESULT getState(USBDeviceState_T *aState);
    265264    HRESULT getBackend(com::Utf8Str &aBackend);
     265    HRESULT getDeviceInfo(std::vector<com::Utf8Str> &aInfo);
    266266
    267267
  • trunk/src/VBox/Main/include/RemoteUSBDeviceImpl.h

    r59117 r59381  
    8080    HRESULT getRemote(BOOL *aRemote);
    8181    HRESULT getBackend(com::Utf8Str &aBackend);
     82    HRESULT getDeviceInfo(std::vector<com::Utf8Str> &aInfo);
    8283
    8384    // wrapped IHostUSBDevice properties
  • trunk/src/VBox/Main/include/USBDeviceImpl.h

    r59117 r59381  
    6060    HRESULT getRemote(BOOL *aRemote);
    6161    HRESULT getBackend(com::Utf8Str &aBackend);
     62    HRESULT getDeviceInfo(std::vector<com::Utf8Str> &aInfo);
    6263
    6364    struct Data
  • trunk/src/VBox/Main/src-client/RemoteUSBDeviceImpl.cpp

    r59122 r59381  
    279279}
    280280
     281HRESULT RemoteUSBDevice::getDeviceInfo(std::vector<com::Utf8Str> &aInfo)
     282{
     283    /* this is const, no need to lock */
     284    aInfo.resize(2);
     285    aInfo[0] = mData.manufacturer;
     286    aInfo[1] = mData.product;
     287
     288    return S_OK;
     289}
     290
    281291// IHostUSBDevice properties
    282292////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/src-client/USBDeviceImpl.cpp

    r59117 r59381  
    325325}
    326326
     327HRESULT OUSBDevice::getDeviceInfo(std::vector<com::Utf8Str> &aInfo)
     328{
     329    /* this is const, no need to lock */
     330    aInfo.resize(2);
     331    aInfo[0] = mData.manufacturer;
     332    aInfo[1] = mData.product;
     333
     334    return S_OK;
     335}
     336
    327337// private methods
    328338/////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/src-server/HostUSBDeviceImpl.cpp

    r59119 r59381  
    168168
    169169    aManufacturer = mUsb->pszManufacturer;
    170     if (mUsb->pszManufacturer == NULL || mUsb->pszManufacturer[0] == 0)
    171         aManufacturer = USBIdDatabase::findVendor(mUsb->idVendor);
    172170    return S_OK;
    173171}
     
    179177
    180178    aProduct = mUsb->pszProduct;
    181     if (mUsb->pszProduct == NULL || mUsb->pszProduct[0] == 0)
    182         aProduct = USBIdDatabase::findProduct(mUsb->idVendor, mUsb->idProduct);
    183179    return S_OK;
    184180}
     
    316312}
    317313
     314
     315HRESULT HostUSBDevice::getDeviceInfo(std::vector<com::Utf8Str> &aInfo)
     316{
     317    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     318
     319    com::Utf8Str strManufacturer;
     320    com::Utf8Str strProduct;
     321
     322    if (mUsb->pszManufacturer && *mUsb->pszManufacturer)
     323        strManufacturer = mUsb->pszManufacturer;
     324    else
     325        strManufacturer = USBIdDatabase::findVendor(mUsb->idVendor);
     326
     327    if (mUsb->pszProduct && *mUsb->pszProduct)
     328        strProduct = mUsb->pszProduct;
     329    else
     330        strProduct = USBIdDatabase::findProduct(mUsb->idVendor, mUsb->idProduct);
     331
     332    aInfo.resize(2);
     333    aInfo[0] = strManufacturer;
     334    aInfo[1] = strProduct;
     335
     336    return S_OK;
     337}
     338
    318339// public methods only for internal purposes
    319340////////////////////////////////////////////////////////////////////////////////
     
    335356    if (haveManufacturer && haveProduct)
    336357        name = Utf8StrFmt("%s %s", mUsb->pszManufacturer, mUsb->pszProduct);
    337     else if (haveManufacturer)
    338         name = mUsb->pszManufacturer;
    339     else if (haveProduct)
    340         name = mUsb->pszProduct;
    341358    else
    342359    {
    343360        Utf8Str strProduct;
    344361        Utf8Str strVendor = USBIdDatabase::findVendorAndProduct(mUsb->idVendor, mUsb->idProduct, &strProduct);
    345         if (strVendor.isNotEmpty() && strProduct.isNotEmpty())
    346             name = Utf8StrFmt("%s %s", strVendor.c_str(), strProduct.c_str());
     362        if (   (strVendor.isNotEmpty() || haveManufacturer)
     363            && (strProduct.isNotEmpty() || haveProduct))
     364            name = Utf8StrFmt("%s %s", haveManufacturer ? mUsb->pszManufacturer
     365                                                        : strVendor.c_str(),
     366                                       haveProduct ? mUsb->pszProduct
     367                                                   : strProduct.c_str());
    347368        else
    348369        {
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