From 4851756ca45d3e9dc2d8add552528db9423332da Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 1 Nov 2008 21:07:14 +0000 Subject: Fix s2s once and for all - Moved dialback to the new mod_dialback (mostly). - Modules can now supply a list of origins to handle to add_handler - Modules can now handle and process any stanza, overriding the core - Modules handle non-jabber:client/jabber:server xmlns'd stanzas --- core/modulemanager.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'core/modulemanager.lua') diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 29139ad7..b65494e7 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -31,17 +31,27 @@ function modulehelpers.add_iq_handler(origin_type, xmlns, handler) 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() @@ -53,6 +63,7 @@ function loadall() load("vcard"); load("private"); load("version"); + load("dialback"); end function load(name) -- cgit v1.2.3