mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
libdivecomputer: remove ifdefs for ancient versions
We bundle our version of libdivecomputer and don't expect Subsurface to work with a different version, certainly not with something older than 0.5. I kept the checks for SAMPLE_EVENT_STRING and DC_FIELD_STRING and DC_SAMPLE_TTS because maybe there's a situation where being able to compile with a current upstream version is useful. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
197ba9b2a4
commit
1c8b73b36f
2 changed files with 1 additions and 39 deletions
|
@ -895,8 +895,6 @@ static dc_status_t write_ostc4_settings(dc_device_t *device, DeviceDetails *m_de
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if DC_VERSION_CHECK(0, 5, 0)
|
|
||||||
static dc_status_t read_ostc3_settings(dc_device_t *device, DeviceDetails *m_deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
static dc_status_t read_ostc3_settings(dc_device_t *device, DeviceDetails *m_deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
||||||
{
|
{
|
||||||
dc_status_t rc;
|
dc_status_t rc;
|
||||||
|
@ -1434,7 +1432,6 @@ static dc_status_t write_ostc3_settings(dc_device_t *device, DeviceDetails *m_de
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
#endif /* DC_VERSION_CHECK(0, 5, 0) */
|
|
||||||
|
|
||||||
static dc_status_t read_ostc_settings(dc_device_t *device, DeviceDetails *m_deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
static dc_status_t read_ostc_settings(dc_device_t *device, DeviceDetails *m_deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
||||||
{
|
{
|
||||||
|
@ -2132,7 +2129,6 @@ void ReadSettingsThread::run()
|
||||||
emit error(tr("Failed!"));
|
emit error(tr("Failed!"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#if DC_VERSION_CHECK(0, 5, 0)
|
|
||||||
case DC_FAMILY_HW_OSTC3:
|
case DC_FAMILY_HW_OSTC3:
|
||||||
rc = read_ostc3_settings(m_data->device, m_deviceDetails, DeviceThread::event_cb, this);
|
rc = read_ostc3_settings(m_data->device, m_deviceDetails, DeviceThread::event_cb, this);
|
||||||
if (rc == DC_STATUS_SUCCESS)
|
if (rc == DC_STATUS_SUCCESS)
|
||||||
|
@ -2140,7 +2136,7 @@ void ReadSettingsThread::run()
|
||||||
else
|
else
|
||||||
emit error(tr("Failed!"));
|
emit error(tr("Failed!"));
|
||||||
break;
|
break;
|
||||||
#endif // divecomputer 0.5.0
|
|
||||||
#ifdef DEBUG_OSTC
|
#ifdef DEBUG_OSTC
|
||||||
case DC_FAMILY_NULL:
|
case DC_FAMILY_NULL:
|
||||||
#endif
|
#endif
|
||||||
|
@ -2181,7 +2177,6 @@ void WriteSettingsThread::run()
|
||||||
emit error(tr("Failed!"));
|
emit error(tr("Failed!"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#if DC_VERSION_CHECK(0, 5, 0)
|
|
||||||
case DC_FAMILY_HW_OSTC3:
|
case DC_FAMILY_HW_OSTC3:
|
||||||
// FIXME: Is this the best way?
|
// FIXME: Is this the best way?
|
||||||
if (m_deviceDetails->model == "OSTC 4")
|
if (m_deviceDetails->model == "OSTC 4")
|
||||||
|
@ -2191,7 +2186,6 @@ void WriteSettingsThread::run()
|
||||||
if (rc != DC_STATUS_SUCCESS)
|
if (rc != DC_STATUS_SUCCESS)
|
||||||
emit error(tr("Failed!"));
|
emit error(tr("Failed!"));
|
||||||
break;
|
break;
|
||||||
#endif // divecomputer 0.5.0
|
|
||||||
#ifdef DEBUG_OSTC
|
#ifdef DEBUG_OSTC
|
||||||
case DC_FAMILY_NULL:
|
case DC_FAMILY_NULL:
|
||||||
#endif
|
#endif
|
||||||
|
@ -2221,14 +2215,12 @@ void FirmwareUpdateThread::run()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (dc_device_get_type(m_data->device)) {
|
switch (dc_device_get_type(m_data->device)) {
|
||||||
#if DC_VERSION_CHECK(0, 5, 0)
|
|
||||||
case DC_FAMILY_HW_OSTC3:
|
case DC_FAMILY_HW_OSTC3:
|
||||||
rc = hw_ostc3_device_fwupdate(m_data->device, qPrintable(m_fileName));
|
rc = hw_ostc3_device_fwupdate(m_data->device, qPrintable(m_fileName));
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_HW_OSTC:
|
case DC_FAMILY_HW_OSTC:
|
||||||
rc = hw_ostc_device_fwupdate(m_data->device, qPrintable(m_fileName));
|
rc = hw_ostc_device_fwupdate(m_data->device, qPrintable(m_fileName));
|
||||||
break;
|
break;
|
||||||
#endif // divecomputer 0.5.0
|
|
||||||
default:
|
default:
|
||||||
emit error(tr("This feature is not yet available for the selected dive computer."));
|
emit error(tr("This feature is not yet available for the selected dive computer."));
|
||||||
return;
|
return;
|
||||||
|
@ -2248,12 +2240,10 @@ void ResetSettingsThread::run()
|
||||||
{
|
{
|
||||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||||
|
|
||||||
#if DC_VERSION_CHECK(0, 5, 0)
|
|
||||||
if (dc_device_get_type(m_data->device) == DC_FAMILY_HW_OSTC3) {
|
if (dc_device_get_type(m_data->device) == DC_FAMILY_HW_OSTC3) {
|
||||||
rc = hw_ostc3_device_config_reset(m_data->device);
|
rc = hw_ostc3_device_config_reset(m_data->device);
|
||||||
emit progress(100);
|
emit progress(100);
|
||||||
}
|
}
|
||||||
#endif // divecomputer 0.5.0
|
|
||||||
if (rc != DC_STATUS_SUCCESS) {
|
if (rc != DC_STATUS_SUCCESS) {
|
||||||
emit error(tr("Reset settings failed!"));
|
emit error(tr("Reset settings failed!"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,18 +32,6 @@
|
||||||
#include "core/file.h"
|
#include "core/file.h"
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
//
|
|
||||||
// If we have an old libdivecomputer, it doesn't
|
|
||||||
// have the new DC_TANKINFO bits, but just volume
|
|
||||||
// type information.
|
|
||||||
//
|
|
||||||
#ifndef DC_TANKINFO_METRIC
|
|
||||||
#define DC_TANKINFO_METRIC DC_TANKVOLUME_METRIC
|
|
||||||
#define DC_TANKINFO_IMPERIAL DC_TANKVOLUME_IMPERIAL
|
|
||||||
#define DC_TANKINFO_CC_O2 0
|
|
||||||
#define DC_TANKINFO_CC_DILUENT 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *dumpfile_name;
|
char *dumpfile_name;
|
||||||
char *logfile_name;
|
char *logfile_name;
|
||||||
const char *progress_bar_text = "";
|
const char *progress_bar_text = "";
|
||||||
|
@ -109,7 +97,6 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
#if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN)
|
|
||||||
unsigned int ntanks = 0;
|
unsigned int ntanks = 0;
|
||||||
rc = dc_parser_get_field(parser, DC_FIELD_TANK_COUNT, 0, &ntanks);
|
rc = dc_parser_get_field(parser, DC_FIELD_TANK_COUNT, 0, &ntanks);
|
||||||
if (rc == DC_STATUS_SUCCESS) {
|
if (rc == DC_STATUS_SUCCESS) {
|
||||||
|
@ -121,7 +108,6 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||||
report_error("Warning: smaller number of gases (%d) than cylinders (%d). Assuming air.", ngases, ntanks);
|
report_error("Warning: smaller number of gases (%d) than cylinders (%d). Assuming air.", ngases, ntanks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
bool no_volume = true;
|
bool no_volume = true;
|
||||||
|
|
||||||
for (i = 0; i < MAX_CYLINDERS && (i < ngases || i < ntanks); i++) {
|
for (i = 0; i < MAX_CYLINDERS && (i < ngases || i < ntanks); i++) {
|
||||||
|
@ -158,7 +144,6 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||||
dive->cylinder[i].gasmix.he.permille = 0;
|
dive->cylinder[i].gasmix.he.permille = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN)
|
|
||||||
if (i < ntanks) {
|
if (i < ntanks) {
|
||||||
dc_tank_t tank = { 0 };
|
dc_tank_t tank = { 0 };
|
||||||
rc = dc_parser_get_field(parser, DC_FIELD_TANK, i, &tank);
|
rc = dc_parser_get_field(parser, DC_FIELD_TANK, i, &tank);
|
||||||
|
@ -234,7 +219,6 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (no_volume) {
|
if (no_volume) {
|
||||||
/* for the first tank, if there is no tanksize available from the
|
/* for the first tank, if there is no tanksize available from the
|
||||||
* dive computer, fill in the default tank information (if set) */
|
* dive computer, fill in the default tank information (if set) */
|
||||||
|
@ -394,7 +378,6 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
||||||
printf("</vendor>\n");
|
printf("</vendor>\n");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if DC_VERSION_CHECK(0, 3, 0)
|
|
||||||
case DC_SAMPLE_SETPOINT:
|
case DC_SAMPLE_SETPOINT:
|
||||||
/* for us a setpoint means constant pO2 from here */
|
/* for us a setpoint means constant pO2 from here */
|
||||||
sample->setpoint.mbar = po2 = lrint(value.setpoint * 1000);
|
sample->setpoint.mbar = po2 = lrint(value.setpoint * 1000);
|
||||||
|
@ -428,7 +411,6 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
||||||
sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0);
|
sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0);
|
||||||
sample->stoptime.seconds = stoptime = value.deco.time;
|
sample->stoptime.seconds = stoptime = value.deco.time;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -669,11 +651,6 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
||||||
if (rc == DC_STATUS_SUCCESS)
|
if (rc == DC_STATUS_SUCCESS)
|
||||||
dive->dc.maxdepth.mm = lrint(maxdepth * 1000);
|
dive->dc.maxdepth.mm = lrint(maxdepth * 1000);
|
||||||
|
|
||||||
#if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN)
|
|
||||||
// if this is defined then we have a fairly late version of libdivecomputer
|
|
||||||
// from the 0.5 development cylcle - most likely temperatures and tank sizes
|
|
||||||
// are supported
|
|
||||||
|
|
||||||
// Parse temperatures
|
// Parse temperatures
|
||||||
double temperature;
|
double temperature;
|
||||||
dc_field_type_t temp_fields[] = {DC_FIELD_TEMPERATURE_SURFACE,
|
dc_field_type_t temp_fields[] = {DC_FIELD_TEMPERATURE_SURFACE,
|
||||||
|
@ -696,7 +673,6 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Parse the gas mixes.
|
// Parse the gas mixes.
|
||||||
unsigned int ngases = 0;
|
unsigned int ngases = 0;
|
||||||
|
@ -706,7 +682,6 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DC_VERSION_CHECK(0, 3, 0)
|
|
||||||
// Check if the libdivecomputer version already supports salinity & atmospheric
|
// Check if the libdivecomputer version already supports salinity & atmospheric
|
||||||
dc_salinity_t salinity = {
|
dc_salinity_t salinity = {
|
||||||
.type = DC_WATER_SALT,
|
.type = DC_WATER_SALT,
|
||||||
|
@ -728,7 +703,6 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
||||||
}
|
}
|
||||||
if (rc == DC_STATUS_SUCCESS)
|
if (rc == DC_STATUS_SUCCESS)
|
||||||
dive->dc.surface_pressure.mbar = lrint(surface_pressure * 1000.0);
|
dive->dc.surface_pressure.mbar = lrint(surface_pressure * 1000.0);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DC_FIELD_STRING
|
#ifdef DC_FIELD_STRING
|
||||||
// The dive parsing may give us more device information
|
// The dive parsing may give us more device information
|
||||||
|
@ -744,7 +718,6 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN)
|
|
||||||
dc_divemode_t divemode;
|
dc_divemode_t divemode;
|
||||||
rc = dc_parser_get_field(parser, DC_FIELD_DIVEMODE, 0, &divemode);
|
rc = dc_parser_get_field(parser, DC_FIELD_DIVEMODE, 0, &divemode);
|
||||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||||
|
@ -767,7 +740,6 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
||||||
dive->dc.divemode = PSCR;
|
dive->dc.divemode = PSCR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
rc = parse_gasmixes(devdata, dive, parser, ngases);
|
rc = parse_gasmixes(devdata, dive, parser, ngases);
|
||||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue