aboutsummaryrefslogtreecommitdiffstats
path: root/core/downloadfromdcthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/downloadfromdcthread.cpp')
-rw-r--r--core/downloadfromdcthread.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index 20f170125..bd8a637f1 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -99,8 +99,15 @@ void fill_computer_list()
#endif
}
+DCDeviceData *DCDeviceData::m_instance = NULL;
+
DCDeviceData::DCDeviceData(QObject *parent) : QObject(parent)
{
+ if (m_instance) {
+ qDebug() << "already have an instance of DCDevieData";
+ return;
+ }
+ m_instance = this;
memset(&data, 0, sizeof(data));
data.trip = nullptr;
data.download_table = nullptr;
@@ -108,6 +115,18 @@ DCDeviceData::DCDeviceData(QObject *parent) : QObject(parent)
data.deviceid = 0;
}
+DCDeviceData *DCDeviceData::instance()
+{
+ if (!m_instance)
+ m_instance = new DCDeviceData();
+ return m_instance;
+}
+
+QStringList DCDeviceData::getProductListFromVendor(const QString &vendor)
+{
+ return productList[vendor];
+}
+
DCDeviceData * DownloadThread::data()
{
return m_data;
@@ -222,3 +241,40 @@ device_data_t* DCDeviceData::internalData()
{
return &data;
}
+
+int DCDeviceData::getDetectedVendorIndex()
+{
+#if defined(BT_SUPPORT)
+ QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
+ if (!btDCs.isEmpty()) {
+ qDebug() << "getVendorIdx" << btDCs.first().vendorIdx;
+ return btDCs.first().vendorIdx;
+ }
+#endif
+ return -1;
+}
+
+int DCDeviceData::getDetectedProductIndex()
+{
+#if defined(BT_SUPPORT)
+ QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
+ if (!btDCs.isEmpty()) {
+ qDebug() << "getProductIdx" << btDCs.first().productIdx;
+ return btDCs.first().productIdx;
+ }
+#endif
+ return -1;
+}
+
+QString DCDeviceData::getDetectedDeviceAddress()
+{
+#if BT_SUPPORT
+ QList<btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
+ if (!btDCs.isEmpty()) {
+ QString btAddr = btDCs.first().btdi.address().toString();
+ qDebug() << "getBtAddress" << btAddr;
+ return btAddr;
+ }
+ return QString();
+#endif
+}