Software /
code /
prosody
Changeset
201:bb1b3201bab5
merge from waqas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 02 Nov 2008 02:02:41 +0000 |
parents | 198:e4755408d40b (diff) 200:5e8b3cce798f (current diff) |
children | 202:6178f6ba47c8 |
files | |
diffstat | 3 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/core/modulemanager.lua Sun Nov 02 06:53:31 2008 +0500 +++ b/core/modulemanager.lua Sun Nov 02 02:02:41 2008 +0000 @@ -18,19 +18,29 @@ local modulehelpers = setmetatable({}, { __index = _G }); -function modulehelpers.add_iq_handler(origin_type, xmlns, handler) - if not (origin_type and handler and xmlns) then return false; end +local function _add_iq_handler(module, origin_type, xmlns, handler) handlers[origin_type] = handlers[origin_type] or {}; handlers[origin_type].iq = handlers[origin_type].iq or {}; if not handlers[origin_type].iq[xmlns] then handlers[origin_type].iq[xmlns]= handler; - handler_info[handler] = getfenv(2).module; - log("debug", "mod_%s now handles tag 'iq' with query namespace '%s'", getfenv(2).module.name, xmlns); + handler_info[handler] = module; + log("debug", "mod_%s now handles tag 'iq' with query namespace '%s'", module.name, xmlns); else - log("warning", "mod_%s wants to handle tag 'iq' with query namespace '%s' but mod_%s already handles that", getfenv(2).module.name, xmlns, handler_info[handlers[origin_type].iq[xmlns]].module.name); + log("warning", "mod_%s wants to handle tag 'iq' with query namespace '%s' but mod_%s already handles that", module.name, xmlns, handler_info[handlers[origin_type].iq[xmlns]].module.name); end end +function modulehelpers.add_iq_handler(origin_type, xmlns, handler) + if not (origin_type and handler and xmlns) then return false; end + if type(origin_type) == "table" then + for _, origin_type in ipairs(origin_type) do + _add_iq_handler(getfenv(2).module, origin_type, xmlns, handler); + end + return; + end + _add_iq_handler(getfenv(2).module, origin_type, xmlns, handler); +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
--- a/plugins/mod_vcard.lua Sun Nov 02 06:53:31 2008 +0500 +++ b/plugins/mod_vcard.lua Sun Nov 02 02:02:41 2008 +0000 @@ -9,7 +9,7 @@ require "util.jid" local jid_split = jid.split; -add_iq_handler("c2s", "vcard-temp", +add_iq_handler({"c2s", "s2sin"}, "vcard-temp", function (session, stanza) if stanza.tags[1].name == "vCard" then local to = stanza.attr.to;
--- a/util/hashes.lua Sun Nov 02 06:53:31 2008 +0500 +++ b/util/hashes.lua Sun Nov 02 02:02:41 2008 +0000 @@ -23,6 +23,8 @@ else error("md5 library found, but unrecognised... no hash functions will be available", 0); end +else + error("No md5 library found. Install md5 using luarocks, for example", 0); end return _M;