rename DecryptedStreamParser and DecryptedTempFileBody

This commit is contained in:
Vincent Breitmoser 2016-06-23 19:06:30 +02:00
parent fcf6e9e9ff
commit 36a3a8bb20
4 changed files with 12 additions and 15 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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();
}

View file

@ -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