// stl includes #include #include #include #include #include // Qt includes #include #include // hyperion-remote include #include "JsonConnection.h" // ssdp discover #include #include "HyperionConfig.h" #include #include using namespace commandline; /// Count the number of true values in a list of booleans int count(std::initializer_list values) { int count = 0; for (bool value : values) { if (value) { count++; } } return count; } void showHelp(Option & option){ QString shortOption; QString longOption = QString("--%1").arg(option.names().last()); if(option.names().size() == 2){ shortOption = QString("-%1").arg(option.names().first()); } qWarning() << qPrintable(QString("\t%1\t%2\t%3").arg(shortOption, longOption, option.description())); } int getInstaneIdbyName(const QJsonObject & reply, const QString & name){ if(reply.contains("instance")){ QJsonArray list = reply.value("instance").toArray(); for (const QJsonValueRef entry : list) { const QJsonObject obj = entry.toObject(); if(obj["friendly_name"] == name && obj["running"].toBool()) { return obj["instance"].toInt(); } } } std::cout << "Can't find a running instance with name '" << name.toStdString()<< "' at this Hyperion server, will use first instance" << std::endl; return 0; } int main(int argc, char * argv[]) { #ifndef _WIN32 setenv("AVAHI_COMPAT_NOWARN", "1", 1); #endif std::cout << "hyperion-remote:" << std::endl << "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; DefaultSignalHandler::install(); QCoreApplication app(argc, argv); // force the locale setlocale(LC_ALL, "C"); QLocale::setDefault(QLocale::c()); try { // create the option parser and initialize all parameters Parser parser("Application to send a command to hyperion using the JSON interface"); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // art variable definition append art to Parser short-, long option description, optional default value // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Option & argAddress = parser.add