summaryrefslogtreecommitdiff
path: root/src/modmanager_dynamic.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-05-26 19:44:13 +0200
committerattilamolnar <attilamolnar@hush.com>2013-09-08 17:11:08 +0200
commit992674362c5f64bdb8e1942eeaa7612524529cd6 (patch)
tree8f29b37db626e0b81002cac48d0561ef998ec2f1 /src/modmanager_dynamic.cpp
parent8a64bd3a0ac72855b681b00f3a9a08cebee755ce (diff)
Automatically register ServiceProviders created by modules
Diffstat (limited to 'src/modmanager_dynamic.cpp')
-rw-r--r--src/modmanager_dynamic.cpp11
1 files changed, 10 insertions, 1 deletions
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<std::string, ServiceList>& 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());