diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-27 10:32:14 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-27 22:10:38 -0700 |
commit | 270e9eccad8644352f5ae07df8b6acb55b115361 (patch) | |
tree | 0b6aaee8221fc2c12d9b084e42179e1a2d9633f0 /desktop-widgets/downloadfromdivecomputer.cpp | |
parent | bb067b6ee4828fc2444395d4cfda80831c4721bb (diff) | |
download | subsurface-270e9eccad8644352f5ae07df8b6acb55b115361.tar.gz |
Make device enumeration use the device transport data
This removes some special-case code for Uemis, replacing it with simply
passing in the device transport information.
This makes device enumeration work for the Garmin Descent (if it is
listed by libdivecomputer as a USB storage device, that is).
I don't actually do any of the libdivecomputer parsing yet, and only
have a stub for the Garmin Descent, but now the directory selection
works with that stub. The actual download obviously does not.
[Dirk Hohndel: removed obsolete FIXME from code]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/downloadfromdivecomputer.cpp')
-rw-r--r-- | desktop-widgets/downloadfromdivecomputer.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index b52efc636..c0e081251 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -143,7 +143,7 @@ void DownloadFromDCWidget::updateState(states state) return; if (state == INITIAL) { - fill_device_list(DC_TYPE_OTHER); + fill_device_list(~0); ui.progressBar->hide(); markChildrenAsEnabled(); timer->stop(); @@ -231,13 +231,14 @@ void DownloadFromDCWidget::updateState(states state) void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString &vendor) { - int dcType = DC_TYPE_SERIAL; + unsigned int transport; + dc_descriptor_t *descriptor; productModel.setStringList(productList[vendor]); ui.product->setCurrentIndex(0); - if (vendor == QString("Uemis")) - dcType = DC_TYPE_UEMIS; - fill_device_list(dcType); + descriptor = descriptorLookup.value(ui.vendor->currentText() + ui.product->currentText()); + transport = dc_descriptor_get_transports(descriptor); + fill_device_list(transport); } void DownloadFromDCWidget::on_product_currentIndexChanged(const QString &) @@ -475,7 +476,7 @@ void DownloadFromDCWidget::updateDeviceEnabled() descriptor = descriptorLookup.value(ui.vendor->currentText() + ui.product->currentText()); // call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL - if (dc_descriptor_get_transports(descriptor) & DC_TRANSPORT_SERIAL) { + if (dc_descriptor_get_transports(descriptor) & (DC_TRANSPORT_SERIAL | DC_TRANSPORT_USBSTORAGE)) { // if the dc_transport_t is DC_TRANSPORT_SERIAL, then enable the device node box. ui.device->setEnabled(true); } else { @@ -567,11 +568,11 @@ static void fillDeviceList(const char *name, void *data) comboBox->addItem(name); } -void DownloadFromDCWidget::fill_device_list(int dc_type) +void DownloadFromDCWidget::fill_device_list(unsigned int transport) { int deviceIndex; ui.device->clear(); - deviceIndex = enumerate_devices(fillDeviceList, ui.device, dc_type); + deviceIndex = enumerate_devices(fillDeviceList, ui.device, transport); if (deviceIndex >= 0) ui.device->setCurrentIndex(deviceIndex); } |