void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString &vendor) { unsigned int transport; dc_descriptor_t *descriptor; productModel.setStringList(productList[vendor]); ui.product->setCurrentIndex(0); descriptor = descriptorLookup.value(ui.vendor->currentText() + ui.product->currentText()); transport = dc_descriptor_get_transports(descriptor); fill_device_list(transport); }
void show_computer_list() { unsigned int transportMask = get_supported_transports(NULL); qDebug() << "Supported dive computers:"; Q_FOREACH (QString vendor, vendorList) { QString msg = vendor + ": "; Q_FOREACH (QString product, productList[vendor]) { dc_descriptor_t *descriptor = descriptorLookup[vendor + product]; unsigned int transport = dc_descriptor_get_transports(descriptor) & transportMask; QString transportString = getTransportString(transport); msg += product + " (" + transportString + "), "; }
void fill_computer_list() { dc_iterator_t *iterator = NULL; dc_descriptor_t *descriptor = NULL; unsigned int transportMask = get_supported_transports(NULL); fill_supported_mobile_list(); dc_descriptor_iterator(&iterator); while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) { // mask out the transports that aren't supported unsigned int transports = dc_descriptor_get_transports(descriptor) & transportMask; if (transports == 0) // none of the transports are available, skip continue; const char *vendor = dc_descriptor_get_vendor(descriptor); const char *product = dc_descriptor_get_product(descriptor); #if defined(Q_OS_ANDROID) if ((transports & ~(DC_TRANSPORT_SERIAL | DC_TRANSPORT_USB | DC_TRANSPORT_USBHID)) == 0) // if the only available transports are serial/USB, then check against // the ones that we explicitly support on Android if (!mobileProductList.contains(vendor) || !mobileProductList[vendor].contains(product)) continue; #endif if (!vendorList.contains(vendor)) vendorList.append(vendor); if (!productList[vendor].contains(product)) productList[vendor].append(product); descriptorLookup[QString(vendor) + QString(product)] = descriptor; } dc_iterator_free(iterator); Q_FOREACH (QString vendor, vendorList) qSort(productList[vendor]); #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) /* currently suppress the Uemis Zurich on Q_OS_ANDROID and Q_OS_IOS, * as it is no BT device */ /* and add the Uemis Zurich which we are handling internally THIS IS A HACK as we magically have a data structure here that happens to match a data structure that is internal to libdivecomputer; this WILL BREAK if libdivecomputer changes the dc_descriptor struct... eventually the UEMIS code needs to move into libdivecomputer, I guess */ struct mydescriptor *mydescriptor = (struct mydescriptor *)malloc(sizeof(struct mydescriptor)); mydescriptor->vendor = "Uemis"; mydescriptor->product = "Zurich"; mydescriptor->type = DC_FAMILY_NULL; mydescriptor->model = 0; mydescriptor->transports = DC_TRANSPORT_USBSTORAGE; if (!vendorList.contains("Uemis")) vendorList.append("Uemis"); if (!productList["Uemis"].contains("Zurich")) productList["Uemis"].push_back("Zurich"); descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor; #endif qSort(vendorList); }