nntp improvements
authoradam <adam@megacz.com>
Sun, 21 Jan 2007 23:10:06 +0000 (23:10 +0000)
committeradam <adam@megacz.com>
Sun, 21 Jan 2007 23:10:06 +0000 (23:10 +0000)
darcs-hash:20070121231006-5007d-71d2a5b823a80c2f0a34b450853f0276661c5395.gz

src/org/ibex/mail/protocol/NNTP.java
src/org/ibex/mail/target/FileBasedMailbox.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
 
index 0e7c6f9..3f198d0 100644 (file)
@@ -74,9 +74,7 @@ public class FileBasedMailbox extends Mailbox.Default {
         String[] files = path.list();
         for(int i=0; i<files.length; i++) {
             try {
-                if (files[i].indexOf('.') == -1) continue;
-                if (files[i].charAt(0) == '.') continue;
-                files[i] = files[i].substring(0, files[i].indexOf('.'));
+                if (files[i].indexOf('.') != -1) files[i] = files[i].substring(0, files[i].indexOf('.'));
                 int n = Integer.parseInt(files[i]);
                 if (n>=uidNext) uidNext = n;
             } catch(Exception e) { Log.error(this, e); }