merge
authoradam <adam@megacz.com>
Fri, 7 Jan 2005 18:25:40 +0000 (18:25 +0000)
committeradam <adam@megacz.com>
Fri, 7 Jan 2005 18:25:40 +0000 (18:25 +0000)
darcs-hash:20050107182540-5007d-3f934459f660e4c290ba270d12606961ad7cd334.gz

src/org/ibex/mail/protocol/NNTP.java

index 3f2817f..b8f9b29 100644 (file)
@@ -62,9 +62,11 @@ public class NNTP {
         private Article article(Query q,  boolean head, boolean body) {
             Mailbox.Iterator it = current.iterator(q);
             if (!it.next()) return null;
-            //Message m = body ? it.cur() : it.head();
-            Message m = it.cur(); // FIXME
-            return new Article(m.messageid, it.num(), m);
+            try {
+                Message m = body ? it.cur() : Message.newMessage(new Stream(it.head() + "\r\n"));
+                //Message m = it.cur(); // FIXME
+                return new Article(m.messageid, it.num(), m);
+            } catch (Exception e) { return null; }
         }
         public Group[]  list() { return list(root, ""); }
         private Group[] list(Mailbox who, String prefix) {
@@ -186,9 +188,11 @@ public class NNTP {
                     int end   = Integer.parseInt(range.substring(range.indexOf('-') + 1));
                     Mailbox.Iterator it = api.current.iterator(Query.messagenum(start, end));
                     while(it.next()) {
-                        Message m = it.cur();
-                        println(it.num()+"\t"+m.subject+"\t"+m.from+"\t"+m.date+"\t"+m.messageid+"\t"+
-                                m.headers.gets("references") + "\t" + m.size() + "\t" + m.lines);
+                        try {
+                            Message m = Message.newMessage(new Stream(it.head() + "\r\n"));
+                            println(it.num()+"\t"+m.subject+"\t"+m.from+"\t"+m.date+"\t"+m.messageid+"\t"+
+                                    m.headers.gets("references") + "\t" + m.size() + "\t" + m.lines);
+                        } 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");
@@ -262,11 +266,13 @@ public class NNTP {
                         println("240 article posted ok");
                         //}
 
-                } else if (command.equals("LIST"))      { 
-                    Group[] g = api.list();
-                    println("215 list of groups follows");
-                    for(int i=0; i<g.length; i++)
-                        println(g[i].name + " " + g[i].last + " " + g[i].first + " " + (g[i].post ? "y" : "n"));
+                } else if (command.equals("XROVER"))      { 
+                    // equivalent to "XHDR References"
+                } else if (command.equals("XHDR"))      { 
+                    // argument: header name
+                    // argument: 1 | 1- | 1-2 | <mid> | nothing (use current article)
+                    println("221 yep");
+                    // print art#+header for all matching messages
                     println(".");
                     // 412 if no group selected and numeric form used
                     // 430 if <mid> and not found