diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-01-09 12:20:21 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-01-09 12:20:21 +0000 |
commit | 6f84254ed6681c79d606679cecb9420d394c8c47 (patch) | |
tree | ae04cac3da6e7bb459fbe0d4ee323c65476c62d3 | |
parent | 5f90329e3053edb1cf85a2bad521a6b2cf3e1256 (diff) |
Add OnExpireLine(XLine *) hook, will be used in xline db stuff to avoid getting a fucked up vector
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8676 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/modules.h | 10 | ||||
-rw-r--r-- | src/modules.cpp | 1 | ||||
-rw-r--r-- | src/xline.cpp | 28 |
3 files changed, 24 insertions, 15 deletions
diff --git a/include/modules.h b/include/modules.h index fb291e17a..298d963aa 100644 --- a/include/modules.h +++ b/include/modules.h @@ -394,7 +394,7 @@ enum Implementation I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreNick, I_OnUserMessage, I_OnUserNotice, I_OnMode, I_OnGetServerDescription, I_OnSyncUser, I_OnSyncChannel, I_OnSyncChannelMetaData, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_ProtoSendMode, I_ProtoSendMetaData, I_OnWallops, I_OnChangeHost, I_OnChangeName, I_OnAddLine, - I_OnDelLine, I_OnCleanup, I_OnUserPostNick, I_OnAccessCheck, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule, + I_OnDelLine, I_OnExpireLine, I_OnCleanup, I_OnUserPostNick, I_OnAccessCheck, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange, I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnOperCompre, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan, @@ -899,13 +899,19 @@ class CoreExport Module : public Extensible */ virtual void OnAddLine(User* source, XLine* line); - /** Called whenever an xline is deleted. + /** Called whenever an xline is deleted MANUALLY. See OnExpireLine for expiry. * This method is triggered after the line is deleted. * @param source The user removing the line or NULL for local server * @param line the line being deleted */ virtual void OnDelLine(User* source, XLine* line); + /** Called whenever an xline expires. + * This method is triggered after the line is deleted. + * @param line The line being deleted. + */ + 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 diff --git a/src/modules.cpp b/src/modules.cpp index 2233c985d..a699cb41b 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -180,6 +180,7 @@ void Module::OnChangeHost(User*, const std::string&) { } void Module::OnChangeName(User*, const std::string&) { } void Module::OnAddLine(User*, XLine*) { } void Module::OnDelLine(User*, XLine*) { } +void Module::OnExpireLine(XLine*) { } void Module::OnCleanup(int, void*) { } int Module::OnChannelPreDelete(Channel*) { return 0; } void Module::OnChannelDelete(Channel*) { } diff --git a/src/xline.cpp b/src/xline.cpp index a77f7dc0b..1dda8dac0 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -289,19 +289,21 @@ XLine* XLineManager::MatchesLine(const std::string &type, const std::string &pat // removes lines that have expired void XLineManager::ExpireLine(ContainerIter container, LookupIter item) { - item->second->DisplayExpiry(); - item->second->Unset(); - - /* TODO: Can we skip this loop by having a 'pending' field in the XLine class, which is set when a line - * is pending, cleared when it is no longer pending, so we skip over this loop if its not pending? - * -- Brain - */ - std::vector<XLine*>::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), item->second); - if (pptr != pending_lines.end()) - pending_lines.erase(pptr); - - delete item->second; - container->second.erase(item); + FOREACH_MOD(I_OnExpireLine, OnExpireLine(item->second)); + + item->second->DisplayExpiry(); + item->second->Unset(); + + /* TODO: Can we skip this loop by having a 'pending' field in the XLine class, which is set when a line + * is pending, cleared when it is no longer pending, so we skip over this loop if its not pending? + * -- Brain + */ + std::vector<XLine*>::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), item->second); + if (pptr != pending_lines.end()) + pending_lines.erase(pptr); + + delete item->second; + container->second.erase(item); } |