mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Corrections
This commit is contained in:
parent
8494132faf
commit
fcde21c7fd
@ -151,12 +151,10 @@ int LedDeviceRazer::open()
|
|||||||
|
|
||||||
obj.insert("category", "application");
|
obj.insert("category", "application");
|
||||||
|
|
||||||
QJsonDocument data = QJsonDocument(obj);
|
|
||||||
|
|
||||||
_restApi->setPort(API_DEFAULT_PORT);
|
_restApi->setPort(API_DEFAULT_PORT);
|
||||||
_restApi->setBasePath(API_BASE_PATH);
|
_restApi->setBasePath(API_BASE_PATH);
|
||||||
|
|
||||||
httpResponse response = _restApi->post(data.toJson(QJsonDocument::Compact));
|
httpResponse response = _restApi->post(obj);
|
||||||
if (!checkApiError(response))
|
if (!checkApiError(response))
|
||||||
{
|
{
|
||||||
QJsonObject jsonObj = response.getBody().object();
|
QJsonObject jsonObj = response.getBody().object();
|
||||||
@ -176,15 +174,14 @@ int LedDeviceRazer::open()
|
|||||||
QJsonObject param;
|
QJsonObject param;
|
||||||
param.insert("color", 255);
|
param.insert("color", 255);
|
||||||
effectObj.insert("param", param);
|
effectObj.insert("param", param);
|
||||||
data = QJsonDocument(effectObj);
|
|
||||||
|
|
||||||
_restApi->setPath(_razerDeviceType);
|
_restApi->setPath(_razerDeviceType);
|
||||||
response = _restApi->put(data.toJson(QJsonDocument::Compact));
|
response = _restApi->put(effectObj);
|
||||||
|
|
||||||
if (!checkApiError(response))
|
if (!checkApiError(response))
|
||||||
{
|
{
|
||||||
_restApi->setPath(_razerDeviceType);
|
_restApi->setPath(_razerDeviceType);
|
||||||
response = _restApi->put(data.toJson(QJsonDocument::Compact));
|
response = _restApi->put(effectObj);
|
||||||
|
|
||||||
if (!checkApiError(response))
|
if (!checkApiError(response))
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,9 @@ httpResponse ProviderRestApi::get()
|
|||||||
httpResponse ProviderRestApi::get(const QUrl& url)
|
httpResponse ProviderRestApi::get(const QUrl& url)
|
||||||
{
|
{
|
||||||
// Perform request
|
// Perform request
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(_networkRequestHeaders);
|
||||||
|
request.setUrl(url);
|
||||||
|
|
||||||
QNetworkReply* reply = _networkManager->get(request);
|
QNetworkReply* reply = _networkManager->get(request);
|
||||||
|
|
||||||
// Connect requestFinished signal to quit slot of the loop.
|
// Connect requestFinished signal to quit slot of the loop.
|
||||||
@ -173,7 +175,9 @@ httpResponse ProviderRestApi::put(const QString &body)
|
|||||||
httpResponse ProviderRestApi::put(const QUrl &url, const QByteArray &body)
|
httpResponse ProviderRestApi::put(const QUrl &url, const QByteArray &body)
|
||||||
{
|
{
|
||||||
// Perform request
|
// Perform request
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(_networkRequestHeaders);
|
||||||
|
request.setUrl(url);
|
||||||
|
|
||||||
QNetworkReply* reply = _networkManager->put(request, body);
|
QNetworkReply* reply = _networkManager->put(request, body);
|
||||||
// Connect requestFinished signal to quit slot of the loop.
|
// Connect requestFinished signal to quit slot of the loop.
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
@ -200,19 +204,23 @@ httpResponse ProviderRestApi::put(const QUrl &url, const QByteArray &body)
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
httpResponse ProviderRestApi::post(const QString& body)
|
httpResponse ProviderRestApi::post(const QJsonObject& body)
|
||||||
{
|
{
|
||||||
return post(getUrl(), body);
|
return post( getUrl(), QJsonDocument(body).toJson(QJsonDocument::Compact));
|
||||||
}
|
}
|
||||||
|
|
||||||
httpResponse ProviderRestApi::post(const QUrl& url, const QString& body)
|
httpResponse ProviderRestApi::post(const QString& body)
|
||||||
|
{
|
||||||
|
return post( getUrl(), body.toUtf8() );
|
||||||
|
}
|
||||||
|
|
||||||
|
httpResponse ProviderRestApi::post(const QUrl& url, const QByteArray& body)
|
||||||
{
|
{
|
||||||
DebugIf(verbose, _log, "POST: [%s] [%s]", QSTRING_CSTR(url.toString()), QSTRING_CSTR(body));
|
|
||||||
// Perform request
|
// Perform request
|
||||||
QNetworkRequest request(_networkRequestHeaders);
|
QNetworkRequest request(_networkRequestHeaders);
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
|
|
||||||
QNetworkReply* reply = _networkManager->post(request, body.toUtf8());
|
QNetworkReply* reply = _networkManager->post(request, body);
|
||||||
// Connect requestFinished signal to quit slot of the loop.
|
// Connect requestFinished signal to quit slot of the loop.
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
QEventLoop::connect(reply,&QNetworkReply::finished,&loop,&QEventLoop::quit);
|
QEventLoop::connect(reply,&QNetworkReply::finished,&loop,&QEventLoop::quit);
|
||||||
@ -222,6 +230,10 @@ httpResponse ProviderRestApi::post(const QUrl& url, const QString& body)
|
|||||||
httpResponse response;
|
httpResponse response;
|
||||||
if (reply->operation() == QNetworkAccessManager::PostOperation)
|
if (reply->operation() == QNetworkAccessManager::PostOperation)
|
||||||
{
|
{
|
||||||
|
if(reply->error() != QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
Debug(_log, "POST: [%s] [%s]", QSTRING_CSTR( url.toString() ),body.constData() );
|
||||||
|
}
|
||||||
response = getResponse(reply);
|
response = getResponse(reply);
|
||||||
}
|
}
|
||||||
// Free space.
|
// Free space.
|
||||||
@ -233,7 +245,6 @@ httpResponse ProviderRestApi::post(const QUrl& url, const QString& body)
|
|||||||
|
|
||||||
httpResponse ProviderRestApi::deleteResource(const QUrl& url)
|
httpResponse ProviderRestApi::deleteResource(const QUrl& url)
|
||||||
{
|
{
|
||||||
DebugIf(verbose, _log, "DELETE: [%s]", QSTRING_CSTR(url.toString()));
|
|
||||||
// Perform request
|
// Perform request
|
||||||
QNetworkRequest request(_networkRequestHeaders);
|
QNetworkRequest request(_networkRequestHeaders);
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
@ -248,6 +259,10 @@ httpResponse ProviderRestApi::deleteResource(const QUrl& url)
|
|||||||
httpResponse response;
|
httpResponse response;
|
||||||
if (reply->operation() == QNetworkAccessManager::DeleteOperation)
|
if (reply->operation() == QNetworkAccessManager::DeleteOperation)
|
||||||
{
|
{
|
||||||
|
if(reply->error() != QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
Debug(_log, "DELETE: [%s]", QSTRING_CSTR(url.toString()));
|
||||||
|
}
|
||||||
response = getResponse(reply);
|
response = getResponse(reply);
|
||||||
}
|
}
|
||||||
// Free space.
|
// Free space.
|
||||||
|
@ -237,6 +237,21 @@ public:
|
|||||||
///
|
///
|
||||||
httpResponse put(const QUrl &url, const QByteArray& body);
|
httpResponse put(const QUrl &url, const QByteArray& body);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Execute POST request
|
||||||
|
///
|
||||||
|
/// @param[in] body The body of the request in JSON
|
||||||
|
/// @return Response The body of the response in JSON
|
||||||
|
///
|
||||||
|
httpResponse post(const QString& body = "");
|
||||||
|
|
||||||
|
/// @brief Execute POST request
|
||||||
|
///
|
||||||
|
/// @param[in] body The body of the request in JSON
|
||||||
|
/// @return Response The body of the response in JSON
|
||||||
|
///
|
||||||
|
httpResponse post(const QJsonObject& body);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// @brief Execute POST request
|
/// @brief Execute POST request
|
||||||
///
|
///
|
||||||
@ -244,7 +259,7 @@ public:
|
|||||||
/// @param[in] body The body of the request in JSON
|
/// @param[in] body The body of the request in JSON
|
||||||
/// @return Response The body of the response in JSON
|
/// @return Response The body of the response in JSON
|
||||||
///
|
///
|
||||||
httpResponse post(const QUrl& url, const QString& body = "");
|
httpResponse post(const QUrl &url, const QByteArray& body);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// @brief Execute DELETE request
|
/// @brief Execute DELETE request
|
||||||
|
Loading…
x
Reference in New Issue
Block a user