2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
10 local st = require "util.stanza";
11 local jid_split = require "util.jid".split;
13 local full_sessions = full_sessions;
14 local bare_sessions = bare_sessions;
16 module:hook("iq/full", function(data)
17 -- IQ to full JID recieved
18 local origin, stanza = data.origin, data.stanza;
20 local session = full_sessions[stanza.attr.to];
22 -- TODO fire post processing event
24 else -- resource not online
25 if stanza.attr.type == "get" or stanza.attr.type == "set" then
26 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
32 module:hook("iq/bare", function(data)
33 -- IQ to bare JID recieved
34 local origin, stanza = data.origin, data.stanza;
36 -- TODO fire post processing events
37 if stanza.attr.type == "get" or stanza.attr.type == "set" then
38 return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
40 module:fire_event("iq/bare/"..stanza.attr.id, data);
45 module:hook("iq/self", function(data)
46 -- IQ to bare JID recieved
47 local origin, stanza = data.origin, data.stanza;
49 if stanza.attr.type == "get" or stanza.attr.type == "set" then
50 return module:fire_event("iq/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
52 module:fire_event("iq/self/"..stanza.attr.id, data);
57 module:hook("iq/host", function(data)
58 -- IQ to a local host recieved
59 local origin, stanza = data.origin, data.stanza;
61 if stanza.attr.type == "get" or stanza.attr.type == "set" then
62 return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
64 module:fire_event("iq/host/"..stanza.attr.id, data);