Changeset

1231:6f251813f1e5

modulemanager: Added hook(event, handler) to the plugin API
author Waqas Hussain <waqas20@gmail.com>
date Sat, 30 May 2009 17:35:32 +0500
parents 1228:853d3d76ba94
children 1232:6ddbb583f067
files core/modulemanager.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/modulemanager.lua	Sat May 30 02:06:04 2009 +0500
+++ b/core/modulemanager.lua	Sat May 30 17:35:32 2009 +0500
@@ -354,6 +354,14 @@
 	return eventmanager.fire_event(...);
 end
 
+function api:hook(event, handler)
+	if self.host ~= '*' then
+		hosts[self.host].events.add_handler(event, handler);
+	else
+		self:log("error", "Global module attempting to hook a host-specific event: %s", event);
+	end
+end
+
 --------------------------------------------------------------------
 
 local actions = {};