diff --git a/src/config/ConfigReader.cpp b/src/config/ConfigReader.cpp index efe00fe2..5e351bc8 100644 --- a/src/config/ConfigReader.cpp +++ b/src/config/ConfigReader.cpp @@ -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) diff --git a/src/config/ConfigReader.hpp b/src/config/ConfigReader.hpp index 32ffbc56..6abc5039 100644 --- a/src/config/ConfigReader.hpp +++ b/src/config/ConfigReader.hpp @@ -23,12 +23,16 @@ #include #include +#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; diff --git a/src/main/main.cpp b/src/main/main.cpp index 635d696a..c63f7247 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -19,6 +19,7 @@ #include +#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( dbUpdateConfig ) ); - if (remoteConfig.enable) - { #if defined HAVE_LMSAPI - serviceManager.startService( std::make_shared( 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( lmsAPIConfig )); #endif - } if (uiConfig.enable) serviceManager.startService( std::make_shared(boost::filesystem::path(argv[0]), uiConfig)); diff --git a/src/service/LmsAPIServerService.cpp b/src/service/LmsAPIServerService.cpp index a6cc6f16..c141c4e0 100644 --- a/src/service/LmsAPIServerService.cpp +++ b/src/service/LmsAPIServerService.cpp @@ -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 diff --git a/src/service/LmsAPIServerService.hpp b/src/service/LmsAPIServerService.hpp index d9bf6192..8fd17f1f 100644 --- a/src/service/LmsAPIServerService.hpp +++ b/src/service/LmsAPIServerService.hpp @@ -23,13 +23,15 @@ #include #include +#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); diff --git a/test/Makefile.am b/test/Makefile.am index 13243127..d551d4f7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,8 +26,8 @@ BUILT_SOURCES = \ remote_client_CXXFLAGS=-std=c++11 -Wall -Wextra -DBOOST_LOG_DYN_LINK -I$(top_srcdir)/src -%.pb.cc %.pb.h: $(top_srcdir)/src/remote/proto/%.proto - $(PROTOC) --proto_path=$(top_srcdir)/src/remote/proto/ --cpp_out=$(builddir)/ $^ +%.pb.cc %.pb.h: $(top_srcdir)/src/lms-api/proto/%.proto + $(PROTOC) --proto_path=$(top_srcdir)/src/lms-api/proto/ --cpp_out=$(builddir)/ $^ endif