Пример #1
0
 void insertParts(MasterSecret masterSecret, long mmsId, PduBody body) throws MmsException {
   for (int i = 0; i < body.getPartsNum(); i++) {
     PduPart part = body.getPart(i);
     PartId partId = insertPart(masterSecret, part, mmsId, part.getThumbnail());
     Log.w(TAG, "Inserted part at ID: " + partId);
   }
 }
Пример #2
0
  private static PduBody pduBodyFor(
      MasterSecret masterSecret, List<TextSecureAttachment> attachments) {
    PduBody body = new PduBody();

    for (TextSecureAttachment attachment : attachments) {
      if (attachment.isPointer()) {
        PduPart media = new PduPart();
        byte[] encryptedKey =
            new MasterCipher(masterSecret).encryptBytes(attachment.asPointer().getKey());

        media.setContentType(Util.toIsoBytes(attachment.getContentType()));
        media.setContentLocation(Util.toIsoBytes(String.valueOf(attachment.asPointer().getId())));
        media.setContentDisposition(Util.toIsoBytes(Base64.encodeBytes(encryptedKey)));
        media.setPendingPush(true);

        body.addPart(media);
      }
    }

    return body;
  }