mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
88fbc4dfde
* 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
51 lines
1.0 KiB
C++
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;
|
|
}
|
|
}
|
|
|
|
|