# HG changeset patch # User Matthew Wild # Date 1244802085 -3600 # Node ID 389b4fb489014a38e2058e323c83cdafbacb5007 # Parent 7c71783b40cf1144e1b97ae8808a6846be43e913# Parent 4443309b55283db4dcd4833acffa44dd27299ce2 Automated merge with http://waqas.ath.cx:8000/ diff -r 4443309b5528 -r 389b4fb48901 core/modulemanager.lua --- a/core/modulemanager.lua Fri Jun 12 11:21:11 2009 +0100 +++ b/core/modulemanager.lua Fri Jun 12 11:21:25 2009 +0100 @@ -47,6 +47,7 @@ local modulehelpers = setmetatable({}, { __index = _G }); local features_table = multitable_new(); +local identities_table = multitable_new(); local handler_table = multitable_new(); local hooked = multitable_new(); local hooks = multitable_new(); @@ -162,6 +163,7 @@ end modulemap[host][name] = nil; features_table:remove(host, name); + identities_table:remove(host, name); local params = handler_table:get(host, name); -- , {module.host, origin_type, tag, xmlns} for _, param in pairs(params or NULL) do local handlers = stanza_handlers:get(param[1], param[2], param[3], param[4]); @@ -326,6 +328,22 @@ addDiscoInfoHandler("*host", function(reply, to, from, node) if #node == 0 then local done = {}; + for module, identities in pairs(identities_table:get(to) or NULL) do -- for each module + for identity, attr in pairs(identities) do + if not done[identity] then + reply:tag("identity", attr):up(); -- TODO cache + done[identity] = true; + end + end + end + for module, identities in pairs(identities_table:get("*") or NULL) do -- for each module + for identity, attr in pairs(identities) do + if not done[identity] then + reply:tag("identity", attr):up(); -- TODO cache + done[identity] = true; + end + end + end for module, features in pairs(features_table:get(to) or NULL) do -- for each module for feature in pairs(features) do if not done[feature] then @@ -349,6 +367,9 @@ function api:add_feature(xmlns) features_table:set(self.host, self.name, xmlns, true); end +function api:add_identity(category, typ) + identities_table:set(self.host, self.name, category.."\0"..typ, {category = category, typ = typ}); +end local event_hook = function(host, mod_name, event_name, ...) if type((...)) == "table" and (...).host and (...).host ~= host then return; end diff -r 4443309b5528 -r 389b4fb48901 plugins/mod_pep.lua --- a/plugins/mod_pep.lua Fri Jun 12 11:21:11 2009 +0100 +++ b/plugins/mod_pep.lua Fri Jun 12 11:21:25 2009 +0100 @@ -11,6 +11,8 @@ local data = {}; local recipients = {}; +module:add_identity("pubsub", "pep"); + local function publish(session, node, item) local stanza = st.message({from=session.full_jid, type='headline'}) :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) @@ -51,7 +53,7 @@ if t == "unavailable" or t == "error" then if recipients[user] then recipients[user][recipient] = nil; end elseif not t then - recipients[user] = recipients[user][recipient] or {}; + recipients[user] = recipients[user] or {}; if not recipients[user][recipient] then recipients[user][recipient] = true; for node, message in pairs(data[user] or {}) do