diff --git a/libguh/types/param.cpp b/libguh/types/param.cpp index a6193172..3e8fd109 100644 --- a/libguh/types/param.cpp +++ b/libguh/types/param.cpp @@ -98,9 +98,3 @@ void ParamList::setParamValue(const QString ¶mName, const QVariant &value) } } } - -ParamList ParamList::operator<<(const Param ¶m) -{ - this->append(param); - return *this; -} diff --git a/libguh/types/param.h b/libguh/types/param.h index cef17eb2..74b05d18 100644 --- a/libguh/types/param.h +++ b/libguh/types/param.h @@ -53,4 +53,12 @@ public: }; QDebug operator<<(QDebug dbg, const ParamList ¶ms); +class ParamList: public QList +{ +public: + bool hasParam(const QString ¶mName) const; + QVariant paramValue(const QString ¶mName) const; + void setParamValue(const QString ¶mName, const QVariant &value); +}; + #endif // PARAM_H diff --git a/plugins/deviceplugins/mock/devicepluginmock.cpp b/plugins/deviceplugins/mock/devicepluginmock.cpp index add4d04d..3c372185 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.cpp +++ b/plugins/deviceplugins/mock/devicepluginmock.cpp @@ -274,9 +274,7 @@ void DevicePluginMock::startMonitoringAutoDevices() DeviceDescriptor mockDescriptor(mockDeviceAutoClassId, "Mock Device (Auto created)"); ParamList params; - qsrand(QDateTime::currentMSecsSinceEpoch()); - int port = 4242 + (qrand() % 1000); - Param param("httpport", port); + Param param("httpport", 4242); params.append(param); mockDescriptor.setParams(params); diff --git a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp index 86a92fa1..030a2aa0 100644 --- a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp +++ b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp @@ -425,24 +425,22 @@ QList DevicePluginOpenweathermap::supportedDevices() const QPair DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) { - if(deviceClassId == openweathermapDeviceClassId){ - QString location; - foreach (const Param ¶m, params) { - if (param.name() == "location") { - location = param.value().toString(); - } + qDebug() << "should discover devices with params:" << params; + QString location; + foreach (const Param ¶m, params) { + qDebug() << "### got param:" << param; + if (param.name() == "location") { + location = param.value().toString(); } - qDebug() << "Searching for... " << location; - if (location.isEmpty()){ - m_openweaher->searchAutodetect(); - }else{ - m_openweaher->search(location); - } - return DeviceManager::DeviceErrorAsync; - }else{ - return DeviceManager::DeviceErrorDeviceClassNotFound; } + + if (location.isEmpty()){ + m_openweaher->searchAutodetect(); + return report(DeviceManager::DeviceErrorAsync); + } + m_openweaher->search(location); + return report(DeviceManager::DeviceErrorAsync); } QPair DevicePluginOpenweathermap::setupDevice(Device *device)