Loading src/com/fsck/k9/activity/MessageCompose.java +13 −6 Original line number Diff line number Diff line Loading @@ -78,10 +78,11 @@ import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.internet.MimeMultipart; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.internet.TextBody; import com.fsck.k9.mail.store.LocalStore; import com.fsck.k9.mail.store.LocalStore.LocalAttachmentBody; import com.fsck.k9.mail.store.LocalStore.LocalAttachmentMessageBody; import com.fsck.k9.view.MessageWebView; import org.apache.james.mime4j.codec.EncoderUtil; import org.apache.james.mime4j.util.MimeUtil; import org.htmlcleaner.CleanerProperties; import org.htmlcleaner.HtmlCleaner; import org.htmlcleaner.SimpleHtmlSerializer; Loading Loading @@ -1471,11 +1472,17 @@ public class MessageCompose extends K9Activity implements OnClickListener { * @throws MessagingException */ private void addAttachmentsToMessage(final MimeMultipart mp) throws MessagingException { LocalAttachmentBody body; for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) { Attachment attachment = (Attachment) mAttachments.getChildAt(i).getTag(); MimeBodyPart bp = new MimeBodyPart( new LocalStore.LocalAttachmentBody(attachment.uri, getApplication())); String contentType = attachment.contentType; if (MimeUtil.isMessage(contentType)) { body = new LocalAttachmentMessageBody(attachment.uri, getApplication()); } else { body = new LocalAttachmentBody(attachment.uri, getApplication()); } MimeBodyPart bp = new MimeBodyPart(body); /* * Correctly encode the filename here. Otherwise the whole Loading @@ -1483,11 +1490,11 @@ public class MessageCompose extends K9Activity implements OnClickListener { * MimeHeader.writeTo(). */ bp.addHeader(MimeHeader.HEADER_CONTENT_TYPE, String.format("%s;\n name=\"%s\"", attachment.contentType, contentType, EncoderUtil.encodeIfNecessary(attachment.name, EncoderUtil.Usage.WORD_ENTITY, 7))); bp.addHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64"); bp.setEncoding(MimeUtility.getEncodingforType(contentType)); /* * TODO: Oh the joys of MIME... Loading src/com/fsck/k9/mail/Body.java +3 −0 Original line number Diff line number Diff line Loading @@ -5,7 +5,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import com.fsck.k9.mail.store.UnavailableStorageException; public interface Body { public InputStream getInputStream() throws MessagingException; public void setEncoding(String encoding) throws UnavailableStorageException, MessagingException; public void writeTo(OutputStream out) throws IOException, MessagingException; } src/com/fsck/k9/mail/BodyPart.java +4 −0 Original line number Diff line number Diff line Loading @@ -11,4 +11,8 @@ public abstract class BodyPart implements Part { public void setParent(Multipart parent) { mParent = parent; } public abstract void setEncoding(String encoding) throws MessagingException; public abstract void setUsing7bitTransport() throws MessagingException; } src/com/fsck/k9/mail/CompositeBody.java 0 → 100644 +29 −0 Original line number Diff line number Diff line package com.fsck.k9.mail; /** * A CompositeBody is a {@link Body} extension that can contain subparts that * may require recursing through or iterating over when converting the * CompositeBody from 8bit to 7bit encoding. The {@link Part} to which a * CompositeBody belongs is only permitted to use 8bit or 7bit content transfer * encoding for the CompositeBody. * */ public interface CompositeBody extends Body { /** * Called just prior to transmission, once the type of transport is known to * be 7bit. * <p> * All subparts that are 8bit and of type {@link CompositeBody} will be * converted to 7bit and recursed. All supbparts that are 8bit but not * of type CompositeBody will be converted to quoted-printable. Bodies with * encodings other than 8bit remain unchanged. * * @throws MessagingException * */ public abstract void setUsing7bitTransport() throws MessagingException; } src/com/fsck/k9/mail/Message.java +3 −6 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import com.fsck.k9.mail.filter.EOLConvertingOutputStream; import com.fsck.k9.mail.store.UnavailableStorageException; public abstract class Message implements Part, Body { public abstract class Message implements Part, CompositeBody { private static final Flag[] EMPTY_FLAG_ARRAY = new Flag[0]; private MessageReference mReference = null; Loading Loading @@ -139,10 +139,6 @@ public abstract class Message implements Part, Body { public abstract void setBody(Body body) throws MessagingException; public boolean isMimeType(String mimeType) throws MessagingException { return getContentType().startsWith(mimeType); } public abstract long getId(); public abstract String getPreview(); Loading Loading @@ -240,7 +236,7 @@ public abstract class Message implements Part, Body { public void destroy() throws MessagingException {} public abstract void setEncoding(String encoding) throws UnavailableStorageException; public abstract void setEncoding(String encoding) throws UnavailableStorageException, MessagingException; public abstract void setCharset(String charset) throws MessagingException; Loading Loading @@ -298,4 +294,5 @@ public abstract class Message implements Part, Body { * </p> */ public abstract Message clone(); public abstract void setUsing7bitTransport() throws MessagingException; } Loading
src/com/fsck/k9/activity/MessageCompose.java +13 −6 Original line number Diff line number Diff line Loading @@ -78,10 +78,11 @@ import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.internet.MimeMultipart; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.internet.TextBody; import com.fsck.k9.mail.store.LocalStore; import com.fsck.k9.mail.store.LocalStore.LocalAttachmentBody; import com.fsck.k9.mail.store.LocalStore.LocalAttachmentMessageBody; import com.fsck.k9.view.MessageWebView; import org.apache.james.mime4j.codec.EncoderUtil; import org.apache.james.mime4j.util.MimeUtil; import org.htmlcleaner.CleanerProperties; import org.htmlcleaner.HtmlCleaner; import org.htmlcleaner.SimpleHtmlSerializer; Loading Loading @@ -1471,11 +1472,17 @@ public class MessageCompose extends K9Activity implements OnClickListener { * @throws MessagingException */ private void addAttachmentsToMessage(final MimeMultipart mp) throws MessagingException { LocalAttachmentBody body; for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) { Attachment attachment = (Attachment) mAttachments.getChildAt(i).getTag(); MimeBodyPart bp = new MimeBodyPart( new LocalStore.LocalAttachmentBody(attachment.uri, getApplication())); String contentType = attachment.contentType; if (MimeUtil.isMessage(contentType)) { body = new LocalAttachmentMessageBody(attachment.uri, getApplication()); } else { body = new LocalAttachmentBody(attachment.uri, getApplication()); } MimeBodyPart bp = new MimeBodyPart(body); /* * Correctly encode the filename here. Otherwise the whole Loading @@ -1483,11 +1490,11 @@ public class MessageCompose extends K9Activity implements OnClickListener { * MimeHeader.writeTo(). */ bp.addHeader(MimeHeader.HEADER_CONTENT_TYPE, String.format("%s;\n name=\"%s\"", attachment.contentType, contentType, EncoderUtil.encodeIfNecessary(attachment.name, EncoderUtil.Usage.WORD_ENTITY, 7))); bp.addHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64"); bp.setEncoding(MimeUtility.getEncodingforType(contentType)); /* * TODO: Oh the joys of MIME... Loading
src/com/fsck/k9/mail/Body.java +3 −0 Original line number Diff line number Diff line Loading @@ -5,7 +5,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import com.fsck.k9.mail.store.UnavailableStorageException; public interface Body { public InputStream getInputStream() throws MessagingException; public void setEncoding(String encoding) throws UnavailableStorageException, MessagingException; public void writeTo(OutputStream out) throws IOException, MessagingException; }
src/com/fsck/k9/mail/BodyPart.java +4 −0 Original line number Diff line number Diff line Loading @@ -11,4 +11,8 @@ public abstract class BodyPart implements Part { public void setParent(Multipart parent) { mParent = parent; } public abstract void setEncoding(String encoding) throws MessagingException; public abstract void setUsing7bitTransport() throws MessagingException; }
src/com/fsck/k9/mail/CompositeBody.java 0 → 100644 +29 −0 Original line number Diff line number Diff line package com.fsck.k9.mail; /** * A CompositeBody is a {@link Body} extension that can contain subparts that * may require recursing through or iterating over when converting the * CompositeBody from 8bit to 7bit encoding. The {@link Part} to which a * CompositeBody belongs is only permitted to use 8bit or 7bit content transfer * encoding for the CompositeBody. * */ public interface CompositeBody extends Body { /** * Called just prior to transmission, once the type of transport is known to * be 7bit. * <p> * All subparts that are 8bit and of type {@link CompositeBody} will be * converted to 7bit and recursed. All supbparts that are 8bit but not * of type CompositeBody will be converted to quoted-printable. Bodies with * encodings other than 8bit remain unchanged. * * @throws MessagingException * */ public abstract void setUsing7bitTransport() throws MessagingException; }
src/com/fsck/k9/mail/Message.java +3 −6 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import com.fsck.k9.mail.filter.EOLConvertingOutputStream; import com.fsck.k9.mail.store.UnavailableStorageException; public abstract class Message implements Part, Body { public abstract class Message implements Part, CompositeBody { private static final Flag[] EMPTY_FLAG_ARRAY = new Flag[0]; private MessageReference mReference = null; Loading Loading @@ -139,10 +139,6 @@ public abstract class Message implements Part, Body { public abstract void setBody(Body body) throws MessagingException; public boolean isMimeType(String mimeType) throws MessagingException { return getContentType().startsWith(mimeType); } public abstract long getId(); public abstract String getPreview(); Loading Loading @@ -240,7 +236,7 @@ public abstract class Message implements Part, Body { public void destroy() throws MessagingException {} public abstract void setEncoding(String encoding) throws UnavailableStorageException; public abstract void setEncoding(String encoding) throws UnavailableStorageException, MessagingException; public abstract void setCharset(String charset) throws MessagingException; Loading Loading @@ -298,4 +294,5 @@ public abstract class Message implements Part, Body { * </p> */ public abstract Message clone(); public abstract void setUsing7bitTransport() throws MessagingException; }