B2G/gecko/dom/mobilemessage/src/ril/MmsPduHelper.jsm
/**
   * @param multiStream
   *        An exsiting nsIMultiplexInputStream.
   * @param msg
   *        A MMS message object.
   *
   * @return An instance of nsIMultiplexInputStream or null in case of errors.
   */
@param multiStream
An exsiting nsIMultiplexInputStream.
@param msg
A MMS message object.

@return An instance of nsIMultiplexInputStream or null in case of errors.
@param multiStream An exsiting nsIMultiplexInputStream . @param msg A MMS message object . @return An instance of nsIMultiplexInputStream or null in case of errors .
function compose(multiStream, msg) {
    if (!multiStream) {
      multiStream = Cc["@mozilla.org/io/multiplex-input-stream;1"]
                    .createInstance(Ci.nsIMultiplexInputStream);
    }
    try {
      let typeinfo = this.checkMandatoryFields(msg);
      let data = this.encodeHeaders(null, msg.headers);
      debug("Composed PDU Header: " + JSON.stringify(data.array));
      WSP.PduHelper.appendArrayToMultiStream(multiStream, data.array, data.offset);
      if (msg.content) {
        WSP.PduHelper.appendArrayToMultiStream(multiStream, msg.content, msg.content.length);
      } else if (msg.parts) {
        WSP.PduHelper.composeMultiPart(multiStream, msg.parts);
      } else if (typeinfo.hasContent) {
        throw new WSP.CodeError("Missing message content");
      }
      return multiStream;
    } catch (e) {
      debug("Failed to compose MMS message, error message: " + e.message);
      return null;
    }
  }
function compose ( multiStream , msg ) { if ( ! multiStream ) { multiStream = Cc [ "@mozilla.org/io/multiplex-input-stream;1" ] . createInstance ( Ci . nsIMultiplexInputStream ) ; } try { let typeinfo = this . checkMandatoryFields ( msg ) ; let data = this . encodeHeaders ( null , msg . headers ) ; debug ( "Composed PDU Header: " + JSON . stringify ( data . array ) ) ; WSP . PduHelper . appendArrayToMultiStream ( multiStream , data . array , data . offset ) ; if ( msg . content ) { WSP . PduHelper . appendArrayToMultiStream ( multiStream , msg . content , msg . content . length ) ; } else if ( msg . parts ) { WSP . PduHelper . composeMultiPart ( multiStream , msg . parts ) ; } else if ( typeinfo . hasContent ) { throw new WSP . CodeError ( "Missing message content" ) ; } return multiStream ; } catch ( e ) { debug ( "Failed to compose MMS message, error message: " + e . message ) ; return null ; } }
@param multiStream
        An exsiting nsIMultiplexInputStream.
@param multiStream An exsiting nsIMultiplexInputStream .
// Validity checks