# HG changeset patch # User Emmanuel Gil Peyrot # Date 1328058303 -3600 # Node ID a118a7822410d890ffcffa557abcfaa6d3530305 # Parent ea276b47c55517b622ae903ddf21c4985c3625d7 Fix presence plugin. diff --git a/plugins/presence.js b/plugins/presence.js --- a/plugins/presence.js +++ b/plugins/presence.js @@ -23,35 +23,40 @@ (function() { var legal_types = ['error', 'probe', 'subscribe', 'subscribed', 'unavailable', 'unsubscribe', 'unsubscribed']; - Lightstring.stanza.presence = function(object) { - if (object) { - var payloads = ""; - var attributs = ""; - if (object.type && legal_types.indexOf(object.type) !== -1) - attributs += " type='" + object.type + "'"; + Lightstring.plugins['presence'] = { + stanzas: { + presence: function(object) { + if (object) { + var payloads = ""; + var attributs = ""; + if (object.type && legal_types.indexOf(object.type) !== -1) + attributs += " type='" + object.type + "'"; - if (object.priority) - payloads += "" + object.priority + ""; + if (object.priority) + payloads += "" + object.priority + ""; - if (object.show) - payloads += "" + object.show + ""; + if (object.show) + payloads += "" + object.show + ""; + + if (object.status) + payloads += "" + object.status + ""; - if (object.status) - payloads += "" + object.status + ""; + if (object.payload) + payloads += object.payload; - if (object.payload) - payloads += object.payload; + if (payloads) + return "" + payloads + ""; + else + return ""; - if (payloads) - return "" + payloads + ""; - else - return ""; - - } else - return ""; - }; - - Lightstring.presence = function(aConnection, aObject) { - aConnection.send(Lightstring.stanza.presence(aObject)); + } else + return ""; + }, + }, + methods: { + presence: function(aObject) { + this.send(Lightstring.stanzas.presence(aObject)); + } + } }; })();