Mailbox -> MailboxTree separation
[org.ibex.mail.git] / src / org / ibex / mail / NNTP.java
index c91c902..d9f6d20 100644 (file)
@@ -59,12 +59,12 @@ public class NNTP {
     }
 
     public static class MailboxWrapper implements Server {
-        private final Mailbox root;
+        private final MailboxTree 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(MailboxTree root) { this(root, false); }
+        public MailboxWrapper(MailboxTree 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) {
@@ -91,13 +91,13 @@ public class NNTP {
             } catch (Exception e) { return null; }
         }
         public Group[]  list() { return list(root, ""); }
-        private Group[] list(Mailbox who, String prefix) {
+        private Group[] list(MailboxTree who, String prefix) {
             Vec v = new Vec();
             if (who == null) who = root;
             String[] s = who.children();
             for(int i=0; i<s.length; i++) {
                 v.addElement(new Group(prefix + s[i], true, 0, 0, 0)); // FIXME numbers
-                Group[] g2 = list(who.slash(s[i], false), prefix + s[i] + ".");
+                Group[] g2 = list(who.slash(s[i], false).getMailbox(), prefix + s[i] + ".");
                 for(int j=0; j<g2.length; j++) v.addElement(g2[j]);
             }
             Group[] ret = new Group[v.size()];
@@ -106,19 +106,19 @@ public class NNTP {
         }
 
         private void setgroup(String s) {
-            Mailbox ncurrent = root;
+            MailboxTree 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;
+            MailboxTree 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[] { }; }
@@ -183,8 +183,7 @@ public class NNTP {
                         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;
                     }