[LmsAPI] Fix build
This commit is contained in:
@@ -77,8 +77,9 @@ ConfigReader::getUserInterfaceConfig(Service::UserInterfaceService::Config& conf
|
||||
config.dbPath = _config.lookup("main.database.path");
|
||||
}
|
||||
|
||||
#if defined HAVE_LMSAPI
|
||||
void
|
||||
ConfigReader::getRemoteServerConfig(Service::RemoteServerService::Config& config)
|
||||
ConfigReader::getLmsAPIConfig(Service::LmsAPIService::Config& config)
|
||||
{
|
||||
config.enable = _config.lookup("remote.enable");
|
||||
if (!config.enable)
|
||||
@@ -92,6 +93,7 @@ ConfigReader::getRemoteServerConfig(Service::RemoteServerService::Config& config
|
||||
|
||||
config.dbPath = _config.lookup("main.database.path");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ConfigReader::getDatabaseUpdateConfig(Service::DatabaseUpdateService::Config& config)
|
||||
|
||||
@@ -23,12 +23,16 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <libconfig.h++>
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
#include "cover/CoverArtGrabber.hpp"
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
#include "service/UserInterfaceService.hpp"
|
||||
#include "service/LmsAPIServerService.hpp"
|
||||
#include "service/DatabaseUpdateService.hpp"
|
||||
#if defined HAVE_LMSAPI
|
||||
#include "service/LmsAPIServerService.hpp"
|
||||
#endif
|
||||
|
||||
class ConfigReader
|
||||
{
|
||||
@@ -44,9 +48,12 @@ class ConfigReader
|
||||
|
||||
// Service configurations
|
||||
void getUserInterfaceConfig(Service::UserInterfaceService::Config& config);
|
||||
void getRemoteServerConfig(Service::RemoteServerService::Config& config);
|
||||
void getDatabaseUpdateConfig(Service::DatabaseUpdateService::Config& config);
|
||||
|
||||
#if defined HAVE_LMSAPI
|
||||
void getLmsAPIConfig(Service::LmsAPIService::Config& config);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
libconfig::Config _config;
|
||||
|
||||
+8
-9
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "config/config.h"
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
#include "config/ConfigReader.hpp"
|
||||
@@ -28,7 +29,9 @@
|
||||
#include "service/ServiceManager.hpp"
|
||||
#include "service/DatabaseUpdateService.hpp"
|
||||
#include "service/UserInterfaceService.hpp"
|
||||
#if defined HAVE_LMSAPI
|
||||
#include "service/LmsAPIServerService.hpp"
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
@@ -81,9 +84,6 @@ int main(int argc, char* argv[])
|
||||
Service::UserInterfaceService::Config uiConfig;
|
||||
configReader.getUserInterfaceConfig(uiConfig);
|
||||
|
||||
Service::RemoteServerService::Config remoteConfig;
|
||||
configReader.getRemoteServerConfig(remoteConfig);
|
||||
|
||||
Service::ServiceManager& serviceManager = Service::ServiceManager::instance();
|
||||
|
||||
// lib init
|
||||
@@ -96,14 +96,13 @@ int main(int argc, char* argv[])
|
||||
if (dbUpdateConfig.enable)
|
||||
serviceManager.startService( std::make_shared<Service::DatabaseUpdateService>( dbUpdateConfig ) );
|
||||
|
||||
if (remoteConfig.enable)
|
||||
{
|
||||
#if defined HAVE_LMSAPI
|
||||
serviceManager.startService( std::make_shared<Service::RemoteServerService>( remoteConfig ));
|
||||
#else
|
||||
LMS_LOG(MOD_MAIN, SEV_ERROR) << "LMS API cannot be activated since it is not compiled";
|
||||
Service::LmsAPIService::Config lmsAPIConfig;
|
||||
configReader.getLmsAPIConfig(lmsAPIConfig);
|
||||
|
||||
if (lmsAPIConfig.enable)
|
||||
serviceManager.startService( std::make_shared<Service::LmsAPIService>( lmsAPIConfig ));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (uiConfig.enable)
|
||||
serviceManager.startService( std::make_shared<Service::UserInterfaceService>(boost::filesystem::path(argv[0]), uiConfig));
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Service {
|
||||
|
||||
RemoteServerService::RemoteServerService(const Config& config)
|
||||
LmsAPIService::LmsAPIService(const Config& config)
|
||||
: _server(boost::asio::ip::tcp::endpoint(config.address, config.port),
|
||||
config.sslCertificatePath,
|
||||
config.sslPrivateKeyPath,
|
||||
@@ -33,26 +33,26 @@ RemoteServerService::RemoteServerService(const Config& config)
|
||||
}
|
||||
|
||||
void
|
||||
RemoteServerService::start(void)
|
||||
LmsAPIService::start(void)
|
||||
{
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::start, starting...";
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "LmsAPIService::start, starting...";
|
||||
_server.start();
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::start, started!";
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "LmsAPIService::start, started!";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RemoteServerService::stop(void)
|
||||
LmsAPIService::stop(void)
|
||||
{
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::stop, stopping...";
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "LmsAPIService::stop, stopping...";
|
||||
_server.stop();
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::stop, stopped!";
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "LmsAPIService::stop, stopped!";
|
||||
}
|
||||
|
||||
void
|
||||
RemoteServerService::restart(void)
|
||||
LmsAPIService::restart(void)
|
||||
{
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::restart, not implemented!";
|
||||
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "LmsAPIService::restart, not implemented!";
|
||||
}
|
||||
|
||||
} // namespace Service
|
||||
|
||||
@@ -23,13 +23,15 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
#include "Service.hpp"
|
||||
|
||||
#include "lms-api/server/Server.hpp"
|
||||
|
||||
namespace Service {
|
||||
|
||||
class RemoteServerService : public Service
|
||||
class LmsAPIService : public Service
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -43,7 +45,7 @@ class RemoteServerService : public Service
|
||||
boost::filesystem::path dbPath;
|
||||
};
|
||||
|
||||
RemoteServerService(const Config& config);
|
||||
LmsAPIService(const Config& config);
|
||||
|
||||
void start(void);
|
||||
void stop(void);
|
||||
|
||||
Reference in New Issue
Block a user