String lastLine = "";
String line;
final List<Result> lastResult = Lists.newArrayList();
+ final List<Download> downloads = Lists.newArrayList();
final List<Connection> lastConnections = Lists.newArrayList();
while ((line = reader.readLine()) != null) {
if (line.equals("")) {
writeLine("End of Search.");
} else if (words[0].equalsIgnoreCase("dcc")) {
int counter = 0;
- for (Download download : FluentIterable.from(core.downloads()).toSortedList(Ordering.from(BY_NAME).compound(BY_RUNNING))) {
+ downloads.clear();
+ downloads.addAll(FluentIterable.from(core.downloads()).toSortedList(Ordering.from(BY_NAME).compound(BY_RUNNING)));
+ for (Download download : downloads) {
DccReceiver dccReceiver = download.dccReceiver();
if (dccReceiver == null) {
/* download has not even started. */
if ((index != null) && (index < lastResult.size())) {
core.fetch(lastResult.get(index).bot(), lastResult.get(index).pack());
}
+ } else if (words[0].equalsIgnoreCase("cancel")) {
+ Integer index = Ints.tryParse(words[1]);
+ if ((index != null) && (index < downloads.size())) {
+ core.cancelDownload(downloads.get(index).bot(), downloads.get(index).pack());
+ }
} else if (words[0].equalsIgnoreCase("stats")) {
int configuredChannelsCount = core.channels().size();
int joinedChannelsCount = core.joinedChannels().size();