diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-11-18 17:30:38 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2017-11-16 14:15:25 +0000 |
commit | 3b51dfb1d611a874c3f1138d1c1ec1bb8984334c (patch) | |
tree | 83e33012964806048fc9f1b69056c24f4246d8d0 /src/modules | |
parent | 5287af979e5abffb2cfcdadb9a7663b42a5c43e5 (diff) |
Add events which are fired when a service is added or deleted.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_pbkdf2.cpp | 68 |
1 files changed, 16 insertions, 52 deletions
diff --git a/src/modules/m_pbkdf2.cpp b/src/modules/m_pbkdf2.cpp index 314f6b836..8b1346c84 100644 --- a/src/modules/m_pbkdf2.cpp +++ b/src/modules/m_pbkdf2.cpp @@ -180,71 +180,35 @@ class ModulePBKDF2 : public Module stdalgo::delete_all(providers); } - void Prioritize() CXX11_OVERRIDE + void OnServiceAdd(ServiceProvider& provider) CXX11_OVERRIDE { - OnLoadModule(NULL); - } - - void OnLoadModule(Module* mod) CXX11_OVERRIDE - { - bool newProv = false; - // As the module doesn't tell us what ServiceProviders it has, let's iterate all (yay ...) the ServiceProviders - // Good thing people don't run loading and unloading those all the time - for (std::multimap<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules->DataProviders.begin(); i != ServerInstance->Modules->DataProviders.end(); ++i) - { - ServiceProvider* provider = i->second; - - // Does the service belong to the new mod? - // In the case this is our first run (mod == NULL, continue anyway) - if (mod && provider->creator != mod) - continue; - - // Check if it's a hash provider - if (provider->name.compare(0, 5, "hash/")) - continue; - - HashProvider* hp = static_cast<HashProvider*>(provider); - - if (hp->IsKDF()) - continue; - - bool has_prov = false; - for (std::vector<PBKDF2Provider*>::const_iterator j = providers.begin(); j != providers.end(); ++j) - { - if ((*j)->provider == hp) - { - has_prov = true; - break; - } - } - if (has_prov) - continue; + // Check if it's a hash provider + if (provider.name.compare(0, 5, "hash/")) + return; - newProv = true; + HashProvider* hp = static_cast<HashProvider*>(&provider); + if (hp->IsKDF()) + return; - PBKDF2Provider* prov = new PBKDF2Provider(this, hp); - providers.push_back(prov); - ServerInstance->Modules->AddService(*prov); - } + PBKDF2Provider* prov = new PBKDF2Provider(this, hp); + providers.push_back(prov); + ServerInstance->Modules.AddService(*prov); - if (newProv) - GetConfig(); + GetConfig(); } - void OnUnloadModule(Module* mod) CXX11_OVERRIDE + void OnServiceDel(ServiceProvider& prov) CXX11_OVERRIDE { - for (std::vector<PBKDF2Provider*>::iterator i = providers.begin(); i != providers.end(); ) + for (std::vector<PBKDF2Provider*>::iterator i = providers.begin(); i != providers.end(); ++i) { PBKDF2Provider* item = *i; - if (item->provider->creator != mod) - { - ++i; + if (item->provider != &prov) continue; - } ServerInstance->Modules->DelService(*item); delete item; - i = providers.erase(i); + providers.erase(i); + break; } } |