From 477749fe7d9a90b044bd545ff802ac9a4023562a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 14 Apr 2014 01:21:27 +0200 Subject: [PATCH] fixed autodetect search from openweather and removed conrad from code temprary --- plugins/deviceplugins/deviceplugins.pro | 2 +- .../devicepluginopenweathermap.cpp | 14 +++++- .../openweathermap/openweathermap.cpp | 45 +++++++++---------- server/main.cpp | 2 +- server/server.pro | 2 +- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/plugins/deviceplugins/deviceplugins.pro b/plugins/deviceplugins/deviceplugins.pro index 3736dc7a..192cc8d0 100644 --- a/plugins/deviceplugins/deviceplugins.pro +++ b/plugins/deviceplugins/deviceplugins.pro @@ -3,7 +3,7 @@ SUBDIRS += elro \ intertechno \ # meisteranker \ wifidetector \ - conrad \ +# conrad \ mock \ # weatherground \ openweathermap \ diff --git a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp index 089c6b8e..39227134 100644 --- a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp +++ b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.cpp @@ -180,6 +180,17 @@ QList DevicePluginOpenweathermap::supportedDevices() const locationParam.insert("name", "location"); locationParam.insert("type", "string"); params.append(locationParam); + + QVariantMap countryParam; + countryParam.insert("name", "country"); + countryParam.insert("type", "string"); + params.append(countryParam); + + QVariantMap idParam; + idParam.insert("name", "id"); + idParam.insert("type", "string"); + params.append(idParam); + deviceClassOpenweathermap.setParams(params); // Actions @@ -294,7 +305,7 @@ DeviceManager::DeviceError DevicePluginOpenweathermap::discoverDevices(const Dev { qDebug() << "should discover divces for" << deviceClassId << params; if(params.value("location").toString() == ""){ - m_openweaher->update(); + m_openweaher->searchAutodetect(); return DeviceManager::DeviceErrorNoError; } m_openweaher->search(params.value("location").toString()); @@ -318,6 +329,7 @@ PluginId DevicePluginOpenweathermap::pluginId() const void DevicePluginOpenweathermap::guhTimer() { + m_openweaher->update(); } void DevicePluginOpenweathermap::searchResultsReady(const QList &cityList) diff --git a/plugins/deviceplugins/openweathermap/openweathermap.cpp b/plugins/deviceplugins/openweathermap/openweathermap.cpp index 852b9af7..e19218e6 100644 --- a/plugins/deviceplugins/openweathermap/openweathermap.cpp +++ b/plugins/deviceplugins/openweathermap/openweathermap.cpp @@ -66,16 +66,7 @@ void OpenWeatherMap::processLocationResponse(QByteArray data) QVariantMap dataMap = jsonDoc.toVariant().toMap(); if(dataMap.contains("city")){ - QString cityName = dataMap.value("city").toString(); - // skip search for cityID... - if(m_cityName != cityName){ - m_cityName = cityName; - updateSearchData(); - return; - }else{ - updateWeatherData(); - return; - } + search(dataMap.value("city").toString()); } } @@ -237,25 +228,25 @@ void OpenWeatherMap::processWeatherResponse(QByteArray data) // emit } } - // qDebug() << "#########################################################"; - // qDebug() << m_cityName << m_cityId; - // qDebug() << "#########################################################"; - // qDebug() << "temp" << m_temperatur; - // qDebug() << "temp min" << m_temperaturMin; - // qDebug() << "temp max" << m_temperaturMax; - // qDebug() << "cloudiness" << m_cloudiness; - // qDebug() << "humidity" << m_humidity; - // qDebug() << "pressure" << m_pressure; - // qDebug() << "wind dir" << m_windDirection; - // qDebug() << "wind speed" << m_windSpeed; - // qDebug() << "sunrise" << QDateTime::fromTime_t(m_sunrise); - // qDebug() << "sunset" << QDateTime::fromTime_t(m_sunset); - // qDebug() << "last update" << QDateTime::fromTime_t(m_lastUpdate); + qDebug() << "#########################################################"; + qDebug() << m_cityName << m_cityId; + qDebug() << "#########################################################"; + qDebug() << "temp" << m_temperatur; + qDebug() << "temp min" << m_temperaturMin; + qDebug() << "temp max" << m_temperaturMax; + qDebug() << "cloudiness" << m_cloudiness; + qDebug() << "humidity" << m_humidity; + qDebug() << "pressure" << m_pressure; + qDebug() << "wind dir" << m_windDirection; + qDebug() << "wind speed" << m_windSpeed; + qDebug() << "sunrise" << QDateTime::fromTime_t(m_sunrise); + qDebug() << "sunset" << QDateTime::fromTime_t(m_sunset); + qDebug() << "last update" << QDateTime::fromTime_t(m_lastUpdate); } void OpenWeatherMap::update() { - updateLocationData(); + updateWeatherData(); } void OpenWeatherMap::searchAutodetect() @@ -280,24 +271,28 @@ void OpenWeatherMap::replyFinished(QNetworkReply *reply) if(reply == m_locationReply && status == 200){ data = reply->readAll(); processLocationResponse(data); + m_locationReply->deleteLater(); return; } if(reply == m_searchReply && status == 200){ data = reply->readAll(); processSearchResponse(data); + m_searchReply->deleteLater(); return; } if(reply == m_searchLocationReply && status == 200){ data = reply->readAll(); processSearchLocationResponse(data); + m_searchLocationReply->deleteLater(); return; } if(reply == m_weatherReply && status == 200){ data = reply->readAll(); processWeatherResponse(data); + m_weatherReply->deleteLater(); return; } } diff --git a/server/main.cpp b/server/main.cpp index 9ef7e1fd..bdfddeb4 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -25,7 +25,7 @@ Q_IMPORT_PLUGIN(DevicePluginElro) Q_IMPORT_PLUGIN(DevicePluginIntertechno) //Q_IMPORT_PLUGIN(DevicePluginMeisterAnker) Q_IMPORT_PLUGIN(DevicePluginWifiDetector) -Q_IMPORT_PLUGIN(DevicePluginConrad) +//Q_IMPORT_PLUGIN(DevicePluginConrad) Q_IMPORT_PLUGIN(DevicePluginMock) //Q_IMPORT_PLUGIN(DevicePluginWeatherground) Q_IMPORT_PLUGIN(DevicePluginOpenweathermap) diff --git a/server/server.pro b/server/server.pro index 8865a65a..798e7910 100644 --- a/server/server.pro +++ b/server/server.pro @@ -19,7 +19,7 @@ LIBS += -L../plugins/deviceplugins/elro/ -lguh_devicepluginelro LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno #LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector -LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad +#LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad LIBS += -L../plugins/deviceplugins/mock -lguh_devicepluginmock #LIBS += -L../plugins/deviceplugins/weatherground -lguh_devicepluginweatherground LIBS += -L../plugins/deviceplugins/openweathermap -lguh_devicepluginopenweathermap