diff options
-rw-r--r-- | include/modules.h | 19 | ||||
-rw-r--r-- | src/modules.cpp | 9 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 4 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_mbedtls.cpp | 4 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_banredirect.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_websocket.cpp | 4 |
7 files changed, 25 insertions, 23 deletions
diff --git a/include/modules.h b/include/modules.h index 3ad0258b8..2481f8207 100644 --- a/include/modules.h +++ b/include/modules.h @@ -649,16 +649,15 @@ class CoreExport Module : public classbase, public usecountbase */ virtual void OnExpireLine(XLine *line); - /** Called before your module is unloaded to clean up Extensibles. - * This method is called once for every user and channel on the network, - * so that when your module unloads it may clear up any remaining data - * in the form of Extensibles added using Extensible::Extend(). - * If the target_type variable is TYPE_USER, then void* item refers to - * a User*, otherwise it refers to a Channel*. - * @param target_type The type of item being cleaned - * @param item A pointer to the item's class - */ - virtual void OnCleanup(int target_type, void* item); + /** Called before the module is unloaded to clean up extensibles. + * This method is called once for every channel, membership, and user. + * so that you can clear up any data relating to the specified extensible. + * @param type The type of extensible being cleaned up. If this is EXT_CHANNEL + * then item is a Channel*, EXT_MEMBERSHIP then item is a Membership*, + * and EXT_USER then item is a User*. + * @param item A pointer to the extensible which is being cleaned up. + */ + virtual void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item); /** Called after any nickchange, local or remote. This can be used to track users after nickchanges * have been applied. Please note that although you can see remote nickchanges through this function, you should diff --git a/src/modules.cpp b/src/modules.cpp index 6d0d3bf94..de2fe96b3 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -126,7 +126,7 @@ void Module::OnChangeIdent(User*, const std::string&) { DetachEvent(I_OnChangeI void Module::OnAddLine(User*, XLine*) { DetachEvent(I_OnAddLine); } void Module::OnDelLine(User*, XLine*) { DetachEvent(I_OnDelLine); } void Module::OnExpireLine(XLine*) { DetachEvent(I_OnExpireLine); } -void Module::OnCleanup(int, void*) { } +void Module::OnCleanup(ExtensionItem::ExtensibleType, Extensible*) { } ModResult Module::OnChannelPreDelete(Channel*) { DetachEvent(I_OnChannelPreDelete); return MOD_RES_PASSTHRU; } void Module::OnChannelDelete(Channel*) { DetachEvent(I_OnChannelDelete); } ModResult Module::OnSetAway(User*, const std::string &) { DetachEvent(I_OnSetAway); return MOD_RES_PASSTHRU; } @@ -375,11 +375,14 @@ void ModuleManager::DoSafeUnload(Module* mod) { Channel* chan = c->second; ++c; - mod->OnCleanup(TYPE_CHANNEL, chan); + mod->OnCleanup(ExtensionItem::EXT_CHANNEL, chan); chan->doUnhookExtensions(items); const Channel::MemberMap& users = chan->GetUsers(); for (Channel::MemberMap::const_iterator mi = users.begin(); mi != users.end(); ++mi) + { + mod->OnCleanup(ExtensionItem::EXT_MEMBERSHIP, mi->second); mi->second->doUnhookExtensions(items); + } } const user_hash& users = ServerInstance->Users->GetUsers(); @@ -388,7 +391,7 @@ void ModuleManager::DoSafeUnload(Module* mod) User* user = u->second; // The module may quit the user (e.g. SSL mod unloading) and that will remove it from the container ++u; - mod->OnCleanup(TYPE_USER, user); + mod->OnCleanup(ExtensionItem::EXT_USER, user); user->doUnhookExtensions(items); } diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 8b414230a..953570945 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -1333,9 +1333,9 @@ class ModuleSSLGnuTLS : public Module ServerInstance->GenRandom = &ServerInstance->HandleGenRandom; } - void OnCleanup(int target_type, void* item) CXX11_OVERRIDE + void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item) CXX11_OVERRIDE { - if(target_type == TYPE_USER) + if (type == ExtensionItem::EXT_USER) { LocalUser* user = IS_LOCAL(static_cast<User*>(item)); diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index f3b5adfd5..28ebb708b 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -904,9 +904,9 @@ class ModuleSSLmbedTLS : public Module } } - void OnCleanup(int target_type, void* item) CXX11_OVERRIDE + void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item) CXX11_OVERRIDE { - if (target_type != TYPE_USER) + if (type != ExtensionItem::EXT_USER) return; LocalUser* user = IS_LOCAL(static_cast<User*>(item)); diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 68f75c87f..4cd8ab29a 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -962,9 +962,9 @@ class ModuleSSLOpenSSL : public Module } } - void OnCleanup(int target_type, void* item) CXX11_OVERRIDE + void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item) CXX11_OVERRIDE { - if (target_type == TYPE_USER) + if (type == ExtensionItem::EXT_USER) { LocalUser* user = IS_LOCAL((User*)item); diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index f98cbd420..5202051f3 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -239,9 +239,9 @@ class ModuleBanRedirect : public Module { } - void OnCleanup(int target_type, void* item) CXX11_OVERRIDE + void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item) CXX11_OVERRIDE { - if(target_type == TYPE_CHANNEL) + if (type == ExtensionItem::EXT_CHANNEL) { Channel* chan = static_cast<Channel*>(item); BanRedirectList* redirects = re.extItem.get(chan); diff --git a/src/modules/m_websocket.cpp b/src/modules/m_websocket.cpp index 399b0b017..a7457f788 100644 --- a/src/modules/m_websocket.cpp +++ b/src/modules/m_websocket.cpp @@ -386,9 +386,9 @@ class ModuleWebSocket : public Module sha1 = &hash; } - void OnCleanup(int target_type, void* item) CXX11_OVERRIDE + void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item) CXX11_OVERRIDE { - if (target_type != TYPE_USER) + if (type != ExtensionItem::EXT_USER) return; LocalUser* user = IS_LOCAL(static_cast<User*>(item)); |