private ContentValues getContentValuesForPart(PduPart part) throws MmsException { ContentValues contentValues = new ContentValues(); if (part.getCharset() != 0) { contentValues.put(CHARSET, part.getCharset()); } if (part.getContentType() != null) { contentValues.put(CONTENT_TYPE, Util.toIsoString(part.getContentType())); if (Util.toIsoString(part.getContentType()).equals(ContentType.APP_SMIL)) { contentValues.put(SEQUENCE, -1); } } else { throw new MmsException("There is no content type for this part."); } if (part.getName() != null) { contentValues.put(NAME, new String(part.getName())); } if (part.getFilename() != null) { contentValues.put(FILENAME, new String(part.getFilename())); } if (part.getContentDisposition() != null) { contentValues.put(CONTENT_DISPOSITION, Util.toIsoString(part.getContentDisposition())); } if (part.getContentId() != null) { contentValues.put(CONTENT_ID, Util.toIsoString(part.getContentId())); } if (part.getContentLocation() != null) { contentValues.put(CONTENT_LOCATION, Util.toIsoString(part.getContentLocation())); } contentValues.put(ENCRYPTED, part.getEncrypted() ? 1 : 0); contentValues.put(PENDING_PUSH_ATTACHMENT, part.isPendingPush() ? 1 : 0); contentValues.put(UNIQUE_ID, part.getUniqueId()); return contentValues; }
private TextSecureAttachmentPointer createAttachmentPointer( MasterSecret masterSecret, PduPart part) throws InvalidPartException { try { MasterCipher masterCipher = new MasterCipher(masterSecret); long id = Long.parseLong(Util.toIsoString(part.getContentLocation())); byte[] key = masterCipher.decryptBytes(Base64.decode(Util.toIsoString(part.getContentDisposition()))); String relay = null; if (part.getName() != null) { relay = Util.toIsoString(part.getName()); } return new TextSecureAttachmentPointer(id, null, key, relay); } catch (InvalidMessageException | IOException e) { Log.w(TAG, e); throw new InvalidPartException(e); } }