hyperion.ng/include/ssdp/SSDPHandler.h
LordGrey 2f573a117f
Hyperion "Light", Build improvements and minor fixes (#1400)
* 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

* - QT5/6 path for arm64 added
- Remove ZLib Dependency
- Fix macOS bundle info details
- Cleanup

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-01-07 14:47:51 +01:00

124 lines
2.9 KiB
C++

#pragma once
#include <ssdp/SSDPServer.h>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QNetworkConfiguration>
#endif
// utils
#include <utils/settings.h>
class WebServer;
class QNetworkConfigurationManager;
///
/// Manage SSDP discovery. SimpleServiceDisoveryProtocol is the discovery subset of UPnP. Implemented is spec V1.0.
/// As SSDP requires a webserver, this class depends on it
/// UPnP 1.0: spec: http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0.pdf
///
class SSDPHandler : public SSDPServer
{
Q_OBJECT
public:
SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 protoBufPort, quint16 jsonServerPort, quint16 sslPort, const QString& name, QObject* parent = nullptr);
~SSDPHandler() override;
///
/// @brief Sends BYE BYE and stop server
///
void stopServer();
public slots:
///
/// @brief Init SSDP after thread start
///
void initServer();
///
/// @brief get state changes from webserver
/// @param newState true for started and false for stopped
///
void handleWebServerStateChange(bool newState);
///
/// @brief Handle settings update from Hyperion Settingsmanager emit
/// @param type settingyType from enum
/// @param config configuration object
///
void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
private:
///
/// @brief Build http url for current ip:port/desc.xml
///
QString getDescAddress() const;
///
/// @brief Get the base address
///
QString getBaseAddress() const;
///
/// @brief Build the ssdp description (description.xml)
///
QString buildDesc() const;
///
/// @brief Get the local address of interface
/// @return the address, might be empty
///
QString getLocalAddress() const;
///
/// @brief Send alive/byebye message based on _deviceList
/// @param alive When true send alive, else byebye
///
void sendAnnounceList(bool alive);
private slots:
///
/// @brief Handle the mSeach request from SSDPServer
/// @param target The ST service type
/// @param mx Answer with delay in s
/// @param address The ip of the caller
/// @param port The port of the caller
///
void handleMSearchRequest(const QString& target, const QString& mx, const QString address, quint16 port);
private:
WebServer* _webserver;
QString _localAddress;
QString _uuid;
/// Targets for announcement
std::vector<QString> _deviceList;
//Handle elements deprecated from Qt 6.x and reported as deprecatedsince 5.15.x
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
#endif
private slots:
///
/// @brief Handle changes in the network configuration
/// @param conig New config
///
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void handleNetworkConfigurationChanged(const QNetworkConfiguration& config);
#endif
private:
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QNetworkConfigurationManager* _NCA;
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QT_WARNING_POP
#endif
};