com.fsck.k9.mail.Message类的使用及代码示例

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

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

Message介绍

暂无

代码示例

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

private Long getUidForMessage(Message message) {
    try {
      return Long.parseLong(message.getUid());
    } catch (NullPointerException | NumberFormatException e) {
      return null;
    }
  }
}

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

private String extractMessageId(Message message) {
  String[] messageIdHeader = message.getHeader("Message-ID");
  return messageIdHeader.length == 0 ? null : messageIdHeader[0];
}

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

public ReplyToAddresses getRecipientsToReplyTo(Message message, Account account) {
  Address[] candidateAddress;
  Address[] replyToAddresses = message.getReplyTo();
  Address[] listPostAddresses = ListHeaders.getListPostAddresses(message);
  Address[] fromAddresses = message.getFrom();
  if (replyToAddresses.length > 0) {
    candidateAddress = replyToAddresses;
  } else if (listPostAddresses.length > 0) {
    candidateAddress = listPostAddresses;
  } else {
    candidateAddress = fromAddresses;
  }
  boolean replyToAddressIsUserIdentity = account.isAnIdentity(candidateAddress);
  if (replyToAddressIsUserIdentity) {
    candidateAddress = message.getRecipients(RecipientType.TO);
  }
  return new ReplyToAddresses(candidateAddress);
}

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

public static boolean shouldShowSender(Message message) {
  Address[] from = message.getFrom();
  Address[] sender = message.getSender();
  return sender != null && sender.length != 0 && !Arrays.equals(from, sender);
}

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

public boolean olderThan(Date earliestDate) {
  if (earliestDate == null) {
    return false;
  }
  Date myDate = getSentDate();
  if (myDate == null) {
    myDate = getInternalDate();
  }
  return myDate != null && myDate.before(earliestDate);
}

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

private boolean shouldImportMessage(Message message, Date earliestDate) {
  if (message.olderThan(earliestDate)) {
    Timber.d("Message %s is older than %s, hence not saving", message.getUid(), earliestDate);
    return false;
  }
  return true;
}

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

private boolean syncFlags(SyncConfig syncConfig, BackendFolder backendFolder, Message remoteMessage) {
  String messageServerId = remoteMessage.getUid();
  if (!backendFolder.isMessagePresent(messageServerId)) {
    return false;
  }
  Set<Flag> localMessageFlags = backendFolder.getMessageFlags(messageServerId);
  if (localMessageFlags.contains(Flag.DELETED)) {
    return false;
  }
  boolean messageChanged = false;
  if (remoteMessage.isSet(Flag.DELETED)) {
    if (syncConfig.getSyncRemoteDeletions()) {
      backendFolder.setMessageFlag(messageServerId, Flag.DELETED, true);
      messageChanged = true;
    }
  } else {
    for (Flag flag : syncConfig.getSyncFlags()) {
      if (remoteMessage.isSet(flag) != localMessageFlags.contains(flag)) {
        backendFolder.setMessageFlag(messageServerId, flag, remoteMessage.isSet(flag));
        messageChanged = true;
      }
    }
  }
  return messageChanged;
}

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

