VirtualBox

Changeset 56584 in vbox


Ignore:
Timestamp:
Jun 22, 2015 5:10:24 PM (9 years ago)
Author:
vboxsync
Message:

Main/RemoteUSBDevice: convert to API wrapper usage

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/RemoteUSBDeviceImpl.h

    r53297 r56584  
    88
    99/*
    10  * Copyright (C) 2006-2011 Oracle Corporation
     10 * Copyright (C) 2006-2015 Oracle Corporation
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222#define ____H_REMOTEUSBDEVICEIMPL
    2323
    24 #include "VirtualBoxBase.h"
     24#include "HostUSBDeviceWrap.h"
    2525
    2626struct _VRDEUSBDEVICEDESC;
     
    2828
    2929class ATL_NO_VTABLE RemoteUSBDevice :
    30     public VirtualBoxBase,
    31     VBOX_SCRIPTABLE_IMPL(IHostUSBDevice)
     30    public HostUSBDeviceWrap
    3231{
    3332public:
    3433
    35     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(RemoteUSBDevice, IHostUSBDevice)
    36 
    37     DECLARE_NOT_AGGREGATABLE (RemoteUSBDevice)
    38 
    39     DECLARE_PROTECT_FINAL_CONSTRUCT()
    40 
    41     BEGIN_COM_MAP (RemoteUSBDevice)
    42         COM_INTERFACE_ENTRY  (IHostUSBDevice)
    43         VBOX_DEFAULT_INTERFACE_ENTRIES  (IUSBDevice)
    44     END_COM_MAP()
    45 
    46     DECLARE_EMPTY_CTOR_DTOR (RemoteUSBDevice)
     34    DECLARE_EMPTY_CTOR_DTOR(RemoteUSBDevice)
    4735
    4836    HRESULT FinalConstruct();
     
    5341    void uninit();
    5442
    55     // IUSBDevice properties
    56     STDMETHOD(COMGETTER(Id)) (BSTR *aId);
    57     STDMETHOD(COMGETTER(VendorId)) (USHORT *aVendorId);
    58     STDMETHOD(COMGETTER(ProductId)) (USHORT *aProductId);
    59     STDMETHOD(COMGETTER(Revision)) (USHORT *aRevision);
    60     STDMETHOD(COMGETTER(Manufacturer)) (BSTR *aManufacturer);
    61     STDMETHOD(COMGETTER(Product)) (BSTR *aProduct);
    62     STDMETHOD(COMGETTER(SerialNumber)) (BSTR *aSerialNumber);
    63     STDMETHOD(COMGETTER(Address)) (BSTR *aAddress);
    64     STDMETHOD(COMGETTER(Port)) (USHORT *aPort);
    65     STDMETHOD(COMGETTER(Version)) (USHORT *aVersion);
    66     STDMETHOD(COMGETTER(PortVersion)) (USHORT *aPortVersion);
    67     STDMETHOD(COMGETTER(Speed)) (USBConnectionSpeed_T *aSpeed);
    68     STDMETHOD(COMGETTER(Remote)) (BOOL *aRemote);
     43    // public methods only for internal purposes
     44    bool dirty(void) const { return mData.dirty; }
     45    void dirty(bool aDirty) { mData.dirty = aDirty; }
    6946
    70     // IHostUSBDevice properties
    71     STDMETHOD(COMGETTER(State)) (USBDeviceState_T *aState);
     47    uint16_t devId(void) const { return mData.devId; }
     48    uint32_t clientId(void) { return mData.clientId; }
    7249
    73     // public methods only for internal purposes
    74     bool dirty (void) const { return mData.dirty; }
    75     void dirty (bool aDirty) { mData.dirty = aDirty; }
    76 
    77     uint16_t devId (void) const { return mData.devId; }
    78     uint32_t clientId (void) { return mData.clientId; }
    79 
    80     bool captured (void) const { return mData.state == USBDeviceState_Captured; }
    81     void captured (bool aCaptured)
     50    bool captured(void) const { return mData.state == USBDeviceState_Captured; }
     51    void captured(bool aCaptured)
    8252    {
    8353        if (aCaptured)
     
    9565private:
    9666
     67    // wrapped IUSBDevice properties
     68    HRESULT getId(com::Guid &aId);
     69    HRESULT getVendorId(USHORT *aVendorId);
     70    HRESULT getProductId(USHORT *aProductId);
     71    HRESULT getRevision(USHORT *aRevision);
     72    HRESULT getManufacturer(com::Utf8Str &aManufacturer);
     73    HRESULT getProduct(com::Utf8Str &aProduct);
     74    HRESULT getSerialNumber(com::Utf8Str &aSerialNumber);
     75    HRESULT getAddress(com::Utf8Str &aAddress);
     76    HRESULT getPort(USHORT *aPort);
     77    HRESULT getVersion(USHORT *aVersion);
     78    HRESULT getPortVersion(USHORT *aPortVersion);
     79    HRESULT getSpeed(USBConnectionSpeed_T *aSpeed);
     80    HRESULT getRemote(BOOL *aRemote);
     81
     82    // wrapped IHostUSBDevice properties
     83    HRESULT getState(USBDeviceState_T *aState);
     84
     85
    9786    struct Data
    9887    {
    99         Data() : vendorId (0), productId (0), revision (0), port (0), version (1),
    100                  portVersion (1), speed (USBConnectionSpeed_Null), dirty (FALSE), devId (0), clientId (0) {}
     88        Data() : vendorId(0), productId(0), revision(0), port(0), version(1),
     89                 portVersion(1), speed(USBConnectionSpeed_Null), dirty(FALSE),
     90                 devId(0), clientId(0) {}
    10191
    10292        const Guid id;
     
    10696        const uint16_t revision;
    10797
    108         const Bstr manufacturer;
    109         const Bstr product;
    110         const Bstr serialNumber;
     98        const Utf8Str manufacturer;
     99        const Utf8Str product;
     100        const Utf8Str serialNumber;
    111101
    112         const Bstr address;
     102        const Utf8Str address;
    113103
    114104        const uint16_t port;
  • trunk/src/VBox/Main/include/USBDeviceImpl.h

    r53297 r56584  
    66
    77/*
    8  * Copyright (C) 2006-2011 Oracle Corporation
     8 * Copyright (C) 2006-2015 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3131public:
    3232
    33     DECLARE_EMPTY_CTOR_DTOR (OUSBDevice)
     33    DECLARE_EMPTY_CTOR_DTOR(OUSBDevice)
    3434
    3535    HRESULT FinalConstruct();
     
    3737
    3838    // public initializer/uninitializer for internal purposes only
    39     HRESULT init (IUSBDevice *a_pUSBDevice);
     39    HRESULT init(IUSBDevice *a_pUSBDevice);
    4040    void uninit();
    4141
     
    6262    struct Data
    6363    {
    64         Data() : vendorId (0), productId (0), revision (0), port (0),
    65                  version (1), portVersion (1), speed (USBConnectionSpeed_Null), remote (FALSE) {}
     64        Data() : vendorId(0), productId(0), revision(0), port(0),
     65                 version(1), portVersion(1), speed(USBConnectionSpeed_Null),
     66                 remote(FALSE) {}
    6667
    6768        /** The UUID of this device. */
  • trunk/src/VBox/Main/src-client/RemoteUSBDeviceImpl.cpp

    r53624 r56584  
    88
    99/*
    10  * Copyright (C) 2006-2011 Oracle Corporation
     10 * Copyright (C) 2006-2015 Oracle Corporation
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3434/////////////////////////////////////////////////////////////////////////////
    3535
    36 DEFINE_EMPTY_CTOR_DTOR (RemoteUSBDevice)
     36DEFINE_EMPTY_CTOR_DTOR(RemoteUSBDevice)
    3737
    3838HRESULT RemoteUSBDevice::FinalConstruct()
     
    5555 * Initializes the remote USB device object.
    5656 */
    57 HRESULT RemoteUSBDevice::init (uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevDesc, bool fDescExt)
     57HRESULT RemoteUSBDevice::init(uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevDesc, bool fDescExt)
    5858{
    5959    LogFlowThisFunc(("u32ClientId=%d,pDevDesc=%p\n", u32ClientId, pDevDesc));
     
    6969    unconst(mData.revision)     = pDevDesc->bcdRev;
    7070
    71     unconst(mData.manufacturer) = pDevDesc->oManufacturer? (char *)pDevDesc + pDevDesc->oManufacturer: "";
    72     unconst(mData.product)      = pDevDesc->oProduct? (char *)pDevDesc + pDevDesc->oProduct: "";
    73     unconst(mData.serialNumber) = pDevDesc->oSerialNumber? (char *)pDevDesc + pDevDesc->oSerialNumber: "";
     71    unconst(mData.manufacturer) = pDevDesc->oManufacturer ? (char *)pDevDesc + pDevDesc->oManufacturer : "";
     72    unconst(mData.product)      = pDevDesc->oProduct ? (char *)pDevDesc + pDevDesc->oProduct : "";
     73    unconst(mData.serialNumber) = pDevDesc->oSerialNumber ? (char *)pDevDesc + pDevDesc->oSerialNumber : "";
    7474
    7575    char id[64];
    76     RTStrPrintf(id, sizeof (id), REMOTE_USB_BACKEND_PREFIX_S "0x%08X&0x%08X", pDevDesc->id, u32ClientId);
     76    RTStrPrintf(id, sizeof(id), REMOTE_USB_BACKEND_PREFIX_S "0x%08X&0x%08X", pDevDesc->id, u32ClientId);
    7777    unconst(mData.address)      = id;
    7878
     
    165165/////////////////////////////////////////////////////////////////////////////
    166166
    167 STDMETHODIMP RemoteUSBDevice::COMGETTER(Id) (BSTR *aId)
    168 {
    169     CheckComArgOutPointerValid(aId);
    170 
    171     AutoCaller autoCaller(this);
    172     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    173 
    174     /* this is const, no need to lock */
    175     mData.id.toUtf16().detachTo(aId);
    176 
    177     return S_OK;
    178 }
    179 
    180 STDMETHODIMP RemoteUSBDevice::COMGETTER(VendorId) (USHORT *aVendorId)
    181 {
    182     CheckComArgOutPointerValid(aVendorId);
    183 
    184     AutoCaller autoCaller(this);
    185     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    186 
     167HRESULT RemoteUSBDevice::getId(com::Guid &aId)
     168{
     169    aId = mData.id;
     170
     171    return S_OK;
     172}
     173
     174HRESULT RemoteUSBDevice::getVendorId(USHORT *aVendorId)
     175{
    187176    /* this is const, no need to lock */
    188177    *aVendorId = mData.vendorId;
     
    191180}
    192181
    193 STDMETHODIMP RemoteUSBDevice::COMGETTER(ProductId) (USHORT *aProductId)
    194 {
    195     CheckComArgOutPointerValid(aProductId);
    196 
    197     AutoCaller autoCaller(this);
    198     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    199 
     182HRESULT RemoteUSBDevice::getProductId(USHORT *aProductId)
     183{
    200184    /* this is const, no need to lock */
    201185    *aProductId = mData.productId;
     
    204188}
    205189
    206 STDMETHODIMP RemoteUSBDevice::COMGETTER(Revision) (USHORT *aRevision)
    207 {
    208     CheckComArgOutPointerValid(aRevision);
    209 
    210     AutoCaller autoCaller(this);
    211     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    212 
     190HRESULT RemoteUSBDevice::getRevision(USHORT *aRevision)
     191{
    213192    /* this is const, no need to lock */
    214193    *aRevision = mData.revision;
     
    217196}
    218197
    219 STDMETHODIMP RemoteUSBDevice::COMGETTER(Manufacturer) (BSTR *aManufacturer)
    220 {
    221     CheckComArgOutPointerValid(aManufacturer);
    222 
    223     AutoCaller autoCaller(this);
    224     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    225 
    226     /* this is const, no need to lock */
    227     mData.manufacturer.cloneTo(aManufacturer);
    228 
    229     return S_OK;
    230 }
    231 
    232 STDMETHODIMP RemoteUSBDevice::COMGETTER(Product) (BSTR *aProduct)
    233 {
    234     CheckComArgOutPointerValid(aProduct);
    235 
    236     AutoCaller autoCaller(this);
    237     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    238 
    239     /* this is const, no need to lock */
    240     mData.product.cloneTo(aProduct);
    241 
    242     return S_OK;
    243 }
    244 
    245 STDMETHODIMP RemoteUSBDevice::COMGETTER(SerialNumber) (BSTR *aSerialNumber)
    246 {
    247     CheckComArgOutPointerValid(aSerialNumber);
    248 
    249     AutoCaller autoCaller(this);
    250     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    251 
    252     /* this is const, no need to lock */
    253     mData.serialNumber.cloneTo(aSerialNumber);
    254 
    255     return S_OK;
    256 }
    257 
    258 STDMETHODIMP RemoteUSBDevice::COMGETTER(Address) (BSTR *aAddress)
    259 {
    260     CheckComArgOutPointerValid(aAddress);
    261 
    262     AutoCaller autoCaller(this);
    263     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    264 
    265     /* this is const, no need to lock */
    266     mData.address.cloneTo(aAddress);
    267 
    268     return S_OK;
    269 }
    270 
    271 STDMETHODIMP RemoteUSBDevice::COMGETTER(Port) (USHORT *aPort)
    272 {
    273     CheckComArgOutPointerValid(aPort);
    274 
    275     AutoCaller autoCaller(this);
    276     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    277 
     198HRESULT RemoteUSBDevice::getManufacturer(com::Utf8Str &aManufacturer)
     199{
     200    /* this is const, no need to lock */
     201    aManufacturer = mData.manufacturer;
     202
     203    return S_OK;
     204}
     205
     206HRESULT RemoteUSBDevice::getProduct(com::Utf8Str &aProduct)
     207{
     208    /* this is const, no need to lock */
     209    aProduct = mData.product;
     210
     211    return S_OK;
     212}
     213
     214HRESULT RemoteUSBDevice::getSerialNumber(com::Utf8Str &aSerialNumber)
     215{
     216    /* this is const, no need to lock */
     217    aSerialNumber = mData.serialNumber;
     218
     219    return S_OK;
     220}
     221
     222HRESULT RemoteUSBDevice::getAddress(com::Utf8Str &aAddress)
     223{
     224    /* this is const, no need to lock */
     225    aAddress = mData.address;
     226
     227    return S_OK;
     228}
     229
     230HRESULT RemoteUSBDevice::getPort(USHORT *aPort)
     231{
    278232    /* this is const, no need to lock */
    279233    *aPort = mData.port;
     
    282236}
    283237
    284 STDMETHODIMP RemoteUSBDevice::COMGETTER(Version) (USHORT *aVersion)
    285 {
    286     CheckComArgOutPointerValid(aVersion);
    287 
    288     AutoCaller autoCaller(this);
    289     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    290 
     238HRESULT RemoteUSBDevice::getVersion(USHORT *aVersion)
     239{
    291240    /* this is const, no need to lock */
    292241    *aVersion = mData.version;
     
    295244}
    296245
    297 STDMETHODIMP RemoteUSBDevice::COMGETTER(PortVersion) (USHORT *aPortVersion)
    298 {
    299     CheckComArgOutPointerValid(aPortVersion);
    300 
    301     AutoCaller autoCaller(this);
    302     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    303 
     246HRESULT RemoteUSBDevice::getPortVersion(USHORT *aPortVersion)
     247{
    304248    /* this is const, no need to lock */
    305249    *aPortVersion = mData.portVersion;
     
    308252}
    309253
    310 STDMETHODIMP RemoteUSBDevice::COMGETTER(Speed) (USBConnectionSpeed_T *aSpeed)
    311 {
    312     CheckComArgOutPointerValid(aSpeed);
    313 
    314     AutoCaller autoCaller(this);
    315     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    316 
     254HRESULT RemoteUSBDevice::getSpeed(USBConnectionSpeed_T *aSpeed)
     255{
    317256    /* this is const, no need to lock */
    318257    *aSpeed = mData.speed;
     
    321260}
    322261
    323 STDMETHODIMP RemoteUSBDevice::COMGETTER(Remote) (BOOL *aRemote)
    324 {
    325     CheckComArgOutPointerValid(aRemote);
    326 
    327     AutoCaller autoCaller(this);
    328     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    329 
     262HRESULT RemoteUSBDevice::getRemote(BOOL *aRemote)
     263{
    330264    /* RemoteUSBDevice is always remote. */
    331265    /* this is const, no need to lock */
     
    338272////////////////////////////////////////////////////////////////////////////////
    339273
    340 STDMETHODIMP RemoteUSBDevice::COMGETTER(State) (USBDeviceState_T *aState)
    341 {
    342     CheckComArgOutPointerValid(aState);
    343 
    344     AutoCaller autoCaller(this);
    345     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    346 
     274HRESULT RemoteUSBDevice::getState(USBDeviceState_T *aState)
     275{
    347276    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    348277
  • trunk/src/VBox/Main/src-client/xpcom/module.cpp

    r55401 r56584  
    66
    77/*
    8  * Copyright (C) 2006-2014 Oracle Corporation
     8 * Copyright (C) 2006-2015 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3838
    3939// XPCOM glue code unfolding
    40 
    41 #ifndef VBOX_COM_INPROC_API_CLIENT
    42 NS_DECL_CLASSINFO(RemoteUSBDevice)
    43 NS_IMPL_THREADSAFE_ISUPPORTS2_CI(RemoteUSBDevice, IHostUSBDevice, IUSBDevice)
    44 #endif /* VBOX_COM_INPROC_API_CLIENT */
    4540
    4641/*
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