Show whether a download has already started.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 18 Apr 2013 04:11:52 +0000 (06:11 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 18 Apr 2013 04:11:52 +0000 (06:11 +0200)
src/main/java/net/pterodactylus/xdcc/core/Core.java
src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java

index 9d5dcb7..33a22f8 100644 (file)
@@ -178,12 +178,12 @@ public class Core extends AbstractExecutionThreadService {
        }
 
        /**
-        * Returns the currently active DCC receivers.
+        * Returns all currently running downloads.
         *
-        * @return The currently active DCC receivers
+        * @return All currently running downloads
         */
-       public Collection<DccReceiver> dccReceivers() {
-               return dccReceivers;
+       public Collection<Download> downloads() {
+               return downloads.values();
        }
 
        //
index a530a1d..836f406 100644 (file)
@@ -118,8 +118,14 @@ public class CommandReader extends AbstractExecutionThreadService {
                                writeLine("End of Search.");
                        } else if (words[0].equalsIgnoreCase("dcc")) {
                                int counter = 0;
-                               for (DccReceiver dccReceiver : core.dccReceivers()) {
-                                       writer.write(String.format("[%d] %s (%s, ", counter++, dccReceiver.filename(), f(dccReceiver.size())));
+                               for (Download download : core.downloads()) {
+                                       DccReceiver dccReceiver = download.dccReceiver();
+                                       if (dccReceiver == null) {
+                                               /* download has not even started. */
+                                               writer.write(String.format("[%d] %s requested from %s (not started yet)\n", counter++, download.pack().name(), download.bot().name()));
+                                               continue;
+                                       }
+                                       writer.write(String.format("[%d] %s from %s (%s, ", counter++, dccReceiver.filename(), download.bot().name(), f(dccReceiver.size())));
                                        if (dccReceiver.isRunning()) {
                                                writer.write(String.format("%.1f%%, %s", dccReceiver.progress() * 100.0 / dccReceiver.size(), f(dccReceiver.currentRate())));
                                        } else {