Search in sources :

Example 6 with PduBody

use of com.google.android.mms.pdu_alt.PduBody in project qksms by moezbhatti.

the class MessageUtils method saveRingtone.

/**
 * Copies media from an Mms to the DrmProvider
 *
 * @param context
 * @param msgId
 */
public static boolean saveRingtone(Context context, long msgId) {
    boolean result = true;
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(context, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "copyToDrmProvider can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }
    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);
        String type = new String(part.getContentType());
        if (DrmUtils.isDrmType(type)) {
            // All parts (but there's probably only a single one) have to be successful
            // for a valid result.
            result &= copyPart(context, part, Long.toHexString(msgId));
        }
    }
    return result;
}
Also used : MmsException(com.google.android.mms.MmsException) PduBody(com.google.android.mms.pdu_alt.PduBody) PduPart(com.google.android.mms.pdu_alt.PduPart)

Example 7 with PduBody

use of com.google.android.mms.pdu_alt.PduBody in project qksms by moezbhatti.

the class MessageUtils method copyMedia.

/**
 * Copies media from an Mms to the "download" directory on the SD card. If any of the parts
 * are audio types, drm'd or not, they're copied to the "Ringtones" directory.
 *
 * @param context
 * @param msgId
 */
public static boolean copyMedia(Context context, long msgId) {
    boolean result = true;
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(context, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "copyMedia can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }
    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);
        // all parts have to be successful for a valid result.
        result &= copyPart(context, part, Long.toHexString(msgId));
    }
    return result;
}
Also used : MmsException(com.google.android.mms.MmsException) PduBody(com.google.android.mms.pdu_alt.PduBody) PduPart(com.google.android.mms.pdu_alt.PduPart)

Example 8 with PduBody

use of com.google.android.mms.pdu_alt.PduBody in project qksms by moezbhatti.

the class MessageUtils method isForwardable.

/**
 * Returns true if all drm'd parts are forwardable.
 *
 * @param context
 * @param msgId
 * @return true if all drm'd parts are forwardable.
 */
public static boolean isForwardable(Context context, long msgId) {
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(context, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "getDrmMimeType can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }
    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);
        String type = new String(part.getContentType());
        if (DrmUtils.isDrmType(type) && !DrmUtils.haveRightsForAction(part.getDataUri(), DrmStore.Action.TRANSFER)) {
            return false;
        }
    }
    return true;
}
Also used : MmsException(com.google.android.mms.MmsException) PduBody(com.google.android.mms.pdu_alt.PduBody) PduPart(com.google.android.mms.pdu_alt.PduPart)

Aggregations

PduBody (com.google.android.mms.pdu_alt.PduBody)8 PduPart (com.google.android.mms.pdu_alt.PduPart)7 MmsException (com.google.android.mms.MmsException)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Cursor (android.database.Cursor)1 MMSPart (com.google.android.mms.MMSPart)1 EncodedStringValue (com.google.android.mms.pdu_alt.EncodedStringValue)1 PduComposer (com.google.android.mms.pdu_alt.PduComposer)1 PduPersister (com.google.android.mms.pdu_alt.PduPersister)1 SendReq (com.google.android.mms.pdu_alt.SendReq)1 ExceedMessageSizeException (com.moez.QKSMS.ExceedMessageSizeException)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1