1 Xmpp4Js.Lang.namespace( "Xmpp4Js.Packet" ); 2 3 /** 4 * Constructs an IQ packet if the PacketBase constructor doesn't 5 * handle it. 6 * 7 * @constructor 8 * @extends Xmpp4Js.Packet.Base 9 * @param {String} to 10 * @param {String} type 11 * @param {String} queryNS 12 */ 13 Xmpp4Js.Packet.IQ = function( to, type, queryNS ) { 14 15 var doc = Xmpp4Js.Packet.getDocument(); 16 17 var node = doc.createElement( "iq" ); 18 Xmpp4Js.Packet.IQ.superclass.constructor.call( this, node ); 19 20 if( to ) { this.setTo( to ); } 21 if( type ) { this.setType( type ); } 22 if( queryNS ) { 23 var query = this.getNode().appendChild( doc.createElement( "query" ) ); 24 query.setAttribute( "xmlns", queryNS ); 25 } 26 } 27 28 Xmpp4Js.Packet.IQ.prototype = { 29 30 setQuery : function( elem ) { 31 // TODO check elem 32 this.elem.appendChild( elem ); 33 }, 34 getQuery : function() { 35 var elem = this.elem.getElementsByTagName("query").item(0); 36 return elem; 37 }, 38 39 /** @deprecated */ 40 getQueryXMLNS : function() { 41 var query = this.getQuery(); 42 return query ? query.getAttribute("xmlns").toString() : ""; 43 } 44 } 45 46 Xmpp4Js.Lang.extend( Xmpp4Js.Packet.IQ, Xmpp4Js.Packet.Base, Xmpp4Js.Packet.IQ.prototype); 47