Update HttpCommander plugin
parent
6cf7309012
commit
781a8696b1
|
|
@ -29,8 +29,9 @@ DevicePluginHttpCommander::DevicePluginHttpCommander()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device *device)
|
void DevicePluginHttpCommander::setupDevice(DeviceSetupInfo *info)
|
||||||
{
|
{
|
||||||
|
Device *device = info->device();
|
||||||
qDebug(dcHttpCommander()) << "Setup device" << device->name() << device->params();
|
qDebug(dcHttpCommander()) << "Setup device" << device->name() << device->params();
|
||||||
|
|
||||||
if(!m_pluginTimer) {
|
if(!m_pluginTimer) {
|
||||||
|
|
@ -42,30 +43,33 @@ Device::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device *device)
|
||||||
QUrl url = device->paramValue(httpGetCommanderDeviceUrlParamTypeId).toUrl();
|
QUrl url = device->paramValue(httpGetCommanderDeviceUrlParamTypeId).toUrl();
|
||||||
if (!url.isValid()) {
|
if (!url.isValid()) {
|
||||||
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
||||||
return Device::DeviceSetupStatusFailure;
|
//: Error setting up device
|
||||||
|
return info->finish(Device::DeviceErrorInvalidParameter, QT_TR_NOOP("The given url is not valid."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Device::DeviceSetupStatusSuccess;
|
return info->finish(Device::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == httpPutCommanderDeviceClassId) {
|
if (device->deviceClassId() == httpPutCommanderDeviceClassId) {
|
||||||
QUrl url = device->paramValue(httpPutCommanderDeviceUrlParamTypeId).toUrl();
|
QUrl url = device->paramValue(httpPutCommanderDeviceUrlParamTypeId).toUrl();
|
||||||
if (!url.isValid()) {
|
if (!url.isValid()) {
|
||||||
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
||||||
return Device::DeviceSetupStatusFailure;
|
//: Error setting up device
|
||||||
|
return info->finish(Device::DeviceErrorInvalidParameter, QT_TR_NOOP("The given url is not valid."));
|
||||||
}
|
}
|
||||||
return Device::DeviceSetupStatusSuccess;
|
return info->finish(Device::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == httpPostCommanderDeviceClassId) {
|
if (device->deviceClassId() == httpPostCommanderDeviceClassId) {
|
||||||
QUrl url = device->paramValue(httpPostCommanderDeviceUrlParamTypeId).toUrl();
|
QUrl url = device->paramValue(httpPostCommanderDeviceUrlParamTypeId).toUrl();
|
||||||
if (!url.isValid()) {
|
if (!url.isValid()) {
|
||||||
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
qDebug(dcHttpCommander()) << "Given URL is not valid";
|
||||||
return Device::DeviceSetupStatusFailure;
|
//: Error setting up device
|
||||||
|
return info->finish(Device::DeviceErrorInvalidParameter, QT_TR_NOOP("The given url is not valid."));
|
||||||
}
|
}
|
||||||
return Device::DeviceSetupStatusSuccess;
|
return info->finish(Device::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
return Device::DeviceSetupStatusFailure;
|
info->finish(Device::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -77,8 +81,11 @@ void DevicePluginHttpCommander::postSetupDevice(Device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Device::DeviceError DevicePluginHttpCommander::executeAction(Device *device, const Action &action)
|
void DevicePluginHttpCommander::executeAction(DeviceActionInfo *info)
|
||||||
{
|
{
|
||||||
|
Device *device = info->device();
|
||||||
|
Action action = info->action();
|
||||||
|
|
||||||
if (device->deviceClassId() == httpPostCommanderDeviceClassId) {
|
if (device->deviceClassId() == httpPostCommanderDeviceClassId) {
|
||||||
|
|
||||||
if (action.actionTypeId() == httpPostCommanderPostActionTypeId) {
|
if (action.actionTypeId() == httpPostCommanderPostActionTypeId) {
|
||||||
|
|
@ -91,10 +98,9 @@ Device::DeviceError DevicePluginHttpCommander::executeAction(Device *device, con
|
||||||
|
|
||||||
m_httpRequests.insert(reply, device);
|
m_httpRequests.insert(reply, device);
|
||||||
|
|
||||||
return Device::DeviceErrorNoError;
|
return info->finish(Device::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
return Device::DeviceErrorActionTypeNotFound;
|
return info->finish(Device::DeviceErrorActionTypeNotFound);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == httpPutCommanderDeviceClassId) {
|
if (device->deviceClassId() == httpPutCommanderDeviceClassId) {
|
||||||
|
|
@ -110,10 +116,10 @@ Device::DeviceError DevicePluginHttpCommander::executeAction(Device *device, con
|
||||||
|
|
||||||
m_httpRequests.insert(reply, device);
|
m_httpRequests.insert(reply, device);
|
||||||
|
|
||||||
return Device::DeviceErrorNoError;
|
return info->finish(Device::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Device::DeviceErrorDeviceClassNotFound;
|
return info->finish(Device::DeviceErrorDeviceClassNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginHttpCommander::makeGetCall(Device *device)
|
void DevicePluginHttpCommander::makeGetCall(Device *device)
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,10 @@ class DevicePluginHttpCommander : public DevicePlugin
|
||||||
public:
|
public:
|
||||||
explicit DevicePluginHttpCommander();
|
explicit DevicePluginHttpCommander();
|
||||||
|
|
||||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
void setupDevice(DeviceSetupInfo *info) override;
|
||||||
void postSetupDevice(Device *device) override;
|
void postSetupDevice(Device *device) override;
|
||||||
void deviceRemoved(Device *device) override;
|
void deviceRemoved(Device *device) override;
|
||||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
void executeAction(DeviceActionInfo *info) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PluginTimer *m_pluginTimer = nullptr;
|
PluginTimer *m_pluginTimer = nullptr;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue