Keep track of extra channels.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 06:24:27 +0000 (08:24 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 06:27:07 +0000 (08:27 +0200)
src/main/java/net/pterodactylus/xdcc/core/Core.java

index 96555e3..d253148 100644 (file)
@@ -78,6 +78,9 @@ public class Core extends AbstractIdleService {
        /** The channels that are currentlymonitored. */
        private final Collection<Channel> joinedChannels = Sets.newHashSet();
 
+       /** The channels that are joined but not configured. */
+       private final Collection<Channel> extraChannels = Sets.newHashSet();
+
        /** The current network connections. */
        private final Map<Network, Connection> networkConnections = Collections.synchronizedMap(Maps.<Network, Connection>newHashMap());
 
@@ -122,6 +125,15 @@ public class Core extends AbstractIdleService {
        }
 
        /**
+        * Returns all currently joined channels that are not configured.
+        *
+        * @return All currently joined but not configured channels
+        */
+       public Collection<Channel> extraChannels() {
+               return ImmutableSet.copyOf(extraChannels);
+       }
+
+       /**
         * Returns all currently known bots.
         *
         * @return All currently known bots
@@ -251,6 +263,9 @@ public class Core extends AbstractIdleService {
 
                        Optional<Channel> channel = getChannel(network.get(), channelJoined.channel());
                        if (!channel.isPresent()) {
+                               /* it’s an extra channel. */
+                               extraChannels.add(new Channel(network.get(), channelJoined.channel()));
+                               logger.info(String.format("Joined extra Channel %s on %s.", channelJoined.channel(), network.get().name()));
                                return;
                        }