diff -r 961a8a3acb9a -r bb6990c0dd1a org/sonews/daemon/command/ListCommand.java --- a/org/sonews/daemon/command/ListCommand.java Mon Aug 17 11:00:51 2009 +0200 +++ b/org/sonews/daemon/command/ListCommand.java Thu Aug 20 14:31:19 2009 +0200 @@ -57,15 +57,15 @@ { final String[] command = line.split(" "); - if (command.length >= 2) + if(command.length >= 2) { - if (command[1].equalsIgnoreCase("OVERVIEW.FMT")) + if(command[1].equalsIgnoreCase("OVERVIEW.FMT")) { conn.println("215 information follows"); conn.println("Subject:\nFrom:\nDate:\nMessage-ID:\nReferences:\nBytes:\nLines:\nXref"); conn.println("."); } - else if (command[1].equalsIgnoreCase("NEWSGROUPS")) + else if(command[1].equalsIgnoreCase("NEWSGROUPS")) { conn.println("215 information follows"); final List list = Channel.getAll(); @@ -75,12 +75,12 @@ } conn.println("."); } - else if (command[1].equalsIgnoreCase("SUBSCRIPTIONS")) + else if(command[1].equalsIgnoreCase("SUBSCRIPTIONS")) { conn.println("215 information follows"); conn.println("."); } - else if (command[1].equalsIgnoreCase("EXTENSIONS")) + else if(command[1].equalsIgnoreCase("EXTENSIONS")) { conn.println("202 Supported NNTP extensions."); conn.println("LISTGROUP"); @@ -88,6 +88,11 @@ conn.println("XPAT"); conn.println("."); } + else if(command[1].equalsIgnoreCase("ACTIVE")) + { + // TODO: Implement wildcards for LIST ACTIVE + printGroupInfo(conn); + } else { conn.println("500 unknown argument to LIST command"); @@ -95,26 +100,31 @@ } else { - final List groups = Channel.getAll(); - if(groups != null) + printGroupInfo(conn); + } + } + + private void printGroupInfo(NNTPConnection conn) + throws IOException, StorageBackendException + { + final List groups = Channel.getAll(); + if (groups != null) + { + conn.println("215 list of newsgroups follows"); + for (Channel g : groups) { - conn.println("215 list of newsgroups follows"); - for (Channel g : groups) + if (!g.isDeleted()) { - if(!g.isDeleted()) - { - String writeable = g.isWriteable() ? " y" : " n"; - // Indeed first the higher article number then the lower - conn.println(g.getName() + " " + g.getLastArticleNumber() + " " - + g.getFirstArticleNumber() + writeable); - } + String writeable = g.isWriteable() ? " y" : " n"; + // Indeed first the higher article number then the lower + conn.println(g.getName() + " " + g.getLastArticleNumber() + " " + g.getFirstArticleNumber() + writeable); } - conn.println("."); } - else - { - conn.println("500 server database malfunction"); - } + conn.println("."); + } + else + { + conn.println("500 server database malfunction"); } }