1 Xmpp4Js.Lang.namespace( "Xmpp4Js.Packet" ); 2 3 /** 4 * Constructs a Presence packet if the Xmpp4Js.Packet.Base constructor doesn't 5 * handle it. 6 * 7 * @constructor 8 * @extends Xmpp4Js.Packet.Base 9 * @param {Object} type 10 */ 11 Xmpp4Js.Packet.Presence = function( type, to, status, show, priority ) { 12 var doc = Xmpp4Js.Packet.getDocument(); 13 14 var node = doc.createElement( "presence" ); 15 Xmpp4Js.Packet.Presence.superclass.constructor.call( this, node ) 16 17 if( to ) { this.setTo( to ); } 18 if( type ) { this.setType( type ); } 19 this.setPresence( show, status, priority ); 20 } 21 22 Xmpp4Js.Packet.Presence.prototype = { 23 24 getType : function() { 25 var type = this.elem.getAttribute( "type" ).toString(); 26 return type ? type : "available"; 27 }, 28 29 /** 30 * 31 * @param {String} status 32 */ 33 setStatus : function( content ) { 34 this.setChildElementContent( "status", content ); 35 }, 36 37 getStatus : function() { 38 return this.getChildElementContent( "status" ); 39 }, 40 41 /** 42 * 43 * @param {String} show 44 */ 45 setShow : function( content ) { 46 this.setChildElementContent( "show", content ); 47 }, 48 49 getShow : function() { 50 return this.getChildElementContent( "show", "normal" ); 51 }, 52 53 setPriority : function( content ) { 54 this.setChildElementContent( "priority", content ); 55 }, 56 57 getPriority : function() { 58 return this.getChildElementContent( "priority", "5" ); 59 }, 60 61 /** 62 * Legacy from JSJaC 63 * @param {String} show 64 * @param {String} status 65 * @param {String} priority 66 * @deprecated 67 */ 68 setPresence : function( show, status, priority ) { 69 if( show != null ) { this.setShow(show); } 70 if( status != null ) { this.setStatus(status); } 71 if( priority != null ) { this.setPriority(priority); } 72 } 73 } 74 75 Xmpp4Js.Lang.extend( Xmpp4Js.Packet.Presence, Xmpp4Js.Packet.Base, Xmpp4Js.Packet.Presence.prototype); 76