From 00f019739ad6aeae86528b62505f44b4037ac113 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 May 2009 21:35:21 +0100 Subject: stanza_router: Fire global event if host doesn't have events, fixes #103 --- core/stanza_router.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 4ade0055..207302c7 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -127,7 +127,7 @@ function core_process_stanza(origin, stanza) else event = "stanza/"..stanza.attr.xmlns..":"..stanza.name; end - if h.events.fire_event(event, {origin = origin, stanza = stanza}) then return; end + if (h.events or prosody.events).fire_event(event, {origin = origin, stanza = stanza}) then return; end end modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza); end @@ -155,7 +155,7 @@ function core_post_stanza(origin, stanza) local event_data = {origin=origin, stanza=stanza}; if origin.full_jid then -- c2s connection - if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing + if (hosts[origin.host].events or prosody.events).fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing end local h = hosts[to_bare] or hosts[host or origin.host]; if h then @@ -163,7 +163,7 @@ function core_post_stanza(origin, stanza) component_handle_stanza(origin, stanza); return; else - if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing + if (h.events or prosody.events).fire_event(stanza.name..to_type, event_data) then return; end -- do processing end else -- non-local recipient core_route_stanza(origin, stanza); -- cgit v1.2.3 From ec3a5489a4d1ad18a3e8339fa1a2120e79906f81 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 May 2009 21:36:12 +0100 Subject: componentmanager: Add events object to registered components if they don't already have one --- core/componentmanager.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core') diff --git a/core/componentmanager.lua b/core/componentmanager.lua index ff60de28..8f624f15 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -89,6 +89,12 @@ function register_component(host, component, session) if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then components[host] = component; hosts[host] = session or create_component(host, component); + + -- Add events object if not already one + if not hosts[host].events then + hosts[host].events = events_new(); + end + -- add to disco_items if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then disco_items:set(host:sub(host:find(".", 1, true)+1), host, true); -- cgit v1.2.3 From f87fd81a4a3de75958eb489de371fa6830e48fb2 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 May 2009 22:52:50 +0100 Subject: stanza_router: Don't route before firing events... waqas, is this safe? --- core/stanza_router.lua | 3 --- 1 file changed, 3 deletions(-) (limited to 'core') diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 207302c7..58dd820d 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -165,9 +165,6 @@ function core_post_stanza(origin, stanza) else if (h.events or prosody.events).fire_event(stanza.name..to_type, event_data) then return; end -- do processing end - else -- non-local recipient - core_route_stanza(origin, stanza); - return; end if host and fire_event(host.."/"..stanza.name, event_data) then -- cgit v1.2.3