aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2021-09-18 18:52:50 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-09-19 16:51:46 -0700
commit85392343fa393054ddd3446aa38c3be941eb02c5 (patch)
treed315365d584cebc22581979da09f73c59f7db492 /desktop-widgets
parentde69f122625e7782f8786c5bf28a9f5c350fbc9d (diff)
downloadsubsurface-85392343fa393054ddd3446aa38c3be941eb02c5.tar.gz
Re-do the libdivecomputer fingerprint save/load code
This tries to make our fingerprinting code work better, by avoiding using the "deviceid" field that has always been unreliable because we've calculated it multiple different ways, and even for the same version of subsurface, it ends up changing in the middle (ie we calculate one value initially, then re-calculate it when we have a proper serial number string). So instead, the fingerprinting code will look up and save the fingerprint file using purely "stable" information that is available early during the download: - the device model name (which is a string with vendor and product name separated by a space) - the DC_EVENT_DEVINFO 32-bit 'serial' number (which is not necessarily a real serial number at all, but hopefully at least a unique number for the particular product) but because the model name is not necessarily a good filename (think slashes and other possibly invalid characters), we hash that model name and use the resulting hex number in the fingerprint file name. This way the fingerprint file is unambiguous at load and save time, and depends purely on libdivecomputer data. But because we also need to verify that we have the actual _dive_ associated with that fingerprint, we also need to save the final deviceid and diveid when saving the fingerprint file, so that when we load it again we can look up the dive and verify that we have it before we use the fingerprint data. To do that, the fingerprint file itself contains not just the fingerprint data from libdivecomputer, but the last 8 bytes of the file are the (subsurface) deviceid and the diveid of the dive that is associated with the fingerprint. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/configuredivecomputerdialog.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/desktop-widgets/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp
index 6434f8c05..e8af051a0 100644
--- a/desktop-widgets/configuredivecomputerdialog.cpp
+++ b/desktop-widgets/configuredivecomputerdialog.cpp
@@ -273,7 +273,7 @@ void OstcFirmwareCheck::checkLatest(QWidget *_parent, device_data_t *data)
// for the OSTC that means highbyte.lowbyte is the version number
// For OSTC 4's its stored as XXXX XYYY YYZZ ZZZB, -> X.Y.Z beta?
- int firmwareOnDevice = devData.libdc_firmware;
+ int firmwareOnDevice = devData.devinfo.firmware;
QString firmwareOnDeviceString;
// Convert the latestFirmwareAvailable to a integear we can compare with
QStringList fwParts = latestFirmwareAvailable.split(".");
@@ -907,7 +907,8 @@ void ConfigureDiveComputerDialog::getDeviceData()
device_data.product = copy_qstring(selected_product);
device_data.descriptor = descriptorLookup.value(selected_vendor.toLower() + selected_product.toLower());
- device_data.deviceid = device_data.diveid = 0;
+ device_data.diveid = 0;
+ memset(&device_data.devinfo, 0, sizeof(device_data.devinfo));
qPrefDiveComputer::set_device(device_data.devname);
#ifdef BT_SUPPORT