diff options
-rw-r--r-- | include/events.h | 57 | ||||
-rw-r--r-- | include/extern.h | 1 | ||||
-rw-r--r-- | include/modules.h | 275 | ||||
-rw-r--r-- | include/services.h | 1 | ||||
-rw-r--r-- | src/botserv.c | 19 | ||||
-rw-r--r-- | src/channels.c | 55 | ||||
-rw-r--r-- | src/chanserv.c | 2 | ||||
-rw-r--r-- | src/core/bs_bot.c | 6 | ||||
-rw-r--r-- | src/core/cs_access.c | 21 | ||||
-rw-r--r-- | src/core/cs_drop.c | 4 | ||||
-rw-r--r-- | src/core/cs_forbid.c | 4 | ||||
-rw-r--r-- | src/core/cs_register.c | 3 | ||||
-rw-r--r-- | src/core/cs_suspend.c | 6 | ||||
-rw-r--r-- | src/core/cs_xop.c | 17 | ||||
-rw-r--r-- | src/core/ns_drop.c | 3 | ||||
-rw-r--r-- | src/core/ns_forbid.c | 3 | ||||
-rw-r--r-- | src/core/ns_group.c | 3 | ||||
-rw-r--r-- | src/core/ns_identify.c | 4 | ||||
-rw-r--r-- | src/core/ns_logout.c | 2 | ||||
-rw-r--r-- | src/core/ns_register.c | 3 | ||||
-rw-r--r-- | src/core/ns_suspend.c | 6 | ||||
-rw-r--r-- | src/core/os_defcon.c | 4 | ||||
-rw-r--r-- | src/init.c | 4 | ||||
-rw-r--r-- | src/main.c | 16 | ||||
-rw-r--r-- | src/misc.c | 6 | ||||
-rw-r--r-- | src/nickserv.c | 2 | ||||
-rw-r--r-- | src/operserv.c | 2 | ||||
-rw-r--r-- | src/protocol/inspircd11.c | 10 | ||||
-rw-r--r-- | src/protocol/inspircd12.cpp | 10 | ||||
-rw-r--r-- | src/protocol/ratbox.c | 10 | ||||
-rw-r--r-- | src/servers.c | 2 | ||||
-rw-r--r-- | src/users.c | 2 |
32 files changed, 386 insertions, 177 deletions
diff --git a/include/events.h b/include/events.h index 29b08c3e7..e69de29bb 100644 --- a/include/events.h +++ b/include/events.h @@ -1,57 +0,0 @@ -/* Prototypes and external variable declarations. - * - * (C) 2003-2009 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for furhter details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * $Id$ - * - */ - -#define EVENT_START "start" -//#define EVENT_STOP "stop" - -#define EVENT_BOT_JOIN "bot_join" -#define EVENT_BOT_CREATE "bot_create" -#define EVENT_BOT_CHANGE "bot_change" -#define EVENT_BOT_FANTASY "bot_command" -#define EVENT_BOT_FANTASY_NO_ACCESS "bot_command_no_access" -#define EVENT_BOT_DEL "bot_del" -#define EVENT_BOT_KICK "bot_kick" -#define EVENT_BOT_BAN "bot_ban" -#define EVENT_TOPIC_UPDATED "chan_topic_updated" -#define EVENT_CHAN_EXPIRE "chan_expire" -#define EVENT_CHAN_REGISTERED "chan_registered" -#define EVENT_CHAN_DROP "chan_dropped" -#define EVENT_CHAN_FORBIDDEN "chan_forbidden" -#define EVENT_CHAN_SUSPENDED "chan_suspended" -#define EVENT_CHAN_UNSUSPEND "chan_unsuspend" -#define EVENT_CONNECT "connect" -#define EVENT_DB_EXPIRE "db_expire" -#define EVENT_RESTART "restart" -#define EVENT_SHUTDOWN "shutdown" -#define EVENT_SIGNAL "signal" -#define EVENT_NICK_REGISTERED "nick_registered" -#define EVENT_NICK_DROPPED "nick_dropped" -#define EVENT_NICK_FORBIDDEN "nick_forbidden" -#define EVENT_NICK_EXPIRE "nick_expire" -#define EVENT_CHANGE_NICK "change_nick" -#define EVENT_USER_LOGOFF "user_logoff" -#define EVENT_GROUP "nick_group" -#define EVENT_NICK_IDENTIFY "nick_id" -#define EVENT_SERVER_SQUIT "server_squit" -#define EVENT_SERVER_CONNECT "server_connect" -#define EVENT_DEFCON_LEVEL "defcon_level" -#define EVENT_NICK_SUSPENDED "nick_suspended" -#define EVENT_NICK_UNSUSPEND "nick_unsuspend" -#define EVENT_JOIN_CHANNEL "join_channel" -#define EVENT_PART_CHANNEL "part_channel" -#define EVENT_ACCESS_ADD "access_add" -#define EVENT_ACCESS_CHANGE "access_change" -#define EVENT_ACCESS_DEL "access_del" -#define EVENT_ACCESS_CLEAR "access_clear" -#define EVENT_NICK_LOGOUT "nick_logout" diff --git a/include/extern.h b/include/extern.h index fed728bbd..5dc597b4a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -939,7 +939,6 @@ E int decode_ip(const char *buf); E char *host_resolve(char *host); E void event_process_hook(const char *name, int argc, char **argv); -E void send_event(const char *name, int argc, ...); #ifdef _WIN32 E char *GetWindowsVersion() ; diff --git a/include/modules.h b/include/modules.h index 1475c9f3d..8c45bdeaa 100644 --- a/include/modules.h +++ b/include/modules.h @@ -536,17 +536,284 @@ class CoreExport Module * NOTE: This event is deprecated pending new database handling. */ virtual void OnBackupDatabase() MARK_DEPRECATED { } + + /** Called on fantasy command + * @param command The command + * @param u The user using the command + * @param ci The channel it's being used in + * @param params The params + */ + virtual void OnBotFantasy(char *command, User *u, ChannelInfo *ci, char *params) { } + + /** Called on fantasy command without access + * @param command The command + * @param u The user using the command + * @param ci The channel it's being used in + * @param params The params + */ + virtual void OnBotNoFantasyAccess(const char *command, User *u, ChannelInfo *ci, const char *params) { } + + /** Called after a bot joins a channel + * @param ci The channael + * @param bi The bot + */ + virtual void OnBotJoin(ChannelInfo *ci, BotInfo *bi) { } + + /** Called when a bot places a ban + * @param u User being banned + * @param ci Channel the ban is placed on + * @param mask The mask being banned + */ + virtual void OnBotBan(User *u, ChannelInfo *ci, const char *mask) { } + + /** Called when a bot kicks a user + * @param u The user being kicked + * @param ci The channel + * @param reason The reason + */ + virtual void OnBotKick(User *u, ChannelInfo *ci, const char *reason) { } + + /** Called before a user parts a channel + * @param u The user + * @param c The channel + */ + virtual void OnPrePartChannel(User *u, Channel *c) {} + + /** Called when a user parts a channel + * @param u The user + * @param c The channel + */ + virtual void OnPartChannel(User *u, Channel *c) { } + + /** Called before a user joins a channel + * @param u The user + * @param channel The channel + */ + virtual void OnPreJoinChannel(User *u, const char *channel) { } + + /** Called when a user joins a channel + * @param u The user + * @param channel The channel + */ + virtual void OnJoinChannel(User *u, Channel *c) { } + + /** Called when a new topic is set + * @param c The channel + * @param topic The new topic + */ + virtual void OnTopicUpdated(Channel *c, const char *topic) { } + + /** Called when a channel expires + * @param chname The channel name + */ + virtual void OnChanExpire(const char *chname) { } + + /** Called before anope connects to its uplink + */ + virtual void OnPreServerConnect() { } + + /** Called when anope connects to its uplink + */ + virtual void OnServerConnect() { } + + /** Called before the database expire routines are called + * Note: Code that is in seperate expiry routines should just be done + * when we save the DB, theres no need to have both + */ + virtual void OnPreDatabaseExpire() MARK_DEPRECATED { } + + /** Called when the database expire routines are called + */ + virtual void OnDatabaseExpire() MARK_DEPRECATED { } + + /** Called before services restart + */ + virtual void OnPreRestart() { } + + /** Called when services restart + */ + virtual void OnRestart() { } + + /** Called before services shutdown + */ + virtual void OnPreShutdown() { } + + /** Called when services shutdown + */ + virtual void OnShutdown() { } + + /** Called on signal + * @param msg The quitmsg + */ + virtual void OnSignal(const char *msg) { } + + /** Called when a nick drops + * @param nick The nick + */ + virtual void OnNickExpire(const char *nick) { } + + /** Called when defcon level changes + * @param level The level + */ + virtual void OnDefconLevel(const char *level) { } + + /** Called when a server quits + * @param server The server + */ + virtual void OnServerQuit(Server *server) { } + + /** Called when a user disconnects + * @param nick The name of the user + */ + virtual void OnUserLogoff(const char *nick) { } + + /** Called when a new bot is made + * @param bi The bot + */ + virtual void OnBotCreate(BotInfo *bi) { } + + /** Called when a bot is changed + * @param bi The bot + */ + virtual void OnBotChange(BotInfo *bi) { } + + /** Called when a bot is deleted + * @param bi The bot + */ + virtual void OnBotDelete(BotInfo *bi) { } + + /** Called when access is deleted from a channel + * @param ci The channel + * @param u The user who removed the access + * @param nick The name of the user whos access was removed + */ + virtual void OnAccessDel(ChannelInfo *ci, User *u, const char *nick) { } + + /** Called when access is changed + * @param ci The channel + * @param u The user who changed the access + * @param nick The nick whos access was changed + * @param level The level of the new access + */ + virtual void OnAccessChange(ChannelInfo *ci, User *u, const char *nick, int level) { } + + /** Called when access is added + * @param ci The channel + * @param u The user who added the access + * @param nick The nick who was added to access + * @param level The level they were added at + */ + virtual void OnAccessAdd(ChannelInfo *ci, User *u, const char *nick, int level) { } + + /** Called when the access list is cleared + * @param ci The channel + * @param u The user who cleared the access + */ + virtual void OnAccessClear(ChannelInfo *ci, User *u) { } + + /** Called when a channel is dropped + * @param chname The channel name + */ + virtual void OnChanDrop(const char *chname) { } + + /** Called when a channel is forbidden + * @param ci The channel + */ + virtual void OnChanForbidden(ChannelInfo *ci) { } + + /** Called when a channel is registered + * @param ci The channel + */ + virtual void OnChanRegistered(ChannelInfo *ci) { } + + /** Called when a channel is suspended + * @param ci The channel + */ + virtual void OnChanSuspend(ChannelInfo *ci) { } + + /** Called when a channel is unsuspended + * @param ci The channel + */ + virtual void OnChanUnsuspend(ChannelInfo *ci) { } + + /** Called when a nick is dropped + * @param nick The nick + */ + virtual void OnNickDrop(const char *nick) { } + + /** Called when a nick is forbidden + * @param na The nick alias of the forbidden nick + */ + virtual void OnNickForbidden(NickAlias *na) { } + + /** Called when a user groups their nick + * @param u The user grouping + * @param target The target they're grouping to + */ + virtual void OnNickGroup(User *u, NickAlias *target) { } + + /** Called when a user identifies + * @param u The user + */ + virtual void OnNickIdentify(User *u) { } + + /** Called when a nick logs out + * @param u The nick + */ + virtual void OnNickLogout(User *u) { } + + /** Called when a nick is registered + * @param The user + */ + virtual void OnNickRegister(User *u) { } + + /** Called when a nick is suspended + * @param na The nick alias + */ + virtual void OnNickSuspend(NickAlias *na) { } + + /** Called when a nick is unsuspneded + * @param na The nick alias + */ + virtual void OnNickUnsuspended(NickAlias *na) { } + + /** Called when the defcon level is changed + * @param level The level + */ + virtual void OnDefconLevel(int level) { } }; -/** Implementation-specific flags which may be set in Module::Implements() +/** Implementation-specific flags which may be set in ModuleManager::Attach() */ enum Implementation { I_BEGIN, - I_OnUserKicked, I_OnReload, I_OnBotAssign, I_OnBotUnAssign, I_OnUserConnect, I_OnServerConnect, - I_OnPreCommand, I_OnPostCommand, I_OnUserNickChange, - I_OnSaveDatabase, I_OnBackupDatabase, + /* NickServ */ + I_OnNickExpire, I_OnNickForbidden, I_OnNickGroup, I_OnNickLogout, I_OnNickIdentify, I_OnNickDrop, + I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended, + + /* ChanServ */ + I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange, + I_OnAccessDel, I_OnAccessClear, I_OnChanRegistered, I_OnChanUnsuspend, + + /* BotServ */ + + I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign, + I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, + + /* Users */ + I_OnUserConnect, I_OnUserNickChange, I_OnUserLogoff, I_OnPreJoinChannel, I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, + + /* OperServ */ + I_OnDefconLevel, + + /* Other */ + + I_OnReload, I_OnPreServerConnect, I_OnServerConnect, I_OnPreCommand, I_OnPostCommand, I_OnSaveDatabase, I_OnBackupDatabase, + I_OnPreDatabaseExpire, I_OnDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal, + I_OnServerQuit, I_OnTopicUpdated, + I_END }; diff --git a/include/services.h b/include/services.h index 25e9528c8..b35ce2e58 100644 --- a/include/services.h +++ b/include/services.h @@ -229,7 +229,6 @@ extern int strncasecmp(const char *, const char *, size_t); /* Miscellaneous definitions. */ #include "defs.h" #include "slist.h" -#include "events.h" /* pull in the various bits of STL to pull in */ #include <string> diff --git a/src/botserv.c b/src/botserv.c index 654d9905f..b9019dd65 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -420,7 +420,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) if (cmd && (cmd[0] == *BSFantasyCharacter)) { char *params = strtok(NULL, ""); - const char *event_name = EVENT_BOT_FANTASY_NO_ACCESS; /* Strip off the fantasy character */ cmd++; @@ -434,13 +433,11 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) bbuf += params; } chanserv(u, const_cast<char *>(bbuf.c_str())); // XXX Unsafe cast, this needs reviewing -- CyberBotX - event_name = EVENT_BOT_FANTASY; + FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(cmd, u, ci, params)); } - - if (params) - send_event(event_name, 4, cmd, u->nick, ci->name, params); else - send_event(event_name, 3, cmd, u->nick, ci->name); + FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(cmd, u, ci, params)); + } } } @@ -766,7 +763,7 @@ void bot_join(ChannelInfo * ci) } ircdproto->SendJoin(ci->bi, ci->c->name, ci->c->creation_time); ircdproto->SendBotOp(ci->bi->nick, ci->c->name); - send_event(EVENT_BOT_JOIN, 2, ci->name, ci->bi->nick); + FOREACH_MOD(I_OnBotJoin, OnBotJoin(ci, ci->bi)); } /*************************************************************************/ @@ -812,7 +809,7 @@ static void check_ban(ChannelInfo * ci, User * u, int ttbtype) ircdproto->SendMode(ci->bi, ci->name, "+b %s", mask); do_cmode(ci->bi->nick, ac, av); - send_event(EVENT_BOT_BAN, 3, u->nick, ci->name, mask); + FOREACH_MOD(I_OnBotBan, OnBotBan(u, ci, mask)); } } @@ -842,7 +839,7 @@ static void bot_kick(ChannelInfo * ci, User * u, int message, ...) av[2] = buf; ircdproto->SendKick(ci->bi, av[0], av[1], "%s", av[2]); do_kick(ci->bi->nick, 3, av); - send_event(EVENT_BOT_KICK, 3, u->nick, ci->name, buf); + FOREACH_MOD(I_OnBotKick, OnBotKick(u, ci, buf)); } /*************************************************************************/ @@ -922,7 +919,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s", kav[2]); do_kick(ci->bi->nick, 3, kav); - send_event(EVENT_BOT_KICK, 3, kav[1], kav[0], kav[2]); + FOREACH_MOD(I_OnBotKick, OnBotKick(u, ci, kav[2])); } /*************************************************************************/ @@ -969,7 +966,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, else ircdproto->SendKick(ci->bi, av[0], av[1], "%s", av[2]); do_kick(ci->bi->nick, 3, av); - send_event(EVENT_BOT_KICK, 3, av[1], av[0], av[2]); + FOREACH_MOD(I_OnBotKick, OnBotKick(u, ci, av[2])); } /*************************************************************************/ diff --git a/src/channels.c b/src/channels.c index e79e8f902..517bb84db 100644 --- a/src/channels.c +++ b/src/channels.c @@ -550,11 +550,9 @@ void do_join(const char *source, int ac, const char **av) while (c) { nextc = c->next; channame = sstrdup(c->chan->name); - send_event(EVENT_PART_CHANNEL, 3, EVENT_START, user->nick, - channame); + FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan)); chan_deluser(user, c->chan); - send_event(EVENT_PART_CHANNEL, 3, EVENT_STOP, user->nick, - channame); + FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan)); delete [] channame; delete c; c = nextc; @@ -563,8 +561,10 @@ void do_join(const char *source, int ac, const char **av) continue; } + chan = findchan(s); + /* how about not triggering the JOIN event on an actual /part :) -certus */ - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, source, s); + FOREACH_MOD(I_OnPreJoinChannel, OnPreJoinChannel(user, s)); /* Make sure check_kick comes before chan_adduser, so banned users * don't get to see things like channel keys. */ @@ -581,11 +581,10 @@ void do_join(const char *source, int ac, const char **av) } } - chan = findchan(s); chan = join_user_update(user, chan, s, ts); chan_set_correct_modes(user, chan, 1); - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, source, s); + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(user, chan)); } } @@ -667,7 +666,6 @@ void do_part(const char *source, int ac, const char **av) User *user; char *s, *t; struct u_chanlist *c; - char *channame; if (ircd->ts6) { user = find_byuid(source); @@ -697,11 +695,12 @@ void do_part(const char *source, int ac, const char **av) alog("user: BUG parting %s: channel entry found but c->chan NULL", s); return; } - channame = sstrdup(c->chan->name); - send_event(EVENT_PART_CHANNEL, (ac >= 2 ? 4 : 3), EVENT_START, - user->nick, channame, (ac >= 2 ? av[1] : "")); + FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan)); chan_deluser(user, c->chan); + + FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan)); + if (c->next) c->next->prev = c->prev; if (c->prev) @@ -709,10 +708,6 @@ void do_part(const char *source, int ac, const char **av) else user->chans = c->next; delete c; - - send_event(EVENT_PART_CHANNEL, (ac >= 2 ? 4 : 3), EVENT_STOP, - user->nick, channame, (ac >= 2 ? av[1] : "")); - delete [] channame; } } } @@ -881,8 +876,7 @@ void do_sjoin(const char *source, int ac, const char **av) ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); } else { if (!check_kick(user, av[1], ts)) { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, - user->nick, av[1]); + FOREACH_MOD(I_OnPreJoinChannel, OnPreJoinChannel(user, av[1])); /* Make the user join; if the channel does not exist it * will be created there. This ensures that the channel @@ -907,8 +901,7 @@ void do_sjoin(const char *source, int ac, const char **av) restore_topic(c->name); chan_set_correct_modes(user, c, 1); - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, - user->nick, av[1]); + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(user, c)); } } @@ -966,8 +959,7 @@ void do_sjoin(const char *source, int ac, const char **av) ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); } else { if (!check_kick(user, av[1], ts)) { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, - user->nick, av[1]); + FOREACH_MOD(I_OnPreJoinChannel, OnPreJoinChannel(user, av[1])); /* Make the user join; if the channel does not exist it * will be created there. This ensures that the channel @@ -989,8 +981,7 @@ void do_sjoin(const char *source, int ac, const char **av) chan_set_correct_modes(user, c, 1); - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, - user->nick, av[1]); + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(user, c)); } } @@ -1041,8 +1032,7 @@ void do_sjoin(const char *source, int ac, const char **av) ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); } else { if (!check_kick(user, av[1], ts)) { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, - user->nick, av[1]); + FOREACH_MOD(I_OnPreJoinChannel, OnPreJoinChannel(user, av[1])); /* Make the user join; if the channel does not exist it * will be created there. This ensures that the channel @@ -1064,8 +1054,7 @@ void do_sjoin(const char *source, int ac, const char **av) chan_set_correct_modes(user, c, 1); - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, - user->nick, av[1]); + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(user, c)); } } @@ -1101,16 +1090,14 @@ void do_sjoin(const char *source, int ac, const char **av) if (is_sqlined && !is_oper(user)) { ircdproto->SendKick(findbot(s_OperServ), av[1], user->nick, "Q-Lined"); } else { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, user->nick, - av[1]); + FOREACH_MOD(I_OnPreJoinChannel, OnPreJoinChannel(user, av[1])); c = join_user_update(user, c, av[1], ts); if (is_created && c->ci) restore_topic(c->name); chan_set_correct_modes(user, c, 1); - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, user->nick, - av[1]); + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(user, c)); } } } @@ -1261,11 +1248,7 @@ void do_topic(const char *source, int ac, const char **av) record_topic(av[0]); - if (ci && ci->last_topic) { - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ci->last_topic); - } else { - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - } + FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[0])); } /*************************************************************************/ diff --git a/src/chanserv.c b/src/chanserv.c index 790733a48..91432defe 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -1396,7 +1396,7 @@ void expire_chans() && !(ci-> flags & (CI_FORBIDDEN | CI_NO_EXPIRE | CI_SUSPENDED))) { - send_event(EVENT_CHAN_EXPIRE, 1, ci->name); + FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci->name)); alog("Expiring channel %s (founder: %s)", ci->name, (ci->founder ? ci->founder->display : "(none)")); delchan(ci); diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c index eb2aa2f8b..9999b0c27 100644 --- a/src/core/bs_bot.c +++ b/src/core/bs_bot.c @@ -130,7 +130,7 @@ class CommandBSBot : public Command notice_lang(s_BotServ, u, BOT_BOT_ADDED, bi->nick, bi->user, bi->host, bi->real); - send_event(EVENT_BOT_CREATE, 1, bi->nick); + FOREACH_MOD(I_OnBotCreate, OnBotCreate(bi)); return MOD_CONT; } @@ -310,7 +310,7 @@ class CommandBSBot : public Command notice_lang(s_BotServ, u, BOT_BOT_CHANGED, oldnick, bi->nick, bi->user, bi->host, bi->real); - send_event(EVENT_BOT_CHANGE, 1, bi->nick); + FOREACH_MOD(I_OnBotChange, OnBotChange(bi)); return MOD_CONT; } @@ -337,7 +337,7 @@ class CommandBSBot : public Command return MOD_CONT; } - send_event(EVENT_BOT_DEL, 1, bi->nick); + FOREACH_MOD(I_OnBotDelete, OnBotDelete(bi)); ircdproto->SendQuit(bi, "Quit: Help! I'm being deleted by %s!", u->nick); ircdproto->SendSQLineDel(bi->nick); diff --git a/src/core/cs_access.c b/src/core/cs_access.c index 6a1a1f819..7a4ad8a78 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -28,7 +28,9 @@ static int access_del(User * u, ChannelInfo *ci, ChanAccess * access, int *perm, nick = access->nc->display; access->nc = NULL; access->in_use = 0; - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, nick); + + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, nick)); + return 1; } @@ -92,7 +94,6 @@ class CommandCSAccess : public Command const char *cmd = params[1].c_str(); const char *nick = params.size() > 2 ? params[2].c_str() : NULL; const char *s = params.size() > 3 ? params[3].c_str() : NULL; - char event_access[BUFSIZE]; ChannelInfo *ci; NickAlias *na = NULL; @@ -180,8 +181,9 @@ class CommandCSAccess : public Command return MOD_CONT; } access->level = level; - snprintf(event_access, BUFSIZE, "%d", access->level); - send_event(EVENT_ACCESS_CHANGE, 4, ci->name, u->nick, na->nick, event_access); + + FOREACH_MOD(I_OnAccessChange, OnAccessChange(ci, u, na->nick, level)); + alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->GetIdent().c_str(), u->host, ulev, access->level, na->nick, nc->display, ci->name); notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED, nc->display, chan, level); return MOD_CONT; @@ -195,8 +197,8 @@ class CommandCSAccess : public Command ci->AddAccess(nc, level); - snprintf(event_access, BUFSIZE, "%d", level); - send_event(EVENT_ACCESS_ADD, 4, ci->name, u->nick, na->nick, event_access); + FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, na->nick, level)); + alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->GetIdent().c_str(), u->host, ulev, level, na->nick, nc->display, ci->name); notice_lang(s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display, ci->name, level); } @@ -278,10 +280,7 @@ class CommandCSAccess : public Command /* We don't know the nick if someone used numbers, so we trigger the event without * nick param. We just do this once, even if someone enters a range. -Certus */ - if (na) - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, na->nick); - else - send_event(EVENT_ACCESS_DEL, 2, ci->name, u->nick); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, (na->nick ? na->nick : NULL))); } } else if (!stricmp(cmd, "LIST")) @@ -326,7 +325,7 @@ class CommandCSAccess : public Command ci->ClearAccess(); - send_event(EVENT_ACCESS_CLEAR, 2, ci->name, u->nick); + FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); notice_lang(s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name); alog("%s: %s!%s@%s (level %d) cleared access list on %s", diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c index 25f381a37..8e6328607 100644 --- a/src/core/cs_drop.c +++ b/src/core/cs_drop.c @@ -90,7 +90,9 @@ class CommandCSDrop : public Command } notice_lang(s_ChanServ, u, CHAN_DROPPED, chan); - send_event(EVENT_CHAN_DROP, 1, chan); + + FOREACH_MOD(I_OnChanDrop, OnChanDrop(chan)); + return MOD_CONT; } diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index b20e1bc20..86b6aab54 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -102,7 +102,9 @@ class CommandCSForbid : public Command alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick, ci->name); notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan); - send_event(EVENT_CHAN_FORBIDDEN, 1, chan); + + FOREACH_MOD(I_OnChanForbidden, OnChanForbidden(ci)); + return MOD_CONT; } diff --git a/src/core/cs_register.c b/src/core/cs_register.c index 0d8b38cfd..9c1bc6077 100644 --- a/src/core/cs_register.c +++ b/src/core/cs_register.c @@ -121,7 +121,8 @@ class CommandCSRegister : public Command ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->adminset, u->nick); if (ircd->owner && ircd->ownerset) ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->ownerset, u->nick); - send_event(EVENT_CHAN_REGISTERED, 1, chan); + + FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci)); } return MOD_CONT; } diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c index f181363dc..7a63a0fe6 100644 --- a/src/core/cs_suspend.c +++ b/src/core/cs_suspend.c @@ -92,7 +92,8 @@ class CommandCSSuspend : public Command alog("%s: %s set SUSPEND for channel %s", s_ChanServ, u->nick, ci->name); notice_lang(s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan); - send_event(EVENT_CHAN_SUSPENDED, 1, chan); + + FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); } else { @@ -167,7 +168,8 @@ class CommandCSUnSuspend : public Command alog("%s: %s set UNSUSPEND for channel %s", s_ChanServ, u->nick, ci->name); notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan); - send_event(EVENT_CHAN_UNSUSPEND, 1, chan); + + FOREACH_MOD(I_OnChanUnsuspend, OnChanUnsuspend(ci)); } else { diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index e5e547aa4..2a73ce3f6 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -109,7 +109,6 @@ class XOPBase : public Command const char *nick = params.size() > 2 ? params[2].c_str() : NULL; ChanAccess *access; int change = 0; - char event_access[BUFSIZE]; if (!nick) { @@ -174,16 +173,14 @@ class XOPBase : public Command alog("%s: %s!%s@%s (level %d) %s access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->GetIdent().c_str(), u->host, ulev, change ? "changed" : "set", level, na->nick, nc->display, ci->name); - snprintf(event_access, BUFSIZE, "%d", level); - if (!change) { - send_event(EVENT_ACCESS_ADD, 4, ci->name, u->nick, na->nick, event_access); + FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, na->nick, level)); notice_lang(s_ChanServ, u, messages[XOP_ADDED], nc->display, ci->name); } else { - send_event(EVENT_ACCESS_CHANGE, 4, ci->name, u->nick, na->nick, event_access); + FOREACH_MOD(I_OnAccessChange, OnAccessChange(ci, u, na->nick, level)); notice_lang(s_ChanServ, u, messages[XOP_MOVED], nc->display, ci->name); } @@ -272,7 +269,9 @@ class XOPBase : public Command notice_lang(s_ChanServ, u, messages[XOP_DELETED], access->nc->display, ci->name); access->nc = NULL; access->in_use = 0; - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, na->nick); + + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, na->nick)); + deleted = 1; } } @@ -349,7 +348,7 @@ class XOPBase : public Command ci->EraseAccess(i - 1); } - send_event(EVENT_ACCESS_CLEAR, 2, ci->name, u->nick); + FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); notice_lang(s_ChanServ, u, messages[XOP_CLEAR], ci->name); @@ -531,7 +530,9 @@ int xop_del(User *u, ChannelInfo *ci, ChanAccess *access, int *perm, int uacc, i } access->nc = NULL; access->in_use = 0; - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, nick); + + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, nick)); + return 1; } diff --git a/src/core/ns_drop.c b/src/core/ns_drop.c index d3454548c..f53142211 100644 --- a/src/core/ns_drop.c +++ b/src/core/ns_drop.c @@ -74,7 +74,8 @@ class CommandNSDrop : public Command alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, na->nick, na->nc->display, na->nc->email ? na->nc->email : "none"); delnick(na); - send_event(EVENT_NICK_DROPPED, 1, my_nick ? my_nick : nick); + + FOREACH_MOD(I_OnNickDrop, OnNickDrop(my_nick ? my_nick : nick)); if (!is_mine) { diff --git a/src/core/ns_forbid.c b/src/core/ns_forbid.c index 7cceb74d9..8525d9c37 100644 --- a/src/core/ns_forbid.c +++ b/src/core/ns_forbid.c @@ -77,7 +77,8 @@ class CommandNSForbid : public Command alog("%s: %s set FORBID for nick %s", s_NickServ, u->nick, nick); notice_lang(s_NickServ, u, NICK_FORBID_SUCCEEDED, nick); - send_event(EVENT_NICK_FORBIDDEN, 1, nick); + + FOREACH_MOD(I_OnNickForbidden, OnNickForbidden(na)); } else { diff --git a/src/core/ns_group.c b/src/core/ns_group.c index eb069bd9f..11030ffcf 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -155,7 +155,8 @@ class CommandNSGroup : public Command u->nc = na->nc; - send_event(EVENT_GROUP, 1, u->nick); + FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); + alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, u->nick, target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none")); notice_lang(s_NickServ, u, NICK_GROUP_JOINED, target->nick); diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c index 457edb974..526e40ca4 100644 --- a/src/core/ns_identify.c +++ b/src/core/ns_identify.c @@ -86,7 +86,9 @@ class CommandNSIdentify : public Command common_svsmode(u, modes, ""); } ircdproto->SendAccountLogin(u, u->nc); - send_event(EVENT_NICK_IDENTIFY, 1, u->nick); + + FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u)); + alog("%s: %s!%s@%s identified for nick %s", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, u->nick); notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); if (ircd->vhost) diff --git a/src/core/ns_logout.c b/src/core/ns_logout.c index 0b7345f55..e6985024e 100644 --- a/src/core/ns_logout.c +++ b/src/core/ns_logout.c @@ -77,7 +77,7 @@ class CommandNSLogout : public Command u2->nc = NULL; /* Send out an event */ - send_event(EVENT_NICK_LOGOUT, 1, u2->nick); + FOREACH_MOD(I_OnNickLogout, OnNickLogout(u2)); } return MOD_CONT; } diff --git a/src/core/ns_register.c b/src/core/ns_register.c index 54bb154a8..26d6046e7 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -86,7 +86,8 @@ class CommandNSConfirm : public Command notice_lang(s_NickServ, u, NICK_REGISTERED_NO_MASK, u->nick); ircdproto->SendAccountLogin(u, u->nc); - send_event(EVENT_NICK_REGISTERED, 1, u->nick); + + FOREACH_MOD(I_OnNickRegister, OnNickRegister(u)); if (enc_decrypt(na->nc->pass, tmp_pass, PASSMAX - 1) == 1) notice_lang(s_NickServ, u, NICK_PASSWORD_IS, tmp_pass); diff --git a/src/core/ns_suspend.c b/src/core/ns_suspend.c index 3c7158f7f..eb4e6547f 100644 --- a/src/core/ns_suspend.c +++ b/src/core/ns_suspend.c @@ -80,7 +80,8 @@ class CommandNSSuspend : public Command alog("%s: %s set SUSPEND for nick %s", s_NickServ, u->nick, nick); notice_lang(s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick); - send_event(EVENT_NICK_SUSPENDED, 1, nick); + + FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na)) } else { @@ -147,7 +148,8 @@ class CommandNSUnSuspend : public Command alog("%s: %s set UNSUSPEND for nick %s", s_NickServ, u->nick, nick); notice_lang(s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick); - send_event(EVENT_NICK_UNSUSPEND, 1, nick); + + FOREACH_MOD(I_OnNickUnsuspended, OnNickUnsuspended(na)); } else { diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c index f079c71e3..dfec49a68 100644 --- a/src/core/os_defcon.c +++ b/src/core/os_defcon.c @@ -49,7 +49,9 @@ class CommandOSDEFCON : public Command return MOD_CONT; } DefConLevel = newLevel; - send_event(EVENT_DEFCON_LEVEL, 1, lvl); + + FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(newLevel)); + DefContimer = time(NULL); notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel); defcon_sendlvls(u); diff --git a/src/init.c b/src/init.c index e80f52c59..8ef0a48df 100644 --- a/src/init.c +++ b/src/init.c @@ -604,7 +604,7 @@ int init_secondary(int ac, char **av) /* Save the databases back to file/mysql to reflect any changes */ alog("Info: Reflecting database records."); save_databases(); - send_event(EVENT_CONNECT, 1, EVENT_START); + FOREACH_MOD(I_OnPreServerConnect, OnPreServerConnect()); /* Connect to the remote server */ std::list<Uplink *>::iterator curr_uplink = Uplinks.begin(), end_uplink = Uplinks.end(); @@ -620,7 +620,7 @@ int init_secondary(int ac, char **av) if (curr_uplink == end_uplink) fatal_perror("Can't connect to any servers"); ircdproto->SendConnect(); - send_event(EVENT_CONNECT, 1, EVENT_STOP); + FOREACH_MOD(I_OnServerConnect, OnServerConnect()); sgets2(inbuf, sizeof(inbuf), servsock); if (strnicmp(inbuf, "ERROR", 5) == 0) { diff --git a/src/main.c b/src/main.c index 64b737e8b..afc893b81 100644 --- a/src/main.c +++ b/src/main.c @@ -109,7 +109,8 @@ extern void expire_all() return; } - send_event(EVENT_DB_EXPIRE, 1, EVENT_START); + FOREACH_MOD(I_OnPreDatabaseExpire, OnPreDatabaseExpire()); + if (debug) alog("debug: Running expire routines"); expire_nicks(); @@ -126,7 +127,8 @@ extern void expire_all() expire_szlines(); } expire_exceptions(); - send_event(EVENT_DB_EXPIRE, 1, EVENT_STOP); + + FOREACH_MOD(I_OnDatabaseExpire, OnDatabaseExpire()); } /*************************************************************************/ @@ -160,7 +162,9 @@ void save_databases() static void services_restart() { alog("Restarting"); - send_event(EVENT_RESTART, 1, EVENT_START); + + FOREACH_MOD(I_OnPreRestart, OnPreRestart()); + if (!quitmsg) quitmsg = "Restarting"; ircdproto->SendSquit(ServerName, quitmsg); @@ -201,7 +205,7 @@ static void services_shutdown() { User *u, *next; - send_event(EVENT_SHUTDOWN, 1, EVENT_START); + FOREACH_MOD(I_OnPreShutdown, OnPreShutdown()); if (!quitmsg) quitmsg = "Terminating, reason unknown"; @@ -220,7 +224,7 @@ static void services_shutdown() u = next; } } - send_event(EVENT_SHUTDOWN, 1, EVENT_STOP); + FOREACH_MOD(I_OnShutdown, OnShutdown()); disconn(servsock); /* First don't unload protocol module, then do so */ modules_unload_all(false); @@ -295,7 +299,7 @@ void sighandler(int signum) /* Should we send the signum here as well? -GD */ - send_event(EVENT_SIGNAL, 1, quitmsg); + FOREACH_MOD(I_OnSignal, OnSignal(quitmsg)); if (started) { diff --git a/src/misc.c b/src/misc.c index b1ab62e32..02375c96b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -26,12 +26,6 @@ struct arc4_stream { uint8 s[256]; } rs; -// XXX: remove me once the old event system is gone. -void send_event(char const*, int, ...) -{ - -} - /*************************************************************************/ /** diff --git a/src/nickserv.c b/src/nickserv.c index 366f9ee43..21c3205fe 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -729,7 +729,7 @@ void expire_nicks() (na->nc->email ? na->nc->email : "none")); tmpnick = sstrdup(na->nick); delnick(na); - send_event(EVENT_NICK_EXPIRE, 1, tmpnick); + FOREACH_MOD(I_OnNickExpire, OnNickExpire(tmpnick)); delete [] tmpnick; } } diff --git a/src/operserv.c b/src/operserv.c index b2b05f1ef..9249d8292 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -1265,7 +1265,7 @@ void resetDefCon(int level) if ((DefContimer) && (time(NULL) - DefContimer >= DefConTimeOut)) { DefConLevel = level; - send_event(EVENT_DEFCON_LEVEL, 1, strLevel); + FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(strLevel)); alog("Defcon level timeout, returning to lvl %d", level); ircdproto->SendGlobops(s_OperServ, getstring(OPER_DEFCON_WALL), diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index 5e93fa68e..0aa2321b4 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -889,10 +889,12 @@ int anope_event_topic(const char *source, int ac, const char **av) record_topic(av[0]); - if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); - else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + if (ac > 1 && *av[1]) { + FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[1])); + } + else { + FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, "")); + } return MOD_CONT; } diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index 0b36267da..0fc07852d 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -968,10 +968,12 @@ int anope_event_topic(const char *source, int ac, const char **av) record_topic(av[0]); - if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); - else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + if (ac > 1 && *av[1]) { + FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[0])); + } + else { + FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, "")); + } return MOD_CONT; } diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index d87d0b64e..261aeb031 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -782,10 +782,12 @@ int anope_event_topic(const char *source, int ac, const char **av) record_topic(av[0]); - if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); - else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + if (ac > 1 && *av[1]) { + FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, av[1])); + } + else { + FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(c, "")); + } } return MOD_CONT; } diff --git a/src/servers.c b/src/servers.c index 18a809762..993a212c1 100644 --- a/src/servers.c +++ b/src/servers.c @@ -437,7 +437,7 @@ void do_squit(const char *source, int ac, const char **av) alog("SQUIT for nonexistent server (%s)!!", av[0]); return; } - send_event(EVENT_SERVER_SQUIT, 1, s->name); + FOREACH_MOD(I_OnServerQuit, OnServerQuit(s)); /* If this is a juped server, send a nice global to inform the online * opers that we received it. diff --git a/src/users.c b/src/users.c index 25e52404c..fd9d25549 100644 --- a/src/users.c +++ b/src/users.c @@ -227,7 +227,7 @@ User::~User() delete [] srealname; } - send_event(EVENT_USER_LOGOFF, 1, this->nick); + FOREACH_MOD(I_OnUserLogoff, OnUserLogoff(this->nick)); if (debug >= 2) alog("debug: User::~User() called"); |