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);
}
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;
}
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);
}
};
}
Aggregations