comparison plugins/mod_iq.lua @ 3660:d50bf9f55ff9

Merge with trunk
author Matthew Wild <mwild1@gmail.com>
date Sat, 27 Nov 2010 21:53:10 +0000
parents 13600f0d56b5
children 43b854062206
comparison
equal deleted inserted replaced
3659:aa7bf12a5668 3660:d50bf9f55ff9
30 end); 30 end);
31 31
32 module:hook("iq/bare", function(data) 32 module:hook("iq/bare", function(data)
33 -- IQ to bare JID recieved 33 -- IQ to bare JID recieved
34 local origin, stanza = data.origin, data.stanza; 34 local origin, stanza = data.origin, data.stanza;
35 local type = stanza.attr.type;
35 36
36 -- TODO fire post processing events 37 -- TODO fire post processing events
37 if stanza.attr.type == "get" or stanza.attr.type == "set" then 38 if type == "get" or type == "set" then
38 return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 39 local child = stanza.tags[1];
40 local ret = module:fire_event("iq/bare/"..child.attr.xmlns..":"..child.name, data);
41 if ret ~= nil then return ret; end
42 return module:fire_event("iq-"..type.."/bare/"..child.attr.xmlns..":"..child.name, data);
39 else 43 else
40 module:fire_event("iq-"..stanza.attr.type.."/bare/"..stanza.attr.id, data); 44 module:fire_event("iq-"..type.."/bare/"..stanza.attr.id, data);
41 return true; 45 return true;
42 end 46 end
43 end); 47 end);
44 48
45 module:hook("iq/self", function(data) 49 module:hook("iq/self", function(data)
46 -- IQ to bare JID recieved 50 -- IQ to self JID recieved
47 local origin, stanza = data.origin, data.stanza; 51 local origin, stanza = data.origin, data.stanza;
52 local type = stanza.attr.type;
48 53
49 if stanza.attr.type == "get" or stanza.attr.type == "set" then 54 if type == "get" or type == "set" then
50 return module:fire_event("iq/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 55 local child = stanza.tags[1];
56 local ret = module:fire_event("iq/self/"..child.attr.xmlns..":"..child.name, data);
57 if ret ~= nil then return ret; end
58 return module:fire_event("iq-"..type.."/self/"..child.attr.xmlns..":"..child.name, data);
51 else 59 else
52 module:fire_event("iq-"..stanza.attr.type.."/self/"..stanza.attr.id, data); 60 module:fire_event("iq-"..type.."/self/"..stanza.attr.id, data);
53 return true; 61 return true;
54 end 62 end
55 end); 63 end);
56 64
57 module:hook("iq/host", function(data) 65 module:hook("iq/host", function(data)
58 -- IQ to a local host recieved 66 -- IQ to a local host recieved
59 local origin, stanza = data.origin, data.stanza; 67 local origin, stanza = data.origin, data.stanza;
68 local type = stanza.attr.type;
60 69
61 if stanza.attr.type == "get" or stanza.attr.type == "set" then 70 if type == "get" or type == "set" then
62 return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 71 local child = stanza.tags[1];
72 local ret = module:fire_event("iq/host/"..child.attr.xmlns..":"..child.name, data);
73 if ret ~= nil then return ret; end
74 return module:fire_event("iq-"..type.."/host/"..child.attr.xmlns..":"..child.name, data);
63 else 75 else
64 module:fire_event("iq-"..stanza.attr.type.."/host/"..stanza.attr.id, data); 76 module:fire_event("iq-"..type.."/host/"..stanza.attr.id, data);
65 return true; 77 return true;
66 end 78 end
67 end); 79 end);