# HG changeset patch # User Matthew Wild # Date 1243816602 -3600 # Node ID 497178e0ddbe6138aceba57a7c53af444181dbbd # Parent 04c1fae0eb0327943fe54aec16ea96dbd60766ae# Parent 01b69efffb1c2090d4e9ef979432c6b5f33369e0 Automated merge with http://waqas.ath.cx:8000/ diff -r 01b69efffb1c -r 497178e0ddbe core/modulemanager.lua --- a/core/modulemanager.lua Sun May 31 22:52:50 2009 +0100 +++ b/core/modulemanager.lua Mon Jun 01 01:36:42 2009 +0100 @@ -49,6 +49,7 @@ local features_table = multitable_new(); local handler_table = multitable_new(); local hooked = multitable_new(); +local hooks = multitable_new(); local event_hooks = multitable_new(); local NULL = {}; @@ -165,6 +166,13 @@ end end event_hooks:remove(host, name); + -- unhook event handlers hooked by module:hook + for event, handlers in pairs(hooks:get(host, name) or NULL) do + for handler in pairs(handlers or NULL) do + (hosts[host] or prosody).events.remove_handler(event, handler); + end + end + hooks:remove(host, name); return true; end @@ -356,6 +364,7 @@ end function api:hook(event, handler) + hooks:set(self.host, self.name, event, handler, true); (hosts[self.host] or prosody).events.add_handler(event, handler); end diff -r 01b69efffb1c -r 497178e0ddbe plugins/mod_iq.lua --- a/plugins/mod_iq.lua Sun May 31 22:52:50 2009 +0100 +++ b/plugins/mod_iq.lua Mon Jun 01 01:36:42 2009 +0100 @@ -22,12 +22,20 @@ -- TODO if not user exists, return an error -- TODO fire post processing events - -- TODO fire event with the xmlns:tag of the child, or with the id of errors and results + if #stanza.tags == 1 then + return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name); + else + return true; -- TODO do something with results and errors + end end); module:hook("iq/host", function(data) -- IQ to a local host recieved local origin, stanza = data.origin, data.stanza; - -- TODO fire event with the xmlns:tag of the child, or with the id of errors and results + if #stanza.tags == 1 then + return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name); + else + return true; -- TODO do something with results and errors + end end);