This commit is contained in:
Paulchen Panther
2020-10-18 17:05:07 +02:00
committed by GitHub
parent 9d2e442d42
commit aa465c018c
18 changed files with 207 additions and 90 deletions

View File

@@ -112,8 +112,9 @@ protected:
/// @param dat The effect data
/// @param callerComp The HYPERION COMPONENT that calls this function! e.g. PROT/FLATBUF
/// REQUIRED dat fields: effectName, priority, duration, origin
/// @return True on success else false
///
void setEffect(const EffectCmdData &dat, hyperion::Components callerComp = hyperion::COMP_INVALID);
bool setEffect(const EffectCmdData &dat, hyperion::Components callerComp = hyperion::COMP_INVALID);
///
/// @brief Set source auto select enabled or disabled
@@ -174,8 +175,10 @@ protected:
///
/// @brief Start instance
/// @param index The instance index
/// @param tan The tan
/// @return True on success else false
///
void startInstance(quint8 index);
bool startInstance(quint8 index, int tan = 0);
///
/// @brief Stop instance
@@ -277,8 +280,9 @@ protected:
/// @brief Set a new token request
/// @param comment The comment
/// @param id The id
/// @param tan The tan
///
void setNewTokenRequest(const QString &comment, const QString &id);
void setNewTokenRequest(const QString &comment, const QString &id, const int &tan);
///
/// @brief Cancel new token request
@@ -367,7 +371,7 @@ signals:
///
/// @brief Emits whenever a new Token request is pending. This signal is just active when ADMIN ACCESS has been granted
/// @param id The id of the request
/// @param id The id of the request
/// @param comment The comment of the request; If the commen is EMPTY the request has been revoked by the caller. So remove it from the pending list
///
void onPendingTokenRequest(const QString &id, const QString &comment);
@@ -378,8 +382,15 @@ signals:
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
/// @param tan The tan that was part of the request
///
void onTokenResponse(bool success, const QString &token, const QString &comment, const QString &id);
void onTokenResponse(bool success, const QString &token, const QString &comment, const QString &id, const int &tan);
///
/// @brief Handle emits from HyperionIManager of startInstance request, just if QObject matches with this instance it will emit.
/// @param tan The tan that was part of the request
///
void onStartInstanceResponse(const int &tan);
private slots:
///
@@ -388,16 +399,6 @@ private slots:
///
void requestActiveRegister(QObject *callerInstance);
///
/// @brief See onTokenResponse(). Here we validate the caller instance and on success we will emit onTokenResponse()
/// @param success If true the request was accepted else false and no token was created
/// @param caller The origin caller instance who requested this token
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
///
void checkTokenResponse(bool success, QObject *caller, const QString &token, const QString &comment, const QString &id);
private:
void stopDataConnectionss();

View File

@@ -65,8 +65,8 @@ public slots:
private slots:
///
/// @brief Handle emits from API of a new Token request.
/// @param id The id of the request
/// @param The comment which needs to be accepted
/// @param id The id of the request
/// @param comment The comment which needs to be accepted
///
void newPendingTokenRequest(const QString &id, const QString &comment);
@@ -76,8 +76,9 @@ private slots:
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
/// @param tan The tan that was part of the request
///
void handleTokenResponse(bool success, const QString &token, const QString &comment, const QString &id);
void handleTokenResponse(bool success, const QString &token, const QString &comment, const QString &id, const int &tan);
///
/// @brief Handle whenever the state of a instance (HyperionIManager) changes according to enum instanceState

View File

