Add a timeout to api info objects
This commit is contained in:
parent
e7a0d63570
commit
32f7f22a7d
@ -258,8 +258,13 @@ DeviceDiscoveryInfo* DeviceManagerImplementation::discoverDevices(const DeviceCl
|
||||
return discoveryInfo;
|
||||
}
|
||||
|
||||
DeviceDiscoveryInfo *discoveryInfo = new DeviceDiscoveryInfo(deviceClassId, effectiveParams, this);
|
||||
DeviceDiscoveryInfo *discoveryInfo = new DeviceDiscoveryInfo(deviceClassId, effectiveParams, this, 30000);
|
||||
connect(discoveryInfo, &DeviceDiscoveryInfo::finished, this, [this, discoveryInfo](){
|
||||
if (discoveryInfo->status() != Device::DeviceErrorNoError) {
|
||||
qCWarning(dcDeviceManager()) << "Discovery failed:" << discoveryInfo->status() << discoveryInfo->displayMessage();
|
||||
return;
|
||||
}
|
||||
qCDebug(dcDeviceManager()) << "Discovery finished. Found devices:" << discoveryInfo->deviceDescriptors().count();
|
||||
foreach (const DeviceDescriptor &descriptor, discoveryInfo->deviceDescriptors()) {
|
||||
m_discoveredDevices[descriptor.deviceClassId()].insert(descriptor.id(), descriptor);
|
||||
}
|
||||
@ -390,7 +395,7 @@ DeviceSetupInfo* DeviceManagerImplementation::reconfigureDevice(const DeviceId &
|
||||
}
|
||||
|
||||
// try to setup the device with the new params
|
||||
DeviceSetupInfo *info = new DeviceSetupInfo(device, this);
|
||||
DeviceSetupInfo *info = new DeviceSetupInfo(device, this, 30000);
|
||||
plugin->setupDevice(info);
|
||||
connect(info, &DeviceSetupInfo::finished, this, [this, info](){
|
||||
|
||||
@ -490,7 +495,7 @@ Device::DeviceError DeviceManagerImplementation::setDeviceSettings(const DeviceI
|
||||
DevicePairingInfo* DeviceManagerImplementation::pairDevice(const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms)
|
||||
{
|
||||
PairingTransactionId transactionId = PairingTransactionId::createPairingTransactionId();
|
||||
DevicePairingInfo *info = new DevicePairingInfo(transactionId, deviceClassId, DeviceId(), name, params, DeviceId(), this);
|
||||
DevicePairingInfo *info = new DevicePairingInfo(transactionId, deviceClassId, DeviceId(), name, params, DeviceId(), this, 30000);
|
||||
pairDeviceInternal(info);
|
||||
return info;
|
||||
}
|
||||
@ -516,7 +521,7 @@ DevicePairingInfo* DeviceManagerImplementation::pairDevice(const DeviceClassId &
|
||||
return info;
|
||||
}
|
||||
|
||||
DevicePairingInfo *info = new DevicePairingInfo(pairingTransactionId, deviceClassId, deviceDescriptor.deviceId(), name, deviceDescriptor.params(), deviceDescriptor.parentDeviceId(), this);
|
||||
DevicePairingInfo *info = new DevicePairingInfo(pairingTransactionId, deviceClassId, deviceDescriptor.deviceId(), name, deviceDescriptor.params(), deviceDescriptor.parentDeviceId(), this, 30000);
|
||||
pairDeviceInternal(info);
|
||||
return info;
|
||||
}
|
||||
@ -735,7 +740,7 @@ BrowseResult *DeviceManagerImplementation::browseDevice(const DeviceId &deviceId
|
||||
{
|
||||
Device *device = m_configuredDevices.value(deviceId);
|
||||
|
||||
BrowseResult *result = new BrowseResult(device, itemId, locale, this);
|
||||
BrowseResult *result = new BrowseResult(device, itemId, locale, this, 30000);
|
||||
|
||||
if (!device) {
|
||||
qCWarning(dcDeviceManager()) << "Cannot browse device. No such device:" << deviceId.toString();
|
||||
@ -762,7 +767,7 @@ BrowserItemResult *DeviceManagerImplementation::browserItemDetails(const DeviceI
|
||||
{
|
||||
Device *device = m_configuredDevices.value(deviceId);
|
||||
|
||||
BrowserItemResult *result = new BrowserItemResult(device, itemId, locale, this);
|
||||
BrowserItemResult *result = new BrowserItemResult(device, itemId, locale, this, 30000);
|
||||
|
||||
if (!device) {
|
||||
qCWarning(dcDeviceManager()) << "Cannot browse device. No such device:" << deviceId.toString();
|
||||
@ -789,7 +794,7 @@ BrowserActionInfo* DeviceManagerImplementation::executeBrowserItem(const Browser
|
||||
{
|
||||
Device *device = m_configuredDevices.value(browserAction.deviceId());
|
||||
|
||||
BrowserActionInfo *info = new BrowserActionInfo(device, browserAction, this);
|
||||
BrowserActionInfo *info = new BrowserActionInfo(device, browserAction, this, 30000);
|
||||
|
||||
if (!device) {
|
||||
info->finish(Device::DeviceErrorDeviceNotFound);
|
||||
@ -808,7 +813,7 @@ BrowserItemActionInfo* DeviceManagerImplementation::executeBrowserItemAction(con
|
||||
{
|
||||
Device *device = m_configuredDevices.value(browserItemAction.deviceId());
|
||||
|
||||
BrowserItemActionInfo *info = new BrowserItemActionInfo(device, browserItemAction, this);
|
||||
BrowserItemActionInfo *info = new BrowserItemActionInfo(device, browserItemAction, this, 30000);
|
||||
|
||||
if (!device) {
|
||||
info->finish(Device::DeviceErrorDeviceNotFound);
|
||||
@ -927,7 +932,7 @@ DeviceActionInfo *DeviceManagerImplementation::executeAction(const Action &actio
|
||||
}
|
||||
finalAction.setParams(finalParams);
|
||||
|
||||
DeviceActionInfo *info = new DeviceActionInfo(device, finalAction, this);
|
||||
DeviceActionInfo *info = new DeviceActionInfo(device, finalAction, this, 30000);
|
||||
|
||||
DevicePlugin *plugin = m_devicePlugins.value(device->pluginId());
|
||||
if (!plugin) {
|
||||
@ -1490,7 +1495,7 @@ DeviceSetupInfo* DeviceManagerImplementation::setupDevice(Device *device)
|
||||
connect(device, &Device::settingChanged, this, &DeviceManagerImplementation::slotDeviceSettingChanged);
|
||||
|
||||
|
||||
DeviceSetupInfo *info = new DeviceSetupInfo(device, this);
|
||||
DeviceSetupInfo *info = new DeviceSetupInfo(device, this, 30000);
|
||||
plugin->setupDevice(info);
|
||||
|
||||
return info;
|
||||
|
||||
@ -22,12 +22,21 @@
|
||||
|
||||
#include "browseractioninfo.h"
|
||||
|
||||
BrowserActionInfo::BrowserActionInfo(Device *device, const BrowserAction &browserAction, QObject *parent):
|
||||
#include <QTimer>
|
||||
|
||||
BrowserActionInfo::BrowserActionInfo(Device *device, const BrowserAction &browserAction, QObject *parent, quint32 timeout):
|
||||
QObject (parent),
|
||||
m_device(device),
|
||||
m_browserAction(browserAction)
|
||||
{
|
||||
connect(this, &BrowserActionInfo::finished, this, &BrowserActionInfo::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Device *BrowserActionInfo::device() const
|
||||
|
||||
@ -32,7 +32,7 @@ class BrowserActionInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BrowserActionInfo(Device* device, const BrowserAction &browserAction, QObject *parent = nullptr);
|
||||
explicit BrowserActionInfo(Device* device, const BrowserAction &browserAction, QObject *parent, quint32 timeout = 0);
|
||||
|
||||
Device* device() const;
|
||||
BrowserAction browserAction() const;
|
||||
@ -42,6 +42,7 @@ public:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
public slots:
|
||||
void finish(Device::DeviceError status);
|
||||
|
||||
@ -22,13 +22,22 @@
|
||||
|
||||
#include "browseresult.h"
|
||||
|
||||
BrowseResult::BrowseResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent):
|
||||
#include <QTimer>
|
||||
|
||||
BrowseResult::BrowseResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_device(device),
|
||||
m_itemId(itemId),
|
||||
m_locale(locale)
|
||||
{
|
||||
connect(this, &BrowseResult::finished, this, &BrowseResult::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Device *BrowseResult::device() const
|
||||
|
||||
@ -31,7 +31,7 @@ class BrowseResult : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BrowseResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent = nullptr);
|
||||
explicit BrowseResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent, quint32 timeout = 0);
|
||||
|
||||
Device* device() const;
|
||||
QString itemId() const;
|
||||
@ -50,6 +50,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
private:
|
||||
Device *m_device = nullptr;
|
||||
|
||||
@ -22,12 +22,21 @@
|
||||
|
||||
#include "browseritemactioninfo.h"
|
||||
|
||||
BrowserItemActionInfo::BrowserItemActionInfo(Device *device, const BrowserItemAction &browserItemAction, QObject *parent):
|
||||
#include <QTimer>
|
||||
|
||||
BrowserItemActionInfo::BrowserItemActionInfo(Device *device, const BrowserItemAction &browserItemAction, QObject *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_device(device),
|
||||
m_browserItemAction(browserItemAction)
|
||||
{
|
||||
connect(this, &BrowserItemActionInfo::finished, this, &BrowserItemActionInfo::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Device *BrowserItemActionInfo::device() const
|
||||
|
||||
@ -32,7 +32,7 @@ class BrowserItemActionInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BrowserItemActionInfo(Device *device, const BrowserItemAction &browserItemAction, QObject *parent = nullptr);
|
||||
explicit BrowserItemActionInfo(Device *device, const BrowserItemAction &browserItemAction, QObject *parent, quint32 timeout = 0);
|
||||
|
||||
Device *device() const;
|
||||
BrowserItemAction browserItemAction() const;
|
||||
@ -43,6 +43,7 @@ public:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
public slots:
|
||||
void finish(Device::DeviceError status);
|
||||
|
||||
@ -22,13 +22,22 @@
|
||||
|
||||
#include "browseritemresult.h"
|
||||
|
||||
BrowserItemResult::BrowserItemResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent):
|
||||
#include <QTimer>
|
||||
|
||||
BrowserItemResult::BrowserItemResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_device(device),
|
||||
m_itemId(itemId),
|
||||
m_locale(locale)
|
||||
{
|
||||
connect(this, &BrowserItemResult::finished, this, &BrowserItemResult::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Device *BrowserItemResult::device() const
|
||||
|
||||
@ -32,7 +32,7 @@ class BrowserItemResult : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BrowserItemResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent = nullptr);
|
||||
explicit BrowserItemResult(Device *device, const QString &itemId, const QLocale &locale, QObject *parent, quint32 timeout = 0);
|
||||
|
||||
Device* device() const;
|
||||
QString itemId() const;
|
||||
@ -49,6 +49,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
private:
|
||||
Device *m_device = nullptr;
|
||||
|
||||
@ -73,6 +73,7 @@ public:
|
||||
DeviceErrorItemNotFound,
|
||||
DeviceErrorItemNotExecutable,
|
||||
DeviceErrorUnsupportedFeature,
|
||||
DeviceErrorTimeout,
|
||||
};
|
||||
Q_ENUM(DeviceError)
|
||||
|
||||
|
||||
@ -24,13 +24,22 @@
|
||||
|
||||
#include "devicemanager.h"
|
||||
|
||||
DeviceActionInfo::DeviceActionInfo(Device *device, const Action &action, DeviceManager *parent):
|
||||
#include <QTimer>
|
||||
|
||||
DeviceActionInfo::DeviceActionInfo(Device *device, const Action &action, DeviceManager *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_device(device),
|
||||
m_action(action),
|
||||
m_deviceManager(parent)
|
||||
{
|
||||
connect(this, &DeviceActionInfo::finished, this, &DeviceActionInfo::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Device *DeviceActionInfo::device() const
|
||||
|
||||
@ -35,7 +35,7 @@ class DeviceActionInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DeviceActionInfo(Device *device, const Action &action, DeviceManager *parent);
|
||||
explicit DeviceActionInfo(Device *device, const Action &action, DeviceManager *parent, quint32 timeout = 0);
|
||||
|
||||
Device* device() const;
|
||||
Action action() const;
|
||||
@ -49,6 +49,7 @@ public:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
public slots:
|
||||
void finish(Device::DeviceError status, const QString &displayMessage = QString());
|
||||
|
||||
@ -23,13 +23,22 @@
|
||||
#include "devicediscoveryinfo.h"
|
||||
#include "devicemanager.h"
|
||||
|
||||
DeviceDiscoveryInfo::DeviceDiscoveryInfo(const DeviceClassId &deviceClassId, const ParamList ¶ms, DeviceManager *deviceManager):
|
||||
#include <QTimer>
|
||||
|
||||
DeviceDiscoveryInfo::DeviceDiscoveryInfo(const DeviceClassId &deviceClassId, const ParamList ¶ms, DeviceManager *deviceManager, quint32 timeout):
|
||||
QObject(deviceManager),
|
||||
m_deviceClassId(deviceClassId),
|
||||
m_params(params),
|
||||
m_deviceManager(deviceManager)
|
||||
{
|
||||
connect(this, &DeviceDiscoveryInfo::finished, this, &DeviceDiscoveryInfo::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DeviceClassId DeviceDiscoveryInfo::deviceClassId() const
|
||||
|
||||
@ -36,7 +36,7 @@ class LIBNYMEA_EXPORT DeviceDiscoveryInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DeviceDiscoveryInfo(const DeviceClassId &deviceClassId, const ParamList ¶ms, DeviceManager *deviceManager);
|
||||
explicit DeviceDiscoveryInfo(const DeviceClassId &deviceClassId, const ParamList ¶ms, DeviceManager *deviceManager, quint32 timeout = 0);
|
||||
|
||||
DeviceClassId deviceClassId() const;
|
||||
ParamList params() const;
|
||||
@ -58,6 +58,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
private:
|
||||
DeviceClassId m_deviceClassId;
|
||||
|
||||
@ -23,7 +23,9 @@
|
||||
#include "devicepairinginfo.h"
|
||||
#include "devicemanager.h"
|
||||
|
||||
DevicePairingInfo::DevicePairingInfo(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceId &deviceId, const QString &deviceName, const ParamList ¶ms, const DeviceId &parentDeviceId, DeviceManager *parent):
|
||||
#include <QTimer>
|
||||
|
||||
DevicePairingInfo::DevicePairingInfo(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceId &deviceId, const QString &deviceName, const ParamList ¶ms, const DeviceId &parentDeviceId, DeviceManager *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_transactionId(pairingTransactionId),
|
||||
m_deviceClassId(deviceClassId),
|
||||
@ -33,6 +35,13 @@ DevicePairingInfo::DevicePairingInfo(const PairingTransactionId &pairingTransact
|
||||
m_parentDeviceId(parentDeviceId)
|
||||
{
|
||||
connect(this, &DevicePairingInfo::finished, this, &DevicePairingInfo::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
PairingTransactionId DevicePairingInfo::transactionId() const
|
||||
|
||||
@ -34,7 +34,7 @@ class LIBNYMEA_EXPORT DevicePairingInfo: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DevicePairingInfo(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceId &deviceId, const QString &deviceName, const ParamList ¶ms, const DeviceId &parentDeviceId, DeviceManager *parent);
|
||||
DevicePairingInfo(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceId &deviceId, const QString &deviceName, const ParamList ¶ms, const DeviceId &parentDeviceId, DeviceManager *parent, quint32 timeout = 0);
|
||||
|
||||
PairingTransactionId transactionId() const;
|
||||
|
||||
@ -56,6 +56,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
private:
|
||||
PairingTransactionId m_transactionId;
|
||||
|
||||
@ -25,12 +25,21 @@
|
||||
#include "deviceplugin.h"
|
||||
#include "devicemanager.h"
|
||||
|
||||
DeviceSetupInfo::DeviceSetupInfo(Device *device, DeviceManager *deviceManager):
|
||||
#include <QTimer>
|
||||
|
||||
DeviceSetupInfo::DeviceSetupInfo(Device *device, DeviceManager *deviceManager, quint32 timeout):
|
||||
QObject(deviceManager),
|
||||
m_device(device),
|
||||
m_deviecManager(deviceManager)
|
||||
{
|
||||
connect(this, &DeviceSetupInfo::finished, this, &DeviceSetupInfo::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
if (timeout > 0) {
|
||||
QTimer::singleShot(timeout, this, [this] {
|
||||
emit aborted();
|
||||
finish(Device::DeviceErrorTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Device *DeviceSetupInfo::device() const
|
||||
|
||||
@ -33,7 +33,7 @@ class LIBNYMEA_EXPORT DeviceSetupInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DeviceSetupInfo(Device *device, DeviceManager *deviceManager);
|
||||
explicit DeviceSetupInfo(Device *device, DeviceManager *deviceManager, quint32 timeout = 0);
|
||||
|
||||
Device *device() const;
|
||||
|
||||
@ -48,6 +48,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void aborted();
|
||||
|
||||
private:
|
||||
Device *m_device = nullptr;
|
||||
|
||||
@ -1538,7 +1538,8 @@
|
||||
"DeviceErrorParameterNotWritable",
|
||||
"DeviceErrorItemNotFound",
|
||||
"DeviceErrorItemNotExecutable",
|
||||
"DeviceErrorUnsupportedFeature"
|
||||
"DeviceErrorUnsupportedFeature",
|
||||
"DeviceErrorTimeout"
|
||||
],
|
||||
"Event": {
|
||||
"deviceId": "Uuid",
|
||||
|
||||
Reference in New Issue
Block a user