summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-04 22:16:52 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-08 23:13:24 +0200
commit9eeae941959511957abd770ed8e11f3ecdcd739e (patch)
treed5e0c12c7762cd904c81ef8b841bb681d32e47c0 /src
parent927937d6105d17fbcd8c85bbf185477d87264bc4 (diff)
Allow dynamic references to reference ServiceProviders, introduce ModeReference
Mode handlers can be referenced using mode/<modename>
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp11
1 files changed, 8 insertions, 3 deletions
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<std::string, ServiceProvider*>::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<ModeHandler*>(&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<ExtensionItem*>(&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<ModeHandler*>(&item)))
throw ModuleException("Mode "+std::string(item.name)+" does not exist.");
- return;
+ // Fall through
case SERVICE_DATA:
case SERVICE_IOHOOK:
{