Mailbox inbox = null;
Mailbox selected = null;
- Mailbox root = null;
+ MailboxTree root = null;
Mailbox selected() { if (selected == null) throw new Bad("no mailbox selected"); return selected; }
final Login auth;
final Client client;
private Mailbox mailbox(String name, boolean create) { return mailbox(name, create, true); }
private Mailbox mailbox(String name, boolean create, boolean throwexn) {
if (name.equalsIgnoreCase("inbox")) return inbox;
- Mailbox m = root;
+ MailboxTree m = root;
for(StringTokenizer st = new StringTokenizer(name, sep + ""); st.hasMoreTokens();)
if ((m = m.slash(st.nextToken(), create)) == null) {
if (throwexn) throw new Server.No("no such mailbox " + name);
return null;
}
- return m;
+ return m.getMailbox();
}
// FEATURE: not accurate when a wildcard and subsequent non-wildcards both match a single component
/** takes an IMAP.Server and exposes it to the world as an IMAP server on a TCP socket */
public static class Listener implements Client {
String selectedName = null;
- Mailbox inbox = null, root = null;
+ Mailbox inbox = null;
+ MailboxTree root = null;
Server api;
Parser parser = null;
Connection conn = null;
Parser.Token token(boolean freak) { return parser.token(freak); }
void println(String s) {
conn.println(s);
- Log.info("", s);
+ //Log.info("", s);
}
void newline() { parser.newline(); }
Query query(int max) { return parser.query(max, maxn(true)); }
} else {
Account account = (Account)ret;
((MailboxWrapper)api).root = root = account.getMailbox(IMAP.class);
- Log.warn(this, "logged in, root="+root);
- ((MailboxWrapper)api).inbox = inbox = root.slash("INBOX", false);
- if (inbox == null) ((MailboxWrapper)api).inbox = inbox = root;
+ ((MailboxWrapper)api).inbox = inbox = root.slash("INBOX", false).getMailbox();
+ if (inbox == null) ((MailboxWrapper)api).inbox = inbox = root.getMailbox();
}
}
}
} catch (Server.Bad b) { println(tag==null ? "* BAD Invalid tag":(tag + " Bad " + b.toString())); Log.warn(this,b);
} catch (Server.No n) { println(tag==null?"* BAD Invalid tag":(tag+" No " + n.toString())); Log.warn(this,n);
- } finally {
- //Log.warn(this, conn.dumpLog()+"\n");
}
}