package org.ibex.mail;
import org.ibex.util.*;
import org.ibex.io.*;
+import org.ibex.net.*;
import org.ibex.mail.target.*;
import org.ibex.jinetd.*;
import java.io.*;
}
public static class MailboxWrapper implements Server {
- private final Mailbox root;
+ private final MailTree root;
private Mailbox current;
private int ptr = 0;
private boolean post;
- public MailboxWrapper(Mailbox root) { this(root, false); }
- public MailboxWrapper(Mailbox root, boolean post) { this.root = root; this.post = post; }
+ public MailboxWrapper(MailTree root) { this(root, false); }
+ public MailboxWrapper(MailTree root, boolean post) { this.root = root; this.post = post; }
public boolean postok() { return post; }
public void post(Message m) throws IOException { current.post(m); }
public Group group(String s) {
Mailbox.Iterator it = current.iterator(q);
if (!it.next()) return null;
try {
+ // FIXME: UGLY!
Message m = body ? it.cur() : Message.newMessage(new Fountain.StringFountain(it.head() + "\r\n"));
return new Article(it.nntpNumber(), m);
} catch (Exception e) { return null; }
}
public Group[] list() { return list(root, ""); }
- private Group[] list(Mailbox who, String prefix) {
+ private Group[] list(MailTree who, String prefix) {
Vec v = new Vec();
if (who == null) who = root;
String[] s = who.children();
}
private void setgroup(String s) {
- Mailbox ncurrent = root;
+ MailTree ncurrent = root;
for(StringTokenizer st = new StringTokenizer(s, ".");
ncurrent != null && st.hasMoreTokens();
ncurrent = ncurrent.slash(st.nextToken(), false));
- if (ncurrent!=null) current=ncurrent;
+ if (ncurrent!=null) current=ncurrent.getMailbox();
}
private Group getgroup(String s) {
- Mailbox box = root;
+ MailTree box = root;
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()));
+ return new Group(s, true, 1, box.getMailbox().count(Query.all()), box.getMailbox().count(Query.all()));
}
public Group[] newgroups(Date d, String[] distributions) { /* FEATURE */ return new Group[] { }; }
}
int code = (head && body) ? 220 : head ? 221 : body ? 222 : 223;
println(code + " " + a.num + " <" + a.message.messageid + "> get ready for some stuff...");
- if (head) println(a.message.headers.getString());
+ if (head) { a.message.headers.getStream().transcribe(conn); println(); }
if (head && body) println();
if (body) {
Stream stream = a.message.getBody().getStream();
pass = st.nextToken();
account = login.login(user, pass);
if (account == null) { println("502 Invalid"); continue; }
- Mailbox box = account.getMailbox(NNTP.class);
- this.api = new MailboxWrapper(box, true);
+ this.api = new MailboxWrapper(account.getMailbox(NNTP.class), true);
println("281 Good to go");
continue;
}
} else {
println("340 send the article");
StringBuffer buf = new StringBuffer();
+ // FIXME: streaming?
while(true) {
String s = conn.readln();
if (s == null) throw new RuntimeException("connection closed");