String uid = message.getUid();
boolean shouldCreateNewMessage = uid == null || copy;
if (shouldCreateNewMessage) {
    message.setUid(randomLocalUid);
  cv.put("message_part_id", rootMessagePartId);
  cv.put("uid", uid);
  cv.put("subject", message.getSubject());
  cv.put("sender_list", Address.pack(message.getFrom()));
  cv.put("date", message.getSentDate() == null
      ? System.currentTimeMillis() : message.getSentDate().getTime());
  cv.put("flags", LocalStore.serializeFlags(message.getFlags()));
  cv.put("deleted", message.isSet(Flag.DELETED) ? 1 : 0);
  cv.put("read", message.isSet(Flag.SEEN) ? 1 : 0);
  cv.put("flagged", message.isSet(Flag.FLAGGED) ? 1 : 0);
  cv.put("answered", message.isSet(Flag.ANSWERED) ? 1 : 0);
  cv.put("forwarded", message.isSet(Flag.FORWARDED) ? 1 : 0);
  cv.put("folder_id", databaseId);
  cv.put("to_list", Address.pack(message.getRecipients(RecipientType.TO)));
  cv.put("cc_list", Address.pack(message.getRecipients(RecipientType.CC)));
  cv.put("bcc_list", Address.pack(message.getRecipients(RecipientType.BCC)));
  cv.put("reply_to_list", Address.pack(message.getReplyTo()));
  cv.put("attachment_count", attachmentCount);
  cv.put("internal_date", message.getInternalDate() == null
      ? System.currentTimeMillis() : message.getInternalDate().getTime());
  cv.put("mime_type", message.getMimeType());
  cv.put("empty", 0);
  cv.put("encryption_type", encryptionType);

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

@Override
public void messageFinished(T message, int number, int ofTotal) {
  try {
    if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) {
      if (message.isSet(Flag.DELETED)) {
        Timber.v("Newly downloaded message %s:%s:%s was marked deleted on server, " +
            "skipping", accountName, folder, message.getUid());
      } else {
        Timber.d("Newly downloaded message %s is older than %s, skipping",
            message.getUid(), earliestDate);
      }
      progress.incrementAndGet();
      //TODO: This might be the source of poll count errors in the UI. Is todo always the same as ofTotal
      listener.syncProgress(folder, progress.get(), todo);
      return;
    }
    if (syncConfig.getMaximumAutoDownloadMessageSize() > 0 &&
        message.getSize() > syncConfig.getMaximumAutoDownloadMessageSize()) {
      largeMessages.add(message);
    } else {
      smallMessages.add(message);
    }
  } catch (Exception e) {
    Timber.e(e, "Error while storing downloaded message.");
  }
}

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

@Test
public void getRecipientsToReplyAllTo_should_returnFromAndToAndCcRecipients() throws Exception {
  when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
  when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
  when(message.getFrom()).thenReturn(FROM_ADDRESSES);
  when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
  when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
  ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
  assertArrayEquals(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class), recipientsToReplyAllTo.to);
  assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
}

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

