Search in sources :

Example 1 with FileFactory

use of com.fsck.k9.mailstore.util.FileFactory in project k-9 by k9mail.

the class DeferredFileBodyTest method setUp.

@Before
public void setUp() throws Exception {
    FileFactory fileFactory = new FileFactory() {

        @Override
        public File createFile() throws IOException {
            assertNull("only a single file should be created", createdFile);
            createdFile = File.createTempFile("test", "tmp");
            createdFile.deleteOnExit();
            return createdFile;
        }
    };
    deferredFileBody = new DeferredFileBody(TEST_THRESHOLD, fileFactory, TEST_ENCODING);
}
Also used : FileFactory(com.fsck.k9.mailstore.util.FileFactory) Before(org.junit.Before)

Example 2 with FileFactory

use of com.fsck.k9.mailstore.util.FileFactory in project k-9 by k9mail.

the class MimePartStreamParser method parse.

public static MimeBodyPart parse(FileFactory fileFactory, InputStream inputStream) throws MessagingException, IOException {
    MimeBodyPart parsedRootPart = new MimeBodyPart();
    MimeConfig parserConfig = new MimeConfig();
    parserConfig.setMaxHeaderLen(-1);
    parserConfig.setMaxLineLen(-1);
    parserConfig.setMaxHeaderCount(-1);
    MimeStreamParser parser = new MimeStreamParser(parserConfig);
    parser.setContentHandler(new PartBuilder(fileFactory, parsedRootPart));
    parser.setRecurse();
    try {
        parser.parse(new EOLConvertingInputStream(inputStream));
    } catch (MimeException e) {
        throw new MessagingException("Failed to parse decrypted content", e);
    }
    return parsedRootPart;
}
Also used : MimeConfig(org.apache.james.mime4j.stream.MimeConfig) MessagingException(com.fsck.k9.mail.MessagingException) MimeStreamParser(org.apache.james.mime4j.parser.MimeStreamParser) MimeException(org.apache.james.mime4j.MimeException) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) EOLConvertingInputStream(org.apache.james.mime4j.io.EOLConvertingInputStream)

Example 3 with FileFactory

use of com.fsck.k9.mailstore.util.FileFactory in project k-9 by k9mail.

the class DecryptedFileProvider method getFileFactory.

public static FileFactory getFileFactory(Context context) {
    final Context applicationContext = context.getApplicationContext();
    return new FileFactory() {

        @Override
        public File createFile() throws IOException {
            registerFileCleanupReceiver(applicationContext);
            File decryptedTempDirectory = getDecryptedTempDirectory(applicationContext);
            return File.createTempFile("decrypted-", null, decryptedTempDirectory);
        }
    };
}
Also used : Context(android.content.Context) File(java.io.File) FileFactory(com.fsck.k9.mailstore.util.FileFactory)

Aggregations

FileFactory (com.fsck.k9.mailstore.util.FileFactory)2 Context (android.content.Context)1 MessagingException (com.fsck.k9.mail.MessagingException)1 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)1 File (java.io.File)1 MimeException (org.apache.james.mime4j.MimeException)1 EOLConvertingInputStream (org.apache.james.mime4j.io.EOLConvertingInputStream)1 MimeStreamParser (org.apache.james.mime4j.parser.MimeStreamParser)1 MimeConfig (org.apache.james.mime4j.stream.MimeConfig)1 Before (org.junit.Before)1