Search in sources :

Example 56 with Address

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);
}
Also used : Address(com.fsck.k9.mail.Address) Before(org.junit.Before)

Example 57 with Address

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");
}
Also used : Address(com.fsck.k9.mail.Address) Message(com.fsck.k9.mail.Message) Uri(android.net.Uri) AddressStyle(com.zegoggles.smssync.preferences.AddressStyle) Test(org.junit.Test)

Example 58 with Address

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()]);
}
Also used : Address(com.fsck.k9.mail.Address) ArrayList(java.util.ArrayList)

Example 59 with Address

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>");
}
Also used : Address(com.fsck.k9.mail.Address) Date(java.util.Date)

Example 60 with Address

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);
    }
}
Also used : Address(com.fsck.k9.mail.Address)

Aggregations

Address (com.fsck.k9.mail.Address)72 Test (org.junit.Test)40 Uri (android.net.Uri)13 RobolectricTest (com.fsck.k9.RobolectricTest)12 Message (com.fsck.k9.mail.Message)10 Date (java.util.Date)8 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)7 ArrayList (java.util.ArrayList)7 MessagingException (com.fsck.k9.mail.MessagingException)6 Contacts (com.fsck.k9.helper.Contacts)5 Recipient (com.fsck.k9.view.RecipientSelectView.Recipient)5 AddressStyle (com.zegoggles.smssync.preferences.AddressStyle)5 IOException (java.io.IOException)5 Intent (android.content.Intent)4 Cursor (android.database.Cursor)4 MatrixCursor (android.database.MatrixCursor)4 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)4 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)4 TextBody (com.fsck.k9.mail.internet.TextBody)4 SpannableString (android.text.SpannableString)3