1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Save multi part epilogue in MimeMultipart

This commit is contained in:
cketti 2014-12-07 03:31:58 +01:00
parent d1d7b60a09
commit 3919c9d2d6
3 changed files with 16 additions and 1 deletions

View File

@ -2,6 +2,7 @@
package com.fsck.k9.mail.internet; package com.fsck.k9.mail.internet;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,6 +15,7 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.MimeException; import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.field.DateTimeField; import org.apache.james.mime4j.dom.field.DateTimeField;
import org.apache.james.mime4j.field.DefaultFieldParser; import org.apache.james.mime4j.field.DefaultFieldParser;
@ -575,6 +577,10 @@ public class MimeMessage extends Message {
@Override @Override
public void epilogue(InputStream is) throws IOException { public void epilogue(InputStream is) throws IOException {
expect(MimeMultipart.class);
ByteArrayOutputStream epilogue = new ByteArrayOutputStream();
IOUtils.copy(is, epilogue);
((MimeMultipart) stack.peek()).setEpilogue(epilogue.toByteArray());
} }
@Override @Override

View File

@ -11,6 +11,7 @@ import java.util.Random;
public class MimeMultipart extends Multipart { public class MimeMultipart extends Multipart {
private String mPreamble; private String mPreamble;
private byte[] mEpilogue;
private String mContentType; private String mContentType;
@ -53,6 +54,10 @@ public class MimeMultipart extends Multipart {
this.mPreamble = preamble; this.mPreamble = preamble;
} }
public void setEpilogue(byte[] epilogue) {
mEpilogue = epilogue;
}
@Override @Override
public String getContentType() { public String getContentType() {
return mContentType; return mContentType;
@ -90,6 +95,9 @@ public class MimeMultipart extends Multipart {
writer.write(mBoundary); writer.write(mBoundary);
writer.write("--\r\n"); writer.write("--\r\n");
writer.flush(); writer.flush();
if (mEpilogue != null) {
out.write(mEpilogue);
}
} }
@Override @Override

View File

@ -42,7 +42,8 @@ public class ReconstructMessageTest extends AndroidTestCase {
"VGhpcyBpcyBhIHRl\r\n" + "VGhpcyBpcyBhIHRl\r\n" +
"c3QgbWVzc2FnZQ==\r\n" + "c3QgbWVzc2FnZQ==\r\n" +
"\r\n" + "\r\n" +
"------Boundary--\r\n"; "------Boundary--\r\n" +
"Hi, I'm the epilogue";
BinaryTempFileBody.setTempDirectory(getContext().getCacheDir()); BinaryTempFileBody.setTempDirectory(getContext().getCacheDir());