Changeset

422:61c8877d703c

Merge from waqas
author Matthew Wild <mwild1@gmail.com>
date Wed, 26 Nov 2008 03:29:06 +0000
parents 418:004c278154dc (current diff) 421:63be85693710 (diff)
children 423:c9c7f026a108
files
diffstat 9 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/core/discomanager.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/core/discomanager.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -5,6 +5,7 @@
 local jid_bare = require "util.jid".bare;
 local usermanager_user_exists = require "core.usermanager".user_exists;
 local rostermanager_is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
+local print = print;
 
 do
 	helper:addDiscoInfoHandler("*host", function(reply, to, from, node)
@@ -36,4 +37,16 @@
 	return helper:addDiscoInfoHandler(jid, func);
 end
 
+function set(plugin, var, origin)
+	-- TODO handle origin and host based on plugin.
+	local handler = function(reply, to, from, node) -- service discovery
+		if #node == 0 then
+			reply:tag("feature", {var = var}):up();
+			return true;
+		end
+	end
+	addDiscoInfoHandler("*node", handler);
+	addDiscoInfoHandler("*host", handler);
+end
+
 return _M;
--- a/plugins/mod_disco.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_disco.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -1,6 +1,9 @@
 
 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");
+
 add_iq_handler({"c2s", "s2sin"}, "http://jabber.org/protocol/disco#info", function (session, stanza)
 	session.send(discomanager_handle(stanza));
 end);
--- a/plugins/mod_legacyauth.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_legacyauth.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -2,6 +2,8 @@
 local st = require "util.stanza";
 local t_concat = table.concat;
 
+require "core.discomanager".set("legacyauth", "jabber:iq:auth");
+
 add_iq_handler("c2s_unauthed", "jabber:iq:auth", 
 		function (session, stanza)
 			local username = stanza.tags[1]:child_with_name("username");
--- a/plugins/mod_private.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_private.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -4,6 +4,8 @@
 local jid_split = require "util.jid".split;
 local datamanager = require "util.datamanager"
 
+require "core.discomanager".set("private", "jabber:iq:private");
+
 add_iq_handler("c2s", "jabber:iq:private",
 	function (session, stanza)
 		local type = stanza.attr.type;
--- a/plugins/mod_register.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_register.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -4,6 +4,8 @@
 local usermanager_create_user = require "core.usermanager".create_user;
 local datamanager_store = require "util.datamanager".store;
 
+require "core.discomanager".set("register", "jabber:iq:register");
+
 add_iq_handler("c2s", "jabber:iq:register", function (session, stanza)
 	if stanza.tags[1].name == "query" then
 		local query = stanza.tags[1];
--- a/plugins/mod_roster.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_roster.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -9,6 +9,8 @@
 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");
+
 add_iq_handler("c2s", "jabber:iq:roster", 
 		function (session, stanza)
 			if stanza.tags[1].name == "query" then
--- a/plugins/mod_uptime.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_uptime.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -6,6 +6,8 @@
 
 local start_time = os.time();
 
+require "core.discomanager".set("uptime", "jabber:iq:last");
+
 add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", 
 	function (origin, stanza)
 		if stanza.tags[1].name == "query" then
@@ -20,5 +22,3 @@
 			end
 		end
 	end);
-
-
--- a/plugins/mod_vcard.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_vcard.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -8,6 +8,8 @@
 require "util.jid"
 local jid_split = jid.split;
 
+require "core.discomanager".set("vcard", "vcard-temp");
+
 add_iq_handler({"c2s", "s2sin"}, "vcard-temp", 
 		function (session, stanza)
 			if stanza.tags[1].name == "vCard" then
--- a/plugins/mod_version.lua	Wed Nov 26 02:21:18 2008 +0000
+++ b/plugins/mod_version.lua	Wed Nov 26 03:29:06 2008 +0000
@@ -5,6 +5,8 @@
 
 local xmlns_version = "jabber:iq:version"
 
+require "core.discomanager".set("version", xmlns_version);
+
 local function handle_version_request(session, stanza)
 	if stanza.attr.type == "get" then
 		session.send(st.reply(stanza):query(xmlns_version)