verse.plugins.disco: Add stream:add_disco_item()

Thu, 26 Aug 2010 17:48:57 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 26 Aug 2010 17:48:57 +0100
changeset 115
9f8cacfca7c7
parent 114
37f5966cff15
child 116
151c8cc776df

verse.plugins.disco: Add stream:add_disco_item()

plugins/disco.lua file | annotate | diff | comparison | revisions
--- a/plugins/disco.lua	Wed Aug 25 16:27:30 2010 +0100
+++ b/plugins/disco.lua	Thu Aug 26 17:48:57 2010 +0100
@@ -99,6 +99,19 @@
 		end
 	end
 
+	function stream:add_disco_item(item, node)
+		local disco_items = self.disco.items;
+		if node then
+			disco_items = self.disco.nodes[node];
+			if not disco_items then
+				disco_items = { features = {}, items = {} };
+				self.disco.nodes[node] = disco_items;
+				disco_items = disco_items.items;
+			end
+		end
+		table.insert(disco_items, item);
+	end
+
 	function stream:jid_has_identity(jid, category, type)
 		local cached_disco = self.disco.cache[jid];
 		if not cached_disco then

mercurial