diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/DecryptStreamParser.java b/k9mail/src/main/java/com/fsck/k9/mailstore/MimePartStreamParser.java similarity index 97% rename from k9mail/src/main/java/com/fsck/k9/mailstore/DecryptStreamParser.java rename to k9mail/src/main/java/com/fsck/k9/mailstore/MimePartStreamParser.java index ee50cd0bf..92315350c 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/DecryptStreamParser.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/MimePartStreamParser.java @@ -34,8 +34,7 @@ import org.apache.james.mime4j.stream.Field; import org.apache.james.mime4j.stream.MimeConfig; import org.apache.james.mime4j.util.MimeUtil; -// TODO rename this class? this class doesn't really bear any 'decrypted' semantics anymore... -public class DecryptStreamParser { +public class MimePartStreamParser { private static final String DECRYPTED_CACHE_DIRECTORY = "decrypted"; @@ -83,7 +82,7 @@ public class DecryptStreamParser { private static Body createBody(InputStream inputStream, String transferEncoding, File decryptedTempDirectory) throws IOException { - DecryptedTempFileBody body = new DecryptedTempFileBody(decryptedTempDirectory, transferEncoding); + ProvidedTempFileBody body = new ProvidedTempFileBody(decryptedTempDirectory, transferEncoding); OutputStream outputStream = body.getOutputStream(); try { InputStream decodingInputStream; diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/DecryptedTempFileBody.java b/k9mail/src/main/java/com/fsck/k9/mailstore/ProvidedTempFileBody.java similarity index 94% rename from k9mail/src/main/java/com/fsck/k9/mailstore/DecryptedTempFileBody.java rename to k9mail/src/main/java/com/fsck/k9/mailstore/ProvidedTempFileBody.java index b96030dfe..d8365242e 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/DecryptedTempFileBody.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/ProvidedTempFileBody.java @@ -17,7 +17,7 @@ import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.internet.SizeAware; import org.apache.commons.io.output.DeferredFileOutputStream; -public class DecryptedTempFileBody extends BinaryAttachmentBody implements SizeAware { +public class ProvidedTempFileBody extends BinaryAttachmentBody implements SizeAware { public static final int MEMORY_BACKED_THRESHOLD = 1024 * 8; @@ -28,7 +28,7 @@ public class DecryptedTempFileBody extends BinaryAttachmentBody implements SizeA private byte[] data; - public DecryptedTempFileBody(File tempDirectory, String transferEncoding) { + public ProvidedTempFileBody(File tempDirectory, String transferEncoding) { this.tempDirectory = tempDirectory; try { setEncoding(transferEncoding); diff --git a/k9mail/src/main/java/com/fsck/k9/message/extractors/AttachmentInfoExtractor.java b/k9mail/src/main/java/com/fsck/k9/message/extractors/AttachmentInfoExtractor.java index d510a55c1..cc4cc22e8 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/extractors/AttachmentInfoExtractor.java +++ b/k9mail/src/main/java/com/fsck/k9/message/extractors/AttachmentInfoExtractor.java @@ -15,7 +15,7 @@ import com.fsck.k9.mail.Part; import com.fsck.k9.mail.internet.MimeHeader; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mailstore.AttachmentViewInfo; -import com.fsck.k9.mailstore.DecryptedTempFileBody; +import com.fsck.k9.mailstore.ProvidedTempFileBody; import com.fsck.k9.mailstore.LocalPart; import com.fsck.k9.provider.AttachmentProvider; import com.fsck.k9.provider.K9FileProvider; @@ -44,18 +44,16 @@ public class AttachmentInfoExtractor { uri = AttachmentProvider.getAttachmentUri(accountUuid, messagePartId); } else { Body body = part.getBody(); - if (body instanceof DecryptedTempFileBody) { - DecryptedTempFileBody decryptedTempFileBody = (DecryptedTempFileBody) body; + if (body instanceof ProvidedTempFileBody) { + ProvidedTempFileBody providedTempFileBody = (ProvidedTempFileBody) body; try { - size = decryptedTempFileBody.getSize(); - - File file = decryptedTempFileBody.getFile(); + File file = providedTempFileBody.getFile(); uri = K9FileProvider.getUriForFile(context, file, part.getMimeType()); + size = providedTempFileBody.getSize(); + return extractAttachmentInfo(part, uri, size); } catch (IOException e) { throw new MessagingException("Error preparing decrypted data as attachment", e); } - - return extractAttachmentInfo(part, uri, size); } else { throw new UnsupportedOperationException(); } diff --git a/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java b/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java index 7193ad933..623e4a95c 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/crypto/MessageCryptoHelper.java @@ -34,7 +34,7 @@ import com.fsck.k9.mail.internet.SizeAware; import com.fsck.k9.mail.internet.TextBody; import com.fsck.k9.mailstore.CryptoResultAnnotation; import com.fsck.k9.mailstore.CryptoResultAnnotation.CryptoError; -import com.fsck.k9.mailstore.DecryptStreamParser; +import com.fsck.k9.mailstore.MimePartStreamParser; import com.fsck.k9.mailstore.LocalMessage; import com.fsck.k9.mailstore.MessageHelper; import org.apache.commons.io.IOUtils; @@ -425,7 +425,7 @@ public class MessageCryptoHelper { @WorkerThread public MimeBodyPart processData(InputStream is) throws IOException { try { - return DecryptStreamParser.parse(context, is); + return MimePartStreamParser.parse(context, is); } catch (MessagingException e) { Log.e(K9.LOG_TAG, "Something went wrong while parsing the decrypted MIME part", e); //TODO: pass error to main thread and display error message to user