# HG changeset patch # User Matthew Wild # Date 1228405699 0 # Node ID c9dbfcf21846edc81e42376389fb8a78f1afa023 # Parent 3521e0851c9ef27b892a83bd147788b5450699f6# Parent 26d000f259397b05859cf6b2a449c33952043071 Automated merge with http://waqas.ath.cx/ diff -r 26d000f25939 -r c9dbfcf21846 core/modulemanager.lua --- a/core/modulemanager.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/core/modulemanager.lua Thu Dec 04 15:48:19 2008 +0000 @@ -22,7 +22,8 @@ local plugin_dir = CFG_PLUGINDIR or "./plugins/"; local logger = require "util.logger"; -local log = logger.init("modulemanager") +local log = logger.init("modulemanager"); +local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler; local loadfile, pcall = loadfile, pcall; local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv; @@ -172,6 +173,15 @@ _add_iq_handler(self, origin_type, xmlns, handler); end +function api:add_feature(xmlns) + addDiscoInfoHandler(self.host, function(reply, to, from, node) + if #node == 0 then + reply:tag("feature", {var = xmlns}):up(); + return true; + end + end); +end + do local event_handlers = {}; diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_disco.lua --- a/plugins/mod_disco.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_disco.lua Thu Dec 04 15:48:19 2008 +0000 @@ -21,8 +21,8 @@ local discomanager_handle = require "core.discomanager".handle; -require "core.discomanager".set("disco", "http://jabber.org/protocol/disco#info"); -require "core.discomanager".set("disco", "http://jabber.org/protocol/disco#items"); +module:add_feature("http://jabber.org/protocol/disco#info"); +module:add_feature("http://jabber.org/protocol/disco#items"); module:add_iq_handler({"c2s", "s2sin"}, "http://jabber.org/protocol/disco#info", function (session, stanza) session.send(discomanager_handle(stanza)); diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_legacyauth.lua --- a/plugins/mod_legacyauth.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_legacyauth.lua Thu Dec 04 15:48:19 2008 +0000 @@ -22,7 +22,7 @@ local st = require "util.stanza"; local t_concat = table.concat; -require "core.discomanager".set("legacyauth", "jabber:iq:auth"); +module:add_feature("jabber:iq:auth"); module:add_iq_handler("c2s_unauthed", "jabber:iq:auth", function (session, stanza) diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_ping.lua --- a/plugins/mod_ping.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_ping.lua Thu Dec 04 15:48:19 2008 +0000 @@ -21,7 +21,7 @@ local st = require "util.stanza"; -require "core.discomanager".set("ping", "urn:xmpp:ping"); +module:add_feature("urn:xmpp:ping"); module:add_iq_handler({"c2s", "s2sin"}, "urn:xmpp:ping", function(session, stanza) diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_private.lua --- a/plugins/mod_private.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_private.lua Thu Dec 04 15:48:19 2008 +0000 @@ -24,7 +24,7 @@ local jid_split = require "util.jid".split; local datamanager = require "util.datamanager" -require "core.discomanager".set("private", "jabber:iq:private"); +module:add_feature("jabber:iq:private"); module:add_iq_handler("c2s", "jabber:iq:private", function (session, stanza) diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_register.lua --- a/plugins/mod_register.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_register.lua Thu Dec 04 15:48:19 2008 +0000 @@ -24,7 +24,7 @@ local usermanager_create_user = require "core.usermanager".create_user; local datamanager_store = require "util.datamanager".store; -require "core.discomanager".set("register", "jabber:iq:register"); +module:add_feature("jabber:iq:register"); module:add_iq_handler("c2s", "jabber:iq:register", function (session, stanza) if stanza.tags[1].name == "query" then diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_roster.lua --- a/plugins/mod_roster.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_roster.lua Thu Dec 04 15:48:19 2008 +0000 @@ -29,7 +29,7 @@ local rm_add_to_roster = require "core.rostermanager".add_to_roster; local rm_roster_push = require "core.rostermanager".roster_push; -require "core.discomanager".set("roster", "jabber:iq:roster"); +module:add_feature("jabber:iq:roster"); module:add_iq_handler("c2s", "jabber:iq:roster", function (session, stanza) diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_time.lua --- a/plugins/mod_time.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_time.lua Thu Dec 04 15:48:19 2008 +0000 @@ -25,7 +25,7 @@ -- XEP-0202: Entity Time -require "core.discomanager".set("time", "urn:xmpp:time"); +module:add_feature("urn:xmpp:time"); module:add_iq_handler({"c2s", "s2sin"}, "urn:xmpp:time", function(session, stanza) @@ -38,7 +38,7 @@ -- XEP-0090: Entity Time (deprecated) -require "core.discomanager".set("time", "jabber:iq:time"); +module:add_feature("jabber:iq:time"); module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:time", function(session, stanza) diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_uptime.lua --- a/plugins/mod_uptime.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_uptime.lua Thu Dec 04 15:48:19 2008 +0000 @@ -26,7 +26,7 @@ local start_time = os.time(); -require "core.discomanager".set("uptime", "jabber:iq:last"); +module:add_feature("jabber:iq:last"); module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", function (origin, stanza) diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_vcard.lua --- a/plugins/mod_vcard.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_vcard.lua Thu Dec 04 15:48:19 2008 +0000 @@ -28,7 +28,7 @@ require "util.jid" local jid_split = jid.split; -require "core.discomanager".set("vcard", "vcard-temp"); +module:add_feature("vcard-temp"); module:add_iq_handler({"c2s", "s2sin"}, "vcard-temp", function (session, stanza) diff -r 26d000f25939 -r c9dbfcf21846 plugins/mod_version.lua --- a/plugins/mod_version.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/plugins/mod_version.lua Thu Dec 04 15:48:19 2008 +0000 @@ -25,7 +25,7 @@ local xmlns_version = "jabber:iq:version" -require "core.discomanager".set("version", xmlns_version); +module:add_feature(xmlns_version); local function handle_version_request(session, stanza) if stanza.attr.type == "get" then diff -r 26d000f25939 -r c9dbfcf21846 util/discohelper.lua --- a/util/discohelper.lua Wed Dec 03 20:44:26 2008 +0000 +++ b/util/discohelper.lua Thu Dec 04 15:48:19 2008 +0000 @@ -57,20 +57,8 @@ elseif query.attr.xmlns == "http://jabber.org/protocol/disco#items" then handlers = self.item_handlers; end - local handler = handlers[to]; -- get the handler - if not handler then -- if not found then use default handler - if to_node then - handler = handlers["*defaultnode"]; - else - handler = handlers["*defaulthost"]; - end - end - local found; -- to keep track of any handlers found - if handler then - for _, h in ipairs(handler) do - if h(reply, to, from, node) then found = true; end - end - end + local handler; + local found; -- to keep track of any handlers found if to_node then -- handlers which get called always handler = handlers["*node"]; else @@ -81,6 +69,19 @@ if h(reply, to, from, node) then found = true; end end end + handler = handlers[to]; -- get the handler + if not handler then -- if not found then use default handler + if to_node then + handler = handlers["*defaultnode"]; + else + handler = handlers["*defaulthost"]; + end + end + if handler then + for _, h in ipairs(handler) do + if h(reply, to, from, node) then found = true; end + end + end if found then return reply; end -- return the reply if there was one return st.error_reply(stanza, "cancel", "service-unavailable"); end