diff options
author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-16 23:47:28 +0000 |
---|---|---|
committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-16 23:47:28 +0000 |
commit | c1c9e17d7995f7e6684316f6dc71d1b43788533f (patch) | |
tree | 1d0dfa3e0f81416d2bb618765c9da869f9c08405 | |
parent | ce3a04f0a879b7d3ebb120e69b87ed072dc376e2 (diff) |
Move OnUserKicked to a module event.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2102 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/events.h | 1 | ||||
-rw-r--r-- | include/modules.h | 72 | ||||
-rw-r--r-- | src/channels.c | 6 |
3 files changed, 19 insertions, 60 deletions
diff --git a/include/events.h b/include/events.h index c5659c2bf..f642a8ee5 100644 --- a/include/events.h +++ b/include/events.h @@ -61,4 +61,3 @@ #define EVENT_ACCESS_DEL "access_del" #define EVENT_ACCESS_CLEAR "access_clear" #define EVENT_NICK_LOGOUT "nick_logout" -#define EVENT_CHAN_KICK "chan_kick" diff --git a/include/modules.h b/include/modules.h index 093bae576..0ec78cb47 100644 --- a/include/modules.h +++ b/include/modules.h @@ -48,7 +48,7 @@ */ #define FOREACH_MOD(y,x) do { \ std::vector<Module*>::iterator safei; \ - for (std::vector<Module*>::iterator _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \ + for (std::vector<Module*>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \ { \ safei = _i; \ ++safei; \ @@ -58,31 +58,7 @@ } \ catch (CoreException& modexcept) \ { \ - ServerInstance->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ - } \ - _i = safei; \ - } \ -} while (0); - -/** - * This #define allows us to call a method in all - * loaded modules in a readable simple way and pass - * an instance pointer to the macro. e.g.: - * 'FOREACH_MOD_I(Instance, OnConnect, OnConnect(user));' - */ -#define FOREACH_MOD_I(z,y,x) do { \ - std::vector<Module*>::iterator safei; \ - for (std::vector<Module*>::iterator _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ) \ - { \ - safei = _i; \ - ++safei; \ - try \ - { \ - (*_i)->x ; \ - } \ - catch (CoreException& modexcept) \ - { \ - z->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ + alog("Exception caught: %s",modexcept.GetReason()); \ } \ _i = safei; \ } \ @@ -97,7 +73,7 @@ do { \ std::vector<Module*>::iterator safei; \ MOD_RESULT = 0; \ - for (std::vector<Module*>::iterator _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \ + for (std::vector<Module*>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \ { \ safei = _i; \ ++safei; \ @@ -111,42 +87,13 @@ do { \ } \ catch (CoreException& modexcept) \ { \ - ServerInstance->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ + alog("Exception caught: %s",modexcept.GetReason()); \ } \ _i = safei; \ } \ } while(0); -/** - * This define is similar to the one above but returns a result in MOD_RESULT. - * The first module to return a nonzero result is the value to be accepted, - * and any modules after are ignored. - */ -#define FOREACH_RESULT_I(z,y,x) \ -do { \ - std::vector<Module*>::iterator safei; \ - MOD_RESULT = 0; \ - for (std::vector<Module*>::iterator _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ) \ - { \ - safei = _i; \ - ++safei; \ - try \ - { \ - int res = (*_i)->x ; \ - if (res != 0) { \ - MOD_RESULT = res; \ - break; \ - } \ - } \ - catch (CoreException& modexcept) \ - { \ - z->Logs->Log("MODULE",DEBUG,"Exception caught: %s",modexcept.GetReason()); \ - } \ - _i = safei; \ - } \ -} while (0); - /** Priority types which can be returned from Module::Prioritize() */ @@ -157,6 +104,7 @@ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFOR enum Implementation { I_BEGIN, + I_OnUserKicked, I_END }; @@ -532,6 +480,16 @@ class CoreExport Module * @param name the name of the callback they wish to delete **/ void DelCallback(const char *name); + + + + /** Called when the ircd notifies that a user has been kicked from a channel. + * @param c The channel the user has been kicked from. + * @param target The user that has been kicked. + * @param kickmsg The reason for the kick. + * NOTE: We may want to add a second User arg for sender in the future. + */ + virtual void OnUserKicked(Channel *c, User *target, const std::string &kickmsg) { } }; diff --git a/src/channels.c b/src/channels.c index d7e97d62f..abbb747b7 100644 --- a/src/channels.c +++ b/src/channels.c @@ -14,6 +14,7 @@ #include "services.h" #include "language.h" +#include "modules.h" Channel *chanlist[1024]; @@ -639,8 +640,9 @@ void do_kick(const char *source, int ac, const char **av) } for (c = user->chans; c && stricmp(av[0], c->chan->name) != 0; c = c->next); - if (c) { - send_event(EVENT_CHAN_KICK, 2, user->nick, av[0]); + if (c) + { + FOREACH_MOD(I_OnUserKicked, OnUserKicked(c->chan, user, merge_args(ac - 2, av + 2))); chan_deluser(user, c->chan); if (c->next) c->next->prev = c->prev; |