Package mms :: Module mms_pdu :: Class MMSEncoder
[hide private]
[frames] | no frames]

Class MMSEncoder

source code

wsp_pdu.Encoder --+
                  |
                 MMSEncoder

Instance Methods [hide private]
 
__init__(self) source code
array.array('B')
encode(self, mmsMessage)
Encodes the specified MMS message
source code
array.array('B')
encodeMessageHeader(self)
Binary-encodes the MMS header data.
source code
array.array('B')
encodeMessageBody(self)
Binary-encodes the MMS body data.
source code
Static Methods [hide private]
tuple
encodeHeader(headerFieldName, headerValue)
Encodes a header entry for an MMS message
source code
list
encodeMMSFieldName(fieldName)
Encodes an MMS header field name, using the "assigned values" for well-known MMS headers as specified in [4].
source code
list
encodeFromValue(fromValue='')
From [4], section 7.2.11: From-value = Value-length (Address-present-token Encoded-string-value | Insert-address-token ) Address-present-token = <Octet 128> Insert-address-token = <Octet 129>
source code
list
encodeEncodedStringValue(stringValue)
From [4], section 7.2.9: Encoded-string-value = Text-string | Value-length Char-set Text-string The Char-set values are registered by IANA as MIBEnum value.
source code
list
encodeMessageTypeValue(messageType)
Defined in [4], section 7.2.14.
source code

Inherited from wsp_pdu.Encoder: encodeAcceptValue, encodeConstrainedEncoding, encodeConstrainedMedia, encodeContentGeneralForm, encodeContentTypeValue, encodeExtensionMedia, encodeIntegerValue, encodeLongInteger, encodeMediaType, encodeNoValue, encodeParameter, encodeShortInteger, encodeShortLength, encodeTextString, encodeTextValue, encodeTokenText, encodeUintvar, encodeValueLength, encodeVersionValue

Method Details [hide private]

encode(self, mmsMessage)

source code 
Encodes the specified MMS message
Parameters:
  • mmsMessage (MMSMessage) - The MMS message to encode
Returns: array.array('B')
The binary-encoded MMS data, as a sequence of bytes

encodeMessageHeader(self)

source code 
Binary-encodes the MMS header data.
Returns: array.array('B')
the MMS PDU header, as an array of bytes

Note: The encoding used for the MMS header is specified in [4]. All "constant" encoded values found/used in this method are also defined in [4]. For a good example, see [2].

encodeMessageBody(self)

source code 
Binary-encodes the MMS body data.
Returns: array.array('B')
The binary-encoded MMS PDU body, as an array of bytes
Notes:
  • The MMS body is of type application/vnd.wap.multipart (mixed or related). As such, its structure is divided into a header, and the data entries/parts:
       [ header ][ entries ]
       ^^^^^^^^^^^^^^^^^^^^^
             MMS Body
    
    The MMS Body header consists of one entry[5]:
    name          type          purpose
    -------      -------        -----------
    nEntries     Uintvar        number of entries in the multipart entity
    
    The MMS body's multipart entries structure:
    name             type                   purpose
    -------          -----                  -----------
    HeadersLen       Uintvar                length of the ContentType and 
                                            Headers fields combined
    DataLen          Uintvar                length of the Data field
    ContentType      Multiple octets        the content type of the data
    Headers          (<HeadersLen> 
                      - length of 
                     <ContentType>) octets  the part's headers
    Data             <DataLen> octets       the part's data
    
  • The MMS body's header should not be confused with the actual MMS header, as returned by _encodeHeader().
  • The encoding used for the MMS body is specified in [5], section 8.5. It is only referenced in [4], however [2] provides a good example of how this ties in with the MMS header encoding.

encodeHeader(headerFieldName, headerValue)
Static Method

source code 

Encodes a header entry for an MMS message

From [4], section 7.1: Header = MMS-header | Application-header MMS-header = MMS-field-name MMS-value MMS-field-name = Short-integer MMS-value = Bcc-value | Cc-value | Content-location-value | Content-type-value | etc
Returns: tuple
The decoded header entry from the MMS, in the format: (<str:header name>, <str/int/float:header value>)
Raises:
  • DecodeError - This uses decodeMMSHeader() and decodeApplicationHeader(), and will raise this exception under the same circumstances as decodeApplicationHeader(). byteIter will not be modified in this case.
Overrides: wsp_pdu.Encoder.encodeHeader

Note: The return type of the "header value" depends on the header itself; it is thus up to the function calling this to determine what that type is (or at least compensate for possibly different return value types).

encodeMMSFieldName(fieldName)
Static Method

source code 

Encodes an MMS header field name, using the "assigned values" for well-known MMS headers as specified in [4].

From [4], section 7.1: MMS-field-name = Short-integer
Parameters:
  • fieldName (str) - The header field name to encode
Returns: list
The encoded header field name, as a sequence of bytes
Raises:
  • EncodeError - The specified header field name is not a well-known MMS header.

encodeFromValue(fromValue='')
Static Method

source code 
From [4], section 7.2.11: From-value = Value-length (Address-present-token Encoded-string-value | Insert-address-token ) Address-present-token = <Octet 128> Insert-address-token = <Octet 129>
Parameters:
  • fromValue (str) - The "originator" of the MMS message. This may be an empty string, in which case a token will be encoded informing the MMSC to insert the address of the device that sent this message (default).
Returns: list
The encoded "From" address value, as a sequence of bytes

encodeEncodedStringValue(stringValue)
Static Method

source code 
From [4], section 7.2.9: Encoded-string-value = Text-string | Value-length Char-set Text-string The Char-set values are registered by IANA as MIBEnum value.
Parameters:
  • stringValue (str) - The text string to encode
Returns: list
The encoded string value, as a sequence of bytes

Note: This function is currently a simple wrappper to encodeTextString()

encodeMessageTypeValue(messageType)
Static Method

source code 
Defined in [4], section 7.2.14.
Parameters:
  • messageType (str) - The MMS message type to encode
Returns: list
The encoded message type, as a sequence of bytes

Note: Unknown message types are discarded; thus they will be encoded as 0x80 ("m-send-req") by this function