bool Target::open(mcp2200::Device &device) { if (isPathSet()){ if (device.open(getPath())){ return true; }else{ cerr << "could not open device (" << getPath() << ")\n"; return false; } } if (isSerialSet()){ if (device.open(getVendorId(), getProductId(), getSerial().c_str())){ return true; }else{ cerr << "could not open device (" << *this << ", serial:" << getSerial() << ")\n"; return false; } } if (device.open(getVendorId(), getProductId())){ return true; }else{ cerr << "could not open device (" << *this << ")\n"; return false; } }
STDMETHODIMP HostUSBDeviceFilterWrap::COMGETTER(ProductId)(BSTR *aProductId) { LogRelFlow(("{%p} %s: enter aProductId=%p\n", this, "HostUSBDeviceFilter::getProductId", aProductId)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aProductId); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getProductId(BSTROutConverter(aProductId).str()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aProductId=%ls hrc=%Rhrc\n", this, "HostUSBDeviceFilter::getProductId", *aProductId, hrc)); return hrc; }
Product* getProduct(char* name, Vector* products) { int i = getProductId(name, products); if (i != -1) { return (Product*) getFromVector(products, i); } //this Product doesn't exist, let's add it Product* res; if ((res = malloc(sizeof(Product))) == NULL) { return NULL; } res->name = malloc((strlen(name) + 1) * sizeof(char)); if (res->name == NULL) { free(res); return NULL; } strcpy(res->name, name); if ((i = addToVector(products, res)) == -1) { free(res); return NULL; } res->id = i; return res; }
void Product::purchase() { if (!manager) { BOOST_ASSERT_MSG(false, "service has to be set"); return; } manager->purchase(getProductId().c_str()); }
bool HIDDeviceManager::initVendorProductVersion(IOHIDDeviceRef device, HIDDeviceDesc* pDevDesc) { if (!getVendorId(device, &(pDevDesc->VendorId))) { return false; } if (!getProductId(device, &(pDevDesc->ProductId))) { return false; } return true; }
bool HIDDeviceManager::getPath(IOHIDDeviceRef device, String* pPath) { String transport; if (!getStringProperty(device, CFSTR(kIOHIDTransportKey), &transport)) { return false; } UInt16 vendorId; if (!getVendorId(device, &vendorId)) { return false; } UInt16 productId; if (!getProductId(device, &productId)) { return false; } String serialNumber; if (!getSerialNumberString(device, &serialNumber)) { return false; } StringBuffer buffer; buffer.AppendFormat("%s:vid=%04hx:pid=%04hx:ser=%s", transport.ToCStr(), vendorId, productId, serialNumber.ToCStr()); *pPath = String(buffer); return true; }
bool HIDDeviceManager::initVendorProductVersion(IOHIDDeviceRef device, HIDDeviceDesc* pDevDesc) { if (!getVendorId(device, &(pDevDesc->VendorId))) { return false; } if (!getProductId(device, &(pDevDesc->ProductId))) { return false; } SInt32 result; if (!getIntProperty(device, CFSTR(kIOHIDVersionNumberKey), &result)) { return false; } pDevDesc->VersionNumber = result; return true; }