Software /
code /
prosody
Comparison
util/discohelper.lua @ 539:cbcadb1a6166
Reorder the disco info elements to place always included elements first
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 04 Dec 2008 20:01:57 +0500 |
parent | 519:cccd610a0ef9 |
child | 615:4ae3e81513f3 |
comparison
equal
deleted
inserted
replaced
532:c24471cadc2c | 539:cbcadb1a6166 |
---|---|
55 if query.attr.xmlns == "http://jabber.org/protocol/disco#info" then -- select handler set | 55 if query.attr.xmlns == "http://jabber.org/protocol/disco#info" then -- select handler set |
56 handlers = self.info_handlers; | 56 handlers = self.info_handlers; |
57 elseif query.attr.xmlns == "http://jabber.org/protocol/disco#items" then | 57 elseif query.attr.xmlns == "http://jabber.org/protocol/disco#items" then |
58 handlers = self.item_handlers; | 58 handlers = self.item_handlers; |
59 end | 59 end |
60 local handler = handlers[to]; -- get the handler | 60 local handler; |
61 local found; -- to keep track of any handlers found | |
62 if to_node then -- handlers which get called always | |
63 handler = handlers["*node"]; | |
64 else | |
65 handler = handlers["*host"]; | |
66 end | |
67 if handler then -- call always called handler | |
68 for _, h in ipairs(handler) do | |
69 if h(reply, to, from, node) then found = true; end | |
70 end | |
71 end | |
72 handler = handlers[to]; -- get the handler | |
61 if not handler then -- if not found then use default handler | 73 if not handler then -- if not found then use default handler |
62 if to_node then | 74 if to_node then |
63 handler = handlers["*defaultnode"]; | 75 handler = handlers["*defaultnode"]; |
64 else | 76 else |
65 handler = handlers["*defaulthost"]; | 77 handler = handlers["*defaulthost"]; |
66 end | 78 end |
67 end | 79 end |
68 local found; -- to keep track of any handlers found | |
69 if handler then | 80 if handler then |
70 for _, h in ipairs(handler) do | |
71 if h(reply, to, from, node) then found = true; end | |
72 end | |
73 end | |
74 if to_node then -- handlers which get called always | |
75 handler = handlers["*node"]; | |
76 else | |
77 handler = handlers["*host"]; | |
78 end | |
79 if handler then -- call always called handler | |
80 for _, h in ipairs(handler) do | 81 for _, h in ipairs(handler) do |
81 if h(reply, to, from, node) then found = true; end | 82 if h(reply, to, from, node) then found = true; end |
82 end | 83 end |
83 end | 84 end |
84 if found then return reply; end -- return the reply if there was one | 85 if found then return reply; end -- return the reply if there was one |