hyperion.ng/libsrc/webconfig/WebConfig.cpp
redPanther 197af35de0 Clone single led color from other led (#157)
* start ledclone

* led cloning: clone scan areas from original led
main: show exceptions, better exit

* tune json schema for new option. somwe cleanup

* fix warnings and bug for framebuffer selection. thx to clang brought by new osx buikld on travis

* make ledclone feature work flawlessly for effects too. Effect sees the ledstring without cloned leds.
cloned leds will be inserted just before sending to leddevice

additional: remove warnings and fix code style

* fix warning
2016-08-08 00:17:00 +02:00

52 lines
1.0 KiB
C++

#include "webconfig/WebConfig.h"
#include "StaticFileServing.h"
WebConfig::WebConfig(QObject * parent)
: QObject(parent)
, _server(nullptr)
{
_port = WEBCONFIG_DEFAULT_PORT;
_hyperion = Hyperion::getInstance();
const Json::Value &config = _hyperion->getJsonConfig();
_baseUrl = QString::fromStdString(WEBCONFIG_DEFAULT_PATH);
_port = WEBCONFIG_DEFAULT_PORT;
bool webconfigEnable = true;
if (config.isMember("webConfig"))
{
const Json::Value & webconfigConfig = config["webConfig"];
webconfigEnable = webconfigConfig.get("enable", true).asBool();
_port = webconfigConfig.get("port", WEBCONFIG_DEFAULT_PORT).asUInt();
_baseUrl = QString::fromStdString( webconfigConfig.get("document_root", WEBCONFIG_DEFAULT_PATH).asString() );
}
if ( webconfigEnable )
start();
}
WebConfig::~WebConfig()
{
stop();
}
void WebConfig::start()
{
if ( _server == nullptr )
_server = new StaticFileServing (_hyperion, _baseUrl, _port, this);
}
void WebConfig::stop()
{
if ( _server != nullptr )
{
delete _server;
_server = nullptr;
}
}