Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f8fc5bc authored by cketti's avatar cketti
Browse files

Merge remote-tracking branch 'k9mail_pgp_mime/master'

Fixed lots of conflicts
parents 7752f42d f89b0548
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
#Sun Nov 30 16:02:23 PST 2014
#Sun Dec 07 14:12:42 GMT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
+25 −1
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ import com.fsck.k9.mail.filter.EOLConvertingOutputStream;

import static com.fsck.k9.mail.K9MailLib.LOG_TAG;


public abstract class Message implements Part, CompositeBody {

    public enum RecipientType {
        TO, CC, BCC,
    }
@@ -117,8 +117,32 @@ public abstract class Message implements Part, CompositeBody {

    public abstract void setReferences(String references) throws MessagingException;

    @Override
    public abstract Body getBody();

    @Override
    public abstract String getContentType() throws MessagingException;

    @Override
    public abstract void addHeader(String name, String value) throws MessagingException;

    @Override
    public abstract void addRawHeader(String name, String raw) throws MessagingException;

    @Override
    public abstract void setHeader(String name, String value) throws MessagingException;

    @Override
    public abstract String[] getHeader(String name) throws MessagingException;

    public abstract Set<String> getHeaderNames() throws MessagingException;

    @Override
    public abstract void removeHeader(String name) throws MessagingException;

    @Override
    public abstract void setBody(Body body) throws MessagingException;

    public abstract long getId();

    public abstract String getPreview();
+2 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ import java.io.OutputStream;
public interface Part {
    void addHeader(String name, String value) throws MessagingException;

    void addRawHeader(String name, String raw) throws MessagingException;

    void removeHeader(String name) throws MessagingException;

    void setHeader(String name, String value) throws MessagingException;
+47 −21
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ import java.io.*;
 * and writeTo one time. After writeTo is called, or the InputStream returned from
 * getInputStream is closed the file is deleted and the Body should be considered disposed of.
 */
public class BinaryTempFileBody implements Body {
public class BinaryTempFileBody implements RawDataBody {
    private static File mTempDirectory;

    private File mFile;
@@ -26,15 +26,56 @@ public class BinaryTempFileBody implements Body {
        mTempDirectory = tempDirectory;
    }

    @Override
    public String getEncoding() {
        return mEncoding;
    }

    public void setEncoding(String encoding) throws MessagingException {
        if (mEncoding != null && mEncoding.equalsIgnoreCase(encoding)) {
            return;
        }

        // The encoding changed, so we need to convert the message
        if (!MimeUtil.ENC_8BIT.equalsIgnoreCase(mEncoding)) {
            throw new RuntimeException("Can't convert from encoding: " + mEncoding);
        }

        try {
            File newFile = File.createTempFile("body", null, mTempDirectory);
            OutputStream out = new FileOutputStream(newFile);
            try {
                if (MimeUtil.ENC_QUOTED_PRINTABLE.equals(encoding)) {
                    out = new QuotedPrintableOutputStream(out, false);
                } else if (MimeUtil.ENC_BASE64.equals(encoding)) {
                    out = new Base64OutputStream(out);
                } else {
                    throw new RuntimeException("Target encoding not supported: " + encoding);
                }

                InputStream in = getInputStream();
                try {
                    IOUtils.copy(in, out);
                } finally {
                    in.close();
                }
            } finally {
                out.close();
            }

            mFile = newFile;
            mEncoding = encoding;
        } catch (IOException e) {
            throw new MessagingException("Unable to convert body", e);
        }
    }

    public BinaryTempFileBody() {
    public BinaryTempFileBody(String encoding) {
        if (mTempDirectory == null) {
            throw new
            RuntimeException("setTempDirectory has not been called on BinaryTempFileBody!");
            throw new RuntimeException("setTempDirectory has not been called on BinaryTempFileBody!");
        }

        mEncoding = encoding;
    }

    public OutputStream getOutputStream() throws IOException {
@@ -53,23 +94,8 @@ public class BinaryTempFileBody implements Body {

    public void writeTo(OutputStream out) throws IOException, MessagingException {
        InputStream in = getInputStream();
        try {
            boolean closeStream = false;
            if (MimeUtil.isBase64Encoding(mEncoding)) {
                out = new Base64OutputStream(out);
                closeStream = true;
            } else if (MimeUtil.isQuotedPrintableEncoded(mEncoding)){
                out = new QuotedPrintableOutputStream(out, false);
                closeStream = true;
            }

        try {
            IOUtils.copy(in, out);
            } finally {
                if (closeStream) {
                    out.close();
                }
            }
        } finally {
            in.close();
        }
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ import com.fsck.k9.mail.MessagingException;
 */
public class BinaryTempFileMessageBody extends BinaryTempFileBody implements CompositeBody {

    public BinaryTempFileMessageBody(String encoding) {
        super(encoding);
    }

    @Override
    public void setEncoding(String encoding) throws MessagingException {
        if (!MimeUtil.ENC_7BIT.equalsIgnoreCase(encoding)
Loading