chris@0: /* chris@0: * StarOffice News Server chris@0: * see AUTHORS for the list of contributors chris@0: * chris@0: * This program is free software: you can redistribute it and/or modify chris@0: * it under the terms of the GNU General Public License as published by chris@0: * the Free Software Foundation, either version 3 of the License, or chris@0: * (at your option) any later version. chris@0: * chris@0: * This program is distributed in the hope that it will be useful, chris@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of chris@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the chris@0: * GNU General Public License for more details. chris@0: * chris@0: * You should have received a copy of the GNU General Public License chris@0: * along with this program. If not, see . chris@0: */ chris@0: chris@0: package com.so.news.command; chris@0: chris@0: import java.io.IOException; chris@0: import java.util.ArrayList; chris@0: import com.so.news.NNTPConnection; chris@0: import com.so.news.storage.Group; chris@0: chris@0: /** chris@0: * Class handling the LIST command. chris@0: * @author Christian Lins chris@0: * @author Dennis Schwerdel chris@0: */ chris@0: public class ListCommand extends Command chris@0: { chris@0: public ListCommand(NNTPConnection conn) chris@0: { chris@0: super(conn); chris@0: } chris@0: chris@0: public boolean process(String[] command) chris@0: throws Exception chris@0: { chris@0: if (command.length >= 2) chris@0: { chris@0: if (command[1].equalsIgnoreCase("OVERVIEW.FMT")) chris@0: { chris@0: printStatus(215, "information follows"); chris@0: printText("Subject:\nFrom:\nDate:\nMessage-ID:\nReferences:\nBytes:\nLines:"); chris@0: return true; chris@0: } chris@0: if (command[1].equalsIgnoreCase("NEWSGROUPS")) chris@0: { chris@0: printStatus(215, "information follows"); chris@0: ArrayList list = Group.getAll(); chris@0: for (Group g : list) chris@0: { chris@0: printTextLine(g.getName() + "\t" + "-"); chris@0: } chris@0: println("."); chris@0: flush(); chris@0: return true; chris@0: } chris@0: if (command[1].equalsIgnoreCase("SUBSCRIPTIONS")) chris@0: { chris@0: printStatus(215, "information follows"); chris@0: println("."); chris@0: flush(); chris@0: return true; chris@0: } chris@0: if (command[1].equalsIgnoreCase("EXTENSIONS")) chris@0: { chris@0: printStatus(202, "Supported NNTP extensions."); chris@0: printTextLine("LISTGROUP"); chris@0: println("."); chris@0: flush(); chris@0: return true; chris@0: } chris@0: return false; chris@0: } chris@0: printStatus(215, "list of newsgroups follows"); chris@0: for (Group g : Group.getAll()) chris@0: { chris@0: //if(g.getEstimatedArticleCount() <= 0) chris@0: // continue; chris@0: chris@0: printTextLine(g.getName() + " " + g.getLastArticle() + " " chris@0: + g.getFirstArticle() + " y"); chris@0: } chris@0: println("."); chris@0: flush(); chris@0: return true; chris@0: } chris@0: chris@0: }