com.vodafone360.people.engine.activities
Class MmsDecoder

java.lang.Object
  extended by com.vodafone360.people.engine.activities.MmsDecoder

public class MmsDecoder
extends java.lang.Object

Helper class to 'decode' MMS messages to provide suitable content for Timeline summary.


Field Summary
private static int ANY_CHARSET
           
private static int BIG5
           
private static int COLUMN_DATE
           
private static int COLUMN_MMS_ID
           
private static int COLUMN_MSG_BOX
           
private static int COLUMN_MSG_THREAD_ID
           
private static int COLUMN_SUBJECT
           
private static int COLUMN_SUBJECT_CS
           
private static java.lang.String ELLIPSIZE
           
private static java.lang.String ID
           
private static int ISO_8859_1
           
private static int ISO_8859_2
           
private static int ISO_8859_3
           
private static int ISO_8859_4
           
private static int ISO_8859_5
           
private static int ISO_8859_6
           
private static int ISO_8859_7
           
private static int ISO_8859_8
           
private static int ISO_8859_9
           
private static int MESSAGE_BOX_INBOX
           
private static int MESSAGE_BOX_SENT
           
private static java.lang.String MIMENAME_ANY_CHARSET
           
private static java.lang.String MIMENAME_BIG5
           
private static java.lang.String MIMENAME_ISO_8859_1
           
private static java.lang.String MIMENAME_ISO_8859_2
           
private static java.lang.String MIMENAME_ISO_8859_3
           
private static java.lang.String MIMENAME_ISO_8859_4
           
private static java.lang.String MIMENAME_ISO_8859_5
           
private static java.lang.String MIMENAME_ISO_8859_6
           
private static java.lang.String MIMENAME_ISO_8859_7
           
private static java.lang.String MIMENAME_ISO_8859_8
           
private static java.lang.String MIMENAME_ISO_8859_9
           
private static java.lang.String MIMENAME_SHIFT_JIS
           
private static java.lang.String MIMENAME_UCS2
           
private static java.lang.String MIMENAME_US_ASCII
           
private static java.lang.String MIMENAME_UTF_16
           
private static java.lang.String MIMENAME_UTF_8
           
protected static Uri MMS_CONTENT_URI
           
private static java.lang.String MMS_SORT_ORDER
           
private static java.lang.String[] MMS_STATUS_PROJECTION
          Fields to be returned from MMS query.
private static int MS_IN_SECONDS
           
private static java.lang.String PART
           
private static int PART_COLUMN_CONTENT_TYPE
           
private static int PART_COLUMN_ID
           
private static java.lang.String[] PART_PROJECTION
           
private static int PDU_FROM_FIELD
           
private static int PDU_TO_FIELD
           
private static int SHIFT_JIS
           
private static java.lang.String TEXT_PLAIN
           
private static java.lang.String THREAD_ID
           
private static int UCS2
           
private static int US_ASCII
           
private static int UTF_16
           
private static int UTF_8
           
 
Constructor Summary
MmsDecoder()
           
 
Method Summary
private static java.lang.String decodeString(int charset, byte[] data)
          Decode MMS data based on character set.
protected static Cursor fetchMmsListCursor(ContentResolver cr, boolean refresh, long oldestTimestamp, long newestTimestamp)
          Get a Cursor for MMS message item from native message log.
private static java.lang.String getMimeName(int charset)
          Return the MIME-type for specified character-set.
private static byte[] getMmsBytes(java.lang.String data)
          Return byte array from supplied String.
protected static boolean getMmsData(Context context, ContentResolver cr, Cursor mmsCursor, ActivitiesTable.TimelineSummaryItem item, DatabaseHelper db, int maxDescLength)
          Get the MMS data for the message at current Cursor position and use it to populate a TimelineSummaryItem.
private static java.lang.String getMmsText(ContentResolver cr, long msgId, int maxLength)
          Generate text required for Timeline entry from content of MMS message.
protected static long getTimestamp(Cursor mmsCursor)
           
private static java.lang.String getToOrFrom(ContentResolver cr, ActivityItem.Type msgType, Uri uri)
          Retrieve the sender/recipient of MMS (based on whether received or sent message).
private static ActivityItem.Type nativeToNpMessageType(int type)
          Convert Native message type (Inbox, Sent) to corresponding ActivityItem type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANY_CHARSET

private static final int ANY_CHARSET
See Also:
Constant Field Values

