use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class AttachmentPresenter method addAttachment.
private void addAttachment(AttachmentViewInfo attachmentViewInfo) {
if (attachments.containsKey(attachmentViewInfo.internalUri)) {
throw new IllegalStateException("Received the same attachmentViewInfo twice!");
}
int loaderId = getNextFreeLoaderId();
Attachment attachment = Attachment.createAttachment(attachmentViewInfo.internalUri, loaderId, attachmentViewInfo.mimeType);
attachment = attachment.deriveWithMetadataLoaded(attachmentViewInfo.mimeType, attachmentViewInfo.displayName, attachmentViewInfo.size);
addAttachmentAndStartLoader(attachment);
}
use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class MessageTest method nestedMessage.
private MimeMessage nestedMessage(MimeMessage subMessage) throws MessagingException, IOException {
BinaryTempFileMessageBody tempMessageBody = new BinaryTempFileMessageBody(MimeUtil.ENC_8BIT);
OutputStream out = tempMessageBody.getOutputStream();
try {
subMessage.writeTo(out);
} finally {
out.close();
}
MimeBodyPart bodyPart = new MimeBodyPart(tempMessageBody, "message/rfc822");
bodyPart.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment");
bodyPart.setEncoding(MimeUtil.ENC_7BIT);
MimeMessage parentMessage = sampleMessage();
((Multipart) parentMessage.getBody()).addBodyPart(bodyPart);
return parentMessage;
}
use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionInvalidSizeParam__shouldReturnUnknownSize.
@Test
public void extractInfoForDb__withDispositionInvalidSizeParam__shouldReturnUnknownSize() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; size=\"notanint\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals(AttachmentViewInfo.UNKNOWN_SIZE, attachmentViewInfo.size);
}
use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionSizeParam__shouldReturnThatSize.
@Test
public void extractInfoForDb__withDispositionSizeParam__shouldReturnThatSize() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; size=\"" + TEST_SIZE + "\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals(TEST_SIZE, attachmentViewInfo.size);
}
Aggregations