2017-04-18 17:14:03 +00:00
|
|
|
#ifndef DOWNLOADFROMDCTHREAD_H
|
|
|
|
#define DOWNLOADFROMDCTHREAD_H
|
|
|
|
|
|
|
|
#include <QThread>
|
2017-04-27 18:24:14 +00:00
|
|
|
#include <QMap>
|
|
|
|
#include <QHash>
|
2017-06-06 02:41:57 +00:00
|
|
|
#include <QLoggingCategory>
|
2017-04-27 18:24:14 +00:00
|
|
|
|
2019-03-04 22:20:29 +00:00
|
|
|
#include "divesite.h"
|
2020-10-19 17:19:32 +00:00
|
|
|
#include "device.h"
|
2017-04-18 17:14:03 +00:00
|
|
|
#include "libdivecomputer.h"
|
2017-10-06 14:51:30 +00:00
|
|
|
#include "connectionlistmodel.h"
|
2017-10-06 14:52:17 +00:00
|
|
|
#if BT_SUPPORT
|
2017-06-06 02:41:57 +00:00
|
|
|
#include "core/btdiscovery.h"
|
2017-10-06 14:52:17 +00:00
|
|
|
#endif
|
2020-03-15 22:12:30 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
#include "core/serial_usb_android.h"
|
|
|
|
#endif
|
|
|
|
|
2017-05-12 17:18:20 +00:00
|
|
|
/* Helper object for access of Device Data in QML */
|
2018-06-09 14:59:02 +00:00
|
|
|
class DCDeviceData {
|
2017-05-12 17:18:20 +00:00
|
|
|
public:
|
2018-06-09 14:59:02 +00:00
|
|
|
DCDeviceData();
|
2017-06-06 02:41:57 +00:00
|
|
|
static DCDeviceData *instance();
|
2017-05-12 17:18:20 +00:00
|
|
|
|
|
|
|
QString vendor() const;
|
|
|
|
QString product() const;
|
|
|
|
QString devName() const;
|
2018-06-09 10:31:31 +00:00
|
|
|
bool bluetoothMode() const;
|
|
|
|
bool saveDump() const;
|
2017-11-12 11:33:20 +00:00
|
|
|
QString devBluetoothName() const;
|
2017-05-12 17:18:20 +00:00
|
|
|
QString descriptor() const;
|
|
|
|
bool forceDownload() const;
|
2017-05-19 09:23:11 +00:00
|
|
|
bool saveLog() const;
|
2017-05-12 17:18:20 +00:00
|
|
|
int deviceId() const;
|
|
|
|
int diveId() const;
|
|
|
|
|
2017-05-19 09:23:11 +00:00
|
|
|
/* this needs to be a pointer to make the C-API happy */
|
2020-03-15 01:11:46 +00:00
|
|
|
device_data_t *internalData();
|
2017-05-19 09:23:11 +00:00
|
|
|
|
2018-06-09 10:31:31 +00:00
|
|
|
QStringList getProductListFromVendor(const QString& vendor);
|
|
|
|
int getMatchingAddress(const QString &vendor, const QString &product);
|
|
|
|
|
|
|
|
int getDetectedVendorIndex();
|
|
|
|
int getDetectedProductIndex(const QString ¤tVendorText);
|
2017-06-06 02:41:57 +00:00
|
|
|
|
2018-06-09 10:31:31 +00:00
|
|
|
void setDeviceId(int deviceId);
|
|
|
|
void setDiveId(int diveId);
|
2017-05-12 17:18:20 +00:00
|
|
|
void setVendor(const QString& vendor);
|
|
|
|
void setProduct(const QString& product);
|
|
|
|
void setDevName(const QString& devName);
|
2017-11-12 11:33:20 +00:00
|
|
|
void setDevBluetoothName(const QString& devBluetoothName);
|
2017-05-12 17:18:20 +00:00
|
|
|
void setBluetoothMode(bool mode);
|
|
|
|
void setForceDownload(bool force);
|
2017-05-19 09:23:11 +00:00
|
|
|
void setSaveDump(bool dumpMode);
|
|
|
|
void setSaveLog(bool saveLog);
|
2020-03-15 01:11:46 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
2020-03-15 22:12:30 +00:00
|
|
|
void setUsbDevice(const android_usb_serial_device_descriptor &usbDescriptor);
|
2020-03-15 01:11:46 +00:00
|
|
|
#endif
|
2017-05-12 17:18:20 +00:00
|
|
|
private:
|
2020-03-15 22:12:30 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
struct android_usb_serial_device_descriptor androidUsbDescriptor;
|
|
|
|
#endif
|
2017-05-12 17:18:20 +00:00
|
|
|
device_data_t data;
|
2017-11-12 11:33:20 +00:00
|
|
|
|
|
|
|
// Bluetooth name is managed outside of libdivecomputer
|
|
|
|
QString m_devBluetoothName;
|
2017-05-12 17:18:20 +00:00
|
|
|
};
|
|
|
|
|
2017-04-18 17:14:03 +00:00
|
|
|
class DownloadThread : public QThread {
|
|
|
|
Q_OBJECT
|
2017-05-26 14:40:50 +00:00
|
|
|
|
2017-04-18 17:14:03 +00:00
|
|
|
public:
|
2017-05-19 09:23:11 +00:00
|
|
|
DownloadThread();
|
2018-09-29 20:13:44 +00:00
|
|
|
void run() override;
|
2017-04-18 17:14:03 +00:00
|
|
|
|
2018-06-09 10:31:31 +00:00
|
|
|
DCDeviceData *data();
|
2017-04-18 17:14:03 +00:00
|
|
|
QString error;
|
2018-12-10 13:49:32 +00:00
|
|
|
struct dive_table downloadTable;
|
2019-02-28 21:45:17 +00:00
|
|
|
struct dive_site_table diveSiteTable;
|
2020-10-19 17:19:32 +00:00
|
|
|
struct device_table deviceTable;
|
2019-09-22 19:48:46 +00:00
|
|
|
|
|
|
|
private:
|
2017-05-26 14:40:50 +00:00
|
|
|
DCDeviceData *m_data;
|
2017-04-18 17:14:03 +00:00
|
|
|
};
|
|
|
|
|
2017-05-19 09:23:11 +00:00
|
|
|
//TODO: C++ify descriptor?
|
2017-04-27 18:24:14 +00:00
|
|
|
struct mydescriptor {
|
|
|
|
const char *vendor;
|
|
|
|
const char *product;
|
|
|
|
dc_family_t type;
|
|
|
|
unsigned int model;
|
2018-08-27 17:32:14 +00:00
|
|
|
unsigned int transports;
|
2017-04-27 18:24:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This fills the vendor list QStringList and related members.
|
|
|
|
* this code needs to be reworked to be less ugly, but it will
|
|
|
|
* stay like this for now.
|
|
|
|
*/
|
|
|
|
void fill_computer_list();
|
2020-11-15 21:12:21 +00:00
|
|
|
extern "C" {
|
2018-04-19 13:37:13 +00:00
|
|
|
void show_computer_list();
|
2020-11-15 21:12:21 +00:00
|
|
|
}
|
2017-05-29 19:25:21 +00:00
|
|
|
extern QStringList vendorList;
|
2017-04-27 18:24:14 +00:00
|
|
|
extern QHash<QString, QStringList> productList;
|
|
|
|
extern QMap<QString, dc_descriptor_t *> descriptorLookup;
|
2017-07-17 04:49:11 +00:00
|
|
|
extern ConnectionListModel connectionListModel;
|
2017-04-18 17:14:03 +00:00
|
|
|
#endif
|