2020-07-12 20:27:56 +02:00
|
|
|
// Local-Hyperion includes
|
|
|
|
#include "ProviderRestApi.h"
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QEventLoop>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QByteArray>
|
2021-08-31 10:55:49 +02:00
|
|
|
#include <QJsonObject>
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
//std includes
|
|
|
|
#include <iostream>
|
2021-03-19 22:52:04 +01:00
|
|
|
#include <chrono>
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
// Constants
|
|
|
|
namespace {
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
bool verbose = false;
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
const QChar ONE_SLASH = '/';
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
const int HTTP_STATUS_NO_CONTENT = 204;
|
|
|
|
const int HTTP_STATUS_BAD_REQUEST = 400;
|
|
|
|
const int HTTP_STATUS_UNAUTHORIZED = 401;
|
|
|
|
const int HTTP_STATUS_NOT_FOUND = 404;
|
|
|
|
|
|
|
|
constexpr std::chrono::milliseconds DEFAULT_REST_TIMEOUT{ 400 };
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
} //End of constants
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
ProviderRestApi::ProviderRestApi(const QString& host, int port, const QString& basePath)
|
2020-07-12 20:27:56 +02:00
|
|
|
:_log(Logger::getInstance("LEDDEVICE"))
|
2021-11-17 20:34:49 +01:00
|
|
|
, _networkManager(nullptr)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
_networkManager = new QNetworkAccessManager();
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
_apiUrl.setScheme("http");
|
2020-07-12 20:27:56 +02:00
|
|
|
_apiUrl.setHost(host);
|
|
|
|
_apiUrl.setPort(port);
|
|
|
|
_basePath = basePath;
|
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
ProviderRestApi::ProviderRestApi(const QString& host, int port)
|
2020-07-12 20:27:56 +02:00
|
|
|
: ProviderRestApi(host, port, "") {}
|
|
|
|
|
|
|
|
ProviderRestApi::ProviderRestApi()
|
|
|
|
: ProviderRestApi("", -1) {}
|
|
|
|
|
|
|
|
ProviderRestApi::~ProviderRestApi()
|
|
|
|
{
|
2020-10-18 17:05:07 +02:00
|
|
|
delete _networkManager;
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
void ProviderRestApi::setUrl(const QUrl& url)
|
|
|
|
{
|
|
|
|
_apiUrl = url;
|
|
|
|
_basePath = url.path();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProviderRestApi::setBasePath(const QString& basePath)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
_basePath.clear();
|
2021-11-17 20:34:49 +01:00
|
|
|
appendPath(_basePath, basePath);
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
void ProviderRestApi::setPath(const QString& path)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
_path.clear();
|
2021-11-17 20:34:49 +01:00
|
|
|
appendPath(_path, path);
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
void ProviderRestApi::appendPath(const QString& path)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-11-17 20:34:49 +01:00
|
|
|
appendPath(_path, path);
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
void ProviderRestApi::appendPath ( QString& path, const QString &appendPath)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-11-17 20:34:49 +01:00
|
|
|
if (!appendPath.isEmpty() && appendPath != ONE_SLASH)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-11-17 20:34:49 +01:00
|
|
|
if (path.isEmpty() || path == ONE_SLASH)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
path.clear();
|
2021-11-17 20:34:49 +01:00
|
|
|
if (appendPath[0] != ONE_SLASH)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
path.push_back(ONE_SLASH);
|
|
|
|
}
|
|
|
|
}
|
2021-11-17 20:34:49 +01:00
|
|
|
else if (path[path.size() - 1] == ONE_SLASH && appendPath[0] == ONE_SLASH)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
path.chop(1);
|
|
|
|
}
|
2021-11-17 20:34:49 +01:00
|
|
|
else if (path[path.size() - 1] != ONE_SLASH && appendPath[0] != ONE_SLASH)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
path.push_back(ONE_SLASH);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Only one slash.
|
|
|
|
}
|
|
|
|
|
|
|
|
path.append(appendPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
void ProviderRestApi::setFragment(const QString& fragment)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
_fragment = fragment;
|
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
void ProviderRestApi::setQuery(const QUrlQuery& query)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
_query = query;
|
|
|
|
}
|
|
|
|
|
|
|
|
QUrl ProviderRestApi::getUrl() const
|
|
|
|
{
|
|
|
|
QUrl url = _apiUrl;
|
|
|
|
|
|
|
|
QString fullPath = _basePath;
|
2021-11-17 20:34:49 +01:00
|
|
|
appendPath(fullPath, _path);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
url.setPath(fullPath);
|
2021-11-17 20:34:49 +01:00
|
|
|
url.setFragment(_fragment);
|
|
|
|
url.setQuery(_query);
|
2020-07-12 20:27:56 +02:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
httpResponse ProviderRestApi::get()
|
|
|
|
{
|
2021-11-17 20:34:49 +01:00
|
|
|
return get(getUrl());
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
httpResponse ProviderRestApi::get(const QUrl& url)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
// Perform request
|
2021-11-17 20:34:49 +01:00
|
|
|
QNetworkRequest request(_networkRequestHeaders);
|
|
|
|
request.setUrl(url);
|
|
|
|
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
|
|
|
_networkManager->setTransferTimeout(DEFAULT_REST_TIMEOUT.count());
|
|
|
|
#endif
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
QNetworkReply* reply = _networkManager->get(request);
|
2021-03-19 22:52:04 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
// Connect requestFinished signal to quit slot of the loop.
|
|
|
|
QEventLoop loop;
|
2021-03-19 22:52:04 +01:00
|
|
|
QEventLoop::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
|
|
|
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
2021-03-19 22:52:04 +01:00
|
|
|
ReplyTimeout::set(reply, DEFAULT_REST_TIMEOUT.count());
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#endif
|
2021-03-19 22:52:04 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
// Go into the loop until the request is finished.
|
|
|
|
loop.exec();
|
|
|
|
|
|
|
|
httpResponse response;
|
2021-11-17 20:34:49 +01:00
|
|
|
if (reply->operation() == QNetworkAccessManager::GetOperation)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
if(reply->error() != QNetworkReply::NoError)
|
|
|
|
{
|
|
|
|
Debug(_log, "GET: [%s]", QSTRING_CSTR( url.toString() ));
|
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
response = getResponse(reply );
|
|
|
|
}
|
|
|
|
// Free space.
|
|
|
|
reply->deleteLater();
|
|
|
|
// Return response
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2021-08-31 10:55:49 +02:00
|
|
|
httpResponse ProviderRestApi::put(const QJsonObject &body)
|
|
|
|
{
|
|
|
|
return put( getUrl(), QJsonDocument(body).toJson(QJsonDocument::Compact));
|
|
|
|
}
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
httpResponse ProviderRestApi::put(const QString &body)
|
|
|
|
{
|
2021-08-31 10:55:49 +02:00
|
|
|
return put( getUrl(), body.toUtf8() );
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-08-31 10:55:49 +02:00
|
|
|
httpResponse ProviderRestApi::put(const QUrl &url, const QByteArray &body)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
// Perform request
|
2021-11-17 20:34:49 +01:00
|
|
|
QNetworkRequest request(_networkRequestHeaders);
|
|
|
|
request.setUrl(url);
|
|
|
|
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
|
|
|
_networkManager->setTransferTimeout(DEFAULT_REST_TIMEOUT.count());
|
|
|
|
#endif
|
|
|
|
|
2021-08-31 10:55:49 +02:00
|
|
|
QNetworkReply* reply = _networkManager->put(request, body);
|
2020-07-12 20:27:56 +02:00
|
|
|
// Connect requestFinished signal to quit slot of the loop.
|
|
|
|
QEventLoop loop;
|
2021-03-19 22:52:04 +01:00
|
|
|
QEventLoop::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
|
|
|
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
2021-03-19 22:52:04 +01:00
|
|
|
ReplyTimeout::set(reply, DEFAULT_REST_TIMEOUT.count());
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#endif
|
2021-03-19 22:52:04 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
// Go into the loop until the request is finished.
|
|
|
|
loop.exec();
|
|
|
|
|
|
|
|
httpResponse response;
|
2021-11-17 20:34:49 +01:00
|
|
|
if (reply->operation() == QNetworkAccessManager::PutOperation)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
if(reply->error() != QNetworkReply::NoError)
|
|
|
|
{
|
2021-08-31 10:55:49 +02:00
|
|
|
Debug(_log, "PUT: [%s] [%s]", QSTRING_CSTR( url.toString() ),body.constData() );
|
2021-03-19 22:52:04 +01:00
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
response = getResponse(reply);
|
|
|
|
}
|
|
|
|
// Free space.
|
|
|
|
reply->deleteLater();
|
|
|
|
|
|
|
|
// Return response
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
httpResponse ProviderRestApi::post(const QJsonObject& body)
|
|
|
|
{
|
|
|
|
return post( getUrl(), QJsonDocument(body).toJson(QJsonDocument::Compact));
|
|
|
|
}
|
|
|
|
|
|
|
|
httpResponse ProviderRestApi::post(const QString& body)
|
|
|
|
{
|
|
|
|
return post( getUrl(), body.toUtf8() );
|
|
|
|
}
|
|
|
|
|
|
|
|
httpResponse ProviderRestApi::post(const QUrl& url, const QByteArray& body)
|
|
|
|
{
|
|
|
|
// Perform request
|
|
|
|
QNetworkRequest request(_networkRequestHeaders);
|
|
|
|
request.setUrl(url);
|
|
|
|
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
|
|
|
_networkManager->setTransferTimeout(DEFAULT_REST_TIMEOUT.count());
|
|
|
|
#endif
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
QNetworkReply* reply = _networkManager->post(request, body);
|
|
|
|
// Connect requestFinished signal to quit slot of the loop.
|
|
|
|
QEventLoop loop;
|
|
|
|
QEventLoop::connect(reply,&QNetworkReply::finished,&loop,&QEventLoop::quit);
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
|
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
|
|
|
ReplyTimeout::set(reply, DEFAULT_REST_TIMEOUT.count());
|
|
|
|
#endif
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
// Go into the loop until the request is finished.
|
|
|
|
loop.exec();
|
|
|
|
|
|
|
|
httpResponse response;
|
|
|
|
if (reply->operation() == QNetworkAccessManager::PostOperation)
|
|
|
|
{
|
|
|
|
if(reply->error() != QNetworkReply::NoError)
|
|
|
|
{
|
|
|
|
Debug(_log, "POST: [%s] [%s]", QSTRING_CSTR( url.toString() ),body.constData() );
|
|
|
|
}
|
|
|
|
response = getResponse(reply);
|
|
|
|
}
|
|
|
|
// Free space.
|
|
|
|
reply->deleteLater();
|
|
|
|
|
|
|
|
// Return response
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
httpResponse ProviderRestApi::deleteResource(const QUrl& url)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-11-17 20:34:49 +01:00
|
|
|
// Perform request
|
|
|
|
QNetworkRequest request(_networkRequestHeaders);
|
|
|
|
request.setUrl(url);
|
|
|
|
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
|
|
|
_networkManager->setTransferTimeout(DEFAULT_REST_TIMEOUT.count());
|
|
|
|
#endif
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
QNetworkReply* reply = _networkManager->deleteResource(request);
|
|
|
|
// Connect requestFinished signal to quit slot of the loop.
|
|
|
|
QEventLoop loop;
|
|
|
|
QEventLoop::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
|
|
|
// Go into the loop until the request is finished.
|
|
|
|
loop.exec();
|
|
|
|
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
|
|
|
ReplyTimeout::set(reply, DEFAULT_REST_TIMEOUT.count());
|
|
|
|
#endif
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
httpResponse response;
|
2021-11-17 20:34:49 +01:00
|
|
|
if (reply->operation() == QNetworkAccessManager::DeleteOperation)
|
|
|
|
{
|
|
|
|
if(reply->error() != QNetworkReply::NoError)
|
|
|
|
{
|
|
|
|
Debug(_log, "DELETE: [%s]", QSTRING_CSTR(url.toString()));
|
|
|
|
}
|
|
|
|
response = getResponse(reply);
|
|
|
|
}
|
|
|
|
// Free space.
|
|
|
|
reply->deleteLater();
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
// Return response
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
httpResponse ProviderRestApi::getResponse(QNetworkReply* const& reply)
|
|
|
|
{
|
|
|
|
httpResponse response;
|
|
|
|
|
|
|
|
int httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
2020-07-12 20:27:56 +02:00
|
|
|
response.setHttpStatusCode(httpStatusCode);
|
|
|
|
response.setNetworkReplyError(reply->error());
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
if (reply->error() == QNetworkReply::NoError)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
if ( httpStatusCode != HTTP_STATUS_NO_CONTENT ){
|
2020-07-12 20:27:56 +02:00
|
|
|
QByteArray replyData = reply->readAll();
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
if (!replyData.isEmpty())
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
QJsonParseError error;
|
|
|
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(replyData, &error);
|
|
|
|
|
|
|
|
if (error.error != QJsonParseError::NoError)
|
|
|
|
{
|
|
|
|
//Received not valid JSON response
|
|
|
|
//std::cout << "Response: [" << replyData.toStdString() << "]" << std::endl;
|
|
|
|
response.setError(true);
|
|
|
|
response.setErrorReason(error.errorString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-17 20:34:49 +01:00
|
|
|
//std::cout << "Response: [" << QString(jsonDoc.toJson(QJsonDocument::Compact)).toStdString() << "]" << std::endl;
|
|
|
|
response.setBody(jsonDoc);
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Create valid body which is empty
|
2021-11-17 20:34:49 +01:00
|
|
|
response.setBody(QJsonDocument());
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
Debug(_log, "Reply.httpStatusCode [%d]", httpStatusCode );
|
2020-07-12 20:27:56 +02:00
|
|
|
QString errorReason;
|
2021-11-17 20:34:49 +01:00
|
|
|
if (httpStatusCode > 0) {
|
|
|
|
QString httpReason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
|
2020-07-12 20:27:56 +02:00
|
|
|
QString advise;
|
|
|
|
switch ( httpStatusCode ) {
|
2021-03-19 22:52:04 +01:00
|
|
|
case HTTP_STATUS_BAD_REQUEST:
|
2020-07-12 20:27:56 +02:00
|
|
|
advise = "Check Request Body";
|
|
|
|
break;
|
2021-03-19 22:52:04 +01:00
|
|
|
case HTTP_STATUS_UNAUTHORIZED:
|
2020-07-12 20:27:56 +02:00
|
|
|
advise = "Check Authentication Token (API Key)";
|
|
|
|
break;
|
2021-03-19 22:52:04 +01:00
|
|
|
case HTTP_STATUS_NOT_FOUND:
|
2020-07-12 20:27:56 +02:00
|
|
|
advise = "Check Resource given";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-11-16 18:12:56 +01:00
|
|
|
errorReason = QString ("[%3 %4] - %5").arg(httpStatusCode).arg(httpReason, advise);
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
mDNS Support (#1452)
* Allow build, if no grabbers are enabled
* Align available functions to right Qt version
* Update to next development version
* Align available functions to right Qt version
* fix workflows (apt/nightly)
* Disable QNetworkConfigurationManager deprecation warnings
* Initial go on Smart Pointers
* Add Deallocation
* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)
* Cluster Build Variables
* Hyperion Light
* Address build warnings
* Hyperion Light - UI
* Update Protobuf to latest master
* Removed compiler warnings
* Added restart ability to systray
* Correct Protobuf
* Ignore 'no-return' warning on protobuf build
* hyperion-remote: Fix auto discovery of hyperion server
* Fix Qt version override
* Update changelog
* Remove Grabber Components, if no Grabber exists
* Standalone Grabber - Fix fps default
* Remote Control - Have Source Selction accrosswhole screen
* Enable Blackborder detection only, if relevant input sources available
* Enable Blackborder detection only, if relevant input sources available
* Remote UI - rearrange containers
* Checkout
* Fix compilation on windows
* Re-added qmdnsengine template cmake
* chrono added for linux
* Removed existing AVAHI/Bonjour, allow to enable/disable mDNS
* hyperiond macos typo fix
* Fix macOS Bundle build
* Fix macOS bundle info details
* Correct CMake files
* Removed existing AVAHI/Bonjour (2)
* Share hyperion's services via mDNS
* Add mDNS Browser and mDNS for LED-Devices
* Support mDNS discovery for standalone grabbers
* Remove ZLib Dependency & Cleanup
* mDNS - hanle 2.local2 an ".local." domains equally
* Hue - Link discovery to bridge class, workaround port 443 for mDNS discovery
* Fix save button state when switching between devices
* Removed sessions (of other hyperions)
* mDNS Publisher - Simplify service naming
* mDNS refactoring & Forwarder discovery
* mDNS Updates to use device service name
* Consistency of standalone grabbers with mDNS Service Registry
* Merge branch 'hyperion-project:master' into mDNS
* Start JSON and WebServers only after Instance 0 is available
* Remove bespoke qDebug Output again
* MDNS updates and refactor Forwarder
* Minor updates
* Upgrade to CMake 3.1
* typo
* macOS fix
* Correct merge
* - Remove dynamic linker flag from standalone dispmanX Grabber
- Added ability to use system qmdns libs
* Cec handler library will load at runtime
* typo fix
* protobuf changes
* mDNS changes for Windows/macOS
* test window build qmdnsengine
* absolute path to protobuf cmake dir
* Rework Hue Wizard supporting mDNS
* LED-Devices - Retry support + Refactoring (excl. Hue)
* LED-Devices - Refactoring/Retry support Hue + additional alignments
* Address LGTM findings
* Fix CI-Build, revert test changes
* Build Windows in Release mode to avoid python problem
* Correct that WebServerObject is available earlier
* Ensure that instance name in logs for one instance are presented
* Update content LEDs
* Rework mDNS Address lookup
* Fix LED UI
* Fix for non mDNS Services (ignore default port)
* Disbale device when now input is available
* Revert back some updates, ensure last color is updated when switched on
* Handle reopening case and changed IP, port for API-calls
* Add UPD-DDP Device
* WLED support for DDP
* Fix printout
* LEDDevice - Allow more retries, udapte defaults
* LED-Net Devices - Select Custom device, if configured
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-05-01 19:42:47 +02:00
|
|
|
else
|
|
|
|
{
|
2020-07-12 20:27:56 +02:00
|
|
|
errorReason = reply->errorString();
|
2021-03-19 22:52:04 +01:00
|
|
|
{
|
|
|
|
response.setError(true);
|
|
|
|
response.setErrorReason(errorReason);
|
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create valid body which is empty
|
2021-11-17 20:34:49 +01:00
|
|
|
response.setBody(QJsonDocument());
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
void ProviderRestApi::setHeader(QNetworkRequest::KnownHeaders header, const QVariant& value)
|
|
|
|
{
|
|
|
|
QVariant headerValue = _networkRequestHeaders.header(header);
|
|
|
|
if (headerValue.isNull())
|
|
|
|
{
|
|
|
|
_networkRequestHeaders.setHeader(header, value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!headerValue.toString().contains(value.toString()))
|
|
|
|
{
|
|
|
|
_networkRequestHeaders.setHeader(header, headerValue.toString() + "," + value.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|