From 992674362c5f64bdb8e1942eeaa7612524529cd6 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 26 May 2013 19:44:13 +0200 Subject: Automatically register ServiceProviders created by modules --- src/modmanager_dynamic.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/modmanager_dynamic.cpp') diff --git a/src/modmanager_dynamic.cpp b/src/modmanager_dynamic.cpp index 7789c90bf..de2593d72 100644 --- a/src/modmanager_dynamic.cpp +++ b/src/modmanager_dynamic.cpp @@ -55,10 +55,14 @@ bool ModuleManager::Load(const std::string& filename, bool defer) Module* newmod = NULL; DLLManager* newhandle = new DLLManager(moduleFile.c_str()); + ServiceList newservices; + if (!defer) + this->NewServices = &newservices; try { newmod = newhandle->CallInit(); + this->NewServices = NULL; if (newmod) { @@ -77,6 +81,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer) ConfigStatus confstatus; AttachAll(newmod); + AddServices(newservices); newmod->init(); newmod->ReadConfig(confstatus); @@ -95,6 +100,8 @@ bool ModuleManager::Load(const std::string& filename, bool defer) } catch (CoreException& modexcept) { + this->NewServices = NULL; + // failure in module constructor if (newmod) { @@ -118,7 +125,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer) } /* We must load the modules AFTER initializing the socket engine, now */ -void ModuleManager::LoadCoreModules() +void ModuleManager::LoadCoreModules(std::map& servicemap) { std::cout << std::endl << "Loading core commands"; fflush(stdout); @@ -134,6 +141,8 @@ void ModuleManager::LoadCoreModules() std::cout << "."; fflush(stdout); + this->NewServices = &servicemap[entry->d_name]; + if (!Load(entry->d_name, true)) { ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, this->LastError()); -- cgit v1.2.3