X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules.cpp;h=e1fb605c0a9a73f78cbe772e6ce466b0ce507bb2;hb=21e25f7aa9091821e24447784d08d8fdd905f1c3;hp=d7aa534ab4b22ddf7fdfea45f87375b2bf7f1b9c;hpb=ae10286658d6bb70e5e22526a004ec1b233f6fba;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules.cpp b/src/modules.cpp index d7aa534ab..e1fb605c0 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -52,13 +52,6 @@ Version::Version(const std::string &desc, int flags, const std::string& linkdata { } -Event::Event(Module* src, const std::string &eventid) : source(src), id(eventid) { } - -void Event::Send() -{ - FOREACH_MOD(OnEvent, (*this)); -} - // These declarations define the behavours of the base class Module (which does nothing at all) Module::Module() { } @@ -119,7 +112,6 @@ ModResult Module::OnStats(char, User*, string_list&) { DetachEvent(I_OnStats); r ModResult Module::OnChangeLocalUserHost(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserHost); return MOD_RES_PASSTHRU; } ModResult Module::OnChangeLocalUserGECOS(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserGECOS); return MOD_RES_PASSTHRU; } ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPreTopicChange); return MOD_RES_PASSTHRU; } -void Module::OnEvent(Event&) { DetachEvent(I_OnEvent); } ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { DetachEvent(I_OnPassCompare); return MOD_RES_PASSTHRU; } void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); } void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { DetachEvent(I_OnUserMessage); } @@ -197,22 +189,20 @@ void ModuleManager::Attach(Implementation* i, Module* mod, size_t sz) void ModuleManager::AttachAll(Module* mod) { - for (size_t i = I_BEGIN + 1; i != I_END; ++i) + for (size_t i = 0; i != I_END; ++i) Attach((Implementation)i, mod); } void ModuleManager::DetachAll(Module* mod) { - for (size_t n = I_BEGIN + 1; n != I_END; ++n) + for (size_t n = 0; n != I_END; ++n) Detach((Implementation)n, mod); } -bool ModuleManager::SetPriority(Module* mod, Priority s) +void ModuleManager::SetPriority(Module* mod, Priority s) { - for (size_t n = I_BEGIN + 1; n != I_END; ++n) + for (size_t n = 0; n != I_END; ++n) SetPriority(mod, (Implementation)n, s); - - return true; } bool ModuleManager::SetPriority(Module* mod, Implementation i, Priority s, Module* which) @@ -655,7 +645,7 @@ ServiceProvider* ModuleManager::FindService(ServiceType type, const std::string& } dynamic_reference_base::dynamic_reference_base(Module* Creator, const std::string& Name) - : name(Name), value(NULL), creator(Creator) + : name(Name), hook(NULL), value(NULL), creator(Creator) { if (!dynrefs) dynrefs = new insp::intrusive_list; @@ -684,9 +674,19 @@ void dynamic_reference_base::SetProvider(const std::string& newname) void dynamic_reference_base::resolve() { - std::multimap::iterator i = ServerInstance->Modules->DataProviders.find(name); - if (i != ServerInstance->Modules->DataProviders.end()) - value = static_cast(i->second); + // Because find() may return any element with a matching key in case count(key) > 1 use lower_bound() + // to ensure a dynref with the same name as another one resolves to the same object + std::multimap::iterator i = ServerInstance->Modules.DataProviders.lower_bound(name); + if ((i != ServerInstance->Modules.DataProviders.end()) && (i->first == this->name)) + { + ServiceProvider* newvalue = i->second; + if (value != newvalue) + { + value = newvalue; + if (hook) + hook->OnCapture(); + } + } else value = NULL; }