Changeset

4337:a2ee8ab82dd9

core.modulemanager, mod_disco: Add support for XEP-0128: Service Discovery Extensions
author Kim Alvefur <zash@zash.se>
date Mon, 08 Aug 2011 18:23:53 +0200
parents 4336:abcbcb15205c
children 4338:5d5d6c6d121a
files core/modulemanager.lua plugins/mod_disco.lua
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/modulemanager.lua	Thu Aug 04 14:00:24 2011 -0400
+++ b/core/modulemanager.lua	Mon Aug 08 18:23:53 2011 +0200
@@ -278,6 +278,9 @@
 function api:add_identity(category, type, name)
 	self:add_item("identity", {category = category, type = type, name = name});
 end
+function api:add_extension(data)
+	self:add_item("extension", data);
+end
 
 function api:fire_event(...)
 	return (hosts[self.host] or prosody).events.fire_event(...);
--- a/plugins/mod_disco.lua	Thu Aug 04 14:00:24 2011 -0400
+++ b/plugins/mod_disco.lua	Mon Aug 08 18:23:53 2011 +0200
@@ -54,6 +54,12 @@
 			done[feature] = true;
 		end
 	end
+	for _,extension in ipairs(module:get_host_items("extension")) do
+		if not done[extension] then
+			query:add_child(extension);
+			done[extension] = true;
+		end
+	end
 	_cached_server_disco_info = query;
 	_cached_server_caps_hash = calculate_hash(query);
 	_cached_server_caps_feature = st.stanza("c", {
@@ -81,8 +87,10 @@
 
 module:hook("item-added/identity", clear_disco_cache);
 module:hook("item-added/feature", clear_disco_cache);
+module:hook("item-added/extension", clear_disco_cache);
 module:hook("item-removed/identity", clear_disco_cache);
 module:hook("item-removed/feature", clear_disco_cache);
+module:hook("item-removed/extension", clear_disco_cache);
 
 -- Handle disco requests to the server
 module:hook("iq/host/http://jabber.org/protocol/disco#info:query", function(event)