diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 1f9f070c..58b7aa04 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -258,6 +258,8 @@ void JsonClientConnection::handleMessage(const std::string &messageString) handleAdjustmentCommand(message); else if (command == "sourceselect") handleSourceSelectCommand(message); + else if (command == "configget") + handleConfigGetCommand(message); else handleNotImplemented(); } @@ -801,6 +803,18 @@ void JsonClientConnection::handleSourceSelectCommand(const Json::Value & message } } +void JsonClientConnection::handleConfigGetCommand(const Json::Value &) +{ + // create result + Json::Value result; + result["success"] = true; + Json::Value & config = result["result"]; + config = _hyperion->getJsonConfig(); + + // send the result + sendMessage(result); +} + void JsonClientConnection::handleNotImplemented() { sendErrorReply("Command not implemented"); diff --git a/libsrc/jsonserver/JsonClientConnection.h b/libsrc/jsonserver/JsonClientConnection.h index 12080ddd..19b70131 100644 --- a/libsrc/jsonserver/JsonClientConnection.h +++ b/libsrc/jsonserver/JsonClientConnection.h @@ -134,6 +134,12 @@ private: /// @param message the incoming message /// void handleSourceSelectCommand(const Json::Value & message); + + /// Handle an incoming JSON GetConfig message + /// + /// @param message the incoming message + /// + void handleConfigGetCommand(const Json::Value & message); /// /// Handle an incoming JSON message of unknown type diff --git a/libsrc/jsonserver/JsonSchemas.qrc b/libsrc/jsonserver/JsonSchemas.qrc index a61322d3..c7bbdf87 100644 --- a/libsrc/jsonserver/JsonSchemas.qrc +++ b/libsrc/jsonserver/JsonSchemas.qrc @@ -12,5 +12,6 @@ schema/schema-adjustment.json schema/schema-effect.json schema/schema-sourceselect.json + schema/schema-configget.json diff --git a/libsrc/jsonserver/schema/schema-configget.json b/libsrc/jsonserver/schema/schema-configget.json new file mode 100644 index 00000000..6812a19b --- /dev/null +++ b/libsrc/jsonserver/schema/schema-configget.json @@ -0,0 +1,12 @@ +{ + "type":"object", + "required":true, + "properties":{ + "command": { + "type" : "string", + "required" : true, + "enum" : ["configget"] + } + }, + "additionalProperties": false +} diff --git a/libsrc/jsonserver/schema/schema.json b/libsrc/jsonserver/schema/schema.json index bbf2058a..186c5843 100644 --- a/libsrc/jsonserver/schema/schema.json +++ b/libsrc/jsonserver/schema/schema.json @@ -5,7 +5,7 @@ "command": { "type" : "string", "required" : true, - "enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature", "adjustment", "sourceselect"] + "enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature", "adjustment", "sourceselect", "configget"] } } } diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 55dd73fa..b5fee9ad 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -220,6 +220,32 @@ void JsonConnection::setSourceAutoSelect() parseReply(reply); } +QString JsonConnection::getConfigFile() +{ + std::cout << "Get configuration file from Hyperion Server" << std::endl; + + // create command + Json::Value command; + command["command"] = "configget"; + + // send command message + Json::Value reply = sendMessage(command); + + // parse reply message + if (parseReply(reply)) + { + if (!reply.isMember("result") || !reply["result"].isObject()) + { + throw std::runtime_error("No configuration file available in result"); + } + + const Json::Value & config = reply["result"]; + return QString(config.toStyledString().c_str()); + } + + return QString(); +} + void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, double * saturationL, double * luminance, double * luminanceMin, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel) { std::cout << "Set color transforms" << std::endl; diff --git a/src/hyperion-remote/JsonConnection.h b/src/hyperion-remote/JsonConnection.h index 8f76b070..e2d9febf 100644 --- a/src/hyperion-remote/JsonConnection.h +++ b/src/hyperion-remote/JsonConnection.h @@ -84,13 +84,21 @@ public: void clearAll(); /// - /// Clear the given priority channel + /// Set current active priority channel and deactivate auto source switching /// /// @param priority The priority /// void setSource(int priority); + /// + /// Enables auto source, if disabled prio by manual selecting input source + /// void setSourceAutoSelect(); + + /// + /// Print the current loaded Hyperion configuration file + /// + QString getConfigFile(); /// /// Set the color transform of the leds diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index 997c990f..828e092e 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -83,6 +83,7 @@ int main(int argc, char * argv[]) AdjustmentParameter & argBAdjust = parameters.add('B', "blueAdjustment", "Set the adjustment of the blue color (requires 3 space seperated values between 0 and 255)"); IntParameter & argSource = parameters.add (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching"); SwitchParameter<> & argSourceAuto = parameters.add >(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source"); + SwitchParameter<> & argConfigGet = parameters.add >(0x0, "configget" , "Print the current loaded Hyperion configuration file"); // set the default values argAddress.setDefault(defaultServerAddress.toStdString()); @@ -106,7 +107,7 @@ int main(int argc, char * argv[]) bool colorModding = colorTransform || colorAdjust || argCorrection.isSet() || argTemperature.isSet(); // check that exactly one command was given - int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet()}); + int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet(), argConfigGet.isSet()}); if (commandCount != 1) { std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl; @@ -116,6 +117,9 @@ int main(int argc, char * argv[]) std::cerr << " " << argServerInfo.usageLine() << std::endl; std::cerr << " " << argClear.usageLine() << std::endl; std::cerr << " " << argClearAll.usageLine() << std::endl; + std::cerr << " " << argSource.usageLine() << std::endl; + std::cerr << " " << argSourceAuto.usageLine() << std::endl; + std::cerr << " " << argConfigGet.usageLine() << std::endl; std::cerr << "or one or more of the available color modding operations:" << std::endl; std::cerr << " " << argId.usageLine() << std::endl; std::cerr << " " << argSaturation.usageLine() << std::endl; @@ -175,6 +179,11 @@ int main(int argc, char * argv[]) { connection.setSourceAutoSelect(); } + else if (argConfigGet.isSet()) + { + QString info = connection.getConfigFile(); + std::cout << "Configuration File:\n" << info.toStdString() << std::endl; + } else if (colorModding) { if (argCorrection.isSet())