Exemplo n.º 1
0
  public BoteMailbox(EmailFolder folder, long uidValidity, long uid) {
    super(new MailboxPath("I2P-Bote", "bote", folder.getName()), uidValidity);
    this.folder = folder;
    this.messageMap =
        Collections.synchronizedSortedMap(
            new TreeMap<Email, BoteMessage>(
                new Comparator<Email>() {
                  @Override
                  public int compare(Email email1, Email email2) {
                    // Try received dates first, this is set for all received.
                    // emails. If not set, this is a sent email, use sent date.
                    Date msg1date = email1.getReceivedDate();
                    if (msg1date == null)
                      try {
                        msg1date = email1.getSentDate();
                      } catch (MessagingException e) {
                      }

                    Date msg2date = email2.getReceivedDate();
                    if (msg2date == null)
                      try {
                        msg2date = email2.getSentDate();
                      } catch (MessagingException e) {
                      }

                    if (msg1date != null && msg2date != null) return msg1date.compareTo(msg2date);

                    // Catch-all
                    return email1.getMessageID().compareTo(email2.getMessageID());
                  }
                }));
    this.uid = uid;

    modSeq = System.currentTimeMillis();
    modSeq <<= 32;

    startListening();
    try {
      List<Email> emails = folder.getElements();
      for (Email email : emails) messageMap.put(email, new BoteMessage(email, getFolderName()));
      updateMessages();
    } catch (PasswordException e) {
      throw new RuntimeException(_t("Password required or invalid password provided"), e);
    }
  }
Exemplo n.º 2
0
 private String getFolderName() {
   return folder.getName();
 }