From 9eeae941959511957abd770ed8e11f3ecdcd739e Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 4 Apr 2013 22:16:52 +0200 Subject: Allow dynamic references to reference ServiceProviders, introduce ModeReference Mode handlers can be referenced using mode/ --- src/modules.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/modules.cpp') diff --git a/src/modules.cpp b/src/modules.cpp index b09639b2e..1194e8358 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -368,10 +368,10 @@ void ModuleManager::DoSafeUnload(Module* mod) ModeHandler* mh; mh = ServerInstance->Modes->FindMode(m, MODETYPE_USER); if (mh && mh->creator == mod) - ServerInstance->Modes->DelMode(mh); + this->DelService(*mh); mh = ServerInstance->Modes->FindMode(m, MODETYPE_CHANNEL); if (mh && mh->creator == mod) - ServerInstance->Modes->DelMode(mh); + this->DelService(*mh); } for(std::multimap::iterator i = DataProviders.begin(); i != DataProviders.end(); ) { @@ -436,6 +436,8 @@ void ModuleManager::AddService(ServiceProvider& item) case SERVICE_MODE: if (!ServerInstance->Modes->AddMode(static_cast(&item))) throw ModuleException("Mode "+std::string(item.name)+" already exists."); + DataProviders.insert(std::make_pair("mode/" + item.name, &item)); + dynamic_reference_base::reset_all(); return; case SERVICE_METADATA: if (!ServerInstance->Extensions.Register(static_cast(&item))) @@ -444,6 +446,9 @@ void ModuleManager::AddService(ServiceProvider& item) case SERVICE_DATA: case SERVICE_IOHOOK: { + if (item.name.substr(0, 5) == "mode/") + throw ModuleException("The \"mode/\" service name prefix is reserved."); + DataProviders.insert(std::make_pair(item.name, &item)); std::string::size_type slash = item.name.find('/'); if (slash != std::string::npos) @@ -466,7 +471,7 @@ void ModuleManager::DelService(ServiceProvider& item) case SERVICE_MODE: if (!ServerInstance->Modes->DelMode(static_cast(&item))) throw ModuleException("Mode "+std::string(item.name)+" does not exist."); - return; + // Fall through case SERVICE_DATA: case SERVICE_IOHOOK: { -- cgit v1.2.3