2014-12-14 10:28:42 -05:00
|
|
|
package com.fsck.k9.mailstore;
|
2014-09-07 08:54:02 -04:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
import org.apache.james.mime4j.util.MimeUtil;
|
|
|
|
|
|
|
|
import com.fsck.k9.mail.CompositeBody;
|
|
|
|
import com.fsck.k9.mail.MessagingException;
|
|
|
|
|
2014-09-22 15:55:08 -04:00
|
|
|
/**
|
2015-01-21 22:12:05 -05:00
|
|
|
* An attachment containing a body of type message/rfc822 whose contents are contained in a file.
|
2014-09-22 15:55:08 -04:00
|
|
|
*/
|
2014-09-07 08:54:02 -04:00
|
|
|
public class TempFileMessageBody extends TempFileBody implements CompositeBody {
|
|
|
|
|
|
|
|
public TempFileMessageBody(String filename) {
|
|
|
|
super(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
|
|
|
AttachmentMessageBodyUtil.writeTo(this, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setUsing7bitTransport() throws MessagingException {
|
2015-01-21 22:12:05 -05:00
|
|
|
/*
|
|
|
|
* There's nothing to recurse into here, so there's nothing to do.
|
|
|
|
* The enclosing BodyPart already called setEncoding(MimeUtil.ENC_7BIT). Once
|
|
|
|
* writeTo() is called, the file with the rfc822 body will be opened
|
|
|
|
* for reading and will then be recursed.
|
|
|
|
*/
|
2014-09-07 08:54:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEncoding(String encoding) throws MessagingException {
|
|
|
|
if (!MimeUtil.ENC_7BIT.equalsIgnoreCase(encoding)
|
|
|
|
&& !MimeUtil.ENC_8BIT.equalsIgnoreCase(encoding)) {
|
|
|
|
throw new MessagingException(
|
|
|
|
"Incompatible content-transfer-encoding applied to a CompositeBody");
|
|
|
|
}
|
|
|
|
mEncoding = encoding;
|
|
|
|
}
|
2014-12-11 18:32:38 -05:00
|
|
|
}
|