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:
redPanther
2017-03-04 22:17:42 +01:00
committed by GitHub
parent 19f8928869
commit bfb9a08c80
90 changed files with 539 additions and 529 deletions

View File

@@ -2,7 +2,7 @@
// Hyperion-AmLogic includes
#include "FramebufferWrapper.h"
FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
FramebufferWrapper::FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
_timer(this),
_grabber(device,grabWidth, grabHeight)
{

View File

@@ -9,7 +9,7 @@ class FramebufferWrapper : public QObject
{
Q_OBJECT
public:
FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
const Image<ColorRgb> & getScreenshot();

View File

@@ -46,7 +46,7 @@ int main(int argc, char ** argv)
parser.showHelp(0);
}
FramebufferWrapper fbWrapper(argDevice.getStdString(parser), argWidth.getInt(parser), argHeight.getInt(parser), 1000 / argFps.getInt(parser));
FramebufferWrapper fbWrapper(argDevice.value(parser), argWidth.getInt(parser), argHeight.getInt(parser), 1000 / argFps.getInt(parser));
if (parser.isSet(argScreenshot))
{

View File

@@ -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;

View File

@@ -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
///

View File

@@ -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))
{

View File

@@ -109,7 +109,7 @@ int main(int argc, char** argv)
// initialize the grabber
V4L2Grabber grabber(
argDevice.getStdString(parser),
argDevice.value(parser),
argInput.getInt(parser),
argVideoStandard.switchValue(parser),
argPixelFormat.switchValue(parser),

View File

@@ -158,9 +158,10 @@ int HyperionDaemon::tryLoadConfig(const QString & configFile, const int schemaVe
_qconfig = QJsonFactory::readConfig(configFile);
if (!schemaChecker.validate(_qconfig))
{
for (std::list<std::string>::const_iterator i = schemaChecker.getMessages().begin(); i != schemaChecker.getMessages().end(); ++i)
QStringList schemaErrors = schemaChecker.getMessages();
foreach (auto & schemaError, schemaErrors)
{
std::cout << *i << std::endl;
std::cout << schemaError.toStdString() << std::endl;
}
throw std::runtime_error("ERROR: Json validation failed");
@@ -536,7 +537,7 @@ void HyperionDaemon::createGrabberFramebuffer(const QJsonObject & grabberConfig)
#ifdef ENABLE_FB
// Construct and start the framebuffer grabber if the configuration is present
_fbGrabber = new FramebufferWrapper(
grabberConfig["device"].toString("/dev/fb0").toStdString(),
grabberConfig["device"].toString("/dev/fb0"),
_grabber_width, _grabber_height, _grabber_frequency, _grabber_priority);
QObject::connect(_kodiVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _fbGrabber, SLOT(setGrabbingMode(GrabbingMode)));
@@ -593,10 +594,10 @@ void HyperionDaemon::createGrabberV4L2()
}
#ifdef ENABLE_V4L2
V4L2Wrapper* grabber = new V4L2Wrapper(
grabberConfig["device"].toString("auto").toStdString(),
grabberConfig["device"].toString("auto"),
grabberConfig["input"].toInt(0),
parseVideoStandard(grabberConfig["standard"].toString("no-change").toStdString()),
parsePixelFormat(grabberConfig["pixelFormat"].toString("no-change").toStdString()),
parseVideoStandard(grabberConfig["standard"].toString("no-change")),
parsePixelFormat(grabberConfig["pixelFormat"].toString("no-change")),
grabberConfig["width"].toInt(-1),
grabberConfig["height"].toInt(-1),
grabberConfig["frameDecimation"].toInt(2),
@@ -605,7 +606,7 @@ void HyperionDaemon::createGrabberV4L2()
grabberConfig["greenSignalThreshold"].toDouble(0.0),
grabberConfig["blueSignalThreshold"].toDouble(0.0),
grabberConfig["priority"].toInt(890));
grabber->set3D(parse3DMode(grabberConfig["mode"].toString("2D").toStdString()));
grabber->set3D(parse3DMode(grabberConfig["mode"].toString("2D")));
grabber->setCropping(
grabberConfig["cropLeft"].toInt(0),
grabberConfig["cropRight"].toInt(0),