use of com.fsck.k9.mailstore.AttachmentViewInfo 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.mailstore.AttachmentViewInfo 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);
}
use of com.fsck.k9.mailstore.AttachmentViewInfo 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);
}
Aggregations