use of com.fsck.k9.mail.internet.TextBody in project k-9 by k9mail.
the class MessagingController method addErrorMessage.
private void addErrorMessage(Account account, String subject, String body) {
if (!K9.isDebug()) {
return;
}
if (!loopCatch.compareAndSet(false, true)) {
return;
}
try {
if (body == null || body.length() < 1) {
return;
}
Store localStore = account.getLocalStore();
LocalFolder localFolder = (LocalFolder) localStore.getFolder(account.getErrorFolderName());
MimeMessage message = new MimeMessage();
MimeMessageHelper.setBody(message, new TextBody(body));
message.setFlag(Flag.X_DOWNLOADED_FULL, true);
message.setSubject(subject);
long nowTime = System.currentTimeMillis();
Date nowDate = new Date(nowTime);
message.setInternalDate(nowDate);
message.addSentDate(nowDate, K9.hideTimeZone());
message.setFrom(new Address(account.getEmail(), "K9mail internal"));
localFolder.appendMessages(Collections.singletonList(message));
localFolder.clearMessagesOlderThan(nowTime - (15 * 60 * 1000));
} catch (Throwable it) {
Timber.e(it, "Could not save error message to %s", account.getErrorFolderName());
} finally {
loopCatch.set(false);
}
}
use of com.fsck.k9.mail.internet.TextBody in project k-9 by k9mail.
the class MessageDecryptVerifierTest method isPartPgpInlineEncryptedOrSigned__withSignedData__shouldReturnTrue.
@Test
public void isPartPgpInlineEncryptedOrSigned__withSignedData__shouldReturnTrue() throws Exception {
String pgpInlineData = "-----BEGIN PGP SIGNED MESSAGE-----\n" + "Header: Value\n" + "\n" + "-----BEGIN PGP SIGNATURE-----\n" + "Header: Value\n" + "\n" + "base64base64base64base64\n" + "-----END PGP SIGNED MESSAGE-----\n";
MimeMessage message = new MimeMessage();
message.setBody(new TextBody(pgpInlineData));
assertTrue(MessageDecryptVerifier.isPartPgpInlineEncryptedOrSigned(message));
}
use of com.fsck.k9.mail.internet.TextBody in project k-9 by k9mail.
the class MessageDecryptVerifierTest method isPgpInlineMethods__withEncryptedDataAndLeadingWhitespace__shouldReturnTrue.
@Test
public void isPgpInlineMethods__withEncryptedDataAndLeadingWhitespace__shouldReturnTrue() throws Exception {
String pgpInlineData = "\n \n \n" + "-----BEGIN PGP MESSAGE-----\n" + "Header: Value\n" + "\n" + "base64base64base64base64\n" + "-----END PGP MESSAGE-----\n";
MimeMessage message = new MimeMessage();
message.setBody(new TextBody(pgpInlineData));
assertTrue(MessageDecryptVerifier.isPartPgpInlineEncryptedOrSigned(message));
assertTrue(MessageDecryptVerifier.isPartPgpInlineEncrypted(message));
}
use of com.fsck.k9.mail.internet.TextBody in project k-9 by k9mail.
the class MessageDecryptVerifierTest method isPgpInlineMethods__withPgpInlineData__shouldReturnTrue.
@Test
public void isPgpInlineMethods__withPgpInlineData__shouldReturnTrue() throws Exception {
String pgpInlineData = "-----BEGIN PGP MESSAGE-----\n" + "Header: Value\n" + "\n" + "base64base64base64base64\n" + "-----END PGP MESSAGE-----\n";
MimeMessage message = new MimeMessage();
message.setBody(new TextBody(pgpInlineData));
assertTrue(MessageDecryptVerifier.isPartPgpInlineEncrypted(message));
}
use of com.fsck.k9.mail.internet.TextBody in project k-9 by k9mail.
the class MessageDecryptVerifierTest method findEncryptedPartsShouldReturnEmptyListForSimpleMessage.
@Test
public void findEncryptedPartsShouldReturnEmptyListForSimpleMessage() throws Exception {
MimeMessage message = new MimeMessage();
message.setBody(new TextBody("message text"));
List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
assertEquals(0, encryptedParts.size());
}
Aggregations