for (T message : largeMessages) {
  if (message.getBody() == null) {
    downloadSaneBody(syncConfig, remoteFolder, backendFolder, message);
  } else {
  String messageServerId = message.getUid();
  Timber.v("About to notify listeners that we got a new large message %s:%s:%s",
      accountName, folder, messageServerId);

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

@Test
public void getRecipientsToReplyTo_should_return_from_otherwise() throws Exception {
  when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
  when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
  when(message.getFrom()).thenReturn(FROM_ADDRESSES);
  ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
  assertArrayEquals(FROM_ADDRESSES, result.to);
  assertArrayEquals(EMPTY_ADDRESSES, result.cc);
  verify(account).isAnIdentity(result.to);
}

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

throws MessagingException {
Address[] from = message.getFrom();
if (from != null && from.length > 0) {
  text.append(resourceProvider.messageHeaderFrom());
Address[] to = message.getRecipients(Message.RecipientType.TO);
if (to != null && to.length > 0) {
  text.append(resourceProvider.messageHeaderTo());
Address[] cc = message.getRecipients(Message.RecipientType.CC);
if (cc != null && cc.length > 0) {
  text.append(resourceProvider.messageHeaderCc());
Date date = message.getSentDate();
if (date != null) {
  text.append(resourceProvider.messageHeaderDate());
String subject = message.getSubject();
text.append(resourceProvider.messageHeaderSubject());
text.append(' ');

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

ByteArrayOutputStream out;
long size = message.getSize();
if (size > Integer.MAX_VALUE) {
  throw new MessagingException("message size > Integer.MAX_VALUE!");
EOLConvertingOutputStream msgOut = new EOLConvertingOutputStream(
    new BufferedOutputStream(out, 1024));
message.writeTo(msgOut);
msgOut.flush();
  messageURL += "/";
messageURL += encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml");
WebDavMessage retMessage = new WebDavMessage(message.getUid(), this);

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

public void populate(final Message message, final Account account) {
  final Contacts contacts = K9.showContactName() ? mContacts : null;
  final CharSequence from = MessageHelper.toFriendly(message.getFrom(), contacts);
  final CharSequence to = MessageHelper.toFriendly(message.getRecipients(Message.RecipientType.TO), contacts);
  final CharSequence cc = MessageHelper.toFriendly(message.getRecipients(Message.RecipientType.CC), contacts);
  final CharSequence bcc = MessageHelper.toFriendly(message.getRecipients(Message.RecipientType.BCC), contacts);
  Address[] fromAddrs = message.getFrom();
  Address[] toAddrs = message.getRecipients(Message.RecipientType.TO);
  Address[] ccAddrs = message.getRecipients(Message.RecipientType.CC);
  boolean fromMe = mMessageHelper.toMe(account, fromAddrs);
    mSenderView.setVisibility(VISIBLE);
    String sender = getResources().getString(R.string.message_view_sender_label,
        MessageHelper.toFriendly(message.getSender(), contacts));
    mSenderView.setText(sender);
  } else {
      message.getSentDate().getTime(),
      DateUtils.FORMAT_SHOW_DATE
      | DateUtils.FORMAT_ABBREV_ALL
  updateAddressField(mCcView, cc, mCcLabel);
  updateAddressField(mBccView, bcc, mBccLabel);
  mAnsweredIcon.setVisibility(message.isSet(Flag.ANSWERED) ? View.VISIBLE : View.GONE);
  mForwardedIcon.setVisibility(message.isSet(Flag.FORWARDED) ? View.VISIBLE : View.GONE);
  mFlagged.setChecked(message.isSet(Flag.FLAGGED));

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

int unsizedMessages = 0;
for (Message message : messages) {
  if (message.getSize() == -1) {
    unsizedMessages++;
  Set<String> msgUidIndex = new HashSet<>();
  for (Message message : messages) {
    msgUidIndex.add(message.getUid());

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

String fromAddress = Address.toString(originalMessage.getFrom());
if (quoteStyle == QuoteStyle.PREFIX) {
  StringBuilder header = new StringBuilder(QuoteHelper.QUOTE_BUFFER_LENGTH);
  header.append("<div style='font-size:10.0pt;font-family:\"Tahoma\",\"sans-serif\";padding:3.0pt 0in 0in 0in'>\r\n");
  header.append("<hr style='border:none;border-top:solid #E1E1E1 1.0pt'>\r\n"); // This gets converted into a horizontal line during html to text conversion.
  if (originalMessage.getFrom() != null && fromAddress.length() != 0) {
    header.append("<b>").append(resourceProvider.messageHeaderFrom()).append("</b> ")
        .append(HtmlConverter.textToHtmlFragment(fromAddress))
        .append("<br>\r\n");
  if (originalMessage.getRecipients(RecipientType.TO) != null && originalMessage.getRecipients(RecipientType.TO).length != 0) {
    header.append("<b>").append(resourceProvider.messageHeaderTo()).append("</b> ")
        .append(HtmlConverter.textToHtmlFragment(Address.toString(originalMessage.getRecipients(RecipientType.TO))))
        .append("<br>\r\n");
  if (originalMessage.getRecipients(RecipientType.CC) != null && originalMessage.getRecipients(RecipientType.CC).length != 0) {
    header.append("<b>").append(resourceProvider.messageHeaderCc()).append("</b> ")
        .append(HtmlConverter.textToHtmlFragment(Address.toString(originalMessage.getRecipients(RecipientType.CC))))
        .append("<br>\r\n");
  if (originalMessage.getSubject() != null) {
    header.append("<b>").append(resourceProvider.messageHeaderSubject()).append("</b> ")
        .append(HtmlConverter.textToHtmlFragment(originalMessage.getSubject()))
        .append("<br>\r\n");

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

@Override
public boolean equals(Object o) {
  if (o == null || !(o instanceof Message)) {
    return false;
  }
  Message other = (Message)o;
  return (getUid().equals(other.getUid())
      && getFolder().getServerId().equals(other.getFolder().getServerId()));
}

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

public void delete(List<? extends Message> msgs, String trashFolder) throws MessagingException {
  for (Message message : msgs) {
    Message myMessage = getMessage(message.getUid());
    myMessage.delete(trashFolder);
  }
}

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

if (!message.isSet(Flag.X_DOWNLOADED_FULL)) {
      || message.getSize() < syncConfig.getMaximumAutoDownloadMessageSize()) {
    completeMessage = true;

相关文章