Delete custom created effect configurations with JSON RPC (#289)

* Add ability to delete custom created Effects

* Add deleteEffect function to Hyperion-Remote

* Add deleteEffect function to Hyperion-Remote

* Update schema.json

* Update JsonSchemas.qrc

* Add schema-delete-effect.json

* Add deleteEffect function to JSON RPC

* Add deleteEffect function to JSON RPC

* Add Effect configuration file (.json) to Effect Definition

* Update EffectDefinition.h
This commit is contained in:
Paulchen Panther
2016-11-18 18:39:21 +01:00
committed by brindosch
parent 4972bc086a
commit c2faf07574
10 changed files with 112 additions and 5 deletions

View File

@@ -209,6 +209,22 @@ void JsonConnection::createEffect(const QString &effectName, const QString &effe
parseReply(reply);
}
void JsonConnection::deleteEffect(const QString &effectName)
{
qDebug() << "Delete effect configuration" << effectName;
// create command
QJsonObject effect;
effect["command"] = QString("delete-effect");
effect["name"] = effectName;
// send command message
QJsonObject reply = sendMessage(effect);
// parse reply message
parseReply(reply);
}
QString JsonConnection::getServerInfo()
{
qDebug() << "Get server info";

View File

@@ -64,6 +64,13 @@ public:
/// @param effectArgs The arguments of the effect
///
void createEffect(const QString &effectName, const QString &effectScript, const QString & effectArgs);
///
/// Delete a effect configuration file (.json)
///
/// @param effectName The name of the effect
///
void deleteEffect(const QString &effectName);
///
/// Retrieve a list of all occupied priority channels

View File

@@ -65,6 +65,7 @@ int main(int argc, char * argv[])
Option & argEffectFile = parser.add<Option> (0x0, "effectFile", "Arguments to use in combination with --createEffect");
Option & argEffectArgs = parser.add<Option> (0x0, "effectArgs", "Arguments to use in combination with the specified effect. Should be a Json object string.", "");
Option & argCreateEffect= parser.add<Option> (0x0, "createEffect","Write a new Json Effect configuration file.\nFirst parameter = Effect name.\nSecond parameter = Effect file (--effectFile).\nLast parameter = Effect arguments (--effectArgs.)", "");
Option & argDeleteEffect= parser.add<Option> (0x0, "deleteEffect","Delete a custom created Json Effect configuration file.");
BooleanOption & argServerInfo = parser.add<BooleanOption>('l', "list" , "List server info and active effects with priority and duration");
BooleanOption & argClear = parser.add<BooleanOption>('x', "clear" , "Clear data for the priority channel provided by the -p option");
BooleanOption & argClearAll = parser.add<BooleanOption>(0x0, "clearall" , "Clear data for all active priority channels");
@@ -108,7 +109,7 @@ int main(int argc, char * argv[])
bool colorModding = colorTransform || colorAdjust;
// check that exactly one command was given
int commandCount = count({parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argServerInfo), parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorModding, parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet)});
int commandCount = count({parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect), parser.isSet(argServerInfo), parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorModding, parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet)});
if (commandCount != 1)
{
qWarning() << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:";
@@ -116,6 +117,7 @@ int main(int argc, char * argv[])
showHelp(argImage);
showHelp(argEffect);
showHelp(argCreateEffect);
showHelp(argDeleteEffect);
showHelp(argServerInfo);
showHelp(argClear);
showHelp(argClearAll);
@@ -163,6 +165,10 @@ int main(int argc, char * argv[])
{
connection.createEffect(argCreateEffect.value(parser), argEffectFile.value(parser), argEffectArgs.value(parser));
}
else if (parser.isSet(argDeleteEffect))
{
connection.deleteEffect(argDeleteEffect.value(parser));
}
else if (parser.isSet(argServerInfo))
{
QString info = connection.getServerInfo();