US_ASCII

private static final int US_ASCII
See Also:
Constant Field Values

ISO_8859_1

private static final int ISO_8859_1
See Also:
Constant Field Values

ISO_8859_2

private static final int ISO_8859_2
See Also:
Constant Field Values

ISO_8859_3

private static final int ISO_8859_3
See Also:
Constant Field Values

ISO_8859_4

private static final int ISO_8859_4
See Also:
Constant Field Values

ISO_8859_5

private static final int ISO_8859_5
See Also:
Constant Field Values

ISO_8859_6

private static final int ISO_8859_6
See Also:
Constant Field Values

ISO_8859_7

private static final int ISO_8859_7
See Also:
Constant Field Values

ISO_8859_8

private static final int ISO_8859_8
See Also:
Constant Field Values

ISO_8859_9

private static final int ISO_8859_9
See Also:
Constant Field Values

SHIFT_JIS

private static final int SHIFT_JIS
See Also:
Constant Field Values

UTF_8

private static final int UTF_8
See Also:
Constant Field Values

BIG5

private static final int BIG5
See Also:
Constant Field Values

UCS2

private static final int UCS2
See Also:
Constant Field Values

UTF_16

private static final int UTF_16
See Also:
Constant Field Values

MIMENAME_ANY_CHARSET

private static final java.lang.String MIMENAME_ANY_CHARSET
See Also:
Constant Field Values

MIMENAME_US_ASCII

private static final java.lang.String MIMENAME_US_ASCII
See Also:
Constant Field Values

MIMENAME_ISO_8859_1

private static final java.lang.String MIMENAME_ISO_8859_1
See Also:
Constant Field Values

MIMENAME_ISO_8859_2

private static final java.lang.String MIMENAME_ISO_8859_2
See Also:
Constant Field Values

MIMENAME_ISO_8859_3

private static final java.lang.String MIMENAME_ISO_8859_3
See Also:
Constant Field Values

MIMENAME_ISO_8859_4

private static final java.lang.String MIMENAME_ISO_8859_4
See Also:
Constant Field Values

MIMENAME_ISO_8859_5

private static final java.lang.String MIMENAME_ISO_8859_5
See Also:
Constant Field Values

MIMENAME_ISO_8859_6

private static final java.lang.String MIMENAME_ISO_8859_6
See Also:
Constant Field Values

MIMENAME_ISO_8859_7

private static final java.lang.String MIMENAME_ISO_8859_7
See Also:
Constant Field Values

MIMENAME_ISO_8859_8

private static final java.lang.String MIMENAME_ISO_8859_8
See Also:
Constant Field Values

MIMENAME_ISO_8859_9

private static final java.lang.String MIMENAME_ISO_8859_9
See Also:
Constant Field Values

MIMENAME_SHIFT_JIS

private static final java.lang.String MIMENAME_SHIFT_JIS
See Also:
Constant Field Values

MIMENAME_UTF_8

private static final java.lang.String MIMENAME_UTF_8
See Also:
Constant Field Values

MIMENAME_BIG5

private static final java.lang.String MIMENAME_BIG5
See Also:
Constant Field Values

MIMENAME_UCS2

private static final java.lang.String MIMENAME_UCS2
See Also:
Constant Field Values

MIMENAME_UTF_16

private static final java.lang.String MIMENAME_UTF_16
See Also:
Constant Field Values

MMS_CONTENT_URI

protected static final Uri MMS_CONTENT_URI

PDU_FROM_FIELD

private static final int PDU_FROM_FIELD
See Also:
Constant Field Values

PDU_TO_FIELD

private static final int PDU_TO_FIELD
See Also:
Constant Field Values

THREAD_ID

private static final java.lang.String THREAD_ID
See Also:
Constant Field Values

ID

private static final java.lang.String ID
See Also:
Constant Field Values

ELLIPSIZE

private static final java.lang.String ELLIPSIZE
See Also:
Constant Field Values

MMS_STATUS_PROJECTION

private static final java.lang.String[] MMS_STATUS_PROJECTION
Fields to be returned from MMS query.


COLUMN_DATE

private static final int COLUMN_DATE
See Also:
Constant Field Values

COLUMN_MMS_ID

private static final int COLUMN_MMS_ID
See Also:
Constant Field Values

COLUMN_SUBJECT

private static final int COLUMN_SUBJECT
See Also:
Constant Field Values

COLUMN_SUBJECT_CS

