summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/android.cpp2
-rw-r--r--core/display.h8
-rw-r--r--core/downloadfromdcthread.cpp6
-rw-r--r--core/downloadfromdcthread.h1
-rw-r--r--core/ios.cpp2
-rw-r--r--core/libdivecomputer.h5
-rw-r--r--core/macos.c6
-rw-r--r--core/unix.c6
-rw-r--r--core/windows.c6
9 files changed, 24 insertions, 18 deletions
diff --git a/core/android.cpp b/core/android.cpp
index 1a9e76e06..08b34dc73 100644
--- a/core/android.cpp
+++ b/core/android.cpp
@@ -81,7 +81,7 @@ const char *system_default_filename(void)
return path;
}
-int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
+int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
{
/* FIXME: we need to enumerate in some other way on android */
/* qtserialport maybee? */
diff --git a/core/display.h b/core/display.h
index b5b6a3938..67feee854 100644
--- a/core/display.h
+++ b/core/display.h
@@ -2,6 +2,8 @@
#ifndef DISPLAY_H
#define DISPLAY_H
+#include "libdivecomputer.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,11 +46,7 @@ extern int is_default_dive_computer(const char *, const char *);
typedef void (*device_callback_t)(const char *name, void *userdata);
-#define DC_TYPE_SERIAL 1
-#define DC_TYPE_UEMIS 2
-#define DC_TYPE_OTHER 3
-
-int enumerate_devices(device_callback_t callback, void *userdata, int dc_type);
+int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport);
extern const char *default_dive_computer_vendor;
extern const char *default_dive_computer_product;
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index da8c09f54..6f957579c 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -158,6 +158,7 @@ void fill_computer_list()
mydescriptor->product = "Zurich";
mydescriptor->type = DC_FAMILY_NULL;
mydescriptor->model = 0;
+ mydescriptor->transports = DC_TRANSPORT_USBSTORAGE;
if (!vendorList.contains("Uemis"))
vendorList.append("Uemis");
@@ -171,14 +172,15 @@ void fill_computer_list()
qSort(vendorList);
}
-#define NUMTRANSPORTS 6
+#define NUMTRANSPORTS 7
static QString transportStringTable[NUMTRANSPORTS] = {
QStringLiteral("SERIAL"),
QStringLiteral("USB"),
QStringLiteral("USBHID"),
QStringLiteral("IRDA"),
QStringLiteral("BT"),
- QStringLiteral("BLE")
+ QStringLiteral("BLE"),
+ QStringLiteral("USBSTORAGE"),
};
static QString getTransportString(unsigned int transport)
diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h
index 185f62aa4..265fb499e 100644
--- a/core/downloadfromdcthread.h
+++ b/core/downloadfromdcthread.h
@@ -78,6 +78,7 @@ struct mydescriptor {
const char *product;
dc_family_t type;
unsigned int model;
+ unsigned int transports;
};
/* This fills the vendor list QStringList and related members.
diff --git a/core/ios.cpp b/core/ios.cpp
index b951f4901..614107d2b 100644
--- a/core/ios.cpp
+++ b/core/ios.cpp
@@ -68,7 +68,7 @@ const char *system_default_filename(void)
return path;
}
-int enumerate_devices(device_callback_t, void *, int)
+int enumerate_devices(device_callback_t, void *, unsigned int)
{
// we can't read from devices on iOS
return -1;
diff --git a/core/libdivecomputer.h b/core/libdivecomputer.h
index b1714f2a1..050834195 100644
--- a/core/libdivecomputer.h
+++ b/core/libdivecomputer.h
@@ -12,6 +12,11 @@
#include <libdivecomputer/device.h>
#include <libdivecomputer/parser.h>
+// Even if we have an old libdivecomputer, Uemis uses this
+#ifndef DC_TRANSPORT_USBSTORAGE
+#define DC_TRANSPORT_USBSTORAGE (1 << 6)
+#endif
+
#include "dive.h"
#ifdef __cplusplus
diff --git a/core/macos.c b/core/macos.c
index e9ab7b8a8..05353b5ba 100644
--- a/core/macos.c
+++ b/core/macos.c
@@ -97,13 +97,13 @@ const char *system_default_filename(void)
return path;
}
-int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
+int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
{
int index = -1, entries = 0;
DIR *dp = NULL;
struct dirent *ep = NULL;
size_t i;
- if (dc_type != DC_TYPE_UEMIS) {
+ if (transport & DC_TRANSPORT_SERIAL) {
const char *dirname = "/dev";
const char *patterns[] = {
"tty.*",
@@ -135,7 +135,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
}
closedir(dp);
}
- if (dc_type != DC_TYPE_SERIAL) {
+ if (transport & DC_TRANSPORT_USBSTORAGE) {
const char *dirname = "/Volumes";
int num_uemis = 0;
dp = opendir(dirname);
diff --git a/core/unix.c b/core/unix.c
index 48fd3f467..1d92a1ad3 100644
--- a/core/unix.c
+++ b/core/unix.c
@@ -100,7 +100,7 @@ const char *system_default_filename(void)
return path;
}
-int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
+int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
{
int index = -1, entries = 0;
DIR *dp = NULL;
@@ -110,7 +110,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
char *line = NULL;
char *fname;
size_t len;
- if (dc_type != DC_TYPE_UEMIS) {
+ if (transport & DC_TRANSPORT_SERIAL) {
const char *dirname = "/dev";
#ifdef __OpenBSD__
const char *patterns[] = {
@@ -153,7 +153,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
closedir(dp);
}
#ifdef __linux__
- if (dc_type != DC_TYPE_SERIAL) {
+ if (transport & DC_TRANSPORT_USBSTORAGE) {
int num_uemis = 0;
file = fopen("/proc/mounts", "r");
if (file == NULL)
diff --git a/core/windows.c b/core/windows.c
index cb031e261..6feb3f740 100644
--- a/core/windows.c
+++ b/core/windows.c
@@ -117,11 +117,11 @@ const char *system_default_filename(void)
return path;
}
-int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
+int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
{
int index = -1;
DWORD i;
- if (dc_type != DC_TYPE_UEMIS) {
+ if (transport & DC_TRANSPORT_SERIAL) {
// Open the registry key.
HKEY hKey;
LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_QUERY_VALUE, &hKey);
@@ -169,7 +169,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
RegCloseKey(hKey);
}
- if (dc_type != DC_TYPE_SERIAL) {
+ if (transport & DC_TRANSPORT_USBSTORAGE) {
int i;
int count_drives = 0;
const int bufdef = 512;