comparison plugins/pubsub.js @ 86:0c10c9a69c69

Lightstring.stanza has been renamed to Lightstring.stanzas.
author Sonny Piers <sonny.piers@gmail.com>
date Wed, 08 Feb 2012 19:51:10 +0100
parents 7f4e43d6cb15
children 0f6f213f0a33
comparison
equal deleted inserted replaced
85:d9804e206393 86:0c10c9a69c69
91 if (aResult) 91 if (aResult)
92 aResult(items); 92 aResult(items);
93 }, aError); 93 }, aError);
94 }, 94 },
95 create: function(aTo, aNode, aFields, aResult, aError) { 95 create: function(aTo, aNode, aFields, aResult, aError) {
96 this.send(Lightstring.stanza.pubsub.create(aTo, aNode, aFields), aResult, aError); 96 this.send(Lightstring.stanzas.pubsub.create(aTo, aNode, aFields), aResult, aError);
97 }, 97 },
98 config: function(aTo, aNode, aResult, aError) { 98 config: function(aTo, aNode, aResult, aError) {
99 this.send(Lightstring.stanza.pubsub.getConfig(aTo, aNode), function(stanza) { 99 this.send(Lightstring.stanzas.pubsub.getConfig(aTo, aNode), function(stanza) {
100 //FIXME: wtf? 100 //FIXME: wtf?
101 var accessmodel = stanza.DOM.querySelector('field[var="pubsub#access_model"]').lastChild.textContent; 101 var accessmodel = stanza.DOM.querySelector('field[var="pubsub#access_model"]').lastChild.textContent;
102 if(accessmodel) 102 if(accessmodel)
103 aResult, aError(accessmodel); 103 aResult, aError(accessmodel);
104 else 104 else
105 aResult, aError(null); 105 aResult, aError(null);
106 }); 106 });
107 }, 107 },
108 retract: function(aTo, aNode, aItem, aResult, aError) { 108 retract: function(aTo, aNode, aItem, aResult, aError) {
109 this.send(Lightstring.stanza.pubsub.retract(aTo, aNode, aItem), aResult, aError); 109 this.send(Lightstring.stanzas.pubsub.retract(aTo, aNode, aItem), aResult, aError);
110 }, 110 },
111 publish: function(aTo, aNode, aItem, aId, aResult, aError) { 111 publish: function(aTo, aNode, aItem, aId, aResult, aError) {
112 this.send(Lightstring.stanza.pubsub.publish(aTo, aNode, aItem, aId), aResult, aError); 112 this.send(Lightstring.stanzas.pubsub.publish(aTo, aNode, aItem, aId), aResult, aError);
113 }, 113 },
114 'delete': function(aTo, aNode, aResult, aError) { 114 'delete': function(aTo, aNode, aResult, aError) {
115 this.send(Lightstring.stanza.pubsub.delete(aTo, aNode), aResult, aError); 115 this.send(Lightstring.stanzas.pubsub.delete(aTo, aNode), aResult, aError);
116 }, 116 },
117 getAffiliations: function(aTo, aNode, aResult, aError) { 117 getAffiliations: function(aTo, aNode, aResult, aError) {
118 this.send(Lightstring.stanza.pubsub.affiliations(aTo, aNode), function(stanza) { 118 this.send(Lightstring.stanzas.pubsub.affiliations(aTo, aNode), function(stanza) {
119 if((stanza.DOM.getAttribute('type') === 'result') && aResult, aError) { 119 if((stanza.DOM.getAttribute('type') === 'result') && aResult, aError) {
120 var affiliations = {}; 120 var affiliations = {};
121 stanza.DOM.querySelectorAll('affiliation').forEach(function(affiliation) { 121 stanza.DOM.querySelectorAll('affiliation').forEach(function(affiliation) {
122 affiliations[affiliation.getAttribute("jid")] = affiliation.getAttribute("affiliation"); 122 affiliations[affiliation.getAttribute("jid")] = affiliation.getAttribute("affiliation");
123 }) 123 })
125 aResult(affiliations); 125 aResult(affiliations);
126 } 126 }
127 }, aError); 127 }, aError);
128 }, 128 },
129 setAffiliations: function(aTo, aNode, aAffiliations, aResult, aError) { 129 setAffiliations: function(aTo, aNode, aAffiliations, aResult, aError) {
130 this.send(Lightstring.stanza.pubsub.setAffiliations(aTo, aNode, aAffiliations), aResult, aError); 130 this.send(Lightstring.stanzas.pubsub.setAffiliations(aTo, aNode, aAffiliations), aResult, aError);
131 } 131 }
132 }, 132 },
133 init: function() { 133 init: function() {
134 //TODO: find a way to put that in handlers, it’s UGLY! 134 //TODO: find a way to put that in handlers, it’s UGLY!
135 this.on('in-message-*-' + Lightstring.ns['pubsub_event'] + ':event', function(stanza) { 135 this.on('in-message-*-' + Lightstring.ns['pubsub_event'] + ':event', function(stanza) {