2008-11-01 17:32:06 -04:00
|
|
|
|
2009-12-14 21:50:53 -05:00
|
|
|
package com.fsck.k9.mail;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public interface Part {
|
2014-12-15 06:05:21 -05:00
|
|
|
void addHeader(String name, String value) throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
void removeHeader(String name) throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
void setHeader(String name, String value) throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
Body getBody();
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
String getContentType() throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
String getDisposition() throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
String getContentId() throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
String[] getHeader(String name) throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
boolean isMimeType(String mimeType) throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
String getMimeType() throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-12-15 06:05:21 -05:00
|
|
|
void setBody(Body body) throws MessagingException;
|
|
|
|
|
|
|
|
void writeTo(OutputStream out) throws IOException, MessagingException;
|
|
|
|
|
Recursively convert attachments of type message/rfc822 to 7bit if necessary.
The preceding commit resulted in attachments of type message/rfc822 being
sent with 8bit encoding even when the SMTP server did not support
8BITMIME. This commit assures that messages will be converted to 7bit
when necessary.
A new interface CompositeBody was created that extends Body, and classes
Message and Multipart were changed from implementing Body to
CompositeBody. Additional classes BinaryTempFileMessageBody and
LocalAttachmentMessageBody were created (by extending BinaryTempFileBody
and LocalAttachmentBody, respectively), and they too implement
CompositeBody.
A CompositeBody is a Body containing a composite-type that can contain
subparts that may require recursive processing when converting from 8bit
to 7bit. The Part to which a CompositeBody belongs is only permitted to
use 8bit or 7bit encoding for the CompositeBody.
Previously, a Message was created so that it was 7bit clean by default
(even though that meant base64 encoding all attachments, including
messages). Then, if the SMTP server supported 8BITMIME,
Message.setEncoding("8bit") was called so that bodies of type TextBody
would been transmitted using 8bit encoding rather than quoted-printable.
Now, messages are created with 8bit encoding by default. Then, if the
SMTP server does not support 8BITMIME, Message.setUsing7bitTransport is
called to recursively convert the message and its subparts to 7bit. The
method setUsing7bitTransport was added to the interfaces Part and
CompositeBody.
setEncoding no longer iterates over parts in Multipart. That task belongs
to setUsing7bitTransport, which may in turn call setEncoding on the parts.
MimeUtility.getEncodingforType was created as a helper function for
choosing a default encoding that should be used for a given MIME type when
an attachment is added to a message (either while composing or when
retrieving from LocalStore).
setEncoding was implemented in MimeBodyPart to assure that the encoding
set in the Part's headers was the same as set for the Part's Body. (The
method already existed in MimeMessage, which has similarities with
MimeBodyPart.)
MimeMessage.parse(InputStream in, boolean recurse) was implemented so that
the parser could be told to recursively process nested messages read from
the InputStream, thus giving access to all subparts at any level that may
need to be converted from 8bit to 7bit.
2013-09-02 23:49:28 -04:00
|
|
|
/**
|
|
|
|
* Called just prior to transmission, once the type of transport is known to
|
|
|
|
* be 7bit.
|
|
|
|
* <p>
|
|
|
|
* All bodies that are 8bit will be converted to 7bit and recursed if of
|
|
|
|
* type {@link CompositeBody}, or will be converted to quoted-printable in all other
|
|
|
|
* cases. Bodies with encodings other than 8bit remain unchanged.
|
|
|
|
*
|
|
|
|
* @throws MessagingException
|
|
|
|
*
|
|
|
|
*/
|
2014-09-14 05:11:48 -04:00
|
|
|
//TODO perhaps it would be clearer to use a flag "force7bit" in writeTo
|
2014-12-15 06:05:21 -05:00
|
|
|
void setUsing7bitTransport() throws MessagingException;
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|