hyperion.ng/libsrc/webconfig/WebConfig.cpp
redPanther 88fbc4dfde refactoring and cleanup (#2)
* make hyperion to singelton.
remove arguments for config and hyperion - both are gettable via Hyperion::getInstance

* refactor hyperiond

* remove qt4 comapt
make zeroconf mandatory
refactor hyperiond

* xbmcchecker is now a singleton

* cleanup in hyperiond
zeroconf switchable between static and shared linking

* fix xbmcchecker
2016-06-17 01:25:40 +02:00

51 lines
1.0 KiB
C++

#include "webconfig/WebConfig.h"
#include "StaticFileServing.h"
WebConfig::WebConfig(QObject * parent)
: QObject(parent)
, _port(WEBCONFIG_DEFAULT_PORT)
, _server(nullptr)
{
_hyperion = Hyperion::getInstance();
const Json::Value &config = _hyperion->getJsonConfig();
_baseUrl = QString::fromStdString(WEBCONFIG_DEFAULT_PATH);
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;
}
}