private static final int COLUMN_SUBJECT_CS
See Also:
Constant Field Values

COLUMN_MSG_BOX

private static final int COLUMN_MSG_BOX
See Also:
Constant Field Values

COLUMN_MSG_THREAD_ID

private static final int COLUMN_MSG_THREAD_ID
See Also:
Constant Field Values

PART_PROJECTION

private static final java.lang.String[] PART_PROJECTION

PART_COLUMN_ID

private static final int PART_COLUMN_ID
See Also:
Constant Field Values

PART_COLUMN_CONTENT_TYPE

private static final int PART_COLUMN_CONTENT_TYPE
See Also:
Constant Field Values

MESSAGE_BOX_INBOX

private static final int MESSAGE_BOX_INBOX
See Also:
Constant Field Values

MESSAGE_BOX_SENT

private static final int MESSAGE_BOX_SENT
See Also:
Constant Field Values

MMS_SORT_ORDER

private static final java.lang.String MMS_SORT_ORDER
See Also:
Constant Field Values

PART

private static final java.lang.String PART
See Also:
Constant Field Values

TEXT_PLAIN

private static final java.lang.String TEXT_PLAIN
See Also:
Constant Field Values

MS_IN_SECONDS

private static final int MS_IN_SECONDS
See Also:
Constant Field Values
Constructor Detail

MmsDecoder

public MmsDecoder()
Method Detail

getTimestamp

protected static long getTimestamp(Cursor mmsCursor)

fetchMmsListCursor

protected static Cursor fetchMmsListCursor(ContentResolver cr,
                                           boolean refresh,
                                           long oldestTimestamp,
                                           long newestTimestamp)
Get a Cursor for MMS message item from native message log.

Parameters:
cr - ContentResolver
timestamp - Timestamp to search against (may be null)
Returns:
Cursor to item in native message log (may be null)

getMmsData

protected static boolean getMmsData(Context context,
                                    ContentResolver cr,
                                    Cursor mmsCursor,
                                    ActivitiesTable.TimelineSummaryItem item,
                                    DatabaseHelper db,
                                    int maxDescLength)
Get the MMS data for the message at current Cursor position and use it to populate a TimelineSummaryItem. We initially check if the MMS is an Inbox or sent item returning false if this is not the case.

Parameters:
context - Context.
cr - ContentResolver.
mmsCursor - Cursor pointing to MMS message entry in native message log.
item - TimeLineSummaryItem to populate using MMS message details
db - Handle to People database.
maxDescLength - maximum length of the description.
Returns:
true if we have created the TimelineSummaryItem false if we haven't (because the MMS is not of a valid type).

getMimeName

private static java.lang.String getMimeName(int charset)
                                     throws java.io.UnsupportedEncodingException
Return the MIME-type for specified character-set.

Parameters:
charset - Character set.
Returns:
String containing MIME-type.
Throws:
java.io.UnsupportedEncodingException - if un-supported character set specified.

decodeString

private static java.lang.String decodeString(int charset,
                                             byte[] data)
Decode MMS data based on character set.

Parameters:
charset - Character set.
data - MMS data.
Returns:
Decoded MMS data as String.

getMmsBytes

private static byte[] getMmsBytes(java.lang.String data)
Return byte array from supplied String.

Parameters:
data - String containing MMS data.
Returns:
byte array containing data.

getToOrFrom

private static java.lang.String getToOrFrom(ContentResolver cr,
                                            ActivityItem.Type msgType,
                                            Uri uri)
Retrieve the sender/recipient of MMS (based on whether received or sent message).

Parameters:
cr - ContentResolver.
msgType - ActivityItem type (i.e. MESSAGE_MMS_SENT).
uri - MMS URI based on MMS_CONTENT_URI.
Returns:
String containing sender/recipient (can be null).

nativeToNpMessageType

private static ActivityItem.Type nativeToNpMessageType(int type)
Convert Native message type (Inbox, Sent) to corresponding ActivityItem type.

Parameters:
type - Native message type.
Returns:
ActivityItem type.

getMmsText

private static java.lang.String getMmsText(ContentResolver cr,
                                           long msgId,
                                           int maxLength)
Generate text required for Timeline entry from content of MMS message.

Parameters:
cr - ContentResolver
msgId - ID of MMS message as retrieved from message log.
maxLength - maximum length for text.
Returns:
String containing retrieved text, can be null.


JavaDoc