# HG changeset patch # User Kim Alvefur # Date 1293757947 -3600 # Node ID 5e2ff25c1dd98debaecd76341578f0ed63ac6b66 # Parent 2189f75e09b980b6ca7793baafe6248dca241c0d plugins.disco: Use the new presence plugin for caching and resending diff -r 2189f75e09b9 -r 5e2ff25c1dd9 plugins/disco.lua --- a/plugins/disco.lua Fri Dec 31 01:32:26 2010 +0100 +++ b/plugins/disco.lua Fri Dec 31 02:12:27 2010 +0100 @@ -31,8 +31,6 @@ stream.caps = {} stream.caps.node = 'http://code.matthewwild.co.uk/verse/' - local _resend_presence; -- Forward declaration of a function - local function cmp_identity(item1, item2) if item1.category < item2.category then return true; @@ -91,14 +89,14 @@ function stream:add_disco_feature(feature) table.insert(self.disco.info.features, {var=feature}); - _resend_presence(); + stream:resend_presence(); end function stream:remove_disco_feature(feature) for idx, disco_feature in ipairs(self.disco.info.features) do if disco_feature.var == feature then table.remove(self.disco.info.features, idx); - _resend_presence(); + stream:resend_presence(); return true; end end @@ -379,29 +377,11 @@ return true; end, 5); - local last_presence; -- Cache to re-send with updated caps - stream:hook("presence-out", function (presence) if not presence:get_child("c", xmlns_caps) then presence:reset():add_child(stream:caps()):reset(); end - if not presence.attr.to then - last_presence = presence; -- Cache non-directed presence - end - end); - - local function update_caps(tag) - if tag.name == "c" and tag.attr.xmlns == xmlns_caps then - return stream:caps(); - end - end - - function _resend_presence() -- Local via forward declaration - if last_presence then - last_presence = last_presence:maptags(update_caps); - stream:send(last_presence); - end - end + end, 10); end -- end of disco.lua