mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Refactor Settings DB and Handling (#1786)
* Refactor config API
* Corrections
* Test Qt 6.8
* Revert "Test Qt 6.8"
This reverts commit eceebec49e
.
* Corrections 2
* Update Changelog
* Add configFilter element for getconfig call
* Do not create errors for DB updates when in read-only mode
* Have configuration migration and validation before Hyperion starts
* Correct Tests
* Corrections
* Add migration items
* Correct windows build
* Ensure that first instance as default one exists
* Remove dependency between AuthManager and SSDPHandler
* Correct typos
* Address CodeQL findings
* Replace CamkeSettings by Presets and provide debug scenarios
This commit is contained in:
@@ -23,7 +23,7 @@ class AuthManager : public QObject
|
||||
private:
|
||||
friend class HyperionDaemon;
|
||||
/// constructor is private, can be called from HyperionDaemon
|
||||
AuthManager(QObject *parent = nullptr, bool readonlyMode = false);
|
||||
AuthManager(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
struct AuthDefinition
|
||||
|
@@ -108,8 +108,6 @@ public:
|
||||
///
|
||||
QString getActiveDeviceType() const;
|
||||
|
||||
bool getReadOnlyMode() const {return _readOnlyMode; }
|
||||
|
||||
public slots:
|
||||
|
||||
///
|
||||
@@ -335,18 +333,9 @@ public slots:
|
||||
///
|
||||
/// @brief Save a complete json config
|
||||
/// @param config The entire config object
|
||||
/// @param correct If true will correct json against schema before save
|
||||
/// @return True on success else false
|
||||
///
|
||||
bool saveSettings(const QJsonObject& config, bool correct = false);
|
||||
|
||||
///
|
||||
/// @brief Restore a complete json config
|
||||
/// @param config The entire config object
|
||||
/// @param correct If true will correct json against schema before save
|
||||
/// @return True on success else false
|
||||
///
|
||||
bool restoreSettings(const QJsonObject& config, bool correct = false);
|
||||
QPair<bool, QStringList> saveSettings(const QJsonObject& config);
|
||||
|
||||
/// ############
|
||||
/// COMPONENTREGISTER
|
||||
@@ -552,7 +541,7 @@ private:
|
||||
/// @brief Constructs the Hyperion instance, just accessible for HyperionIManager
|
||||
/// @param instance The instance index
|
||||
///
|
||||
Hyperion(quint8 instance, bool readonlyMode = false);
|
||||
Hyperion(quint8 instance);
|
||||
|
||||
/// instance index
|
||||
const quint8 _instIndex;
|
||||
@@ -615,6 +604,4 @@ private:
|
||||
/// Boblight instance
|
||||
BoblightServer* _boblightServer;
|
||||
#endif
|
||||
|
||||
bool _readOnlyMode;
|
||||
};
|
||||
|
@@ -59,12 +59,18 @@ public slots:
|
||||
///
|
||||
QVector<QVariantMap> getInstanceData() const;
|
||||
|
||||
QString getInstanceName(quint8 inst = 0);
|
||||
|
||||
///
|
||||
/// @brief Get all instance indicies of running instances
|
||||
///
|
||||
QList<quint8> getRunningInstanceIdx() const;
|
||||
|
||||
///
|
||||
/// @brief Get all instance indicies configured
|
||||
///
|
||||
QList<quint8> getInstanceIds() const;
|
||||
|
||||
///
|
||||
/// @brief Start a Hyperion instance
|
||||
/// @param instance Instance index
|
||||
@@ -115,8 +121,6 @@ public slots:
|
||||
///
|
||||
bool saveName(quint8 inst, const QString& name);
|
||||
|
||||
QString getRootPath() const { return _rootPath; }
|
||||
|
||||
signals:
|
||||
///
|
||||
/// @brief Emits whenever the state of a instance changes according to enum instanceState
|
||||
@@ -195,9 +199,8 @@ private:
|
||||
friend class HyperionDaemon;
|
||||
///
|
||||
/// @brief Construct the Manager
|
||||
/// @param The root path of all userdata
|
||||
///
|
||||
HyperionIManager(const QString& rootPath, QObject* parent = nullptr, bool readonlyMode = false);
|
||||
HyperionIManager(QObject* parent = nullptr);
|
||||
|
||||
///
|
||||
/// @brief Start all instances that are marked as enabled in db. Non blocking
|
||||
@@ -218,12 +221,9 @@ private:
|
||||
private:
|
||||
Logger* _log;
|
||||
InstanceTable* _instanceTable;
|
||||
const QString _rootPath;
|
||||
QMap<quint8, Hyperion*> _runningInstances;
|
||||
|
||||
QList<quint8> _startQueue;
|
||||
|
||||
bool _readonlyMode;
|
||||
|
||||
/// All pending requests
|
||||
QMap<quint8, PendingRequests> _pendingRequests;
|
||||
};
|
||||
|
@@ -3,14 +3,11 @@
|
||||
#include <utils/Logger.h>
|
||||
#include <utils/settings.h>
|
||||
|
||||
#include <utils/version.hpp>
|
||||
using namespace semver;
|
||||
#include <db/SettingsTable.h>
|
||||
|
||||
// qt includes
|
||||
#include <QJsonObject>
|
||||
|
||||
const int GLOABL_INSTANCE_ID = 255;
|
||||
|
||||
class Hyperion;
|
||||
class SettingsTable;
|
||||
|
||||
@@ -26,23 +23,21 @@ public:
|
||||
/// @params instance Instance index of HyperionInstanceManager
|
||||
/// @params parent The parent hyperion instance
|
||||
///
|
||||
SettingsManager(quint8 instance, QObject* parent = nullptr, bool readonlyMode = false);
|
||||
SettingsManager(quint8 instance = GLOABL_INSTANCE_ID, QObject* parent = nullptr);
|
||||
|
||||
///
|
||||
/// @brief Save a complete json configuration
|
||||
/// @brief Save a complete JSON configuration
|
||||
/// @param config The entire config object
|
||||
/// @param correct If true will correct json against schema before save
|
||||
/// @return True on success else false
|
||||
/// @return True on success else false, plus validation errors
|
||||
///
|
||||
bool saveSettings(QJsonObject config, bool correct = false);
|
||||
QPair<bool, QStringList> saveSettings(const QJsonObject& config);
|
||||
|
||||
///
|
||||
/// @brief Restore a complete json configuration
|
||||
/// @brief Correct a complete JSON configuration
|
||||
/// @param config The entire config object
|
||||
/// @param correct If true will correct json against schema before save
|
||||
/// @return True on success else false
|
||||
/// @return True on success else false, plus correction details
|
||||
///
|
||||
bool restoreSettings(QJsonObject config, bool correct = false);
|
||||
QPair<bool, QStringList> correctSettings(QJsonObject& config);
|
||||
|
||||
///
|
||||
/// @brief get a single setting json from configuration
|
||||
@@ -52,10 +47,18 @@ public:
|
||||
QJsonDocument getSetting(settings::type type) const;
|
||||
|
||||
///
|
||||
/// @brief get the full settings object of this instance (with global settings)
|
||||
/// @brief get a single setting json from configuration
|
||||
/// @param type The type as string
|
||||
/// @return The requested json data as QJsonDocument
|
||||
///
|
||||
QJsonDocument getSetting(const QString& type) const;
|
||||
|
||||
///
|
||||
/// @brief get the selected settings objects of this instance (including global settings)
|
||||
/// @return The requested json
|
||||
///
|
||||
QJsonObject getSettings() const;
|
||||
QJsonObject getSettings(const QStringList& filteredTypes = {}) const;
|
||||
QJsonObject getSettings(const QVariant& instance, const QStringList& filteredTypes = {} ) const;
|
||||
|
||||
signals:
|
||||
///
|
||||
@@ -71,31 +74,19 @@ private:
|
||||
/// @param config The configuration object
|
||||
/// @return True when a migration has been triggered
|
||||
///
|
||||
bool handleConfigUpgrade(QJsonObject& config);
|
||||
bool upgradeConfig(QJsonObject& config);
|
||||
|
||||
|
||||
bool resolveConfigVersion(QJsonObject& config);
|
||||
|
||||
/// Logger instance
|
||||
Logger* _log;
|
||||
|
||||
/// Hyperion instance
|
||||
Hyperion* _hyperion;
|
||||
|
||||
/// Instance number
|
||||
quint8 _instance;
|
||||
|
||||
/// instance of database table interface
|
||||
SettingsTable* _sTable;
|
||||
|
||||
/// the schema
|
||||
static QJsonObject schemaJson;
|
||||
|
||||
/// the current configuration of this instance
|
||||
QJsonObject _qconfig;
|
||||
|
||||
semver::version _configVersion;
|
||||
semver::version _previousVersion;
|
||||
|
||||
bool _readonlyMode;
|
||||
};
|
||||
|
Reference in New Issue
Block a user