private int randomUidValidity = new Random().nextInt();
public int uidValidity() { return randomUidValidity; }
+ public int maxuid() {
+ int ret = -1;
+ for(Mailbox.Iterator it = iterator(); it.next(); ) ret = Math.max(ret, it.uid());
+ return ret;
+ }
+
/** default, inefficient implementation of Mailbox; only requires a few methods to be implemented */
public static abstract class Default extends Mailbox {
public Mailbox.Iterator iterator(Query q) { return new Mailbox.Iterator.QueryIterator(q, this); }
public void copy(Query q, Mailbox dest) { for(Mailbox.Iterator it = iterator(q); it.next();) dest.insert(it.cur(), it.getFlags()); }
public int count(Query q) { int count = 0; for(Mailbox.Iterator it = iterator(q); it.next();) count++; return count; }
- public void rename(String newName) { throw new MailException("not supported"); }
- public void destroy(boolean recursive) { throw new MailException("not supported"); }
- public MailboxTree slash(String name, boolean create) { return null; }
+ public MailTree slash(String name, boolean create) { return null; }
public String[] children() { return new String[] { }; }
public void post(Message message) { insert(message, Flag.RECENT); }
public void move(Query q, Mailbox dest) {
}
public static abstract class Iterator implements Mailbox.Iterator {
// FIXME: NNTP spec allows us to use longs (64-bit) here
+ // FIXME: NNTP spec requires that the minimum nntpNumber of a group must never, ever decrease (no, that's not a typo)
public int nntpNumber() { throw new MailException("not supported"); }
public int getFlags() { return 0; }
public void setFlags(int flags) { throw new MailException("not supported"); }
public static interface Iterator {
public abstract Message cur();
public abstract Headers head();
+
+ // FIXME: change all code to actually use this convention!
+ /** JDBC convention: iterator starts "before the first element" */
public abstract boolean next();
+
public abstract void delete();
/** a unique identifier for this message */
/**
* Message number according to IMAP semantics.
+ * - must range from 1..numMessagesInMailbox
* - no two messages in the same mailbox may have the same imapNumber
* - sorting by uid must yield the same order as sorting them by imapNumber
- * - imapNumber may only change if uidValidity changes
- * - if uidValidity changes, imapNumbers may change or be reused
+ * - imapNumber changes when messages with lower imapNumbers are deleted
*/
public abstract int imapNumber();
public int uidValidity() { return m.uidValidity(); }
}
- public static abstract class AclWrapper extends MailboxWrapper {
+ public static class AclWrapper extends MailboxWrapper {
private Mailbox m;
private Acl.Entry acl;
public AclWrapper(Mailbox m, Acl.Entry acl) { super(m); this.acl = acl; }