From: adam Date: Sun, 21 Jan 2007 23:10:06 +0000 (+0000) Subject: nntp improvements X-Git-Url: http://git.megacz.com/?p=org.ibex.mail.git;a=commitdiff_plain;h=8a4fb7b7043f096c7901f147295e5a539fbd71a6 nntp improvements darcs-hash:20070121231006-5007d-71d2a5b823a80c2f0a34b450853f0276661c5395.gz --- diff --git a/src/org/ibex/mail/protocol/NNTP.java b/src/org/ibex/mail/protocol/NNTP.java index 44a5ca3..523c6ea 100644 --- a/src/org/ibex/mail/protocol/NNTP.java +++ b/src/org/ibex/mail/protocol/NNTP.java @@ -24,7 +24,7 @@ public class NNTP { public static final DateFormat dateFormat = new SimpleDateFormat("yyyyMMDDhhmmss"); - public static class No extends RuntimeException { int code = 400; } // 4xx response codes + public static class No extends RuntimeException { int code = 400; } // 4xx response codes public static class Bad extends RuntimeException { int code = 500; public Bad(String s) { super(s); } } // 5xx response codes public static class Group { @@ -37,7 +37,7 @@ public class NNTP { } public static class Article { - public Article(int num, Message message) { this.message = message; this.num = num;} + public Article(int num, Message message) { this.message = message; this.num = num; } public final int num; public final Message message; } @@ -65,7 +65,8 @@ public class NNTP { public MailboxWrapper(Mailbox root, boolean post) { this.root = root; this.post = post; } public boolean postok() { return post; } public void post(Message m) throws IOException { current.accept(m); } - public Group group(String s) { + + public Group group(String s) { ptr = 0; Group g = getgroup(s); if (g==null) return null; @@ -111,8 +112,6 @@ public class NNTP { } private Group getgroup(String s) { Mailbox box = root; - Log.error("", "getgroup " + s); - Log.error("", "mailbox " + 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())); @@ -224,8 +223,10 @@ public class NNTP { } catch (Exception e) { Log.error(this, e); } } println("."); - } else if (command.equals("LAST")) { Article a = api.last(); println("223 "+a.num+" "+a.message.messageid+" ok"); - } else if (command.equals("NEXT")) { Article a = api.next(); println("223 "+a.num+" "+a.message.messageid+" ok"); + } else if (command.equals("LAST")) { + Article a = api.last(); println("223 "+a.num+" "+a.message.messageid+" ok"); + } else if (command.equals("NEXT")) { + Article a = api.next(); println("223 "+a.num+" "+a.message.messageid+" ok"); } else if (command.equals("QUIT")) { println("205 Bye."); conn.close(); return; } else if (command.equals("GROUP")) { Group g = api.group(st.nextToken().toLowerCase()); @@ -275,7 +276,8 @@ public class NNTP { // add NNTP-Posting-Host header // Path header: prepend , (any punctuation separates the list) // Expires header: the date when expiration happens (??) should we ignore this? - // Control header: body is the command. Inteprert posts to all.all.ctl as control messages, use Subject line if no Cntrol line + // Control header: body is the command. Inteprert posts to all.all.ctl as control messages, + // use Subject line if no Cntrol line // "Approved" line is used for moderaion // Xref: drop this header if you see it diff --git a/src/org/ibex/mail/target/FileBasedMailbox.java b/src/org/ibex/mail/target/FileBasedMailbox.java index 0e7c6f9..3f198d0 100644 --- a/src/org/ibex/mail/target/FileBasedMailbox.java +++ b/src/org/ibex/mail/target/FileBasedMailbox.java @@ -74,9 +74,7 @@ public class FileBasedMailbox extends Mailbox.Default { String[] files = path.list(); for(int i=0; i=uidNext) uidNext = n; } catch(Exception e) { Log.error(this, e); }