diff --git a/CMakeLists.txt b/CMakeLists.txt index 7631baf6..da0774bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ SET ( HYPERION_VERSION_STABLE OFF ) SET ( HYPERION_VERSION_MAJOR 2 ) SET ( HYPERION_VERSION_MINOR 0 ) SET ( HYPERION_VERSION_PATCH 0 ) -SET ( CURRENT_CONFIG_VERSION 2 ) SET ( DEFAULT_AMLOGIC OFF ) SET ( DEFAULT_DISPMANX OFF ) @@ -160,7 +159,7 @@ IF ( ${CHECK_EFFECTS_FAILED} ) ENDIF () EXECUTE_PROCESS ( - COMMAND python test/jsonchecks/checkschema.py config/hyperion.config.json.default libsrc/hyperion/schemas/hyperion.schema-${CURRENT_CONFIG_VERSION}.json + COMMAND python test/jsonchecks/checkschema.py config/hyperion.config.json.default libsrc/hyperion/hyperion.schema.json WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} RESULT_VARIABLE CHECK_CONFIG_FAILED ) diff --git a/HyperionConfig.h.in b/HyperionConfig.h.in index 483d4ab7..db6cf109 100644 --- a/HyperionConfig.h.in +++ b/HyperionConfig.h.in @@ -30,9 +30,6 @@ // Define to enable profiler for development purpose #cmakedefine ENABLE_PROFILER -// Define version id of current config -#define CURRENT_CONFIG_VERSION ${CURRENT_CONFIG_VERSION} - // the hyperion build id string #define HYPERION_BUILD_ID "${HYPERION_BUILD_ID}" diff --git a/assets/webconfig/js/content_general.js b/assets/webconfig/js/content_general.js index 55cf7076..b1a91039 100644 --- a/assets/webconfig/js/content_general.js +++ b/assets/webconfig/js/content_general.js @@ -40,7 +40,7 @@ $(document).ready( function() { var r = new FileReader(); r.onload = function(e) { - var content = e.target.result; + var content = e.target.result.replace(/[^:]?\/\/.*/g, ''); //remove Comments //check file is json var check = isJsonString(content); @@ -56,7 +56,7 @@ $(document).ready( function() { if(typeof content.leds === 'undefined' || typeof content.general === 'undefined') { showInfoDialog('error', "", $.i18n('infoDialog_import_hyperror_text', f.name)); - dis_imp_btn(true); + dis_imp_btn(true); } else { diff --git a/include/utils/jsonschema/QJsonFactory.h b/include/utils/jsonschema/QJsonFactory.h index 89e5ef61..fb42ee38 100644 --- a/include/utils/jsonschema/QJsonFactory.h +++ b/include/utils/jsonschema/QJsonFactory.h @@ -25,17 +25,14 @@ public: // create the validator QJsonSchemaChecker schemaChecker; schemaChecker.setSchema(schemaTree); - - bool valid = schemaChecker.validate(configTree); QStringList messages = schemaChecker.getMessages(); - for (int i = 0; i < messages.size(); ++i) - { - std::cout << messages[i].toStdString() << std::endl; - } - - if (!valid) + + if (!schemaChecker.validate(configTree).first) { + for (int i = 0; i < messages.size(); ++i) + std::cout << messages[i].toStdString() << std::endl; + std::cerr << "Validation failed for configuration file: " << config.toStdString() << std::endl; return -3; } @@ -54,6 +51,7 @@ public: throw std::runtime_error(QString("Configuration file not found: '" + path + "' (" + file.errorString() + ")").toStdString()); } + //Allow Comments in Config QString config = QString(file.readAll()); config.remove(QRegularExpression("([^:]?\\/\\/.*)")); @@ -112,23 +110,62 @@ public: } } - throw std::runtime_error(QString("ERROR: Json schema wrong: " + error.errorString() + " at Line: " + QString::number(errorLine) - + ", Column: " + QString::number(errorColumn)).toStdString() - ); + throw std::runtime_error(QString("ERROR: Json schema wrong: " + error.errorString() + + " at Line: " + QString::number(errorLine) + + ", Column: " + QString::number(errorColumn)).toStdString()); } - return doc.object(); + return resolveReferences(doc.object()); } - static void writeJson(const QString& filename, QJsonObject& jsonTree) + static QJsonObject resolveReferences(const QJsonObject& schema) + { + QJsonObject result; + + for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i) + { + QString attribute = i.key(); + const QJsonValue & attributeValue = *i; + + if (attribute == "$ref" && attributeValue.isString()) + { + try + { + result = readSchema(":/" + attributeValue.toString()); + } + catch (std::runtime_error& error) + { + throw std::runtime_error(error.what()); + } + } + else if (attributeValue.isObject()) + result.insert(attribute, resolveReferences(attributeValue.toObject())); + else + result.insert(attribute, attributeValue); + } + + return result; + } + + static bool writeJson(const QString& filename, QJsonObject& jsonTree) { QJsonDocument doc; + doc.setObject(jsonTree); QByteArray configData = doc.toJson(QJsonDocument::Indented); - + QFile configFile(filename); - configFile.open(QIODevice::WriteOnly | QIODevice::Truncate); + if (!configFile.open(QFile::WriteOnly | QFile::Truncate)) + return false; + configFile.write(configData); + + QFile::FileError error = configFile.error(); + if (error != QFile::NoError) + return false; + configFile.close(); + + return true; } }; diff --git a/include/utils/jsonschema/QJsonSchemaChecker.h b/include/utils/jsonschema/QJsonSchemaChecker.h index cd32f89e..a0c4569f 100644 --- a/include/utils/jsonschema/QJsonSchemaChecker.h +++ b/include/utils/jsonschema/QJsonSchemaChecker.h @@ -5,6 +5,7 @@ #include #include #include +#include /// JsonSchemaChecker is a very basic implementation of json schema. /// The json schema definition draft can be found at @@ -33,13 +34,23 @@ public: /// @return true upon succes /// bool setSchema(const QJsonObject & schema); - + /// /// @brief Validate a JSON structure /// @param value The JSON value to check - /// @return true when the arguments is valid according to the schema + /// @param ignoreRequired Ignore the "required" keyword in hyperion schema. Default is false + /// @return The first boolean is true when the arguments is valid according to the schema. The second is true when the schema contains no errors + /// @return TODO: Check the Schema in SetSchema() function and remove the QPair result /// - bool validate(const QJsonObject & value, bool ignoreRequired = false); + QPair validate(const QJsonObject & value, bool ignoreRequired = false); + + /// + /// @brief Auto correct a JSON structure + /// @param value The JSON value to correct + /// @param ignoreRequired Ignore the "required" keyword in hyperion schema. Default is false + /// @return The corrected JSON structure + /// + QJsonObject getAutoCorrectedConfig(const QJsonObject & value, bool ignoreRequired = false); /// /// @return A list of error messages @@ -72,7 +83,7 @@ private: /// @param[in] value The given value /// @param[in] schema The specified type (as json-value) /// - void checkType(const QJsonValue & value, const QJsonValue & schema); + void checkType(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); /// /// Checks is required properties of an json-object exist and if all properties are of the @@ -101,7 +112,7 @@ private: /// @param[in] value The given value /// @param[in] schema The minimum value (as json-value) /// - void checkMinimum(const QJsonValue & value, const QJsonValue & schema); + void checkMinimum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); /// /// Checks if the given value is smaller or equal to the specified value. If this is not the @@ -110,7 +121,7 @@ private: /// @param[in] value The given value /// @param[in] schema The maximum value (as json-value) /// - void checkMaximum(const QJsonValue & value, const QJsonValue & schema); + void checkMaximum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); /// /// Checks if the given value is hugher than the specified value. If this is the @@ -119,7 +130,7 @@ private: /// @param value The given value /// @param schema The minimum size specification (as json-value) /// - void checkMinLength(const QJsonValue & value, const QJsonValue & schema); + void checkMinLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); /// /// Checks if the given value is smaller than the specified value. If this is the @@ -128,7 +139,7 @@ private: /// @param value The given value /// @param schema The maximum size specification (as json-value) /// - void checkMaxLength(const QJsonValue & value, const QJsonValue & schema); + void checkMaxLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); /// /// Validates all the items of an array. @@ -145,7 +156,7 @@ private: /// @param value The json-array /// @param schema The minimum size specification (as json-value) /// - void checkMinItems(const QJsonValue & value, const QJsonValue & schema); + void checkMinItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); /// /// Checks if a given array has at most a maximum number of items. If this is not the case @@ -154,7 +165,7 @@ private: /// @param value The json-array /// @param schema The maximum size specification (as json-value) /// - void checkMaxItems(const QJsonValue & value, const QJsonValue & schema); + void checkMaxItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); /// /// Checks if a given array contains only unique items. If this is not the case @@ -172,17 +183,23 @@ private: /// @param value The enum value /// @param schema The enum schema definition /// - void checkEnum(const QJsonValue & value, const QJsonValue & schema); + void checkEnum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue); private: /// The schema of the entire json-configuration QJsonObject _qSchema; /// ignore the required value in json schema bool _ignoreRequired; + /// Auto correction variable + QString _correct; + /// The auto corrected json-configuration + QJsonObject _autoCorrected; /// The current location into a json-configuration structure being checked QStringList _currentPath; /// The result messages collected during the schema verification QStringList _messages; /// Flag indicating an error occured during validation bool _error; + /// Flag indicating an schema error occured during validation + bool _schemaError; }; diff --git a/include/utils/jsonschema/QJsonUtils.h b/include/utils/jsonschema/QJsonUtils.h new file mode 100644 index 00000000..60381dbe --- /dev/null +++ b/include/utils/jsonschema/QJsonUtils.h @@ -0,0 +1,273 @@ +#pragma once + +// QT include +#include +#include +#include +#include +#include + +class QJsonUtils +{ +public: + + static void modify(QJsonObject& value, QStringList path, const QJsonValue& newValue = QJsonValue::Null, QString propertyName = "") + { + QJsonObject result; + + if (!path.isEmpty()) + { + if (path.first() == "[root]") + path.removeFirst(); + + for (QStringList::iterator it = path.begin(); it != path.end(); ++it) + { + QString current = *it; + if (current.left(1) == ".") + *it = current.mid(1, current.size()-1); + } + + if (!value.isEmpty()) + modifyValue(value, result, path, newValue, propertyName); + else if (newValue != QJsonValue::Null && !propertyName.isEmpty()) + result[propertyName] = newValue; + } + + value = result; + } + + static QJsonValue create(QJsonValue schema, bool ignoreRequired = false) + { + return createValue(schema, ignoreRequired); + } + +private: + + static QJsonValue createValue(QJsonValue schema, bool ignoreRequired) + { + QJsonObject result; + QJsonObject obj = schema.toObject(); + + if (obj.find("type") != obj.end() && obj.find("type").value().isString()) + { + QJsonValue ret = QJsonValue::Null; + + if (obj.find("type").value().toString() == "object" && ( obj.find("required").value().toBool() || ignoreRequired ) ) + ret = createValue(obj["properties"], ignoreRequired); + else if (obj.find("type").value().toString() == "array" && ( obj.find("required").value().toBool() || ignoreRequired ) ) + { + QJsonArray array; + + if (obj.find("default") != obj.end()) + ret = obj.find("default").value(); + else + { + ret = createValue(obj["items"], ignoreRequired); + + if (!ret.toObject().isEmpty()) + array.append(ret); + ret = array; + } + } + else if ( obj.find("required").value().toBool() || ignoreRequired ) + if (obj.find("default") != obj.end()) + ret = obj.find("default").value(); + + return ret; + } + else + { + for (QJsonObject::const_iterator i = obj.begin(); i != obj.end(); ++i) + { + QString attribute = i.key(); + const QJsonValue & attributeValue = *i; + QJsonValue subValue = obj[attribute]; + + if (attributeValue.toObject().find("type") != attributeValue.toObject().end()) + { + if (attributeValue.toObject().find("type").value().toString() == "object" && ( attributeValue.toObject().find("required").value().toBool() || ignoreRequired ) ) + { + if (obj.contains("properties")) + result[attribute] = createValue(obj["properties"], ignoreRequired); + else + result[attribute] = createValue(subValue, ignoreRequired); + } + else if (attributeValue.toObject().find("type").value().toString() == "array" && ( attributeValue.toObject().find("required").value().toBool() || ignoreRequired ) ) + { + QJsonArray array; + + if (attributeValue.toObject().find("default") != attributeValue.toObject().end()) + result[attribute] = attributeValue.toObject().find("default").value(); + else + { + QJsonValue retEmpty; + retEmpty = createValue(attributeValue.toObject()["items"], ignoreRequired); + + if (!retEmpty.toObject().isEmpty()) + array.append(retEmpty); + result[attribute] = array; + } + } + else if ( attributeValue.toObject().find("required").value().toBool() || ignoreRequired ) + { + if (attributeValue.toObject().find("default") != attributeValue.toObject().end()) + result[attribute] = attributeValue.toObject().find("default").value(); + else + result[attribute] = QJsonValue::Null; + } + } + } + } + + return result; + } + + static void modifyValue(QJsonValue source, QJsonObject& target, QStringList path, const QJsonValue& newValue, QString& property) + { + QJsonObject obj = source.toObject(); + + if (!obj.isEmpty()) + { + for (QJsonObject::iterator i = obj.begin(); i != obj.end(); ++i) + { + QString propertyName = i.key(); + QJsonValue subValue = obj[propertyName]; + + if (subValue.isObject()) + { + if (!path.isEmpty()) + { + if (propertyName == path.first()) + { + path.removeFirst(); + + if (!path.isEmpty()) + { + QJsonObject obj; + modifyValue(subValue, obj, path, newValue, property); + subValue = obj; + } + else if (newValue != QJsonValue::Null) + subValue = newValue; + else + continue; + + if (!subValue.toObject().isEmpty()) + target[propertyName] = subValue; + } + else + { + if (path.first() == property && newValue != QJsonValue::Null) + { + target[property] = newValue; + property = QString(); + } + + target[propertyName] = subValue; + } + } + else + if (!subValue.toObject().isEmpty()) + target[propertyName] = subValue; + } + else if (subValue.isArray()) + { + if (!path.isEmpty()) + { + if (propertyName == path.first()) + { + path.removeFirst(); + + int arrayLevel = -1; + if (!path.isEmpty()) + { + if ((path.first().left(1) == "[") && (path.first().right(1) == "]")) + { + arrayLevel = path.first().mid(1, path.first().size()-2).toInt(); + path.removeFirst(); + } + } + + QJsonArray array = subValue.toArray(); + QJsonArray json_array; + + for (QJsonArray::iterator i = array.begin(); i != array.end(); ++i) + { + if (!path.isEmpty()) + { + QJsonObject arr; + modifyValue(*i, arr, path, newValue, property); + subValue = arr; + } + else if (newValue != QJsonValue::Null) + subValue = newValue; + else + continue; + + if (!subValue.toObject().isEmpty()) + json_array.append(subValue); + else if (newValue != QJsonValue::Null && arrayLevel != -1) + json_array.append( (i - array.begin() == arrayLevel) ? subValue : *i ); + } + + if (!json_array.isEmpty()) + target[propertyName] = json_array; + else if (newValue != QJsonValue::Null && arrayLevel == -1) + target[propertyName] = newValue; + } + else + { + if (path.first() == property && newValue != QJsonValue::Null) + { + target[property] = newValue; + property = QString(); + } + + target[propertyName] = subValue; + } + } + else + if (!subValue.toArray().isEmpty()) + target[propertyName] = subValue; + } + else + { + if (!path.isEmpty()) + { + if (propertyName == path.first()) + { + path.removeFirst(); + + if (path.isEmpty()) + { + if (newValue != QJsonValue::Null && property.isEmpty()) + subValue = newValue; + else + continue; + } + + target[propertyName] = subValue; + } + else + { + if (path.first() == property && newValue != QJsonValue::Null) + { + target[property] = newValue; + property = QString(); + } + + target[propertyName] = subValue; + } + } + else + target[propertyName] = subValue; + } + } + } + else if (newValue != QJsonValue::Null && !property.isEmpty()) + { + target[property] = newValue; + property = QString(); + } + } +}; diff --git a/libsrc/effectengine/EffectEngine.cpp b/libsrc/effectengine/EffectEngine.cpp index 327c9d87..a064cb59 100644 --- a/libsrc/effectengine/EffectEngine.cpp +++ b/libsrc/effectengine/EffectEngine.cpp @@ -150,7 +150,7 @@ bool EffectEngine::loadEffectDefinition(const QString &path, const QString &effe QJsonSchemaChecker schemaChecker; schemaChecker.setSchema(configSchema.object()); - if (!schemaChecker.validate(configEffect.object())) + if (!schemaChecker.validate(configEffect.object()).first) { const QStringList & errors = schemaChecker.getMessages(); foreach (auto & error, errors) diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json index 47151a01..3fd91e8a 100644 --- a/libsrc/hyperion/hyperion.schema.json +++ b/libsrc/hyperion/hyperion.schema.json @@ -5,9 +5,84 @@ { "general" : { - "type" : "object", - "required" : true + "$ref": "schema-general.json" + }, + "logger" : + { + "$ref": "schema-logger.json" + }, + "device" : + { + "$ref": "schema-device.json" + }, + "color" : + { + "$ref": "schema-color.json" + }, + "smoothing": + { + "$ref": "schema-smoothing.json" + }, + "grabberV4L2" : + { + "$ref": "schema-grabberV4L2.json" + }, + "framegrabber" : + { + "$ref": "schema-framegrabber.json" + }, + "blackborderdetector" : + { + "$ref": "schema-blackborderdetector.json" + }, + "kodiVideoChecker" : + { + "$ref": "schema-kodiVideoChecker.json" + }, + "foregroundEffect" : + { + "$ref": "schema-foregroundEffect.json" + }, + "backgroundEffect" : + { + "$ref": "schema-backgroundEffect.json" + }, + "forwarder" : + { + "$ref": "schema-forwarder.json" + }, + "jsonServer" : + { + "$ref": "schema-jsonServer.json" + }, + "protoServer" : + { + "$ref": "schema-protoServer.json" + }, + "boblightServer" : + { + "$ref": "schema-boblightServer.json" + }, + "udpListener" : + { + "$ref": "schema-udpListener.json" + }, + "webConfig" : + { + "$ref": "schema-webConfig.json" + }, + "effects" : + { + "$ref": "schema-effects.json" + }, + "ledConfig": + { + "$ref": "schema-ledConfig.json" + }, + "leds": + { + "$ref": "schema-leds.json" } }, - "additionalProperties" : true + "additionalProperties" : false } diff --git a/libsrc/hyperion/resource.qrc b/libsrc/hyperion/resource.qrc index cfd09a60..8bb420c2 100644 --- a/libsrc/hyperion/resource.qrc +++ b/libsrc/hyperion/resource.qrc @@ -1,8 +1,26 @@ - - hyperion.schema.json - schemas/hyperion.schema-1.json - schemas/hyperion.schema-2.json - ../../config/hyperion.config.json.default - + + hyperion.schema.json + ../../config/hyperion.config.json.default + schema/schema-general.json + schema/schema-logger.json + schema/schema-device.json + schema/schema-color.json + schema/schema-smoothing.json + schema/schema-grabberV4L2.json + schema/schema-framegrabber.json + schema/schema-blackborderdetector.json + schema/schema-kodiVideoChecker.json + schema/schema-foregroundEffect.json + schema/schema-backgroundEffect.json + schema/schema-forwarder.json + schema/schema-jsonServer.json + schema/schema-protoServer.json + schema/schema-boblightServer.json + schema/schema-udpListener.json + schema/schema-webConfig.json + schema/schema-effects.json + schema/schema-ledConfig.json + schema/schema-leds.json + diff --git a/libsrc/hyperion/schema/schema-backgroundEffect.json b/libsrc/hyperion/schema/schema-backgroundEffect.json new file mode 100644 index 00000000..ffd47791 --- /dev/null +++ b/libsrc/hyperion/schema/schema-backgroundEffect.json @@ -0,0 +1,48 @@ +{ + "type" : "object", + "title" : "edt_conf_bge_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : true, + "propertyOrder" : 1 + }, + "type" : + { + "type" : "string", + "title" : "edt_conf_fge_type_title", + "enum" : ["color", "effect"], + "default" : "effect", + "options" : { + "enum_titles" : ["edt_conf_enum_color", "edt_conf_enum_effect"] + }, + "propertyOrder" : 2 + }, + "color" : + { + "type" : "array", + "format" : "colorpicker", + "title" : "edt_conf_fge_color_title", + "default" : [255,138,0], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 3 + }, + "effect" : + { + "type" : "string", + "format" : "select", + "title" : "edt_conf_fge_effect_title", + "propertyOrder" : 4 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-blackborderdetector.json b/libsrc/hyperion/schema/schema-blackborderdetector.json new file mode 100644 index 00000000..2b73d019 --- /dev/null +++ b/libsrc/hyperion/schema/schema-blackborderdetector.json @@ -0,0 +1,72 @@ +{ + "type" : "object", + "title" : "edt_conf_bb_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : true, + "propertyOrder" : 1 + }, + "threshold" : + { + "type" : "integer", + "title" : "edt_conf_bb_threshold_title", + "minimum" : 0, + "maximum" : 100, + "default" : 5, + "append" : "edt_append_percent", + "propertyOrder" : 2 + }, + "unknownFrameCnt" : + { + "type" : "integer", + "title" : "edt_conf_bb_unknownFrameCnt_title", + "minimum" : 0, + "default" : 600, + "access" : "expert", + "propertyOrder" : 3 + }, + "borderFrameCnt" : + { + "type" : "integer", + "title" : "edt_conf_bb_borderFrameCnt_title", + "minimum" : 0, + "default" : 50, + "access" : "expert", + "propertyOrder" : 4 + }, + "maxInconsistentCnt" : + { + "type" : "integer", + "title" : "edt_conf_bb_maxInconsistentCnt_title", + "minimum" : 0, + "default" : 10, + "access" : "expert", + "propertyOrder" : 5 + }, + "blurRemoveCnt" : + { + "type" : "integer", + "title" : "edt_conf_bb_blurRemoveCnt_title", + "minimum" : 0, + "default" : 1, + "access" : "expert", + "propertyOrder" : 6 + }, + "mode" : + { + "type" : "string", + "title": "edt_conf_bb_mode_title", + "enum" : ["default", "classic", "osd"], + "default" : "default", + "options" : { + "enum_titles" : ["edt_conf_enum_bbdefault", "edt_conf_enum_bbclassic", "edt_conf_enum_bbosd"] + }, + "propertyOrder" : 7 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-boblightServer.json b/libsrc/hyperion/schema/schema-boblightServer.json new file mode 100644 index 00000000..22758038 --- /dev/null +++ b/libsrc/hyperion/schema/schema-boblightServer.json @@ -0,0 +1,33 @@ +{ + "type" : "object", + "title" : "edt_conf_bobls_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : false, + "propertyOrder" : 1 + }, + "port" : + { + "type" : "integer", + "required" : true, + "title" : "edt_conf_general_port_title", + "minimum" : 0, + "maximum" : 65535, + "propertyOrder" : 2 + }, + "priority" : + { + "type" : "integer", + "title" : "edt_conf_general_priority_title", + "minimum" : 100, + "maximum" : 254, + "default" : 201, + "propertyOrder" : 3 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-color.json b/libsrc/hyperion/schema/schema-color.json new file mode 100644 index 00000000..9ef5ea26 --- /dev/null +++ b/libsrc/hyperion/schema/schema-color.json @@ -0,0 +1,257 @@ +{ + "type":"object", + "title" : "edt_conf_color_heading_title", + "required" : true, + "properties": + { + "imageToLedMappingType" : + { + "type" : "string", + "required" : true, + "title" : "edt_conf_color_imageToLedMappingType_title", + "enum" : ["multicolor_mean", "unicolor_mean"], + "default" : "multicolor_mean", + "options" : { + "enum_titles" : ["edt_conf_enum_multicolor_mean", "edt_conf_enum_unicolor_mean"] + }, + "propertyOrder" : 1 + }, + "channelAdjustment" : + { + "type" : "array", + "title" : "edt_conf_color_channelAdjustment_header_title", + "required" : true, + "propertyOrder" : 3, + "items" : + { + "type" : "object", + "required" : true, + "title" : "edt_conf_color_channelAdjustment_header_itemtitle", + "properties" : + { + "id" : + { + "type" : "string", + "title" : "edt_conf_color_id_title", + "required" : true, + "default" : "A userdefined name", + "propertyOrder" : 1 + }, + "leds" : + { + "type" : "string", + "title" : "edt_conf_color_leds_title", + "required" : true, + "default" : "*", + "propertyOrder" : 2 + }, + "black" : + { + "type" : "array", + "title" : "edt_conf_color_black_title", + "format" : "colorpicker", + "required" : true, + "default": [0,0,0], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 3 + }, + "white" : + { + "type" : "array", + "title" : "edt_conf_color_white_title", + "format" : "colorpicker", + "required" : true, + "default": [255,255,255], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 4 + }, + "red" : + { + "type" : "array", + "title" : "edt_conf_color_red_title", + "format" : "colorpicker", + "required" : true, + "default": [255,0,0], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 5 + }, + "green" : + { + "type" : "array", + "title" : "edt_conf_color_green_title", + "format" : "colorpicker", + "required" : true, + "default": [0,255,0], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 6 + }, + "blue" : + { + "type" : "array", + "title" : "edt_conf_color_blue_title", + "format" : "colorpicker", + "required" : true, + "default": [0,0,255], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 7 + }, + "cyan" : + { + "type" : "array", + "title" : "edt_conf_color_cyan_title", + "format" : "colorpicker", + "required" : true, + "default": [0,255,255], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 8 + }, + "magenta" : + { + "type" : "array", + "title" : "edt_conf_color_magenta_title", + "format" : "colorpicker", + "required" : true, + "default": [255,0,255], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 9 + }, + "yellow" : + { + "type" : "array", + "title" : "edt_conf_color_yellow_title", + "format" : "colorpicker", + "required" : true, + "default": [255,255,0], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 10 + }, + "backlightThreshold" : + { + "type" : "integer", + "title" : "edt_conf_color_backlightThreshold_title", + "required" : true, + "minimum" : 0, + "maximum": 100, + "default" : 0, + "append" : "edt_append_percent", + "propertyOrder" : 11 + }, + "backlightColored" : + { + "type" : "boolean", + "title" : "edt_conf_color_backlightColored_title", + "required" : true, + "default" : false, + "propertyOrder" : 12 + }, + "brightness" : + { + "type" : "integer", + "title" : "edt_conf_color_brightness_title", + "required" : true, + "minimum" : 0, + "maximum": 100, + "default" : 100, + "append" : "edt_append_percent", + "propertyOrder" : 13 + }, + "brightnessCompensation" : + { + "type" : "integer", + "title" : "edt_conf_color_brightnessComp_title", + "required" : true, + "minimum" : 0, + "maximum": 100, + "default" : 90, + "append" : "edt_append_percent", + "access" : "advanced", + "propertyOrder" : 14 + }, + "gammaRed" : + { + "type" : "number", + "title" : "edt_conf_color_gammaRed_title", + "required" : true, + "minimum" : 0.1, + "maximum": 100.0, + "default" : 1.5, + "step" : 0.1, + "propertyOrder" : 15 + }, + "gammaGreen" : + { + "type" : "number", + "title" : "edt_conf_color_gammaGreen_title", + "required" : true, + "minimum" : 0.1, + "maximum": 100.0, + "default" : 1.5, + "step" : 0.1, + "propertyOrder" : 16 + }, + "gammaBlue" : + { + "type" : "number", + "title" : "edt_conf_color_gammaBlue_title", + "required" : true, + "minimum" : 0.1, + "maximum": 100.0, + "default" : 1.5, + "step" : 0.1, + "propertyOrder" : 17 + } + }, + "additionalProperties" : false + } + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-device.json b/libsrc/hyperion/schema/schema-device.json new file mode 100644 index 00000000..53556c79 --- /dev/null +++ b/libsrc/hyperion/schema/schema-device.json @@ -0,0 +1,41 @@ +{ + "type" : "object", + "title" : "edt_dev_general_heading_title", + "required" : true, + "defaultProperties": ["ledCount","colorOrder","rewriteTime","minimumWriteTime"], + "properties" : + { + "type" : + { + "type" : "string" + }, + "ledCount" : + { + "type" : "integer", + "minimum" : 0, + "title" : "edt_dev_general_ledCount_title", + "propertyOrder" : 2 + }, + "colorOrder" : + { + "type" : "string", + "title" : "edt_dev_general_colorOrder_title", + "enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"], + "default" : "rgb", + "options" : { + "enum_titles" : ["edt_conf_enum_rgb", "edt_conf_enum_bgr", "edt_conf_enum_rbg", "edt_conf_enum_brg", "edt_conf_enum_gbr", "edt_conf_enum_grb"] + }, + "propertyOrder" : 3 + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 4 + } + }, + "additionalProperties" : true +} diff --git a/libsrc/hyperion/schema/schema-effects.json b/libsrc/hyperion/schema/schema-effects.json new file mode 100644 index 00000000..e872d96f --- /dev/null +++ b/libsrc/hyperion/schema/schema-effects.json @@ -0,0 +1,29 @@ +{ + "type" : "object", + "title" : "edt_conf_effp_heading_title", + "properties" : + { + "paths" : + { + "type" : "array", + "title" : "edt_conf_effp_paths_title", + "default" : ["../custom-effects"], + "items" : { + "type": "string", + "title" : "edt_conf_effp_paths_itemtitle" + }, + "propertyOrder" : 1 + }, + "disable" : + { + "type" : "array", + "title" : "edt_conf_effp_disable_title", + "items" : { + "type": "string", + "title" : "edt_conf_effp_disable_itemtitle" + }, + "propertyOrder" : 2 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-foregroundEffect.json b/libsrc/hyperion/schema/schema-foregroundEffect.json new file mode 100644 index 00000000..bb70904c --- /dev/null +++ b/libsrc/hyperion/schema/schema-foregroundEffect.json @@ -0,0 +1,57 @@ +{ + "type" : "object", + "title" : "edt_conf_fge_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : true, + "propertyOrder" : 1 + }, + "type" : + { + "type" : "string", + "title" : "edt_conf_fge_type_title", + "enum" : ["color", "effect"], + "default" : "effect", + "options" : { + "enum_titles" : ["edt_conf_enum_color", "edt_conf_enum_effect"] + }, + "propertyOrder" : 2 + }, + "color" : + { + "type" : "array", + "format" : "colorpicker", + "title" : "edt_conf_fge_color_title", + "default" : [255,0,0], + "items" : { + "type" : "integer", + "minimum" : 0, + "maximum" : 255 + }, + "minItems" : 3, + "maxItems" : 3, + "propertyOrder" : 3 + }, + "effect" : + { + "type" : "string", + "format" : "select", + "title" : "edt_conf_fge_effect_title", + "propertyOrder" : 4 + }, + "duration_ms" : + { + "type" : "integer", + "title" : "edt_conf_fge_duration_ms_title", + "default" : 3000, + "minimum" : 100, + "append" : "edt_append_ms", + "propertyOrder" : 5 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-forwarder.json b/libsrc/hyperion/schema/schema-forwarder.json new file mode 100644 index 00000000..9ee2d67b --- /dev/null +++ b/libsrc/hyperion/schema/schema-forwarder.json @@ -0,0 +1,36 @@ +{ + "type" : "object", + "title" : "edt_conf_fw_heading_title", + "required" : true, + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "propertyOrder" : 1 + }, + "json" : + { + "type" : "array", + "title" : "edt_conf_fw_json_title", + "required" : true, + "items" : { + "type": "string", + "title" : "edt_conf_fw_json_itemtitle" + }, + "propertyOrder" : 2 + }, + "proto" : + { + "type" : "array", + "title" : "edt_conf_fw_proto_title", + "items" : { + "type": "string", + "title" : "edt_conf_fw_proto_itemtitle" + }, + "propertyOrder" : 3 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-framegrabber.json b/libsrc/hyperion/schema/schema-framegrabber.json new file mode 100644 index 00000000..366d05b6 --- /dev/null +++ b/libsrc/hyperion/schema/schema-framegrabber.json @@ -0,0 +1,132 @@ +{ + "type" : "object", + "title" : "edt_conf_fg_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : true, + "propertyOrder" : 1 + }, + "type" : + { + "type" : "string", + "title" : "edt_conf_fg_type_title", + "enum" : ["auto","dispmanx","amlogic","x11","framebuffer"], + "default" : "auto", + "propertyOrder" : 2 + }, + "width" : + { + "type" : "integer", + "title" : "edt_conf_fg_width_title", + "minimum" : 10, + "default" : 80, + "append" : "edt_append_pixel", + "propertyOrder" : 3 + }, + "height" : + { + "type" : "integer", + "title" : "edt_conf_fg_height_title", + "minimum" : 10, + "default" : 45, + "append" : "edt_append_pixel", + "propertyOrder" : 3 + }, + "frequency_Hz" : + { + "type" : "integer", + "title" : "edt_conf_fg_frequency_Hz_title", + "minimum" : 1, + "default" : 10, + "append" : "edt_append_hz", + "propertyOrder" : 4 + }, + "priority" : + { + "type" : "integer", + "title" : "edt_conf_general_priority_title", + "minimum" : 100, + "maximum" : 254, + "default" : 250, + "propertyOrder" : 5 + }, + "cropLeft" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropLeft_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 6 + }, + "cropRight" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropRight_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 7 + }, + "cropTop" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropTop_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 8 + }, + "cropBottom" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropBottom_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 9 + }, + "useXGetImage" : + { + "type" : "boolean", + "title" : "edt_conf_fg_useXGetImage_title", + "default" : false, + "propertyOrder" : 10 + }, + "horizontalPixelDecimation" : + { + "type" : "integer", + "title" : "edt_conf_fg_horizontalPixelDecimation_title", + "minimum" : 0, + "default" : 8, + "propertyOrder" : 11 + }, + "verticalPixelDecimation" : + { + "type" : "integer", + "title" : "edt_conf_fg_verticalPixelDecimation_title", + "minimum" : 0, + "default" : 8, + "propertyOrder" : 12 + }, + "device" : + { + "type" : "string", + "title" : "edt_conf_fg_device_title", + "default" : "/dev/fb0", + "propertyOrder" : 13 + }, + "display" : + { + "type" : "integer", + "title" : "edt_conf_fg_display_title", + "minimum" : 0, + "propertyOrder" : 14 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-general.json b/libsrc/hyperion/schema/schema-general.json new file mode 100644 index 00000000..af73ecf6 --- /dev/null +++ b/libsrc/hyperion/schema/schema-general.json @@ -0,0 +1,34 @@ +{ + "type" : "object", + "title" : "edt_conf_gen_heading_title", + "required" : true, + "properties" : + { + "name" : + { + "type" : "string", + "title" : "edt_conf_gen_name_title", + "default" : "My Hyperion Config", + "minLength" : 4, + "maxLength" : 20, + "required" : true, + "propertyOrder" : 1 + }, + "showOptHelp" : + { + "type" : "boolean", + "title" : "edt_conf_gen_showOptHelp_title", + "default" : true, + "required" : true, + "propertyOrder" : 2 + }, + "configVersion" : + { + "type" : "integer", + "default" : 2, + "minimum" : 1, + "access" : "system", + "required" : true + } + } +} diff --git a/libsrc/hyperion/schema/schema-grabberV4L2.json b/libsrc/hyperion/schema/schema-grabberV4L2.json new file mode 100644 index 00000000..4eebf510 --- /dev/null +++ b/libsrc/hyperion/schema/schema-grabberV4L2.json @@ -0,0 +1,226 @@ +{ + "type":"array", + "title" : "edt_conf_v4l2_heading_title", + "minItems": 1, + "maxItems": 2, + "items": + { + "type" : "object", + "title" : "edt_conf_v4l2_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : false, + "propertyOrder" : 1 + }, + "device" : + { + "type" : "string", + "title" : "edt_conf_v4l2_device_title", + "default" : "auto", + "propertyOrder" : 2 + }, + "input" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_input_title", + "minimum" : 0, + "default" : 0, + "propertyOrder" : 3 + }, + "standard" : + { + "type" : "string", + "title" : "edt_conf_v4l2_standard_title", + "enum" : ["PAL","NTSC"], + "default" : "PAL", + "options" : { + "enum_titles" : ["edt_conf_enum_PAL", "edt_conf_enum_NTSC"] + }, + "propertyOrder" : 4 + }, + "width" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_width_title", + "minimum" : -1, + "default" : -1, + "append" : "edt_append_pixel", + "propertyOrder" : 5 + }, + "height" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_height_title", + "minimum" : -1, + "default" : -1, + "append" : "edt_append_pixel", + "propertyOrder" : 6 + }, + "frameDecimation" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_frameDecimation_title", + "minimum" : 0, + "default" : 2, + "propertyOrder" : 7 + }, + "sizeDecimation" : + { + "type" : "integer", + "title" : "Size decimation", + "minimum" : 0, + "default" : 6, + "propertyOrder" : 8 + }, + "priority" : + { + "type" : "integer", + "minimum" : 100, + "maximum" : 253, + "title" : "edt_conf_general_priority_title", + "default" : 240, + "propertyOrder" : 9 + }, + "mode" : + { + "type" : "string", + "title" : "edt_conf_v4l2_mode_title", + "enum" : ["2D","3DSBS","3DTAB"], + "default" : "2D", + "propertyOrder" : 10 + }, + "useKodiChecker" : + { + "type" : "boolean", + "title" : "edt_conf_v4l2_useKodiChecker_title", + "default" : false, + "propertyOrder" : 11 + }, + "cropLeft" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropLeft_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 12 + }, + "cropRight" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropRight_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 13 + }, + "cropTop" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropTop_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 14 + }, + "cropBottom" : + { + "type" : "integer", + "title" : "edt_conf_v4l2_cropBottom_title", + "minimum" : 0, + "default" : 0, + "append" : "edt_append_pixel", + "propertyOrder" : 15 + }, + "signalDetection" : + { + "type" : "boolean", + "title" : "edt_conf_v4l2_signalDetection_title", + "default" : true, + "propertyOrder" : 16 + }, + "redSignalThreshold" : + { + "type" : "number", + "title" : "edt_conf_v4l2_redSignalThreshold_title", + "minimum" : 0.0, + "maximum" : 1.0, + "default" : 0.1, + "step" : 0.005, + "append" : "edt_append_percent", + "propertyOrder" : 17 + }, + "greenSignalThreshold" : + { + "type" : "number", + "title" : "edt_conf_v4l2_greenSignalThreshold_title", + "minimum" : 0.0, + "maximum" : 1.0, + "default" : 0.1, + "step" : 0.025, + "append" : "edt_append_percent", + "propertyOrder" : 18 + }, + "blueSignalThreshold" : + { + "type" : "number", + "title" : "edt_conf_v4l2_blueSignalThreshold_title", + "minimum" : 0.0, + "maximum" : 1.0, + "default" : 0.1, + "step" : 0.005, + "append" : "edt_append_percent", + "propertyOrder" : 19 + }, + "signalDetectionVerticalOffsetMin" : + { + "type" : "number", + "title" : "edt_conf_v4l2_signalDetectionVerticalOffsetMin_title", + "minimum" : 0.0, + "maximum" : 1.0, + "default" : 0.1, + "step" : 0.005, + "append" : "edt_append_percent", + "propertyOrder" : 20 + }, + "signalDetectionVerticalOffsetMax" : + { + "type" : "number", + "title" : "edt_conf_v4l2_signalDetectionVerticalOffsetMax_title", + "minimum" : 0.0, + "maximum" : 1.0, + "default" : 0.1, + "step" : 0.005, + "append" : "edt_append_percent", + "propertyOrder" : 21 + }, + "signalDetectionHorizontalOffsetMin" : + { + "type" : "number", + "title" : "edt_conf_v4l2_signalDetectionHorizontalOffsetMin_title", + "minimum" : 0.0, + "maximum" : 1.0, + "default" : 0.1, + "step" : 0.005, + "append" : "edt_append_percent", + "propertyOrder" : 22 + }, + "signalDetectionHorizontalOffsetMax" : + { + "type" : "number", + "title" : "edt_conf_v4l2_signalDetectionHorizontalOffsetMax_title", + "minimum" : 0.0, + "maximum" : 1.0, + "default" : 0.1, + "step" : 0.005, + "append" : "edt_append_percent", + "propertyOrder" : 23 + } + }, + "additionalProperties" : false + } +} diff --git a/libsrc/hyperion/schema/schema-jsonServer.json b/libsrc/hyperion/schema/schema-jsonServer.json new file mode 100644 index 00000000..722f7f4f --- /dev/null +++ b/libsrc/hyperion/schema/schema-jsonServer.json @@ -0,0 +1,18 @@ +{ + "type" : "object", + "required" : true, + "title" : "edt_conf_js_heading_title", + "properties" : + { + "port" : + { + "type" : "integer", + "required" : true, + "title" : "edt_conf_general_port_title", + "minimum" : 0, + "maximum" : 65535, + "default" : 19444 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-kodiVideoChecker.json b/libsrc/hyperion/schema/schema-kodiVideoChecker.json new file mode 100644 index 00000000..d9d757ae --- /dev/null +++ b/libsrc/hyperion/schema/schema-kodiVideoChecker.json @@ -0,0 +1,80 @@ +{ + "type" : "object", + "title" : "edt_conf_kodic_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : false, + "propertyOrder" : 1 + }, + "kodiAddress" : + { + "type" : "string", + "title" : "edt_conf_kodic_kodiAddress_title", + "default" : "127.0.0.1", + "propertyOrder" : 2 + }, + "kodiTcpPort" : + { + "type" : "integer", + "title" : "edt_conf_kodic_kodiTcpPort_title", + "minimum" : 0, + "maximum" : 65535, + "default" : 9090, + "propertyOrder" : 3 + }, + "grabVideo" : + { + "type" : "boolean", + "title" : "edt_conf_kodic_grabVideo_title", + "default" : true, + "propertyOrder" : 4 + }, + "grabPictures" : + { + "type" : "boolean", + "title" : "edt_conf_kodic_grabPictures_title", + "default" : true, + "propertyOrder" : 5 + }, + "grabAudio" : + { + "type" : "boolean", + "title" : "edt_conf_kodic_grabAudio_title", + "default" : true, + "propertyOrder" : 6 + }, + "grabMenu" : + { + "type" : "boolean", + "title" : "edt_conf_kodic_grabMenu_title", + "default" : false, + "propertyOrder" : 7 + }, + "grabPause" : + { + "type" : "boolean", + "title" : "edt_conf_kodic_grabPause_title", + "default" : false, + "propertyOrder" : 8 + }, + "grabScreensaver" : + { + "type" : "boolean", + "title" : "edt_conf_kodic_grabScreensaver_title", + "default" : false, + "propertyOrder" : 9 + }, + "enable3DDetection" : + { + "type" : "boolean", + "title" : "edt_conf_kodic_enable3DDetection_title", + "default" : false, + "propertyOrder" : 10 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-ledConfig.json b/libsrc/hyperion/schema/schema-ledConfig.json new file mode 100644 index 00000000..b05f581c --- /dev/null +++ b/libsrc/hyperion/schema/schema-ledConfig.json @@ -0,0 +1,80 @@ +{ + "type" : "object", + "properties" : + { + "top" : + { + "type" : "integer", + "minimum" : 0, + "default" : 8 + }, + "bottom" : + { + "type" : "integer", + "minimum" : 0, + "default" : 8 + }, + "left" : + { + "type" : "integer", + "minimum" : 0, + "default" : 5 + }, + "right" : + { + "type" : "integer", + "minimum" : 0, + "default" : 5 + }, + "glength" : + { + "type" : "integer", + "minimum" : 0, + "default" : 0 + }, + "gpos" : + { + "type" : "integer", + "minimum" : 0, + "default" : 0 + }, + "position" : + { + "type" : "integer", + "default" : 0 + }, + "reverse" : + { + "type" : "boolean", + "default" : false + }, + "hdepth" : + { + "type" : "integer", + "minimum" : 1, + "maximum" : 100, + "default" : 8 + }, + "vdepth" : + { + "type" : "integer", + "minimum" : 1, + "maximum" : 100, + "default" : 5 + }, + "overlap" : + { + "type" : "integer", + "minimum" : 0, + "default" : 0 + }, + "edgegap" : + { + "type" : "integer", + "minimum" : 0, + "maximum" : 50, + "default" : 0 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-leds.json b/libsrc/hyperion/schema/schema-leds.json new file mode 100644 index 00000000..ed31d7f5 --- /dev/null +++ b/libsrc/hyperion/schema/schema-leds.json @@ -0,0 +1,70 @@ +{ + "type":"array", + "required":true, + "items": + { + "type":"object", + "properties": + { + "index": + { + "type":"integer", + "required":true + }, + "clone": + { + "type":"integer" + }, + "hscan": + { + "type":"object", + "properties": + { + "minimum": + { + "type":"number", + "minimum" : 0, + "maximum" : 1, + "required":true + }, + "maximum": + { + "type":"number", + "minimum" : 0, + "maximum" : 1, + "required":true + } + }, + "additionalProperties" : false + }, + "vscan": + { + "type":"object", + "properties": + { + "minimum": + { + "type":"number", + "minimum" : 0, + "maximum" : 1, + "required":true + }, + "maximum": + { + "type":"number", + "minimum" : 0, + "maximum" : 1, + "required":true + } + }, + "additionalProperties" : false + }, + "colorOrder": + { + "type": "string", + "enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"] + } + }, + "additionalProperties" : false + } +} diff --git a/libsrc/hyperion/schema/schema-logger.json b/libsrc/hyperion/schema/schema-logger.json new file mode 100644 index 00000000..11243b05 --- /dev/null +++ b/libsrc/hyperion/schema/schema-logger.json @@ -0,0 +1,18 @@ +{ + "type" : "object", + "title" : "edt_conf_log_heading_title", + "properties" : + { + "level" : + { + "type" : "string", + "enum" : ["silent", "warn", "verbose", "debug"], + "title" : "edt_conf_log_level_title", + "options" : { + "enum_titles" : ["edt_conf_enum_logsilent", "edt_conf_enum_logwarn", "edt_conf_enum_logverbose", "edt_conf_enum_logdebug"] + }, + "default" : "warn" + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-protoServer.json b/libsrc/hyperion/schema/schema-protoServer.json new file mode 100644 index 00000000..f4665bad --- /dev/null +++ b/libsrc/hyperion/schema/schema-protoServer.json @@ -0,0 +1,18 @@ +{ + "type" : "object", + "required" : true, + "title" : "edt_conf_ps_heading_title", + "properties" : + { + "port" : + { + "type" : "integer", + "required" : true, + "title" : "edt_conf_general_port_title", + "minimum" : 0, + "maximum" : 65535, + "default" : 19445 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-smoothing.json b/libsrc/hyperion/schema/schema-smoothing.json new file mode 100644 index 00000000..bf7d6e29 --- /dev/null +++ b/libsrc/hyperion/schema/schema-smoothing.json @@ -0,0 +1,63 @@ +{ + "type" : "object", + "title" : "edt_conf_smooth_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : true, + "propertyOrder" : 1 + }, + "type" : + { + "type" : "string", + "title" : "edt_conf_smooth_type_title", + "enum" : ["linear"], + "default" : "linear", + "options" : { + "enum_titles" : ["edt_conf_enum_linear"] + }, + "propertyOrder" : 2 + }, + "time_ms" : + { + "type" : "integer", + "title" : "edt_conf_smooth_time_ms_title", + "minimum" : 25, + "maximum": 600, + "default" : 200, + "append" : "edt_append_ms", + "propertyOrder" : 3 + }, + "updateFrequency" : + { + "type" : "number", + "title" : "edt_conf_smooth_updateFrequency_title", + "minimum" : 1.0, + "maximum" : 100.0, + "default" : 25.0, + "append" : "edt_append_hz", + "propertyOrder" : 4 + }, + "updateDelay" : + { + "type" : "integer", + "title" : "edt_conf_smooth_updateDelay_title", + "minimum" : 0, + "maximum": 2048, + "default" : 0, + "append" : "edt_append_ms", + "propertyOrder" : 5 + }, + "continuousOutput" : + { + "type" : "boolean", + "title" : "edt_conf_smooth_continuousOutput_title", + "default" : true, + "propertyOrder" : 6 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-udpListener.json b/libsrc/hyperion/schema/schema-udpListener.json new file mode 100644 index 00000000..7b08a1e1 --- /dev/null +++ b/libsrc/hyperion/schema/schema-udpListener.json @@ -0,0 +1,56 @@ +{ + "type" : "object", + "title" : "edt_conf_udpl_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : false, + "propertyOrder" : 1 + }, + "address" : + { + "type" : "string", + "title" : "edt_conf_udpl_address_title", + "default" : "239.255.28.01", + "propertyOrder" : 2 + }, + "port" : + { + "type" : "integer", + "title" : "edt_conf_general_port_title", + "minimum" : 0, + "maximum" : 65535, + "default" : 2801, + "propertyOrder" : 3 + }, + "priority" : + { + "type" : "integer", + "title" : "edt_conf_general_priority_title", + "minimum" : 100, + "maximum" : 254, + "default" : 200, + "propertyOrder" : 4 + }, + "timeout" : + { + "type" : "integer", + "title" : "edt_conf_udpl_timeout_title", + "minimum" : 1000, + "default" : 10000, + "append" : "edt_append_ms", + "propertyOrder" : 5 + }, + "shared" : + { + "type" : "boolean", + "title" : "edt_conf_udpl_shared_title", + "default" : false, + "propertyOrder" : 6 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schema/schema-webConfig.json b/libsrc/hyperion/schema/schema-webConfig.json new file mode 100644 index 00000000..b8590a83 --- /dev/null +++ b/libsrc/hyperion/schema/schema-webConfig.json @@ -0,0 +1,33 @@ +{ + "type" : "object", + "title" : "edt_conf_webc_heading_title", + "properties" : + { + "enable" : + { + "type" : "boolean", + "title" : "edt_conf_general_enable_title", + "default" : true, + "access" : "expert", + "propertyOrder" : 1 + }, + "document_root" : + { + "type" : "string", + "title" : "edt_conf_webc_docroot_title", + "access" : "expert", + "propertyOrder" : 2 + }, + "port" : + { + "type" : "integer", + "title" : "edt_conf_general_port_title", + "minimum" : 0, + "maximum" : 65535, + "default" : 8099, + "access" : "expert", + "propertyOrder" : 3 + } + }, + "additionalProperties" : false +} diff --git a/libsrc/hyperion/schemas/hyperion.schema-1.json b/libsrc/hyperion/schemas/hyperion.schema-1.json deleted file mode 100644 index c36b9558..00000000 --- a/libsrc/hyperion/schemas/hyperion.schema-1.json +++ /dev/null @@ -1,386 +0,0 @@ -{ - "type" : "object", - "required" : true, - "properties" : { - "device" : { - "type" : "object", - "required" : true, - "properties" : { - "name" : { - "type" : "string", - "required" : true - }, - "type" : { - "type" : "string", - "required" : true - }, - "output" : { - "type" : "string", - "required" : true - }, - "rate" : { - "type" : "integer", - "required" : true, - "minimum" : 0 - }, - "colorOrder" : { - "type" : "string", - "required" : false - }, - "bgr-output" : { - "type" : "boolean", - "required" : false - } - }, - "additionalProperties" : false - }, - "color": { - "type":"object", - "required":false, - "properties": { - "hsv" : { - "type" : "object", - "required" : false, - "properties" : { - "saturationGain" : { - "type" : "number", - "required" : false, - "minimum" : 0.0 - }, - "valueGain" : { - "type" : "number", - "required" : false, - "minimum" : 0.0 - } - }, - "additionalProperties" : false - }, - "hsl" : { - "type" : "object", - "required" : false, - "properties" : { - "saturationGain" : { - "type" : "number", - "required" : false, - "minimum" : 0.0 - }, - "luminanceGain" : { - "type" : "number", - "required" : false, - "minimum" : 0.0 - }, - "luminanceMinimum" : { - "type" : "number", - "required" : false, - "minimum" : 0.0 - } - }, - "additionalProperties" : false - }, - "red": { - "type":"object", - "required":false, - "properties":{ - "gamma": { - "type":"number", - "required":false - }, - "blacklevel": { - "type":"number", - "required":false - }, - "whitelevel": { - "type":"number", - "required":false - }, - "threshold": { - "type":"number", - "required":false, - "minimum" : 0.0, - "maximum" : 1.0 - } - }, - "additionalProperties" : false - }, - "green": { - "type":"object", - "required":false, - "properties":{ - "gamma": { - "type":"number", - "required":false - }, - "blacklevel": { - "type":"number", - "required":false - }, - "whitelevel": { - "type":"number", - "required":false - }, - "threshold": { - "type":"number", - "required":false, - "minimum" : 0.0, - "maximum" : 1.0 - } - }, - "additionalProperties" : false - }, - "blue": { - "type":"object", - "required":false, - "properties":{ - "gamma": { - "type":"number", - "required":false - }, - "whitelevel": { - "type":"number", - "required":false - }, - "blacklevel": { - "type":"number", - "required":false - }, - "threshold": { - "type":"number", - "required":false, - "minimum" : 0.0, - "maximum" : 1.0 - } - }, - "additionalProperties" : false - }, - "smoothing" : { - "type" : "object", - "required" : false, - "properties" : { - "type" : { - "type" : "enum", - "required" : true, - "values" : ["none", "linear"] - }, - "time_ms" : { - "type" : "integer", - "required" : false, - "minimum" : 10 - }, - "updateFrequency" : { - "type" : "number", - "required" : false, - "minimum" : 0.001 - } - }, - "additionalProperties" : false - } - - }, - "additionalProperties" : false - }, - "leds": { - "type":"array", - "required":true, - "items": { - "type":"object", - "properties": { - "index": { - "type":"integer", - "required":true - }, - "hscan": { - "type":"object", - "required":true, - "properties": { - "minimum": { - "type":"number", - "required":true - }, - "maximum": { - "type":"number", - "required":true - } - }, - "additionalProperties" : false - }, - "vscan": { - "type":"object", - "required":true, - "properties": { - "minimum": { - "type":"number", - "required":true - }, - "maximum": { - "type":"number", - "required":true - } - }, - "additionalProperties" : false - }, - "colorOrder" : { - "type" : "string", - "required" : false - } - }, - "additionalProperties" : false - } - }, - "effects" : - { - "type" : "object", - "required" : false, - "properties" : { - "paths" : { - "type" : "array", - "required" : false, - "items" : { - "type" : "string" - } - } - }, - "additionalProperties" : false - }, - "blackborderdetector" : - { - "type" : "object", - "required" : false, - "properties" : { - "enable" : { - "type" : "boolean", - "required" : true - }, - "threshold" : { - "type" : "number", - "required" : false, - "minimum" : 0.0, - "maximum" : 1.0 - } - }, - "additionalProperties" : false - }, - "xbmcVideoChecker" : - { - "type" : "object", - "required" : false, - "properties" : { - "xbmcAddress" : { - "type" : "string", - "required" : true - }, - "xbmcTcpPort" : { - "type" : "integer", - "required" : true - }, - "grabVideo" : { - "type" : "boolean", - "required" : true - }, - "grabPictures" : { - "type" : "boolean", - "required" : true - }, - "grabAudio" : { - "type" : "boolean", - "required" : true - }, - "grabMenu" : { - "type" : "boolean", - "required" : true - }, - "grabPause" : { - "type" : "boolean", - "required" : false - }, - "grabScreensaver" : { - "type" : "boolean", - "required" : false - }, - "enable3DDetection" : { - "type" : "boolean", - "required" : false - } - }, - "additionalProperties" : false - }, - "bootsequence" : - { - "type" : "object", - "required" : false, - "properties" : { - "path" : { - "type" : "string", - "required" : true - }, - "effect" : { - "type" : "string", - "required" : true - } - }, - "additionalProperties" : false - }, - "framegrabber" : - { - "type" : "object", - "required" : false, - "properties" : { - "width" : { - "type" : "integer", - "required" : true - }, - "height" : { - "type" : "integer", - "required" : true - }, - "frequency_Hz" : { - "type" : "integer", - "required" : true - } - }, - "additionalProperties" : false - }, - "jsonServer" : - { - "type" : "object", - "required" : false, - "properties" : { - "port" : { - "type" : "integer", - "required" : true, - "minimum" : 0, - "maximum" : 65535 - } - }, - "additionalProperties" : false - }, - "protoServer" : - { - "type" : "object", - "required" : false, - "properties" : { - "port" : { - "type" : "integer", - "required" : true, - "minimum" : 0, - "maximum" : 65535 - } - }, - "additionalProperties" : false - }, - "boblightServer" : - { - "type" : "object", - "required" : false, - "properties" : { - "port" : { - "type" : "integer", - "required" : true, - "minimum" : 0, - "maximum" : 65535 - } - }, - "additionalProperties" : false - } - }, - "additionalProperties" : false -} diff --git a/libsrc/hyperion/schemas/hyperion.schema-2.json b/libsrc/hyperion/schemas/hyperion.schema-2.json deleted file mode 100644 index bfb3bdab..00000000 --- a/libsrc/hyperion/schemas/hyperion.schema-2.json +++ /dev/null @@ -1,1426 +0,0 @@ -{ - "type" : "object", - "required" : true, - "properties" : - { - "general" : - { - "type" : "object", - "title" : "edt_conf_gen_heading_title", - "required" : true, - "properties" : - { - "name" : - { - "type" : "string", - "title" : "edt_conf_gen_name_title", - "default" : "My Hyperion Config", - "minLength" : 4, - "maxLength" : 20, - "required" : true, - "propertyOrder" : 1 - }, - "showOptHelp" : - { - "type" : "boolean", - "title" : "edt_conf_gen_showOptHelp_title", - "default" : true, - "required" : true, - "propertyOrder" : 2 - }, - "configVersion" : - { - "type" : "integer", - "minimum" : 1, - "access" : "system", - "required" : true - } - } - }, - "logger" : - { - "type" : "object", - "title" : "edt_conf_log_heading_title", - "properties" : - { - "level" : - { - "type" : "string", - "enum" : ["silent", "warn", "verbose", "debug"], - "title" : "edt_conf_log_level_title", - "options" : { - "enum_titles" : ["edt_conf_enum_logsilent", "edt_conf_enum_logwarn", "edt_conf_enum_logverbose", "edt_conf_enum_logdebug"] - }, - "default" : "warn" - } - }, - "additionalProperties" : false - }, - "device" : - { - "type" : "object", - "title" : "edt_dev_general_heading_title", - "required" : true, - "defaultProperties": ["ledCount","colorOrder","rewriteTime","minimumWriteTime"], - "properties" : - { - "type" : - { - "type" : "string" - }, - "ledCount" : - { - "type" : "integer", - "minimum" : 0, - "title" : "edt_dev_general_ledCount_title", - "propertyOrder" : 2 - }, - "colorOrder" : - { - "type" : "string", - "title" : "edt_dev_general_colorOrder_title", - "enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"], - "default" : "rgb", - "options" : { - "enum_titles" : ["edt_conf_enum_rgb", "edt_conf_enum_bgr", "edt_conf_enum_rbg", "edt_conf_enum_brg", "edt_conf_enum_gbr", "edt_conf_enum_grb"] - }, - "propertyOrder" : 3 - }, - "rewriteTime": { - "type": "integer", - "title":"edt_dev_general_rewriteTime_title", - "default": 1000, - "append" : "edt_append_ms", - "minimum": 0, - "access" : "expert", - "propertyOrder" : 4 - } - }, - "additionalProperties" : true - }, - "color" : - { - "type":"object", - "title" : "edt_conf_color_heading_title", - "required" : true, - "properties": - { - "imageToLedMappingType" : - { - "type" : "string", - "title" : "edt_conf_color_imageToLedMappingType_title", - "enum" : ["multicolor_mean", "unicolor_mean"], - "default" : "multicolor_mean", - "options" : { - "enum_titles" : ["edt_conf_enum_multicolor_mean", "edt_conf_enum_unicolor_mean"] - }, - "propertyOrder" : 1 - }, - "channelAdjustment" : - { - "type" : "array", - "title" : "edt_conf_color_channelAdjustment_header_title", - "required" : true, - "propertyOrder" : 3, - "items" : - { - "type" : "object", - "required" : true, - "title" : "edt_conf_color_channelAdjustment_header_itemtitle", - "properties" : - { - "id" : - { - "type" : "string", - "title" : "edt_conf_color_id_title", - "required" : true, - "default" : "A userdefined name", - "propertyOrder" : 1 - }, - "leds" : - { - "type" : "string", - "title" : "edt_conf_color_leds_title", - "required" : true, - "default" : "*", - "propertyOrder" : 2 - }, - "black" : - { - "type" : "array", - "title" : "edt_conf_color_black_title", - "format" : "colorpicker", - "required" : true, - "default": [0,0,0], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 3 - }, - "white" : - { - "type" : "array", - "title" : "edt_conf_color_white_title", - "format" : "colorpicker", - "required" : true, - "default": [255,255,255], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 4 - }, - "red" : - { - "type" : "array", - "title" : "edt_conf_color_red_title", - "format" : "colorpicker", - "required" : true, - "default": [255,0,0], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 5 - }, - "green" : - { - "type" : "array", - "title" : "edt_conf_color_green_title", - "format" : "colorpicker", - "required" : true, - "default": [0,255,0], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 6 - }, - "blue" : - { - "type" : "array", - "title" : "edt_conf_color_blue_title", - "format" : "colorpicker", - "required" : true, - "default": [0,0,255], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 7 - }, - "cyan" : - { - "type" : "array", - "title" : "edt_conf_color_cyan_title", - "format" : "colorpicker", - "required" : true, - "default": [0,255,255], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 8 - }, - "magenta" : - { - "type" : "array", - "title" : "edt_conf_color_magenta_title", - "format" : "colorpicker", - "required" : true, - "default": [255,0,255], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 9 - }, - "yellow" : - { - "type" : "array", - "title" : "edt_conf_color_yellow_title", - "format" : "colorpicker", - "required" : true, - "default": [255,255,0], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 10 - }, - "backlightThreshold" : - { - "type" : "integer", - "title" : "edt_conf_color_backlightThreshold_title", - "required" : true, - "minimum" : 0, - "maximum": 100, - "default" : 0, - "append" : "edt_append_percent", - "propertyOrder" : 11 - }, - "backlightColored" : - { - "type" : "boolean", - "title" : "edt_conf_color_backlightColored_title", - "required" : true, - "default" : false, - "propertyOrder" : 12 - }, - "brightness" : - { - "type" : "integer", - "title" : "edt_conf_color_brightness_title", - "required" : true, - "minimum" : 0, - "maximum": 100, - "default" : 100, - "append" : "edt_append_percent", - "propertyOrder" : 13 - }, - "brightnessCompensation" : - { - "type" : "integer", - "title" : "edt_conf_color_brightnessComp_title", - "required" : true, - "minimum" : 0, - "maximum": 100, - "default" : 90, - "append" : "edt_append_percent", - "access" : "advanced", - "propertyOrder" : 14 - }, - "gammaRed" : - { - "type" : "number", - "title" : "edt_conf_color_gammaRed_title", - "required" : true, - "minimum" : 0.1, - "maximum": 100.0, - "default" : 1.5, - "step" : 0.1, - "propertyOrder" : 15 - }, - "gammaGreen" : - { - "type" : "number", - "title" : "edt_conf_color_gammaGreen_title", - "required" : true, - "minimum" : 0.1, - "maximum": 100.0, - "default" : 1.5, - "step" : 0.1, - "propertyOrder" : 16 - }, - "gammaBlue" : - { - "type" : "number", - "title" : "edt_conf_color_gammaBlue_title", - "required" : true, - "minimum" : 0.1, - "maximum": 100.0, - "default" : 1.5, - "step" : 0.1, - "propertyOrder" : 17 - } - }, - "additionalProperties" : false - } - } - }, - "additionalProperties" : false - }, - "smoothing": - { - "type" : "object", - "title" : "edt_conf_smooth_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : true, - "propertyOrder" : 1 - }, - "type" : - { - "type" : "string", - "title" : "edt_conf_smooth_type_title", - "enum" : ["linear"], - "default" : "linear", - "options" : { - "enum_titles" : ["edt_conf_enum_linear"] - }, - "propertyOrder" : 2 - }, - "time_ms" : - { - "type" : "integer", - "title" : "edt_conf_smooth_time_ms_title", - "minimum" : 25, - "maximum": 600, - "default" : 200, - "append" : "edt_append_ms", - "propertyOrder" : 3 - }, - "updateFrequency" : - { - "type" : "number", - "title" : "edt_conf_smooth_updateFrequency_title", - "minimum" : 1.0, - "maximum" : 100.0, - "default" : 25.0, - "append" : "edt_append_hz", - "propertyOrder" : 4 - }, - "updateDelay" : - { - "type" : "integer", - "title" : "edt_conf_smooth_updateDelay_title", - "minimum" : 0, - "maximum": 2048, - "default" : 0, - "append" : "edt_append_ms", - "propertyOrder" : 5 - }, - "continuousOutput" : - { - "type" : "boolean", - "title" : "edt_conf_smooth_continuousOutput_title", - "default" : true, - "propertyOrder" : 6 - } - }, - "additionalProperties" : false - }, - "grabberV4L2" : - { - "type":"array", - "title" : "edt_conf_v4l2_heading_title", - "minItems": 1, - "maxItems": 2, - "items": - { - "type" : "object", - "title" : "edt_conf_v4l2_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : false, - "propertyOrder" : 1 - }, - "device" : - { - "type" : "string", - "title" : "edt_conf_v4l2_device_title", - "default" : "auto", - "propertyOrder" : 2 - }, - "input" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_input_title", - "minimum" : 0, - "default" : 0, - "propertyOrder" : 3 - }, - "standard" : - { - "type" : "string", - "title" : "edt_conf_v4l2_standard_title", - "enum" : ["PAL","NTSC"], - "default" : "PAL", - "options" : { - "enum_titles" : ["edt_conf_enum_PAL", "edt_conf_enum_NTSC"] - }, - "propertyOrder" : 4 - }, - "width" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_width_title", - "minimum" : -1, - "default" : -1, - "append" : "edt_append_pixel", - "propertyOrder" : 5 - }, - "height" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_height_title", - "minimum" : -1, - "default" : -1, - "append" : "edt_append_pixel", - "propertyOrder" : 6 - }, - "frameDecimation" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_frameDecimation_title", - "minimum" : 0, - "default" : 2, - "propertyOrder" : 7 - }, - "sizeDecimation" : - { - "type" : "integer", - "title" : "Size decimation", - "minimum" : 0, - "default" : 6, - "propertyOrder" : 8 - }, - "priority" : - { - "type" : "integer", - "minimum" : 100, - "maximum" : 253, - "title" : "edt_conf_general_priority_title", - "default" : 240, - "propertyOrder" : 9 - }, - "mode" : - { - "type" : "string", - "title" : "edt_conf_v4l2_mode_title", - "enum" : ["2D","3DSBS","3DTAB"], - "default" : "2D", - "propertyOrder" : 10 - }, - "useKodiChecker" : - { - "type" : "boolean", - "title" : "edt_conf_v4l2_useKodiChecker_title", - "default" : false, - "propertyOrder" : 11 - }, - "cropLeft" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropLeft_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 12 - }, - "cropRight" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropRight_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 13 - }, - "cropTop" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropTop_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 14 - }, - "cropBottom" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropBottom_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 15 - }, - "signalDetection" : - { - "type" : "boolean", - "title" : "edt_conf_v4l2_signalDetection_title", - "default" : true, - "propertyOrder" : 16 - }, - "redSignalThreshold" : - { - "type" : "number", - "title" : "edt_conf_v4l2_redSignalThreshold_title", - "minimum" : 0.0, - "maximum" : 1.0, - "default" : 0.1, - "step" : 0.005, - "append" : "edt_append_percent", - "propertyOrder" : 17 - }, - "greenSignalThreshold" : - { - "type" : "number", - "title" : "edt_conf_v4l2_greenSignalThreshold_title", - "minimum" : 0.0, - "maximum" : 1.0, - "default" : 0.1, - "step" : 0.025, - "append" : "edt_append_percent", - "propertyOrder" : 18 - }, - "blueSignalThreshold" : - { - "type" : "number", - "title" : "edt_conf_v4l2_blueSignalThreshold_title", - "minimum" : 0.0, - "maximum" : 1.0, - "default" : 0.1, - "step" : 0.005, - "append" : "edt_append_percent", - "propertyOrder" : 19 - }, - "signalDetectionVerticalOffsetMin" : - { - "type" : "number", - "title" : "edt_conf_v4l2_signalDetectionVerticalOffsetMin_title", - "minimum" : 0.0, - "maximum" : 1.0, - "default" : 0.1, - "step" : 0.005, - "append" : "edt_append_percent", - "propertyOrder" : 20 - }, - "signalDetectionVerticalOffsetMax" : - { - "type" : "number", - "title" : "edt_conf_v4l2_signalDetectionVerticalOffsetMax_title", - "minimum" : 0.0, - "maximum" : 1.0, - "default" : 0.1, - "step" : 0.005, - "append" : "edt_append_percent", - "propertyOrder" : 21 - }, - "signalDetectionHorizontalOffsetMin" : - { - "type" : "number", - "title" : "edt_conf_v4l2_signalDetectionHorizontalOffsetMin_title", - "minimum" : 0.0, - "maximum" : 1.0, - "default" : 0.1, - "step" : 0.005, - "append" : "edt_append_percent", - "propertyOrder" : 22 - }, - "signalDetectionHorizontalOffsetMax" : - { - "type" : "number", - "title" : "edt_conf_v4l2_signalDetectionHorizontalOffsetMax_title", - "minimum" : 0.0, - "maximum" : 1.0, - "default" : 0.1, - "step" : 0.005, - "append" : "edt_append_percent", - "propertyOrder" : 23 - } - }, - "additionalProperties" : false - } - }, - "framegrabber" : - { - "type" : "object", - "title" : "edt_conf_fg_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : true, - "propertyOrder" : 1 - }, - "type" : - { - "type" : "string", - "title" : "edt_conf_fg_type_title", - "enum" : ["auto","dispmanx","amlogic","x11","framebuffer"], - "default" : "auto", - "propertyOrder" : 2 - }, - "width" : - { - "type" : "integer", - "title" : "edt_conf_fg_width_title", - "minimum" : 10, - "default" : 80, - "append" : "edt_append_pixel", - "propertyOrder" : 3 - }, - "height" : - { - "type" : "integer", - "title" : "edt_conf_fg_height_title", - "minimum" : 10, - "default" : 45, - "append" : "edt_append_pixel", - "propertyOrder" : 3 - }, - "frequency_Hz" : - { - "type" : "integer", - "title" : "edt_conf_fg_frequency_Hz_title", - "minimum" : 1, - "default" : 10, - "append" : "edt_append_hz", - "propertyOrder" : 4 - }, - "priority" : - { - "type" : "integer", - "title" : "edt_conf_general_priority_title", - "minimum" : 100, - "maximum" : 254, - "default" : 250, - "propertyOrder" : 5 - }, - "cropLeft" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropLeft_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 6 - }, - "cropRight" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropRight_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 7 - }, - "cropTop" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropTop_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 8 - }, - "cropBottom" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropBottom_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 9 - }, - "useXGetImage" : - { - "type" : "boolean", - "title" : "edt_conf_fg_useXGetImage_title", - "default" : false, - "propertyOrder" : 10 - }, - "horizontalPixelDecimation" : - { - "type" : "integer", - "title" : "edt_conf_fg_horizontalPixelDecimation_title", - "minimum" : 0, - "default" : 8, - "propertyOrder" : 11 - }, - "verticalPixelDecimation" : - { - "type" : "integer", - "title" : "edt_conf_fg_verticalPixelDecimation_title", - "minimum" : 0, - "default" : 8, - "propertyOrder" : 12 - }, - "device" : - { - "type" : "string", - "title" : "edt_conf_fg_device_title", - "default" : "/dev/fb0", - "propertyOrder" : 13 - }, - "display" : - { - "type" : "integer", - "title" : "edt_conf_fg_display_title", - "minimum" : 0, - "propertyOrder" : 14 - } - }, - "additionalProperties" : false - }, - "blackborderdetector" : - { - "type" : "object", - "title" : "edt_conf_bb_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : true, - "propertyOrder" : 1 - }, - "threshold" : - { - "type" : "integer", - "title" : "edt_conf_bb_threshold_title", - "minimum" : 0, - "maximum" : 100, - "default" : 5, - "append" : "edt_append_percent", - "propertyOrder" : 2 - }, - "unknownFrameCnt" : - { - "type" : "integer", - "title" : "edt_conf_bb_unknownFrameCnt_title", - "minimum" : 0, - "default" : 600, - "access" : "expert", - "propertyOrder" : 3 - }, - "borderFrameCnt" : - { - "type" : "integer", - "title" : "edt_conf_bb_borderFrameCnt_title", - "minimum" : 0, - "default" : 50, - "access" : "expert", - "propertyOrder" : 4 - }, - "maxInconsistentCnt" : - { - "type" : "integer", - "title" : "edt_conf_bb_maxInconsistentCnt_title", - "minimum" : 0, - "default" : 10, - "access" : "expert", - "propertyOrder" : 5 - }, - "blurRemoveCnt" : - { - "type" : "integer", - "title" : "edt_conf_bb_blurRemoveCnt_title", - "minimum" : 0, - "default" : 1, - "access" : "expert", - "propertyOrder" : 6 - }, - "mode" : - { - "type" : "string", - "title": "edt_conf_bb_mode_title", - "enum" : ["default", "classic", "osd"], - "default" : "default", - "options" : { - "enum_titles" : ["edt_conf_enum_bbdefault", "edt_conf_enum_bbclassic", "edt_conf_enum_bbosd"] - }, - "propertyOrder" : 7 - } - }, - "additionalProperties" : false - }, - "kodiVideoChecker" : - { - "type" : "object", - "title" : "edt_conf_kodic_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : false, - "propertyOrder" : 1 - }, - "kodiAddress" : - { - "type" : "string", - "title" : "edt_conf_kodic_kodiAddress_title", - "default" : "127.0.0.1", - "propertyOrder" : 2 - }, - "kodiTcpPort" : - { - "type" : "integer", - "title" : "edt_conf_kodic_kodiTcpPort_title", - "minimum" : 0, - "maximum" : 65535, - "default" : 9090, - "propertyOrder" : 3 - }, - "grabVideo" : - { - "type" : "boolean", - "title" : "edt_conf_kodic_grabVideo_title", - "default" : true, - "propertyOrder" : 4 - }, - "grabPictures" : - { - "type" : "boolean", - "title" : "edt_conf_kodic_grabPictures_title", - "default" : true, - "propertyOrder" : 5 - }, - "grabAudio" : - { - "type" : "boolean", - "title" : "edt_conf_kodic_grabAudio_title", - "default" : true, - "propertyOrder" : 6 - }, - "grabMenu" : - { - "type" : "boolean", - "title" : "edt_conf_kodic_grabMenu_title", - "default" : false, - "propertyOrder" : 7 - }, - "grabPause" : - { - "type" : "boolean", - "title" : "edt_conf_kodic_grabPause_title", - "default" : false, - "propertyOrder" : 8 - }, - "grabScreensaver" : - { - "type" : "boolean", - "title" : "edt_conf_kodic_grabScreensaver_title", - "default" : false, - "propertyOrder" : 9 - }, - "enable3DDetection" : - { - "type" : "boolean", - "title" : "edt_conf_kodic_enable3DDetection_title", - "default" : false, - "propertyOrder" : 10 - } - }, - "additionalProperties" : false - }, - "foregroundEffect" : - { - "type" : "object", - "title" : "edt_conf_fge_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : true, - "propertyOrder" : 1 - }, - "type" : - { - "type" : "string", - "title" : "edt_conf_fge_type_title", - "enum" : ["color", "effect"], - "default" : "effect", - "options" : { - "enum_titles" : ["edt_conf_enum_color", "edt_conf_enum_effect"] - }, - "propertyOrder" : 2 - }, - "color" : - { - "type" : "array", - "format" : "colorpicker", - "title" : "edt_conf_fge_color_title", - "default" : [255,0,0], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 3 - }, - "effect" : - { - "type" : "string", - "format" : "select", - "title" : "edt_conf_fge_effect_title", - "propertyOrder" : 4 - }, - "duration_ms" : - { - "type" : "integer", - "title" : "edt_conf_fge_duration_ms_title", - "default" : 3000, - "minimum" : 100, - "append" : "edt_append_ms", - "propertyOrder" : 5 - } - }, - "additionalProperties" : false - }, - "backgroundEffect" : - { - "type" : "object", - "title" : "edt_conf_bge_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : true, - "propertyOrder" : 1 - }, - "type" : - { - "type" : "string", - "title" : "edt_conf_fge_type_title", - "enum" : ["color", "effect"], - "default" : "effect", - "options" : { - "enum_titles" : ["edt_conf_enum_color", "edt_conf_enum_effect"] - }, - "propertyOrder" : 2 - }, - "color" : - { - "type" : "array", - "format" : "colorpicker", - "title" : "edt_conf_fge_color_title", - "default" : [255,138,0], - "items" : { - "type" : "integer", - "minimum" : 0, - "maximum" : 255 - }, - "minItems" : 3, - "maxItems" : 3, - "propertyOrder" : 3 - }, - "effect" : - { - "type" : "string", - "format" : "select", - "title" : "edt_conf_fge_effect_title", - "propertyOrder" : 4 - } - }, - "additionalProperties" : false - }, - "forwarder" : - { - "type" : "object", - "title" : "edt_conf_fw_heading_title", - "required" : true, - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "propertyOrder" : 1 - }, - "json" : - { - "type" : "array", - "title" : "edt_conf_fw_json_title", - "items" : { - "type": "string", - "title" : "edt_conf_fw_json_itemtitle" - }, - "propertyOrder" : 2 - }, - "proto" : - { - "type" : "array", - "title" : "edt_conf_fw_proto_title", - "items" : { - "type": "string", - "title" : "edt_conf_fw_proto_itemtitle" - }, - "propertyOrder" : 3 - } - }, - "additionalProperties" : false - }, - "jsonServer" : - { - "type" : "object", - "required" : true, - "title" : "edt_conf_js_heading_title", - "properties" : - { - "port" : - { - "type" : "integer", - "required" : true, - "title" : "edt_conf_general_port_title", - "minimum" : 0, - "maximum" : 65535, - "default" : 19444 - } - }, - "additionalProperties" : false - }, - "protoServer" : - { - "type" : "object", - "required" : true, - "title" : "edt_conf_ps_heading_title", - "properties" : - { - "port" : - { - "type" : "integer", - "required" : true, - "title" : "edt_conf_general_port_title", - "minimum" : 0, - "maximum" : 65535, - "default" : 19445 - } - }, - "additionalProperties" : false - }, - "boblightServer" : - { - "type" : "object", - "title" : "edt_conf_bobls_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : false, - "propertyOrder" : 1 - }, - "port" : - { - "type" : "integer", - "required" : true, - "title" : "edt_conf_general_port_title", - "minimum" : 0, - "maximum" : 65535, - "propertyOrder" : 2 - }, - "priority" : - { - "type" : "integer", - "title" : "edt_conf_general_priority_title", - "minimum" : 100, - "maximum" : 254, - "default" : 201, - "propertyOrder" : 3 - } - }, - "additionalProperties" : false - }, - "udpListener" : - { - "type" : "object", - "title" : "edt_conf_udpl_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : false, - "propertyOrder" : 1 - }, - "address" : - { - "type" : "string", - "title" : "edt_conf_udpl_address_title", - "default" : "239.255.28.01", - "propertyOrder" : 2 - }, - "port" : - { - "type" : "integer", - "title" : "edt_conf_general_port_title", - "minimum" : 0, - "maximum" : 65535, - "default" : 2801, - "propertyOrder" : 3 - }, - "priority" : - { - "type" : "integer", - "title" : "edt_conf_general_priority_title", - "minimum" : 100, - "maximum" : 254, - "default" : 200, - "propertyOrder" : 4 - }, - "timeout" : - { - "type" : "integer", - "title" : "edt_conf_udpl_timeout_title", - "minimum" : 1000, - "default" : 10000, - "append" : "edt_append_ms", - "propertyOrder" : 5 - }, - "shared" : - { - "type" : "boolean", - "title" : "edt_conf_udpl_shared_title", - "default" : false, - "propertyOrder" : 6 - } - }, - "additionalProperties" : false - }, - "webConfig" : - { - "type" : "object", - "title" : "edt_conf_webc_heading_title", - "properties" : - { - "enable" : - { - "type" : "boolean", - "title" : "edt_conf_general_enable_title", - "default" : true, - "access" : "expert", - "propertyOrder" : 1 - }, - "document_root" : - { - "type" : "string", - "title" : "edt_conf_webc_docroot_title", - "access" : "expert", - "propertyOrder" : 2 - }, - "port" : - { - "type" : "integer", - "title" : "edt_conf_general_port_title", - "minimum" : 0, - "maximum" : 65535, - "default" : 8099, - "access" : "expert", - "propertyOrder" : 3 - } - }, - "additionalProperties" : false - }, - "effects" : - { - "type" : "object", - "title" : "edt_conf_effp_heading_title", - "properties" : - { - "paths" : - { - "type" : "array", - "title" : "edt_conf_effp_paths_title", - "default" : ["../custom-effects"], - "items" : { - "type": "string", - "title" : "edt_conf_effp_paths_itemtitle" - }, - "propertyOrder" : 1 - }, - "disable" : - { - "type" : "array", - "title" : "edt_conf_effp_disable_title", - "items" : { - "type": "string", - "title" : "edt_conf_effp_disable_itemtitle" - }, - "propertyOrder" : 2 - } - }, - "additionalProperties" : false - }, - "ledConfig": - { - "type" : "object", - "properties" : - { - "top" : - { - "type" : "integer", - "minimum" : 0, - "default" : 8 - }, - "bottom" : - { - "type" : "integer", - "minimum" : 0, - "default" : 8 - }, - "left" : - { - "type" : "integer", - "minimum" : 0, - "default" : 5 - }, - "right" : - { - "type" : "integer", - "minimum" : 0, - "default" : 5 - }, - "glength" : - { - "type" : "integer", - "minimum" : 0, - "default" : 0 - }, - "gpos" : - { - "type" : "integer", - "minimum" : 0, - "default" : 0 - }, - "position" : - { - "type" : "integer", - "default" : 0 - }, - "reverse" : - { - "type" : "boolean", - "default" : false - }, - "hdepth" : - { - "type" : "integer", - "minimum" : 1, - "maximum" : 100, - "default" : 8 - }, - "vdepth" : - { - "type" : "integer", - "minimum" : 1, - "maximum" : 100, - "default" : 5 - }, - "overlap" : - { - "type" : "integer", - "minimum" : 0, - "default" : 0 - }, - "edgegap" : - { - "type" : "integer", - "minimum" : 0, - "maximum" : 50, - "default" : 0 - } - }, - "additionalProperties" : false - }, - "leds": - { - "type":"array", - "required":true, - "items": - { - "type":"object", - "properties": - { - "index": - { - "type":"integer", - "required":true - }, - "clone": - { - "type":"integer" - }, - "hscan": - { - "type":"object", - "properties": - { - "minimum": - { - "type":"number", - "minimum" : 0, - "maximum" : 1, - "required":true - }, - "maximum": - { - "type":"number", - "minimum" : 0, - "maximum" : 1, - "required":true - } - }, - "additionalProperties" : false - }, - "vscan": - { - "type":"object", - "properties": - { - "minimum": - { - "type":"number", - "minimum" : 0, - "maximum" : 1, - "required":true - }, - "maximum": - { - "type":"number", - "minimum" : 0, - "maximum" : 1, - "required":true - } - }, - "additionalProperties" : false - }, - "colorOrder": - { - "type": "string", - "enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"] - } - }, - "additionalProperties" : false - } - } - }, - "additionalProperties" : false -} diff --git a/libsrc/utils/CMakeLists.txt b/libsrc/utils/CMakeLists.txt index a996d390..66ac2627 100644 --- a/libsrc/utils/CMakeLists.txt +++ b/libsrc/utils/CMakeLists.txt @@ -27,6 +27,7 @@ SET(Utils_HEADERS ${CURRENT_HEADER_DIR}/RgbToRgbw.h ${CURRENT_HEADER_DIR}/jsonschema/QJsonFactory.h ${CURRENT_HEADER_DIR}/jsonschema/QJsonSchemaChecker.h + ${CURRENT_HEADER_DIR}/jsonschema/QJsonUtils.h ${CURRENT_HEADER_DIR}/global_defines.h ${CURRENT_HEADER_DIR}/SysInfo.h ) diff --git a/libsrc/utils/JsonProcessor.cpp b/libsrc/utils/JsonProcessor.cpp index ee5bc4b6..ba4531cf 100644 --- a/libsrc/utils/JsonProcessor.cpp +++ b/libsrc/utils/JsonProcessor.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -594,6 +593,7 @@ void JsonProcessor::handleServerInfoCommand(const QJsonObject&, const QString& c ledDevices["available"] = availableLedDevices; info["ledDevices"] = ledDevices; +#if defined(ENABLE_DISPMANX) || defined(ENABLE_V4L2) || defined(ENABLE_FB) || defined(ENABLE_AMLOGIC) || defined(ENABLE_OSX) || defined(ENABLE_X11) // get available grabbers QJsonObject grabbers; //grabbers["active"] = ????; @@ -605,6 +605,9 @@ void JsonProcessor::handleServerInfoCommand(const QJsonObject&, const QString& c grabbers["available"] = availableGrabbers; info["grabbers"] = grabbers; +#else + info["grabbers"] = QString("none"); +#endif // get available components QJsonArray component; @@ -844,45 +847,19 @@ void JsonProcessor::handleSchemaGetCommand(const QJsonObject& message, const QSt // make sure the resources are loaded (they may be left out after static linking) Q_INIT_RESOURCE(resource); - QJsonParseError error; // read the hyperion json schema from the resource - QFile schemaData(":/hyperion-schema-"+QString::number(_hyperion->getConfigVersionId())); + QString schemaFile = ":/hyperion-schema"; - if (!schemaData.open(QIODevice::ReadOnly)) + try { - std::stringstream error; - error << "Schema not found: " << schemaData.errorString().toStdString(); - throw std::runtime_error(error.str()); + schemaJson = QJsonFactory::readSchema(schemaFile); } - - QByteArray schema = schemaData.readAll(); - QJsonDocument doc = QJsonDocument::fromJson(schema, &error); - schemaData.close(); - - if (error.error != QJsonParseError::NoError) + catch(const std::runtime_error& error) { - // report to the user the failure and their locations in the document. - int errorLine(0), errorColumn(0); - - for( int i=0, count=qMin( error.offset,schema.size()); i +#include QJsonSchemaChecker::QJsonSchemaChecker() { @@ -25,11 +26,12 @@ bool QJsonSchemaChecker::setSchema(const QJsonObject & schema) return true; } -bool QJsonSchemaChecker::validate(const QJsonObject & value, bool ignoreRequired) +QPair QJsonSchemaChecker::validate(const QJsonObject & value, bool ignoreRequired) { // initialize state _ignoreRequired = ignoreRequired; _error = false; + _schemaError = false; _messages.clear(); _currentPath.clear(); _currentPath.append("[root]"); @@ -37,7 +39,27 @@ bool QJsonSchemaChecker::validate(const QJsonObject & value, bool ignoreRequired // validate validate(value, _qSchema); - return !_error; + return QPair(!_error, !_schemaError); +} + +QJsonObject QJsonSchemaChecker::getAutoCorrectedConfig(const QJsonObject& value, bool ignoreRequired) +{ + _ignoreRequired = ignoreRequired; + QStringList sequence = QStringList() << "remove" << "modify" << "create"; + _error = false; + _schemaError = false; + _messages.clear(); + _autoCorrected = value; + + for(const QString &correct : sequence) + { + _correct = correct; + _currentPath.clear(); + _currentPath.append("[root]"); + validate(_autoCorrected, _qSchema); + } + + return _autoCorrected; } void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &schema) @@ -48,15 +70,17 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s QString attribute = i.key(); const QJsonValue & attributeValue = *i; + QJsonObject::const_iterator defaultValue = schema.find("default"); + if (attribute == "type") - checkType(value, attributeValue); + checkType(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "properties") { if (value.isObject()) checkProperties(value.toObject(), attributeValue.toObject()); else { - _error = true; + _schemaError = true; setMessage("properties attribute is only valid for objects"); continue; } @@ -76,19 +100,19 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s } else { - _error = true; + _schemaError = true; setMessage("additional properties attribute is only valid for objects"); continue; } } else if (attribute == "minimum") - checkMinimum(value, attributeValue); + checkMinimum(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "maximum") - checkMaximum(value, attributeValue); + checkMaximum(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "minLength") - checkMinLength(value, attributeValue); + checkMinLength(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "maxLength") - checkMaxLength(value, attributeValue); + checkMaxLength(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "items") { if (value.isArray()) @@ -101,13 +125,13 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s } } else if (attribute == "minItems") - checkMinItems(value, attributeValue); + checkMinItems(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "maxItems") - checkMaxItems(value, attributeValue); + checkMaxItems(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "uniqueItems") checkUniqueItems(value, attributeValue); else if (attribute == "enum") - checkEnum(value, attributeValue); + checkEnum(value, attributeValue, (defaultValue != schema.end() ? defaultValue.value() : QJsonValue::Null)); else if (attribute == "required") ; // nothing to do. value is present so always oke else if (attribute == "id") @@ -118,7 +142,7 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s else { // no check function defined for this attribute - _error = true; + _schemaError = true; setMessage("No check function defined for attribute " + attribute); continue; } @@ -135,7 +159,7 @@ const QStringList & QJsonSchemaChecker::getMessages() const return _messages; } -void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { QString type = schema.toString(); @@ -145,7 +169,12 @@ void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue & else if (type == "number") wrongType = !value.isDouble(); else if (type == "integer") - wrongType = (rint(value.toDouble()) != value.toDouble()); + { + if (value.isDouble()) //check if value type not boolean (true = 1 && false = 0) + wrongType = (rint(value.toDouble()) != value.toDouble()); + else + wrongType = true; + } else if (type == "double") wrongType = !value.isDouble(); else if (type == "boolean") @@ -160,13 +189,16 @@ void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue & wrongType = !value.isString(); else if (type == "any") wrongType = false; -// else -// assert(false); if (wrongType) { _error = true; - setMessage(type + " expected"); + + if (_correct == "modify") + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue); + + if (_correct == "") + setMessage(type + " expected"); } } @@ -176,7 +208,7 @@ void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonO { QString property = i.key(); - const QJsonValue & propertyValue = i.value(); + const QJsonValue & propertyValue = *i; _currentPath.append("." + property); QJsonObject::const_iterator required = propertyValue.toObject().find("required"); @@ -185,11 +217,19 @@ void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonO { validate(value[property], propertyValue.toObject()); } - else if (required != propertyValue.toObject().end() && required.value().toBool() && !_ignoreRequired) + else if (required != propertyValue.toObject().end() && propertyValue.toObject().find("required").value().toBool() && !_ignoreRequired) { _error = true; - setMessage("missing member"); + + if (_correct == "create") + QJsonUtils::modify(_autoCorrected, _currentPath, QJsonUtils::create(propertyValue, _ignoreRequired), property); + + if (_correct == "") + setMessage("missing member"); } + else if (_correct == "create" && _ignoreRequired) + QJsonUtils::modify(_autoCorrected, _currentPath, QJsonUtils::create(propertyValue, _ignoreRequired), property); + _currentPath.removeLast(); } } @@ -208,7 +248,12 @@ void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, co if (schema.toBool() == false) { _error = true; - setMessage("no schema definition"); + + if (_correct == "remove") + QJsonUtils::modify(_autoCorrected, _currentPath); + + if (_correct == "") + setMessage("no schema definition"); } } else @@ -220,7 +265,7 @@ void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, co } } -void QJsonSchemaChecker::checkMinimum(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkMinimum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { if (!value.isDouble()) { @@ -233,11 +278,18 @@ void QJsonSchemaChecker::checkMinimum(const QJsonValue & value, const QJsonValue if (value.toDouble() < schema.toDouble()) { _error = true; - setMessage("value is too small (minimum=" + schema.toString() + ")"); + + if (_correct == "modify") + (defaultValue != QJsonValue::Null) ? + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) : + QJsonUtils::modify(_autoCorrected, _currentPath, schema); + + if (_correct == "") + setMessage("value is too small (minimum=" + QString::number(schema.toDouble()) + ")"); } } -void QJsonSchemaChecker::checkMaximum(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkMaximum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { if (!value.isDouble()) { @@ -250,11 +302,18 @@ void QJsonSchemaChecker::checkMaximum(const QJsonValue & value, const QJsonValue if (value.toDouble() > schema.toDouble()) { _error = true; - setMessage("value is too large (maximum=" + schema.toString() + ")"); + + if (_correct == "modify") + (defaultValue != QJsonValue::Null) ? + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) : + QJsonUtils::modify(_autoCorrected, _currentPath, schema); + + if (_correct == "") + setMessage("value is too large (maximum=" + QString::number(schema.toDouble()) + ")"); } } -void QJsonSchemaChecker::checkMinLength(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkMinLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { if (!value.isString()) { @@ -267,11 +326,18 @@ void QJsonSchemaChecker::checkMinLength(const QJsonValue & value, const QJsonVal if (value.toString().size() < schema.toInt()) { _error = true; - setMessage("value is too short (minLength=" + schema.toString() + ")"); + + if (_correct == "modify") + (defaultValue != QJsonValue::Null) ? + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) : + QJsonUtils::modify(_autoCorrected, _currentPath, schema); + + if (_correct == "") + setMessage("value is too short (minLength=" + QString::number(schema.toInt()) + ")"); } } -void QJsonSchemaChecker::checkMaxLength(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkMaxLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { if (!value.isString()) { @@ -284,7 +350,14 @@ void QJsonSchemaChecker::checkMaxLength(const QJsonValue & value, const QJsonVal if (value.toString().size() > schema.toInt()) { _error = true; - setMessage("value is too long (maxLength=" + schema.toString() + ")"); + + if (_correct == "modify") + (defaultValue != QJsonValue::Null) ? + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) : + QJsonUtils::modify(_autoCorrected, _currentPath, schema); + + if (_correct == "") + setMessage("value is too long (maxLength=" + QString::number(schema.toInt()) + ")"); } } @@ -299,6 +372,11 @@ void QJsonSchemaChecker::checkItems(const QJsonValue & value, const QJsonObject } QJsonArray jArray = value.toArray(); + + if (_correct == "remove") + if (jArray.isEmpty()) + QJsonUtils::modify(_autoCorrected, _currentPath); + for(int i = 0; i < jArray.size(); ++i) { // validate each item @@ -308,7 +386,7 @@ void QJsonSchemaChecker::checkItems(const QJsonValue & value, const QJsonObject } } -void QJsonSchemaChecker::checkMinItems(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkMinItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { if (!value.isArray()) { @@ -318,17 +396,22 @@ void QJsonSchemaChecker::checkMinItems(const QJsonValue & value, const QJsonValu return; } - int minimum = schema.toInt(); - QJsonArray jArray = value.toArray(); - if (static_cast(jArray.size()) < minimum) + if (jArray.size() < schema.toInt()) { _error = true; - setMessage("array is too large (minimum=" + QString::number(minimum) + ")"); + + if (_correct == "modify") + (defaultValue != QJsonValue::Null) ? + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) : + QJsonUtils::modify(_autoCorrected, _currentPath, schema); + + if (_correct == "") + setMessage("array is too small (minimum=" + QString::number(schema.toInt()) + ")"); } } -void QJsonSchemaChecker::checkMaxItems(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkMaxItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { if (!value.isArray()) { @@ -338,13 +421,18 @@ void QJsonSchemaChecker::checkMaxItems(const QJsonValue & value, const QJsonValu return; } - int maximum = schema.toInt(); - QJsonArray jArray = value.toArray(); - if (static_cast(jArray.size()) > maximum) + if (jArray.size() > schema.toInt()) { _error = true; - setMessage("array is too large (maximum=" + QString::number(maximum) + ")"); + + if (_correct == "modify") + (defaultValue != QJsonValue::Null) ? + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) : + QJsonUtils::modify(_autoCorrected, _currentPath, schema); + + if (_correct == "") + setMessage("array is too large (maximum=" + QString::number(schema.toInt()) + ")"); } } @@ -362,6 +450,8 @@ void QJsonSchemaChecker::checkUniqueItems(const QJsonValue & value, const QJsonV { // make sure no two items are identical + bool removeDuplicates = false; + QJsonArray jArray = value.toArray(); for(int i = 0; i < jArray.size(); ++i) { @@ -371,14 +461,28 @@ void QJsonSchemaChecker::checkUniqueItems(const QJsonValue & value, const QJsonV { // found a value twice _error = true; - setMessage("array must have unique values"); + removeDuplicates = true; + + if (_correct == "") + setMessage("array must have unique values"); } } } + + if (removeDuplicates && _correct == "modify") + { + QJsonArray uniqueItemsArray; + + for(int i = 0; i < jArray.size(); ++i) + if (!uniqueItemsArray.contains(jArray[i])) + uniqueItemsArray.append(jArray[i]); + + QJsonUtils::modify(_autoCorrected, _currentPath, uniqueItemsArray); + } } } -void QJsonSchemaChecker::checkEnum(const QJsonValue & value, const QJsonValue & schema) +void QJsonSchemaChecker::checkEnum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue) { if (schema.isArray()) { @@ -395,7 +499,16 @@ void QJsonSchemaChecker::checkEnum(const QJsonValue & value, const QJsonValue & // nothing found _error = true; - QJsonDocument doc(schema.toArray()); - QString strJson(doc.toJson(QJsonDocument::Compact)); - setMessage("Unknown enum value (allowed values are: " + schema.toString() + strJson+ ")"); + + if (_correct == "modify") + (defaultValue != QJsonValue::Null) ? + QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) : + QJsonUtils::modify(_autoCorrected, _currentPath, schema.toArray().first()); + + if (_correct == "") + { + QJsonDocument doc(schema.toArray()); + QString strJson(doc.toJson(QJsonDocument::Compact)); + setMessage("Unknown enum value (allowed values are: " + strJson+ ")"); + } } diff --git a/libsrc/webconfig/CgiHandler.cpp b/libsrc/webconfig/CgiHandler.cpp index 97af4f83..7f8ffbf1 100644 --- a/libsrc/webconfig/CgiHandler.cpp +++ b/libsrc/webconfig/CgiHandler.cpp @@ -105,14 +105,43 @@ void CgiHandler::cmd_cfg_set() { // make sure the resources are loaded (they may be left out after static linking) Q_INIT_RESOURCE(resource); - QJsonObject schemaJson = QJsonFactory::readSchema(":/hyperion-schema-"+QString::number(_hyperion->getConfigVersionId())); + + QString schemaFile = ":/hyperion-schema"; + QJsonObject schemaJson; + + try + { + schemaJson = QJsonFactory::readSchema(schemaFile); + } + catch(const std::runtime_error& error) + { + throw std::runtime_error(error.what()); + } + QJsonSchemaChecker schemaChecker; schemaChecker.setSchema(schemaJson); - if ( schemaChecker.validate(hyperionConfigJsonObj) ) + + QPair validate = schemaChecker.validate(hyperionConfigJsonObj); + + + if (validate.first && validate.second) { QJsonFactory::writeJson(_hyperion->getConfigFileName(), hyperionConfigJsonObj); } - else + else if (!validate.first && validate.second) + { + Warning(_log,"Errors have been found in the configuration file. Automatic correction is applied"); + + QStringList schemaErrors = schemaChecker.getMessages(); + foreach (auto & schemaError, schemaErrors) + Info(_log, schemaError.toUtf8().constData()); + + hyperionConfigJsonObj = schemaChecker.getAutoCorrectedConfig(hyperionConfigJsonObj); + + if (!QJsonFactory::writeJson(_hyperion->getConfigFileName(), hyperionConfigJsonObj)) + throw std::runtime_error("ERROR: can not save configuration file, aborting "); + } + else //Error in Schema { QString errorMsg = "ERROR: Json validation failed: \n"; QStringList schemaErrors = schemaChecker.getMessages(); @@ -121,6 +150,7 @@ void CgiHandler::cmd_cfg_set() Error(_log, "config write validation: %s", QSTRING_CSTR(schemaError)); errorMsg += schemaError + "\n"; } + throw std::runtime_error(errorMsg.toStdString()); } } diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index 08929a55..6a3a1173 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -8,10 +8,6 @@ QT5_WRAP_CPP(Hyperiond_HEADERS_MOC ${Hyperiond_QT_HEADERS}) add_executable(hyperiond ${Hyperiond_QT_HEADERS} ${Hyperiond_HEADERS_MOC} - configMigratorBase.cpp - configMigratorBase.h - configMigrator.cpp - configMigrator.h hyperiond.cpp main.cpp ) diff --git a/src/hyperiond/configMigrator.cpp b/src/hyperiond/configMigrator.cpp deleted file mode 100644 index 633998f5..00000000 --- a/src/hyperiond/configMigrator.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "configMigrator.h" - - -ConfigMigrator::ConfigMigrator() -{ -} - -ConfigMigrator::~ConfigMigrator() -{ -} - -bool ConfigMigrator::migrate(QString configFile, int fromVersion,int toVersion) -{ - Debug(_log, "migrate config %s from version %d to %d.", configFile.toLocal8Bit().constData(), fromVersion, toVersion); - - for (int v=fromVersion; v - -/// -/// class that contains migration code -/// helper code goeas to base class -class ConfigMigrator : public ConfigMigratorBase - -{ - -public: - ConfigMigrator(); - ~ConfigMigrator(); - - bool migrate(QString configFile, int fromVersion,int toVersion); - -private: - void migrateFrom1(); -}; \ No newline at end of file diff --git a/src/hyperiond/configMigratorBase.cpp b/src/hyperiond/configMigratorBase.cpp deleted file mode 100644 index 90db5075..00000000 --- a/src/hyperiond/configMigratorBase.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "configMigratorBase.h" - -ConfigMigratorBase::ConfigMigratorBase() - : _log(Logger::getInstance("ConfigMigrator")) -{ -} - -ConfigMigratorBase::~ConfigMigratorBase() -{ -} - diff --git a/src/hyperiond/configMigratorBase.h b/src/hyperiond/configMigratorBase.h deleted file mode 100644 index 457b6a21..00000000 --- a/src/hyperiond/configMigratorBase.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -#include - -class ConfigMigratorBase -{ - -public: - ConfigMigratorBase(); - ~ConfigMigratorBase(); - -protected: - Logger * _log; -}; \ No newline at end of file diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 894a595f..231e8c87 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -31,7 +32,6 @@ #include #include "hyperiond.h" -#include "configMigrator.h" HyperionDaemon::HyperionDaemon(QString configFile, QObject *parent) : QObject(parent) @@ -52,7 +52,7 @@ HyperionDaemon::HyperionDaemon(QString configFile, QObject *parent) , _hyperion(nullptr) , _stats(nullptr) { - loadConfig(configFile, CURRENT_CONFIG_VERSION ); + loadConfig(configFile); if (Logger::getLogLevel() == Logger::WARNING) { @@ -135,16 +135,16 @@ void HyperionDaemon::run() connect(_hyperion,SIGNAL(closing()),this,SLOT(freeObjects())); } -int HyperionDaemon::tryLoadConfig(const QString & configFile, const int schemaVersion) +void HyperionDaemon::loadConfig(const QString & configFile) { + Info(_log, "Selected configuration file: %s", configFile.toUtf8().constData()); + // make sure the resources are loaded (they may be left out after static linking) Q_INIT_RESOURCE(resource); // read the json schema from the resource + QString schemaFile = ":/hyperion-schema"; - if (schemaVersion > 0) - schemaFile += "-" + QString::number(schemaVersion); - QJsonObject schemaJson; try { @@ -159,45 +159,25 @@ int HyperionDaemon::tryLoadConfig(const QString & configFile, const int schemaVe schemaChecker.setSchema(schemaJson); _qconfig = QJsonFactory::readConfig(configFile); - if (!schemaChecker.validate(_qconfig)) + QPair validate = schemaChecker.validate(_qconfig); + + if (!validate.first && validate.second) + { + Warning(_log,"Errors have been found in the configuration file. Automatic correction is applied"); + + _qconfig = schemaChecker.getAutoCorrectedConfig(_qconfig); + + if (!QJsonFactory::writeJson(configFile, _qconfig)) + throw std::runtime_error("ERROR: can not save configuration file, aborting "); + } + else if (validate.first && !validate.second) //Error in Schema { QStringList schemaErrors = schemaChecker.getMessages(); foreach (auto & schemaError, schemaErrors) - { std::cout << schemaError.toStdString() << std::endl; - } throw std::runtime_error("ERROR: Json validation failed"); } - - const QJsonObject & generalConfig = _qconfig["general"].toObject(); - return generalConfig["configVersion"].toInt(-1); -} - -void HyperionDaemon::loadConfig(const QString & configFile, const int neededConfigVersion) -{ - Info(_log, "Selected configuration file: %s", configFile.toUtf8().constData()); - - int configVersionId = tryLoadConfig(configFile,0); - - // no config id found, assume legacy hyperion - if (configVersionId < 0) - { - Debug(_log, "config file has no version, assume old hyperion."); - configVersionId = tryLoadConfig(configFile,1); - } - Debug(_log, "config version: %d", configVersionId); - configVersionId = tryLoadConfig(configFile, configVersionId); - - if (neededConfigVersion == configVersionId) - { - return; - } - - // migrate configVersionId - ConfigMigrator migrator; - migrator.migrate(configFile, configVersionId, neededConfigVersion); - } diff --git a/src/hyperiond/hyperiond.h b/src/hyperiond/hyperiond.h index 762af51d..2e69fb98 100644 --- a/src/hyperiond/hyperiond.h +++ b/src/hyperiond/hyperiond.h @@ -54,9 +54,8 @@ class HyperionDaemon : public QObject public: HyperionDaemon(QString configFile, QObject *parent=nullptr); ~HyperionDaemon(); - - int tryLoadConfig(const QString & configFile, const int schemaVersion); - void loadConfig(const QString & configFile, const int neededConfigVersion); + + void loadConfig(const QString & configFile); void run(); void startInitialEffect(); diff --git a/test/TestConfigFile.cpp b/test/TestConfigFile.cpp index d7d59fa8..e7c3c6d2 100644 --- a/test/TestConfigFile.cpp +++ b/test/TestConfigFile.cpp @@ -1,9 +1,6 @@ - -// STL includes -#include - // QT includes #include +#include // JsonSchema includes #include @@ -12,7 +9,7 @@ #include #include "HyperionConfig.h" -bool loadConfig(const QString & configFile) +bool loadConfig(const QString & configFile, bool correct, bool ignore) { // make sure the resources are loaded (they may be left out after static linking) Q_INIT_RESOURCE(resource); @@ -39,46 +36,75 @@ bool loadConfig(const QString & configFile) // read and validate the configuration file from the command line //////////////////////////////////////////////////////////// - const QJsonObject jsonConfig = QJsonFactory::readConfig(configFile); - - if (!schemaChecker.validate(jsonConfig)) + QJsonObject jsonConfig = QJsonFactory::readConfig(configFile); + + if (!correct) { - QStringList schemaErrors = schemaChecker.getMessages(); - foreach (auto & schemaError, schemaErrors) + if (!schemaChecker.validate(jsonConfig).first) { - std::cout << "config write validation: " << schemaError.toStdString() << std::endl; + QStringList schemaErrors = schemaChecker.getMessages(); + foreach (auto & schemaError, schemaErrors) + { + qDebug() << "config write validation: " << schemaError; + } + + qDebug() << "FAILED"; + exit(1); + return false; } - - std::cout << "FAILED" << std::endl; - exit(1); - return false; + } + else + { + jsonConfig = schemaChecker.getAutoCorrectedConfig(jsonConfig, ignore); // The second parameter is to ignore the "required" keyword in hyperion schema + QJsonFactory::writeJson(configFile, jsonConfig); } return true; } +void usage() +{ + qDebug() << "Missing required configuration file to test"; + qDebug() << "Usage: test_configfile