# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1312820633 -7200
# Node ID a2ee8ab82dd9be9f2e7d6778d4e08e5c3e247a0b
# Parent  abcbcb15205c418afc26269865ddefd86a65df14
core.modulemanager, mod_disco: Add support for XEP-0128: Service Discovery Extensions

diff -r abcbcb15205c -r a2ee8ab82dd9 core/modulemanager.lua
--- 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(...);
diff -r abcbcb15205c -r a2ee8ab82dd9 plugins/mod_disco.lua
--- 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)