Merge remote-tracking branch 'upstream/master' into support_for_philips_hue

Former-commit-id: 51089fb3522bf9c228d67f2c2f9a1a5b33e5d0a5
This commit is contained in:
ntim
2016-01-18 10:36:20 +01:00
41 changed files with 776 additions and 74 deletions

View File

@@ -5,7 +5,7 @@
#include <json/json.h>
// qt includes
#include <QtCore/qmath.h>
#include <QtCore/qmath.h>
#include <QEventLoop>
#include <QNetworkReply>
@@ -200,22 +200,30 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) {
// Next light id.
idx++;
}
#ifdef ENABLE_QT5
#else
timer.start();
#endif
return 0;
}
int LedDevicePhilipsHue::switchOff() {
#ifdef ENABLE_QT5
#else
timer.stop();
// If light states have been saved before, ...
if (areStatesSaved()) {
// ... restore them.
restoreStates();
}
#endif
return 0;
}
void LedDevicePhilipsHue::put(QString route, QString content) {
QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route);
void LedDevicePhilipsHue::put(QString route, QString content) {
QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route);
// Perfrom request
QNetworkRequest request(url);
QNetworkReply* reply = manager->put(request, content.toAscii());
@@ -226,8 +234,8 @@ void LedDevicePhilipsHue::put(QString route, QString content) {
loop.exec();
}
QByteArray LedDevicePhilipsHue::get(QString route) {
QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route);
QByteArray LedDevicePhilipsHue::get(QString route) {
QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route);
// Perfrom request
QNetworkRequest request(url);
QNetworkReply* reply = manager->get(request);
@@ -236,8 +244,8 @@ QByteArray LedDevicePhilipsHue::get(QString route) {
loop.connect(reply, SIGNAL(finished()), SLOT(quit()));
// Go into the loop until the request is finished.
loop.exec();
// Read all data of the response.
return reply->readAll();
// Read all data of the response.
return reply->readAll();
}
QString LedDevicePhilipsHue::getStateRoute(unsigned int lightId) {