use of i2p.bote.folder.FolderListener in project i2p.i2p-bote by i2p.
the class BoteMailbox method startListening.
protected void startListening() {
folderListener = new FolderListener() {
public void elementAdded(String messageId) {
try {
// Add new emails to map
Email email = folder.getEmail(messageId);
email.setFlag(Flag.RECENT, true);
messageMap.put(email, new BoteMessage(email, getMailboxId()));
updateMessages();
} catch (PasswordException e) {
throw new RuntimeException(_t("Password required or invalid password provided"), e);
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void elementUpdated() {
// Noop, BoteMessage has a reference to the Email
}
public void elementRemoved(String messageId) {
// Remove old email from map
Set<Email> emails = messageMap.keySet();
Iterator<Email> iter = emails.iterator();
while (iter.hasNext()) {
Email email = iter.next();
if (email.getMessageID().equals(messageId)) {
iter.remove();
break;
}
}
updateMessages();
}
};
folder.addFolderListener(folderListener);
}
Aggregations