comparison plugins/pubsub.js @ 90:c1566c6981e5 master

Pubsub configure stanza and method
author Sonny Piers <sonny.piers@gmail.com>
date Wed, 29 Feb 2012 19:13:40 +0100
parents 55548845b177
children 7affe7ac8fc7
comparison
equal deleted inserted replaced
89:55548845b177 90:c1566c6981e5
62 iq += "</x></configure>"; 62 iq += "</x></configure>";
63 } 63 }
64 iq += "</pubsub></iq>"; 64 iq += "</pubsub></iq>";
65 return iq; 65 return iq;
66 }, 66 },
67 setConfig: function(aTo, aNode, aFields) {
68 var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><configure node='" + aNode + "'><x xmlns='" + Lightstring.ns.x + "' type='submit'>";
69 aFields.forEach(function(field) {
70 iq += field;
71 });
72 iq += "</x></configure></pubsub></iq>";
73 return iq;
74 },
67 setAffiliations: function(aTo, aNode, aAffiliations) { 75 setAffiliations: function(aTo, aNode, aAffiliations) {
68 var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'>"; 76 var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'>";
69 for (var i = 0; i < aAffiliations.length; i++) 77 for (var i = 0; i < aAffiliations.length; i++)
70 iq += "<affiliation jid='" + aAffiliations[i][0] + "' affiliation='" + aAffiliations[i][1] + "'/>"; 78 iq += "<affiliation jid='" + aAffiliations[i][0] + "' affiliation='" + aAffiliations[i][1] + "'/>";
71 iq += "</affiliations></pubsub></iq>"; 79 iq += "</affiliations></pubsub></iq>";
96 aResult(stanza); 104 aResult(stanza);
97 }, aError); 105 }, aError);
98 }, 106 },
99 create: function(aTo, aNode, aFields, aResult, aError) { 107 create: function(aTo, aNode, aFields, aResult, aError) {
100 this.send(Lightstring.stanzas.pubsub.create(aTo, aNode, aFields), aResult, aError); 108 this.send(Lightstring.stanzas.pubsub.create(aTo, aNode, aFields), aResult, aError);
109 },
110 configure: function(aTo, aNode, aFields, aResult, aError) {
111 this.send(Lightstring.stanzas.pubsub.setConfig(aTo, aNode, aFields), aResult, aError);
101 }, 112 },
102 config: function(aTo, aNode, aResult, aError) { 113 config: function(aTo, aNode, aResult, aError) {
103 this.send(Lightstring.stanzas.pubsub.getConfig(aTo, aNode), function(stanza) { 114 this.send(Lightstring.stanzas.pubsub.getConfig(aTo, aNode), function(stanza) {
104 //FIXME: wtf? 115 //FIXME: wtf?
105 var accessmodel = stanza.DOM.querySelector('field[var="pubsub#access_model"]').lastChild.textContent; 116 var accessmodel = stanza.DOM.querySelector('field[var="pubsub#access_model"]').lastChild.textContent;