HostUSBDeviceImpl.cpp revision c79efcf08c72772e87ae3daeb97064f93d890e50
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * VirtualBox IHostUSBDevice COM interface implementation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * available from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * General Public License as published by the Free Software Foundation,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * If you received this file as part of a commercial VirtualBox
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * distribution, then only the terms of your commercial VirtualBox
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * license agreement apply instead of the previous paragraph.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync// constructor / destructor
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/////////////////////////////////////////////////////////////////////////////
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync// public initializer/uninitializer for internal purposes only
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/////////////////////////////////////////////////////////////////////////////
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Initializes the USB device object.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @returns COM result indicator
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param aUsb Pointer to the usb device structure for which the object is to be a wrapper.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This structure is now fully owned by the HostUSBDevice object and will be
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * freed when it is destructed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param aUSBProxyService Pointer to the USB Proxy Service object.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncHRESULT HostUSBDevice::init(PUSBDEVICE aUsb, USBProxyService *aUSBProxyService)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /* Enclose the state transition NotReady->InInit->Ready */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * We need a unique ID for this VBoxSVC session.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * The UUID isn't stored anywhere.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Convert from USBDEVICESTATE to USBDeviceState.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Note that not all proxy backend can detect the HELD_BY_PROXY
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * and USED_BY_GUEST states. But that shouldn't matter much.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync AssertMsgFailed(("aUsb->enmState=%d\n", aUsb->enmState));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /* Other data members */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/// @todo remove
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /* Confirm the successful initialization */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Uninitializes the instance and sets the ready flag to FALSE.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Called either from FinalRelease() or by the parent when it gets destroyed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /* Enclose the state transition Ready->InUninit->NotReady */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync// IUSBDevice properties
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/////////////////////////////////////////////////////////////////////////////
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(Id)(GUIDPARAMOUT aId)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /* mId is constant during life time, no need to lock */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(VendorId)(USHORT *aVendorId)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(ProductId)(USHORT *aProductId)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(Revision)(USHORT *aRevision)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(Manufacturer)(BSTR *aManufacturer)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Bstr (mUsb->pszManufacturer).cloneTo (aManufacturer);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(Product)(BSTR *aProduct)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(SerialNumber)(BSTR *aSerialNumber)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Bstr (mUsb->pszSerialNumber).cloneTo (aSerialNumber);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(Address)(BSTR *aAddress)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(Port)(USHORT *aPort)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ///@todo implement
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(Remote)(BOOL *aRemote)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync// IHostUSBDevice properties
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/////////////////////////////////////////////////////////////////////////////
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncSTDMETHODIMP HostUSBDevice::COMGETTER(State) (USBDeviceState_T *aState)
if (!aState)
return E_POINTER;
return S_OK;
else if(haveManufacturer)
else if(haveProduct)
return name;
mIgnored = true;
mIgnored = false;
/** @todo this operation might fail and cause the device to the reattached with a different address and all that. */
#if !defined (__WIN__)
if (iDiff)
return iDiff;
if (iDiff)
return iDiff;
/** @todo Sander, will this work on windows as well? Linux won't reuse an address for quite a while. */
switch (mState)
switch (mState)
case USBDEVICESTATE_UNUSED:
switch (mState)
switch (mState)
switch (mState)