private Mailbox current;
private int ptr = 0;
public MailboxWrapper(Mailbox root) { this.root = root; }
- public Group group(String s) { ptr = 0; setgroup(s); return getgroup(s); }
+ public Group group(String s) {
+ ptr = 0;
+ Group g = getgroup(s);
+ if (g==null) return null;
+ setgroup(s);
+ return g;
+ }
public boolean ihave(String messageid) { /* FEATURE */ return false; }
public boolean post(Message m) { /* FEATURE */ return false; }
}
private void setgroup(String s) {
- current = root;
+ Mailbox ncurrent = root;
for(StringTokenizer st = new StringTokenizer(s, ".");
- st.hasMoreTokens();
- current = current.slash(st.nextToken(), false));
+ ncurrent != null && st.hasMoreTokens();
+ ncurrent = ncurrent.slash(st.nextToken(), false));
+ if (ncurrent!=null) current=ncurrent;
}
private Group getgroup(String s) {
Mailbox box = root;
- for(StringTokenizer st = new StringTokenizer(s, "."); st.hasMoreTokens(); box = box.slash(st.nextToken(), false));
+ for(StringTokenizer st = new StringTokenizer(s, "."); box!=null && st.hasMoreTokens(); box = box.slash(st.nextToken(), false));
+ if (box==null) return null;
return new Group(s, true, 1, box.count(Query.all()), box.count(Query.all()));
}
} else if (command.equals("QUIT")) { println("205 Bye."); conn.close(); return;
} else if (command.equals("GROUP")) {
Group g = api.group(st.nextToken().toLowerCase());
- println("211 " + g.count + " " + g.first + " " + g.last + " " + g.name);
+ if (g==null) println("411 no such group");
+ else println("211 " + g.count + " " + g.first + " " + g.last + " " + g.name);
} else if (command.equals("NEWGROUPS") || command.equals("NEWNEWS")) {
// FIXME: * and ! unsupported
// NEWNEWS is often not supported