com.fsck.k9.mail.Message.setFrom()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(246)

本文整理了Java中com.fsck.k9.mail.Message.setFrom()方法的一些代码示例,展示了Message.setFrom()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setFrom()方法的具体详情如下:
包路径:com.fsck.k9.mail.Message
类名称:Message
方法名:setFrom

Message.setFrom介绍

暂无

代码示例

代码示例来源:origin: k9mail/k-9

@Test
public void multipartSigned__shouldCallOpenPgpApiAsync() throws Exception {
  BodyPart signedBodyPart = spy(bodypart("text/plain", "content"));
  Message message = messageFromBody(
      multipart("signed", "protocol=\"application/pgp-signature\"",
          signedBodyPart,
          bodypart("application/pgp-signature", "content")
      )
  );
  message.setFrom(Address.parse("Test <test@example.org>")[0]);
  OutputStream outputStream = mock(OutputStream.class);
  processSignedMessageAndCaptureMocks(message, signedBodyPart, outputStream);
  assertEquals(OpenPgpApi.ACTION_DECRYPT_VERIFY, capturedApiIntent.getAction());
  assertEquals("test@example.org", capturedApiIntent.getStringExtra(OpenPgpApi.EXTRA_SENDER_ADDRESS));
  verify(autocryptOperations).addAutocryptPeerUpdateToIntentIfPresent(message, capturedApiIntent);
  verifyNoMoreInteractions(autocryptOperations);
}

代码示例来源:origin: k9mail/k-9

@Test
public void multipartEncrypted__shouldCallOpenPgpApiAsync() throws Exception {
  Body encryptedBody = spy(new TextBody("encrypted data"));
  Message message = messageFromBody(
      multipart("encrypted", "protocol=\"application/pgp-encrypted\"",
          bodypart("application/pgp-encrypted", "content"),
          bodypart("application/octet-stream", encryptedBody)
      )
  );
  message.setFrom(Address.parse("Test <test@example.org>")[0]);
  OutputStream outputStream = mock(OutputStream.class);
  Intent resultIntent = new Intent();
  resultIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
  OpenPgpDecryptionResult decryptionResult = mock(OpenPgpDecryptionResult.class);
  resultIntent.putExtra(OpenPgpApi.RESULT_DECRYPTION, decryptionResult);
  OpenPgpSignatureResult signatureResult = mock(OpenPgpSignatureResult.class);
  resultIntent.putExtra(OpenPgpApi.RESULT_SIGNATURE, signatureResult);
  PendingIntent pendingIntent = mock(PendingIntent.class);
  resultIntent.putExtra(OpenPgpApi.RESULT_INTENT, pendingIntent);
  processEncryptedMessageAndCaptureMocks(message, encryptedBody, outputStream);
  MimeBodyPart decryptedPart = new MimeBodyPart(new TextBody("text"));
  capturedCallback.onReturn(resultIntent, decryptedPart);
  assertEquals(OpenPgpApi.ACTION_DECRYPT_VERIFY, capturedApiIntent.getAction());
  assertEquals("test@example.org", capturedApiIntent.getStringExtra(OpenPgpApi.EXTRA_SENDER_ADDRESS));
  assertPartAnnotationHasState(message, messageCryptoCallback, CryptoError.OPENPGP_OK, decryptedPart,
      decryptionResult, signatureResult, pendingIntent);
  verify(autocryptOperations).addAutocryptPeerUpdateToIntentIfPresent(message, capturedApiIntent);
  verifyNoMoreInteractions(autocryptOperations);
}

代码示例来源:origin: k9mail/k-9

@Test
public void generateMessageId_withFromAndReplyToAddress() throws Exception {
  Message message = new MimeMessage();
  message.setFrom(new Address("alice@example.org"));
  message.setReplyTo(Address.parse("bob@example.com"));
  
  String result = messageIdGenerator.generateMessageId(message);
  
  assertEquals("<00000000-0000-4000-0000-000000000000@example.org>", result);
}

代码示例来源:origin: jberkel/sms-backup-plus

private @Nullable Message messageFromMapSms(Map<String, String> msgMap) throws MessagingException {
  final String address = msgMap.get(Telephony.TextBasedSmsColumns.ADDRESS);
  if (TextUtils.isEmpty(address)) return null;
  PersonRecord record = personLookup.lookupPerson(address);
  if (!includePersonInBackup(record, DataType.SMS)) return null;
  final Message msg = new MimeMessage();
  msg.setSubject(getSubject(DataType.SMS, record));
  setBody(msg, new TextBody(msgMap.get(Telephony.TextBasedSmsColumns.BODY)));
  final int messageType = toInt(msgMap.get(Telephony.TextBasedSmsColumns.TYPE));
  if (Telephony.TextBasedSmsColumns.MESSAGE_TYPE_INBOX == messageType) {
    // Received message
    msg.setFrom(record.getAddress(addressStyle));
    msg.setRecipient(Message.RecipientType.TO, userAddress);
  } else {
    // Sent message
    msg.setRecipient(Message.RecipientType.TO, record.getAddress(addressStyle));
    msg.setFrom(userAddress);
  }
  Date sentDate;
  try {
    // TODO: should probably be TextBasedSmsColumns.DATE_SENT
    sentDate = new Date(Long.valueOf(msgMap.get(Telephony.TextBasedSmsColumns.DATE)));
  } catch (NumberFormatException n) {
    Log.e(TAG, ERROR_PARSING_DATE, n);
    sentDate = new Date();
  }
  headerGenerator.setHeaders(msg, msgMap, DataType.SMS, address, record, sentDate, messageType);
  return msg;
}

代码示例来源:origin: jberkel/sms-backup-plus

msg.setFrom(userAddress);
  msg.setRecipient(Message.RecipientType.TO, record.getAddress(addressStyle));
  break;
case CallLog.Calls.VOICEMAIL_TYPE:
  msg.setFrom(record.getAddress(addressStyle));
  msg.setRecipient(Message.RecipientType.TO, userAddress);
  break;

代码示例来源:origin: jberkel/sms-backup-plus

msg.setFrom(details.getRecipientAddress());
  msg.setRecipient(Message.RecipientType.TO, userAddress);
} else {
  msg.setRecipients(Message.RecipientType.TO, details.getAddresses());
  msg.setFrom(userAddress);

相关文章