1 Xmpp4Js.Lang.namespace( "Xmpp4Js.Packet" );
  2 
  3 /**
  4  * Constructs a Presence packet if the Packet.Base constructor doesn't
  5  * handle it.
  6  * 
  7  * @constructor
  8  * @extends Xmpp4Js.Packet.Base
  9  * @param {Object} to
 10  * @param {Object} type
 11  * @param {Object} body
 12  */
 13 Xmpp4Js.Packet.Message = function( to, type, body, subject ) {
 14     var doc = Xmpp4Js.Packet.getDocument();
 15     
 16     var node = doc.createElement( "message" );
 17     Xmpp4Js.Packet.Message.superclass.constructor.call( this, node );
 18 
 19     if( to ) { this.setTo( to ); }
 20     if( type ) { this.setType( type ); }
 21     if( body != null ) { this.setBody( body ); }
 22     if( subject != null ) { this.setSubject( subject ); }
 23 }
 24 
 25 Xmpp4Js.Packet.Message.prototype = {
 26     /**
 27      * 
 28      * @param {Object} Element or string containing body content.
 29      */
 30     setBody : function( content ) {
 31         this.setChildElementContent( "body", content );
 32         
 33     },
 34     getBodyNode : function() {
 35         return this.getChildElementNode("body");
 36     },
 37     getBody : function() {
 38         return this.getChildElementContent("body");
 39     },
 40     
 41     /**
 42      * 
 43      * @param {String} subject
 44      */
 45     setSubject : function( content ) {
 46         this.setChildElementContent( "subject", content );
 47     },
 48     getSubjectNode : function() {
 49         return this.getChildElementNode("subject");
 50     },
 51     getSubject : function() {
 52         return this.getChildElementContent("subject");
 53     },
 54     
 55     
 56     /**
 57      * 
 58      * @param {String} subject
 59      */
 60     setThread : function( content ) {
 61         this.setChildElementContent( "thread", content );
 62         
 63     },
 64     getThreadNode : function() {
 65         return this.getChildElementNode("thread");
 66     },
 67     getThread : function() {
 68         return this.getChildElementContent("thread");
 69     },
 70     
 71     hasContent : function() {
 72         var messageText = this.getBody();
 73         return messageText != null && messageText != undefined;
 74     }
 75 }
 76 
 77 Xmpp4Js.Lang.extend( Xmpp4Js.Packet.Message, Xmpp4Js.Packet.Base, Xmpp4Js.Packet.Message.prototype);
 78