@@ -29,6 +29,7 @@ public:
QString id;
QString comment;
QObject *caller;
int tan;
uint64_t timeoutTime;
QString token;
QString lastUse;
@@ -142,16 +143,16 @@ public slots:
/// @param caller The QObject of the caller to deliver the reply
/// @param comment The comment as ident helper
/// @param id The id created by the caller
/// @param tan The tan created by the caller
///
void setNewTokenRequest(QObject *caller, const QString &comment, const QString &id);
void setNewTokenRequest(QObject *caller, const QString &comment, const QString &id, const int &tan = 0);
///
/// @brief Cancel a pending token request with the provided comment and id as identifier helper
/// @param caller The QObject of the caller to deliver the reply
/// @param comment The comment as ident helper
/// @param id The id created by the caller
///
void cancelNewTokenRequest(QObject *caller, const QString &comment, const QString &id);
void cancelNewTokenRequest(QObject *caller, const QString &, const QString &id);
///
/// @brief Handle a token request by id, generate token and inform token caller or deny
@@ -200,8 +201,9 @@ signals:
/// @param token The new token that is now valid
/// @param comment The comment that was part of the request
/// @param id The id that was part of the request
/// @param tan The tan that was part of the request
///
void tokenResponse(bool success, QObject *caller, const QString &token, const QString &comment, const QString &id);
void tokenResponse(bool success, QObject *caller, const QString &token, const QString &comment, const QString &id, const int &tan);
///
/// @brief Emits whenever the token list changes

View File

@@ -28,6 +28,12 @@ class HyperionIManager : public QObject
Q_OBJECT
public:
struct PendingRequests
{
QObject *caller;
int tan;
};
// global instance pointer
static HyperionIManager* getInstance() { return HIMinstance; }
static HyperionIManager* HIMinstance;
@@ -54,11 +60,11 @@ public slots:
///
/// @brief Start a Hyperion instance
/// @param instance Instance index
/// @param block If true return when thread has been started
/// @param instance Instance index
/// @param block If true return when thread has been started
/// @return Return true on success, false if not found in db
///
bool startInstance(quint8 inst, bool block = false);
bool startInstance(quint8 inst, bool block = false, QObject *caller = nullptr, int tan = 0);
///
/// @brief Stop a Hyperion instance
@@ -110,6 +116,13 @@ signals:
///
void change();
///
/// @brief Emits when the user has requested to start a instance
/// @param caller The origin caller instance who requested
/// @param tan The tan that was part of the request
///
void startInstanceResponse(QObject *caller, const int &tan);
signals:
///////////////////////////////////////
/// FROM HYPERIONDAEMON TO HYPERION ///
@@ -180,4 +193,6 @@ private:
const QString _rootPath;
QMap<quint8, Hyperion*> _runningInstances;
QList<quint8> _startQueue;
/// All pending requests
QMap<quint8, PendingRequests> _pendingRequests;
};

View File

@@ -20,7 +20,7 @@ class SSDPHandler : public SSDPServer
{
Q_OBJECT
public:
SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 jsonServerPort, const QString &name, QObject * parent = nullptr);
SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 protoBufPort, quint16 jsonServerPort, quint16 sslPort, const QString &name, QObject * parent = nullptr);
~SSDPHandler() override;
///

View File

@@ -85,16 +85,36 @@ public:
quint16 getFlatBufPort() const { return _fbsPort.toInt(); };
///
/// @brief set new jsonserver server port
/// @brief set new protobuf server port
///
void setProtoBufPort(quint16 port) { _pbsPort = QString::number(port); };
///
/// @brief Get current protobuf server port
///
quint16 getProtoBufPort() const { return _pbsPort.toInt(); };
///
/// @brief set new json server port
///
void setJsonServerPort(quint16 port) { _jssPort = QString::number(port); };
///
/// @brief get new jsonserver server port
/// @brief get new json server port
///
quint16 getJsonServerPort() const { return _jssPort.toInt(); };
///
///
/// @brief set new ssl server port
///
void setSSLServerPort(quint16 port) { _sslPort = QString::number(port); };
///
/// @brief get new ssl server port
///
quint16 getSSLServerPort() const { return _sslPort.toInt(); };
///
/// @brief set new hyperion name
///
void setHyperionName(const QString &name) { _name = name; };
@@ -119,13 +139,15 @@ private:
Logger* _log;
QUdpSocket* _udpSocket;
QString _serverHeader;
QString _uuid;
QString _fbsPort;
QString _jssPort;
QString _name;
QString _descAddress;
bool _running;
QString _serverHeader,
_uuid,
_fbsPort,
_pbsPort,
_jssPort,
_sslPort,
_name,
_descAddress;
bool _running;
private slots:
void readPendingDatagrams();