2018-12-28 18:12:45 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// qt incl
|
|
|
|
#include <QObject>
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
|
|
|
// components def
|
|
|
|
#include <utils/Components.h>
|
|
|
|
// bonjour
|
2020-05-12 19:51:19 +02:00
|
|
|
#ifdef ENABLE_AVAHI
|
2018-12-28 18:12:45 +01:00
|
|
|
#include <bonjour/bonjourrecord.h>
|
2020-05-12 19:51:19 +02:00
|
|
|
#endif
|
2018-12-28 18:12:45 +01:00
|
|
|
// videModes
|
|
|
|
#include <utils/VideoMode.h>
|
|
|
|
// settings
|
|
|
|
#include <utils/settings.h>
|
2020-03-26 17:59:41 +01:00
|
|
|
// AuthManager
|
|
|
|
#include <hyperion/AuthManager.h>
|
2018-12-28 18:12:45 +01:00
|
|
|
|
|
|
|
class Hyperion;
|
|
|
|
class ComponentRegister;
|
|
|
|
class BonjourBrowserWrapper;
|
|
|
|
class PriorityMuxer;
|
|
|
|
|
|
|
|
class JsonCB : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-09-17 21:33:46 +02:00
|
|
|
JsonCB(QObject* parent);
|
2018-12-28 18:12:45 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Subscribe to future data updates given by cmd
|
2019-09-17 21:33:46 +02:00
|
|
|
/// @param cmd The cmd which will be subscribed for
|
|
|
|
/// @param unsubscribe Revert subscription
|
2018-12-28 18:12:45 +01:00
|
|
|
/// @return True on success, false if not found
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
bool subscribeFor(const QString& cmd, bool unsubscribe = false);
|
2018-12-28 18:12:45 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Get all possible commands to subscribe for
|
|
|
|
/// @return The list of commands
|
|
|
|
///
|
|
|
|
QStringList getCommands() { return _availableCommands; };
|
2019-09-17 21:33:46 +02:00
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
///
|
|
|
|
/// @brief Get all subscribed commands
|
|
|
|
/// @return The list of commands
|
|
|
|
///
|
|
|
|
QStringList getSubscribedCommands() { return _subscribedCommands; };
|
2019-09-17 21:33:46 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Reset subscriptions, disconnect all signals
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
void resetSubscriptions();
|
2019-09-17 21:33:46 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Re-apply all current subs to a new Hyperion instance, the connections to the old instance will be dropped
|
|
|
|
///
|
|
|
|
void setSubscriptionsTo(Hyperion* hyperion);
|
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
signals:
|
|
|
|
///
|
|
|
|
/// @brief Emits whenever a new json mesage callback is ready to send
|
|
|
|
/// @param The JsonObject message
|
|
|
|
///
|
|
|
|
void newCallback(QJsonObject);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
///
|
|
|
|
/// @brief handle component state changes
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
void handleComponentState(hyperion::Components comp, bool state);
|
2020-05-12 19:51:19 +02:00
|
|
|
#ifdef ENABLE_AVAHI
|
2018-12-28 18:12:45 +01:00
|
|
|
///
|
|
|
|
/// @brief handle emits from bonjour wrapper
|
|
|
|
/// @param bRegisters The full register map
|
|
|
|
///
|
|
|
|
void handleBonjourChange(const QMap<QString,BonjourRecord>& bRegisters);
|
2020-05-12 19:51:19 +02:00
|
|
|
#endif
|
2018-12-28 18:12:45 +01:00
|
|
|
///
|
|
|
|
/// @brief handle emits from PriorityMuxer
|
|
|
|
///
|
|
|
|
void handlePriorityUpdate();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Handle imageToLedsMapping updates
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
void handleImageToLedsMappingChange(int mappingType);
|
2018-12-28 18:12:45 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Handle the adjustment update
|
|
|
|
///
|
|
|
|
void handleAdjustmentChange();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Handle video mode change
|
|
|
|
/// @param mode The new videoMode
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
void handleVideoModeChange(VideoMode mode);
|
2018-12-28 18:12:45 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Handle effect list change
|
|
|
|
///
|
|
|
|
void handleEffectListChange();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Handle a config part change. This does NOT include (global) changes from other hyperion instances
|
|
|
|
/// @param type The settings type from enum
|
|
|
|
/// @param data The data as QJsonDocument
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
void handleSettingsChange(settings::type type, const QJsonDocument& data);
|
2018-12-28 18:12:45 +01:00
|
|
|
|
2019-07-20 11:28:16 +02:00
|
|
|
///
|
|
|
|
/// @brief Handle led config specific updates (required for led color streaming with positional display)
|
|
|
|
/// @param type The settings type from enum
|
|
|
|
/// @param data The data as QJsonDocument
|
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
void handleLedsConfigChange(settings::type type, const QJsonDocument& data);
|
2019-07-20 11:28:16 +02:00
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
///
|
|
|
|
/// @brief Handle Hyperion instance manager change
|
|
|
|
///
|
|
|
|
void handleInstanceChange();
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
///
|
|
|
|
/// @brief Handle AuthManager token changes
|
|
|
|
///
|
|
|
|
void handleTokenChange(const QVector<AuthManager::AuthDefinition> &def);
|
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
private:
|
|
|
|
/// pointer of Hyperion instance
|
|
|
|
Hyperion* _hyperion;
|
|
|
|
/// pointer of comp register
|
|
|
|
ComponentRegister* _componentRegister;
|
2020-05-12 19:51:19 +02:00
|
|
|
#ifdef ENABLE_AVAHI
|
2018-12-28 18:12:45 +01:00
|
|
|
/// Bonjour instance
|
|
|
|
BonjourBrowserWrapper* _bonjour;
|
2020-05-12 19:51:19 +02:00
|
|
|
#endif
|
2018-12-28 18:12:45 +01:00
|
|
|
/// priority muxer instance
|
|
|
|
PriorityMuxer* _prioMuxer;
|
|
|
|
/// contains all available commands
|
|
|
|
QStringList _availableCommands;
|
|
|
|
/// contains active subscriptions
|
|
|
|
QStringList _subscribedCommands;
|
|
|
|
/// construct callback msg
|
|
|
|
void doCallback(const QString& cmd, const QVariant& data);
|
|
|
|
};
|