2020-07-12 20:27:56 +02:00
|
|
|
#ifndef PROVIDERRESTKAPI_H
|
|
|
|
#define PROVIDERRESTKAPI_H
|
|
|
|
|
|
|
|
// Local-Hyperion includes
|
|
|
|
#include <utils/Logger.h>
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QUrlQuery>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
#include <QBasicTimer>
|
|
|
|
#include <QTimerEvent>
|
|
|
|
|
|
|
|
//Set QNetworkReply timeout without external timer
|
|
|
|
//https://stackoverflow.com/questions/37444539/how-to-set-qnetworkreply-timeout-without-external-timer
|
|
|
|
|
|
|
|
class ReplyTimeout : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum HandleMethod { Abort, Close };
|
|
|
|
ReplyTimeout(QNetworkReply* reply, const int timeout, HandleMethod method = Abort) :
|
|
|
|
QObject(reply), m_method(method)
|
|
|
|
{
|
|
|
|
Q_ASSERT(reply);
|
|
|
|
if (reply && reply->isRunning()) {
|
|
|
|
m_timer.start(timeout, this);
|
|
|
|
connect(reply, &QNetworkReply::finished, this, &QObject::deleteLater);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void set(QNetworkReply* reply, const int timeout, HandleMethod method = Abort)
|
|
|
|
{
|
|
|
|
new ReplyTimeout(reply, timeout, method);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QBasicTimer m_timer;
|
|
|
|
HandleMethod m_method;
|
|
|
|
void timerEvent(QTimerEvent * ev) override {
|
|
|
|
if (!m_timer.isActive() || ev->timerId() != m_timer.timerId())
|
|
|
|
return;
|
|
|
|
auto reply = static_cast<QNetworkReply*>(parent());
|
|
|
|
if (reply->isRunning())
|
|
|
|
{
|
|
|
|
if (m_method == Close)
|
|
|
|
reply->close();
|
|
|
|
else if (m_method == Abort)
|
|
|
|
reply->abort();
|
|
|
|
m_timer.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
///
|
|
|
|
/// Response object for REST-API calls and JSON-responses
|
|
|
|
///
|
|
|
|
class httpResponse
|
|
|
|
{
|
|
|
|
public:
|
2020-08-08 00:21:19 +02:00
|
|
|
httpResponse() = default;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
bool error() const { return _hasError; }
|
2020-07-12 20:27:56 +02:00
|
|
|
void setError(const bool hasError) { _hasError = hasError; }
|
|
|
|
|
|
|
|
QJsonDocument getBody() const { return _responseBody; }
|
2021-11-17 20:34:49 +01:00
|
|
|
void setBody(const QJsonDocument& body) { _responseBody = body; }
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
QString getErrorReason() const { return _errorReason; }
|
2021-11-17 20:34:49 +01:00
|
|
|
void setErrorReason(const QString& errorReason) { _errorReason = errorReason; }
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
int getHttpStatusCode() const { return _httpStatusCode; }
|
2020-08-08 13:09:15 +02:00
|
|
|
void setHttpStatusCode(int httpStatusCode) { _httpStatusCode = httpStatusCode; }
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
QNetworkReply::NetworkError getNetworkReplyError() const { return _networkReplyError; }
|
2021-11-17 20:34:49 +01:00
|
|
|
void setNetworkReplyError(const QNetworkReply::NetworkError networkReplyError) { _networkReplyError = networkReplyError; }
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
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
|
|
|
QJsonDocument _responseBody {};
|
2020-07-12 20:27:56 +02:00
|
|
|
bool _hasError = false;
|
|
|
|
QString _errorReason;
|
|
|
|
|
|
|
|
int _httpStatusCode = 0;
|
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
|
|
|
QNetworkReply::NetworkError _networkReplyError { QNetworkReply::NoError };
|
2020-07-12 20:27:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Wrapper class supporting REST-API calls with JSON requests and responses
|
|
|
|
///
|
|
|
|
/// Usage sample:
|
|
|
|
/// @code
|
|
|
|
///
|
|
|
|
/// ProviderRestApi* _restApi = new ProviderRestApi(hostname, port );
|
|
|
|
///
|
|
|
|
/// _restApi->setBasePath( QString("/api/%1/").arg(token) );
|
|
|
|
/// _restApi->setPath( QString("%1/%2").arg( "groups" ).arg( groupId ) );
|
|
|
|
///
|
|
|
|
/// httpResponse response = _restApi->get();
|
|
|
|
/// if ( !response.error() )
|
|
|
|
/// response.getBody();
|
|
|
|
///
|
|
|
|
/// delete _restApi;
|
|
|
|
///
|
|
|
|
///@endcode
|
|
|
|
///
|
|
|
|
class ProviderRestApi
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Constructor of the REST-API wrapper
|
|
|
|
///
|
2020-08-08 00:21:19 +02:00
|
|
|
ProviderRestApi();
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Constructor of the REST-API wrapper
|
|
|
|
///
|
|
|
|
/// @param[in] host
|
|
|
|
/// @param[in] port
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
explicit ProviderRestApi(const QString& host, int port);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Constructor of the REST-API wrapper
|
|
|
|
///
|
|
|
|
/// @param[in] host
|
|
|
|
/// @param[in] port
|
|
|
|
/// @param[in] API base-path
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
explicit ProviderRestApi(const QString& host, int port, const QString& basePath);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Destructor of the REST-API wrapper
|
|
|
|
///
|
|
|
|
virtual ~ProviderRestApi();
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
///
|
|
|
|
/// @brief Set an API's host
|
|
|
|
///
|
|
|
|
/// @param[in] host
|
|
|
|
///
|
|
|
|
void setHost(const QString& host) { _apiUrl.setHost(host); }
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Set an API's port
|
|
|
|
///
|
|
|
|
/// @param[in] port
|
|
|
|
///
|
|
|
|
void setPort(const int port) { _apiUrl.setPort(port); }
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Set an API's url
|
|
|
|
///
|
|
|
|
/// @param[in] url, e.g. "http://locahost:60351/chromalink/"
|
|
|
|
///
|
|
|
|
void setUrl(const QUrl& url);
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
///
|
|
|
|
/// @brief Get the URL as defined using scheme, host, port, API-basepath, path, query, fragment
|
|
|
|
///
|
|
|
|
/// @return url
|
|
|
|
///
|
|
|
|
QUrl getUrl() const;
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Set an API's base path (the stable path element before addressing resources)
|
|
|
|
///
|
|
|
|
/// @param[in] basePath, e.g. "/api/v1/" or "/json"
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
void setBasePath(const QString& basePath);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Set an API's path to address resources
|
|
|
|
///
|
|
|
|
/// @param[in] path, e.g. "/lights/1/state/"
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
void setPath(const QString& path);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Append an API's path element to path set before
|
|
|
|
///
|
|
|
|
/// @param[in] path
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
void appendPath(const QString& appendPath);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Set an API's fragment
|
|
|
|
///
|
|
|
|
/// @param[in] fragment, e.g. "question3"
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
void setFragment(const QString& fragment);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Set an API's query string
|
|
|
|
///
|
|
|
|
/// @param[in] query, e.g. "&A=128&FX=0"
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
void setQuery(const QUrlQuery& query);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Execute GET request
|
|
|
|
///
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
|
|
|
httpResponse get();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Execute GET request
|
|
|
|
///
|
|
|
|
/// @param[in] url GET request for URL
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
httpResponse get(const QUrl& url);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-08-31 10:55:49 +02:00
|
|
|
/// @brief Execute PUT request
|
|
|
|
///
|
|
|
|
/// @param[in] body The body of the request in JSON
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
httpResponse put(const QJsonObject& body);
|
2021-08-31 10:55:49 +02:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
///
|
|
|
|
/// @brief Execute PUT request
|
|
|
|
///
|
|
|
|
/// @param[in] body The body of the request in JSON
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
httpResponse put(const QString& body = "");
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Execute PUT request
|
|
|
|
///
|
|
|
|
/// @param[in] URL for PUT request
|
|
|
|
/// @param[in] body The body of the request in JSON
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
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);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Execute POST request
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
/// @param[in] URL for POST request
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] body The body of the request in JSON
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
httpResponse post(const QUrl &url, const QByteArray& body);
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Execute DELETE request
|
|
|
|
///
|
|
|
|
/// @param[in] URL (Resource) for DELETE request
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
|
|
|
httpResponse deleteResource(const QUrl& url);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Handle responses for REST requests
|
|
|
|
///
|
|
|
|
/// @param[in] reply Network reply
|
|
|
|
/// @return Response The body of the response in JSON
|
|
|
|
///
|
2021-11-17 20:34:49 +01:00
|
|
|
httpResponse getResponse(QNetworkReply* const& reply);
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Adds a header field.
|
|
|
|
///
|
|
|
|
/// @param[in] The type of the header field.
|
|
|
|
/// @param[in] The value of the header field.
|
|
|
|
/// If the header field exists, the value will be combined as comma separated string.
|
|
|
|
|
|
|
|
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant& value);
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Remove all header fields.
|
|
|
|
///
|
|
|
|
void removeAllHeaders() { _networkRequestHeaders = QNetworkRequest(); }
|
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
|
|
|
///
|
|
|
|
/// @brief Set the common logger for LED-devices.
|
|
|
|
///
|
|
|
|
/// @param[in] log The logger to be used
|
|
|
|
///
|
|
|
|
void setLogger(Logger* log) { _log = log; }
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Append an API's path element to path given as param
|
|
|
|
///
|
|
|
|
/// @param[in/out] path to be updated
|
|
|
|
/// @param[in] path, element to be appended
|
|
|
|
///
|
2021-03-19 22:52:04 +01:00
|
|
|
static void appendPath (QString &path, const QString &appendPath) ;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
Logger* _log;
|
|
|
|
|
|
|
|
// QNetworkAccessManager object for sending REST-requests.
|
|
|
|
QNetworkAccessManager* _networkManager;
|
|
|
|
|
|
|
|
QUrl _apiUrl;
|
|
|
|
|
|
|
|
QString _basePath;
|
|
|
|
QString _path;
|
|
|
|
|
|
|
|
QString _fragment;
|
|
|
|
QUrlQuery _query;
|
|
|
|
|
2021-11-17 20:34:49 +01:00
|
|
|
QNetworkRequest _networkRequestHeaders;
|
2020-07-12 20:27:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PROVIDERRESTKAPI_H
|