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

Class MMSDecoder

source code

wsp_pdu.Decoder --+
                  |
                 MMSDecoder

A decoder for MMS messages

Instance Methods [hide private]
 
__init__(self, filename=None) source code
MMSMessage
decodeFile(self, filename)
Load the data contained in the specified file, and decode it.
source code
MMSMessage
decodeData(self, data)
Decode the specified MMS message data
source code
 
decodeMessageHeader(self)
Decodes the (full) MMS header data
source code
 
decodeMessageBody(self, dataIter)
Decodes the MMS message body
source code
Static Methods [hide private]
tuple
decodeHeader(byteIter)
Decodes a header entry from an MMS message, starting at the byte pointed to by byteIter.next()
source code
tuple
decodeMMSHeader(byteIter)
From [4], section 7.1: 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
source code
str
decodeEncodedStringValue(byteIter)
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
str
decodeBooleanValue(byteIter)
From [4], section 7.2.6:
source code
str
decodeFromValue(byteIter)
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
str
decodeMessageClassValue(byteIter)
From [4], section 7.2.12: Message-class-value = Class-identifier | Token-text Class-identifier = Personal | Advertisement | Informational | Auto Personal = <Octet 128> Advertisement = <Octet 129> Informational = <Octet 130> Auto = <Octet 131> The token-text is an extension method to the message class.
source code
str
decodeMessageTypeValue(byteIter)
Defined in [4], section 7.2.14.
source code
str
decodePriorityValue(byteIter)
Defined in [4], section 7.2.17
source code
str
decodeSenderVisibilityValue(byteIter)
Defined in [4], section 7.2.22:
source code
str
decodeResponseStatusValue(byteIter)
Defined in [4], section 7.2.20
source code
str
decodeStatusValue(byteIter)
Defined in [4], section 7.2.23
source code
str or int
decodeExpiryValue(byteIter)
Defined in [4], section 7.2.10
source code

Inherited from wsp_pdu.Decoder: decodeAcceptValue, decodeApplicationHeader, decodeCompactValue, decodeConstrainedEncoding, decodeConstrainedMedia, decodeContentGeneralForm, decodeContentTypeValue, decodeDateValue, decodeDeltaSecondsValue, decodeExtensionMedia, decodeIntegerValue, decodeLongInteger, decodeMediaType, decodeNoValue, decodeParameter, decodePragmaValue, decodeQValue, decodeQuotedString, decodeShortInteger, decodeShortIntegerFromByte, decodeShortLength, decodeTextString, decodeTextValue, decodeTokenText, decodeTypedParameter, decodeTypedValue, decodeUint8, decodeUintvar, decodeUntypedParameter, decodeUntypedValue, decodeUriValue, decodeValueLength, decodeVersionValue, decodeWellKnownCharset, decodeWellKnownHeader, decodeWellKnownMedia, decodeWellKnownParameter

Method Details [hide private]

__init__(self, filename=None)
(Constructor)

source code 
Parameters:
  • filename (str) - If specified, decode the content of the MMS message file with this name

decodeFile(self, filename)

source code 
Load the data contained in the specified file, and decode it.
Parameters:
  • filename (str) - The name of the MMS message file to open
Returns: MMSMessage
The decoded MMS data
Raises:
  • OSError - The filename is invalid

decodeData(self, data)

source code 
Decode the specified MMS message data
Parameters:
  • data (array.array('B')) - The MMS message data to decode
Returns: MMSMessage
The decoded MMS data

decodeMessageHeader(self)

source code 
Decodes the (full) MMS header data

Note: This must be called before _decodeBody(), as it sets certain internal variables relating to data lengths, etc.

decodeMessageBody(self, dataIter)

source code 
Decodes the MMS message body
Parameters:
  • dataIter (iter) - an iterator over the sequence of bytes of the MMS body

decodeHeader(byteIter)
Static Method

source code 

Decodes a header entry from an MMS message, starting at the byte pointed to by byteIter.next()

From [4], section 7.1: Header = MMS-header | Application-header
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.Decoder.decodeHeader

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).

decodeMMSHeader(byteIter)
Static Method

source code 

From [4], section 7.1: 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

This method takes into account the assigned number values for MMS field names, as specified in [4], section 7.3, table 8.
Returns: tuple
The decoded MMS header, in the format: (<str:MMS-field-name>, <str:MMS-value>)
Raises:
  • wsp_pdu.DecodeError - The MMS field name could not be parsed. byteIter will not be modified in this case.

decodeEncodedStringValue(byteIter)
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.
Returns: str
The decoded text string

Note: This function is not fully implemented, in that it does not have proper support for the Char-set values; it basically just reads over that sequence of bytes, and ignores it (see code for details) - any help with this will be greatly appreciated.

decodeBooleanValue(byteIter)
Static Method

source code 
From [4], section 7.2.6:
Delivery-report-value = Yes | No
Yes = <Octet 128>
No = <Octet 129>
A lot of other yes/no fields use this encoding (read-reply, report-allowed, etc)
Returns: str
The value for the field: 'Yes' or 'No'
Raises:
  • wsp_pdu.DecodeError - The boolean value could not be parsed. byteIter will not be modified in this case.

decodeFromValue(byteIter)
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>
Returns: str
The "From" address value

decodeMessageClassValue(byteIter)
Static Method

source code 
From [4], section 7.2.12: Message-class-value = Class-identifier | Token-text Class-identifier = Personal | Advertisement | Informational | Auto Personal = <Octet 128> Advertisement = <Octet 129> Informational = <Octet 130> Auto = <Octet 131> The token-text is an extension method to the message class.
Returns: str
The decoded message class

decodeMessageTypeValue(byteIter)
Static Method

source code 
Defined in [4], section 7.2.14.
Returns: str
The decoded message type, or '<unknown>'

decodePriorityValue(byteIter)
Static Method

source code 
Defined in [4], section 7.2.17
Returns: str
The decoded priority value
Raises:
  • wsp_pdu.DecodeError - The priority value could not be decoded; byteIter is not modified in this case.

decodeSenderVisibilityValue(byteIter)
Static Method

source code 
Defined in [4], section 7.2.22:
Sender-visibility-value = Hide | Show
Hide = <Octet 128>
Show = <Octet 129>
Returns: str
The sender visibility: 'Hide' or 'Show'
Raises:
  • wsp_pdu.DecodeError - The sender visibility value could not be parsed. byteIter will not be modified in this case.

decodeResponseStatusValue(byteIter)
Static Method

source code 

Defined in [4], section 7.2.20

Used to decode the "Response Status" MMS header.
Returns: str
The decoded Response-status-value
Raises:
  • wsp_pdu.DecodeError - The sender visibility value could not be parsed. byteIter will not be modified in this case.

decodeStatusValue(byteIter)
Static Method

source code 

Defined in [4], section 7.2.23

Used to decode the "Status" MMS header.
Returns: str
The decoded Status-value
Raises:
  • wsp_pdu.DecodeError - The sender visibility value could not be parsed. byteIter will not be modified in this case.

decodeExpiryValue(byteIter)
Static Method

source code 

Defined in [4], section 7.2.10

Used to decode the "Expiry" MMS header.

From [4], section 7.2.10: Expiry-value = Value-length (Absolute-token Date-value | Relative-token Delta-seconds-value) Absolute-token = <Octet 128> Relative-token = <Octet 129>
Returns: str or int
The decoded Expiry-value, either as a date, or as a delta-seconds value
Raises: