summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViper <Viper@Anope.org>2011-04-28 21:00:46 +0200
committerViper <Viper@Anope.org>2011-04-28 21:00:46 +0200
commit01946cb46701aed6161e96ec8455bfacd8c3b164 (patch)
tree66ca44fe4dfac7d38541a919c78edab45460bd4d
parent0e0538408dac890d23e888c5692924cb7fc64e6c (diff)
Added events for module loading/unloading and command creation/deletion.
Enables modules expanding on other modules to adjust hooks if needed. - Related to bug #1263.
-rw-r--r--Changes2
-rw-r--r--docs/EVENTS27
-rw-r--r--include/events.h4
-rw-r--r--src/modules.c15
-rw-r--r--version.log3
5 files changed, 50 insertions, 1 deletions
diff --git a/Changes b/Changes
index a84470a6c..2927d7e6f 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,8 @@ Anope Version 1.8 - GIT
10/31 A Added support for plexus3's channel mode +z [#1202]
02/23 A Added account tracking support to ratbox protocol module [ #00]
03/21 A Added support for Hybrid's m_services and m_change [ #00]
+03/28 A Added internal events called when a module is loaded/unloaded. [ #00]
+03/28 A Added internal events called when a command is added/deleted. [ #00]
09/11 F Fixed db-convert handling some vhost collisions [ #00]
09/14 F Fixed ./configure failing with partial SQL installations [ #00]
09/28 F Fixed ForkForMail to always work [ #00]
diff --git a/docs/EVENTS b/docs/EVENTS
index de2ff5422..c572c015d 100644
--- a/docs/EVENTS
+++ b/docs/EVENTS
@@ -435,3 +435,30 @@ Anope Internal Events
A user has left the network. This event is emitted before the internal
removal is performed, so the user still exists internally.
av[0] The nickname of the user leaving the network.
+
+ EVENT_MODLOAD
+ A module has been loaded. This event is emitted after the loading
+ sequence has been finished: AnopeInit() has been called and the
+ module has already been added to the modules table.
+ av[0] Name of the loaded module.
+
+ EVENT_MODUNLOAD
+ A module has been unloaded. This event is emitted when the unloading
+ sequence is almost complete: AnopeFini() has been called and all
+ commands, hooks and callbacks have been removed. The module itself
+ is still in memory however.
+ av[0] Name of the unloaded module.
+
+ EVENT_ADDCOMMAND
+ A command hook has been added to anopes command table.
+ Note that the command may have previously existed and merely a new hook
+ was added before or after an existing command hook.
+ av[0] Name of the module adding the command.
+ av[1] Name of the command hook that was added.
+
+ EVENT_DELCOMMAND
+ A command hook has been removed from anopes command table.
+ Note that the command may still exist in anopes command table if other
+ modules have hooks for the same command.
+ av[0] Name of the module deleting the command.
+ av[1] Name of the command hook that was removed.
diff --git a/include/events.h b/include/events.h
index 1fca188df..2c221b2a0 100644
--- a/include/events.h
+++ b/include/events.h
@@ -64,3 +64,7 @@
#define EVENT_ACCESS_CLEAR "access_clear"
#define EVENT_NICK_LOGOUT "nick_logout"
#define EVENT_CHAN_KICK "chan_kick"
+#define EVENT_MODLOAD "modload"
+#define EVENT_MODUNLOAD "modunload"
+#define EVENT_ADDCOMMAND "addcommand"
+#define EVENT_DELCOMMAND "delcommand"
diff --git a/src/modules.c b/src/modules.c
index b85898668..76e2f14ff 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -713,6 +713,10 @@ int loadModule(Module * m, User * u)
notice_lang(s_OperServ, u, OPER_MODULE_LOADED, m->name);
}
addModule(m);
+
+ /* Loading is complete.. send out an event in case anyone s interested.. ~ Viper */
+ send_event(EVENT_MODLOAD, 1, m->name);
+
return MOD_ERR_OK;
#else
@@ -761,6 +765,10 @@ int unloadModule(Module * m, User * u)
return MOD_ERR_UNKNOWN;
}
+ /* Unloading is complete: AnopeFini has been called and all commands, hooks and callbacks
+ * have been removed.. send out an event in case anyone s interested.. ~ Viper */
+ send_event(EVENT_MODUNLOAD, 1, m->name);
+
if ((ano_modclose(m->handle)) != 0) {
alog("%s", ano_moderr());
if (u) {
@@ -1277,6 +1285,7 @@ int addCommand(CommandHash * cmdTable[], Command * c, int pos)
if (debug)
alog("debug: existing cmd: (0x%p), new cmd (0x%p)",
(void *) c->next, (void *) c);
+ send_event(EVENT_ADDCOMMAND, 2, c->mod_name, c->name);
return MOD_ERR_OK;
} else if (pos == 2) {
@@ -1289,6 +1298,7 @@ int addCommand(CommandHash * cmdTable[], Command * c, int pos)
tail->next = c;
c->next = NULL;
+ send_event(EVENT_ADDCOMMAND, 2, c->mod_name, c->name);
return MOD_ERR_OK;
} else
return MOD_ERR_EXISTS;
@@ -1308,6 +1318,7 @@ int addCommand(CommandHash * cmdTable[], Command * c, int pos)
else
lastHash->next = newHash;
+ send_event(EVENT_ADDCOMMAND, 2, c->mod_name, c->name);
return MOD_ERR_OK;
}
@@ -1343,6 +1354,7 @@ int delCommand(CommandHash * cmdTable[], Command * c, char *mod_name)
} else {
current->c = tail->next;
}
+ send_event(EVENT_DELCOMMAND, 2, c->mod_name, c->name);
return MOD_ERR_OK;
}
last = tail;
@@ -1351,6 +1363,7 @@ int delCommand(CommandHash * cmdTable[], Command * c, char *mod_name)
} else {
cmdTable[index] = current->next;
free(current->name);
+ send_event(EVENT_DELCOMMAND, 2, c->mod_name, c->name);
return MOD_ERR_OK;
}
} else {
@@ -1364,6 +1377,7 @@ int delCommand(CommandHash * cmdTable[], Command * c, char *mod_name)
} else {
current->c = tail->next;
}
+ send_event(EVENT_DELCOMMAND, 2, c->mod_name, c->name);
return MOD_ERR_OK;
}
last = tail;
@@ -1372,6 +1386,7 @@ int delCommand(CommandHash * cmdTable[], Command * c, char *mod_name)
} else {
lastHash->next = current->next;
free(current->name);
+ send_event(EVENT_DELCOMMAND, 2, c->mod_name, c->name);
return MOD_ERR_OK;
}
}
diff --git a/version.log b/version.log
index 9dfbbf1f6..b754df270 100644
--- a/version.log
+++ b/version.log
@@ -8,9 +8,10 @@ VERSION_MAJOR="1"
VERSION_MINOR="8"
VERSION_PATCH="5"
VERSION_EXTRA="-git"
-VERSION_BUILD="3067"
+VERSION_BUILD="3068"
# $Log$ # Changes since 1.8.5 Release
+#Revision 3068 - Added events for module loading/unloading and command creation/deletion. Enables modules expanding on other modules to adjust hooks if needed. - Related to bug #1263.
#Revision 3067 - Fixed bug #1252 - The group display nick showing in HS req memos instead of the requesting alias. Also cleaned up the mess in Changes...
#Revision 3066 - Added support m_services.c and m_change.c from Hybrid's contrib folder
#Revision 3065 - Change to users masked host instead of the real one after turning vhost off in inspircd.