Merge remote-tracking branch 'refs/remotes/hyperion-project/master' into weba

This commit is contained in:
brindosch
2017-01-24 21:30:00 +01:00
16 changed files with 350 additions and 128 deletions

View File

@@ -74,6 +74,7 @@ V4L2Grabber::~V4L2Grabber()
void V4L2Grabber::uninit()
{
Debug(_log,"uninit grabber: %s", _deviceName.c_str());
// stop if the grabber was not stopped
if (_initialized)
{

View File

@@ -27,6 +27,8 @@ GrabberWrapper::GrabberWrapper(std::string grabberName, const int priority, hype
GrabberWrapper::~GrabberWrapper()
{
stop();
Debug(_log,"Close grabber: %s", _grabberName.c_str());
delete _processor;
}

View File

@@ -447,8 +447,13 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
}
void Hyperion::freeObjects()
void Hyperion::freeObjects(bool emitCloseSignal)
{
if (emitCloseSignal)
{
emit closing();
}
// switch off all leds
clearall();
_device->switchOff();
@@ -462,7 +467,7 @@ void Hyperion::freeObjects()
Hyperion::~Hyperion()
{
freeObjects();
freeObjects(false);
}
unsigned Hyperion::getLedCount() const

View File

@@ -892,7 +892,7 @@ void JsonClientConnection::handleConfigCommand(const QJsonObject& message, const
}
else if (subcommand == "reload")
{
_hyperion->freeObjects();
_hyperion->freeObjects(true);
Process::restartHyperion();
sendErrorReply("failed to restart hyperion", full_command, tan);
}
@@ -912,7 +912,7 @@ void JsonClientConnection::handleConfigGetCommand(const QJsonObject& message, co
try
{
result["result"] = QJsonFactory::readJson(QString::fromStdString(_hyperion->getConfigFileName()));
result["result"] = QJsonFactory::readConfig(QString::fromStdString(_hyperion->getConfigFileName()));
}
catch(...)
{

View File

@@ -115,6 +115,7 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
else
{
// no check function defined for this attribute
_error = true;
setMessage(std::string("No check function defined for attribute ") + attribute.toStdString());
continue;
}

View File

@@ -73,6 +73,13 @@ static inline void printErrorToReply (QtHttpReply * reply, QString errorMessage)
reply->appendRawData (errorMessage.toLocal8Bit ());
}
static inline void printError404ToReply (QtHttpReply * reply, QString errorMessage)
{
reply->setStatusCode(QtHttpReply::NotFound);
reply->addHeader ("Content-Type", QByteArrayLiteral ("text/plain"));
reply->appendRawData (errorMessage.toLocal8Bit ());
}
void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpReply * reply)
{
QString command = request->getCommand ();
@@ -103,7 +110,7 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
Q_INIT_RESOURCE(WebConfig);
QFileInfo info(_baseUrl % "/" % path);
if ( path == "/" || path.isEmpty() || ! info.exists() )
if ( path == "/" || path.isEmpty() )
{
path = "index.html";
}
@@ -134,7 +141,7 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
}
else
{
printErrorToReply (reply, "Requested file " % path % " couldn't be found !");
printError404ToReply (reply, "404 Not Found\n" % path % " couldn't be found !");
}
}
else

View File

@@ -23,7 +23,7 @@ WebConfig::WebConfig(QObject * parent)
_baseUrl = webconfigConfig["document_root"].toString(_baseUrl);
}
if (_baseUrl != ":/webconfig")
if ( (_baseUrl != ":/webconfig") && !_baseUrl.trimmed().isEmpty())
{
QFileInfo info(_baseUrl);
if (!info.exists() || !info.isDir())
@@ -32,6 +32,8 @@ WebConfig::WebConfig(QObject * parent)
_baseUrl = WEBCONFIG_DEFAULT_PATH;
}
}
else
_baseUrl = WEBCONFIG_DEFAULT_PATH;
Debug(log, "WebUI initialized, document root: %s", _baseUrl.toUtf8().constData());
if ( webconfigEnable )