core/modulemanager.lua

changeset 191
e64c8a44060f
parent 188
0d9f03009b8a
child 196
ebe23269b377
--- a/core/modulemanager.lua	Sat Nov 01 18:28:46 2008 +0000
+++ b/core/modulemanager.lua	Sat Nov 01 21:07:14 2008 +0000
@@ -31,19 +31,29 @@
 	end
 end
 
-function modulehelpers.add_handler(origin_type, tag, xmlns, handler)
-	if not (origin_type and tag and xmlns and handler) then return false; end
+local function _add_handler(module, origin_type, tag, xmlns, handler)
 	handlers[origin_type] = handlers[origin_type] or {};
 	if not handlers[origin_type][tag] then
 		handlers[origin_type][tag] = handlers[origin_type][tag] or {};
 		handlers[origin_type][tag][xmlns]= handler;
-		handler_info[handler] = getfenv(2).module;
-		log("debug", "mod_%s now handles tag '%s'", getfenv(2).module.name, tag);
+		handler_info[handler] = module;
+		log("debug", "mod_%s now handles tag '%s'", module.name, tag);
 	elseif handler_info[handlers[origin_type][tag]] then
-		log("warning", "mod_%s wants to handle tag '%s' but mod_%s already handles that", getfenv(2).module.name, tag, handler_info[handlers[origin_type][tag]].module.name);
+		log("warning", "mod_%s wants to handle tag '%s' but mod_%s already handles that", module.name, tag, handler_info[handlers[origin_type][tag]].module.name);
 	end
 end
 
+function modulehelpers.add_handler(origin_type, tag, xmlns, handler)
+	if not (origin_type and tag and xmlns and handler) then return false; end
+	if type(origin_type) == "table" then
+		for _, origin_type in ipairs(origin_type) do
+			_add_handler(getfenv(2).module, origin_type, tag, xmlns, handler);
+		end
+		return;
+	end
+	_add_handler(getfenv(2).module, origin_type, tag, xmlns, handler);
+end
+
 function loadall()
 	load("saslauth");
 	load("legacyauth");
@@ -53,6 +63,7 @@
 	load("vcard");
 	load("private");
 	load("version");
+	load("dialback");
 end
 
 function load(name)

mercurial