Move time formatting to command reader; use function to calculate the remaining trans...
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / core / Core.java
index b157851..24d9c38 100644 (file)
@@ -70,6 +70,7 @@ import net.pterodactylus.xdcc.data.Network;
 import net.pterodactylus.xdcc.data.Pack;
 import net.pterodactylus.xdcc.data.Server;
 
+import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
@@ -168,6 +169,20 @@ public class Core extends AbstractExecutionThreadService {
        }
 
        /**
+        * Returns all connected networks.
+        *
+        * @return All connected networks
+        */
+       public Collection<Network> connectedNetworks() {
+               return Lists.newArrayList(Optional.presentInstances(FluentIterable.from(networkConnections.values()).transform(new Function<Connection, Optional<Network>>() {
+                       @Override
+                       public Optional<Network> apply(Connection connection) {
+                               return getNetwork(connection);
+                       }
+               })));
+       }
+
+       /**
         * Returns all configured channels. Due to various circumstances, configured
         * channels might not actually be joined.
         *
@@ -489,6 +504,7 @@ public class Core extends AbstractExecutionThreadService {
         * @param connectionFailed
         *              The connection failed event
         */
+       @Subscribe
        public void connectionFailed(ConnectionFailed connectionFailed) {
                removeConnection(connectionFailed.connection());
        }