mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
migrate std::string to qstring + add sysinfo via json (#412)
* std::string -> qstring part 1 * more string migration * more string migration ... * ... * more qstring mogrations add sysinfo via json * remove unneccessary includes * integrate sysinfo into webui
This commit is contained in:
@@ -256,6 +256,33 @@ QString JsonConnection::getServerInfo()
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString JsonConnection::getSysInfo()
|
||||
{
|
||||
qDebug() << "Get system info";
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
command["command"] = QString("sysinfo");
|
||||
|
||||
// send command message
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
if (parseReply(reply))
|
||||
{
|
||||
if (!reply.contains("info") || !reply["info"].isObject())
|
||||
{
|
||||
throw std::runtime_error("No info available in result");
|
||||
}
|
||||
|
||||
QJsonDocument doc(reply["info"].toObject());
|
||||
QString info(doc.toJson(QJsonDocument::Indented));
|
||||
return info;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void JsonConnection::clear(int priority)
|
||||
{
|
||||
qDebug() << "Clear priority channel " << priority;
|
||||
|
@@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
// stl includes
|
||||
#include <string>
|
||||
|
||||
// Qt includes
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
@@ -79,6 +76,13 @@ public:
|
||||
///
|
||||
QString getServerInfo();
|
||||
|
||||
///
|
||||
/// Retrieve system info
|
||||
///
|
||||
/// @return String with the sys info
|
||||
///
|
||||
QString getSysInfo();
|
||||
|
||||
///
|
||||
/// Clear the given priority channel
|
||||
///
|
||||
|
@@ -67,6 +67,7 @@ int main(int argc, char * argv[])
|
||||
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 & argSysInfo = parser.add<BooleanOption>('s', "sysinfo" , "show system info");
|
||||
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");
|
||||
Option & argEnableComponent = parser.add<Option> ('E', "enable" , "Enable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER, V4L]");
|
||||
@@ -110,7 +111,7 @@ int main(int argc, char * argv[])
|
||||
|
||||
// check that exactly one command was given
|
||||
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), colorAdjust,
|
||||
parser.isSet(argServerInfo), parser.isSet(argSysInfo),parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorAdjust,
|
||||
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
|
||||
parser.isSet(argMapping) });
|
||||
if (commandCount != 1)
|
||||
@@ -122,6 +123,7 @@ int main(int argc, char * argv[])
|
||||
showHelp(argCreateEffect);
|
||||
showHelp(argDeleteEffect);
|
||||
showHelp(argServerInfo);
|
||||
showHelp(argSysInfo);
|
||||
showHelp(argClear);
|
||||
showHelp(argClearAll);
|
||||
showHelp(argEnableComponent);
|
||||
@@ -171,8 +173,11 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else if (parser.isSet(argServerInfo))
|
||||
{
|
||||
QString info = connection.getServerInfo();
|
||||
std::cout << "Server info:\n" << info.toStdString() << std::endl;
|
||||
std::cout << "Server info:\n" << connection.getServerInfo().toStdString() << std::endl;
|
||||
}
|
||||
else if (parser.isSet(argSysInfo))
|
||||
{
|
||||
std::cout << "System info:\n" << connection.getSysInfo().toStdString() << std::endl;
|
||||
}
|
||||
else if (parser.isSet(argClear))
|
||||
{
|
||||
|
Reference in New Issue
Block a user