nntp improvements
[org.ibex.mail.git] / src / org / ibex / mail / protocol / NNTP.java
index 44a5ca3..523c6ea 100644 (file)
@@ -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 <myname>, (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