aboutsummaryrefslogtreecommitdiffstats
path: root/core/modulemanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-01 21:07:14 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-01 21:07:14 +0000
commit4851756ca45d3e9dc2d8add552528db9423332da (patch)
tree1e33e3e6bc432810ab76b987925bb7e4dca097c6 /core/modulemanager.lua
parent7a2fc45f65a14933f2ab8e83d6ae9487b59e6a79 (diff)
downloadprosody-4851756ca45d3e9dc2d8add552528db9423332da.tar.gz
prosody-4851756ca45d3e9dc2d8add552528db9423332da.zip
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
Diffstat (limited to 'core/modulemanager.lua')
-rw-r--r--core/modulemanager.lua21
1 files changed, 16 insertions, 5 deletions
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)