use of com.fsck.k9.mail.Address in project sms-backup-plus by jberkel.
the class MessageGeneratorTest method before.
@Before
public void before() {
initMocks(this);
me = new Address("mine@mine.com", "me");
generator = new MessageGenerator(RuntimeEnvironment.application, me, AddressStyle.NAME, headerGenerator, personLookup, false, null, mmsSupport, CallLogTypes.EVERYTHING, dataTypePreferences);
}
use of com.fsck.k9.mail.Address in project sms-backup-plus by jberkel.
the class MessageGeneratorTest method testShouldGenerateSubjectWithNameForMMS.
@Test
public void testShouldGenerateSubjectWithNameForMMS() throws Exception {
PersonRecord personRecord = new PersonRecord(1, "Foo Bar", "foo@bar.com", "1234");
MmsSupport.MmsDetails details = new MmsSupport.MmsDetails(true, "foo", personRecord, new Address("foo@bar.com"));
when(mmsSupport.getDetails(any(Uri.class), any(AddressStyle.class))).thenReturn(details);
Message msg = generator.messageForDataType(mockMessage("1234", personRecord), DataType.MMS);
assertThat(msg).isNotNull();
assertThat(msg.getSubject()).isEqualTo("SMS with Foo Bar");
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class PgpMessageBuilder method getCryptoRecipientsWithoutBcc.
private String[] getCryptoRecipientsWithoutBcc() {
ArrayList<String> recipientAddresses = new ArrayList<>(Arrays.asList(cryptoStatus.getRecipientAddresses()));
Address[] bccAddresses = currentProcessedMimeMessage.getRecipients(RecipientType.BCC);
for (Address bccAddress : bccAddresses) {
recipientAddresses.remove(bccAddress.getAddress());
}
return recipientAddresses.toArray(new String[recipientAddresses.size()]);
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageViewInfoExtractor method addMessageHeaderHtml.
/**
* Extract important header values from a message to display inline (HTML version).
*
* @param html
* The {@link StringBuilder} that will receive the (HTML) output.
* @param message
* The message to extract the header values from.
*
* @throws com.fsck.k9.mail.MessagingException
* In case of an error.
*/
private void addMessageHeaderHtml(StringBuilder html, Message message) throws MessagingException {
html.append("<table style=\"border: 0\">");
// From: <sender>
Address[] from = message.getFrom();
if (from != null && from.length > 0) {
addTableRow(html, resourceProvider.messageHeaderFrom(), Address.toString(from));
}
// To: <recipients>
Address[] to = message.getRecipients(Message.RecipientType.TO);
if (to != null && to.length > 0) {
addTableRow(html, resourceProvider.messageHeaderTo(), Address.toString(to));
}
// Cc: <recipients>
Address[] cc = message.getRecipients(Message.RecipientType.CC);
if (cc != null && cc.length > 0) {
addTableRow(html, resourceProvider.messageHeaderCc(), Address.toString(cc));
}
// Date: <date>
Date date = message.getSentDate();
if (date != null) {
addTableRow(html, resourceProvider.messageHeaderDate(), date.toString());
}
// Subject: <subject>
String subject = message.getSubject();
addTableRow(html, resourceProvider.messageHeaderSubject(), (subject == null) ? resourceProvider.noSubject() : subject);
html.append("</table>");
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageBuilder method buildHeader.
private void buildHeader(MimeMessage message) throws MessagingException {
message.addSentDate(sentDate, hideTimeZone);
Address from = new Address(identity.getEmail(), identity.getName());
message.setFrom(from);
setRecipients(message, "To", to);
setRecipients(message, "CC", cc);
setRecipients(message, "BCC", bcc);
message.setSubject(subject);
if (requestReadReceipt) {
message.setHeader("Disposition-Notification-To", from.toEncodedString());
message.setHeader("X-Confirm-Reading-To", from.toEncodedString());
message.setHeader("Return-Receipt-To", from.toEncodedString());
}
if (!K9.isHideUserAgent()) {
String encodedUserAgent = MimeHeaderEncoder.encode("User-Agent", resourceProvider.userAgent());
message.setHeader("User-Agent", encodedUserAgent);
}
message.setReplyTo(replyTo);
if (inReplyTo != null) {
message.setInReplyTo(inReplyTo);
}
if (references != null) {
message.setReferences(references);
}
String messageId = messageIdGenerator.generateMessageId(message);
message.setMessageId(messageId);
if (isDraft && isPgpInlineEnabled) {
message.setFlag(Flag.X_DRAFT_OPENPGP_INLINE, true);
}
if (isDraft) {
message.setFlag(Flag.DRAFT, true);
}
}
Aggregations