X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=2894945ee656d8e3bc5f49563551924d20fcf95b;hb=a6601fb1de49f42c26eccb9dff5c07a17feceafc;hp=5a80f3154529682e65e85a9e96852ba9461af59b;hpb=abe29a1d19532ea1c13024cf78c5faf388287faf;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 5a80f31..2894945 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -44,7 +44,6 @@ import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; import net.pterodactylus.util.logging.Logging; -import net.pterodactylus.util.notify.NotificationManager; import net.pterodactylus.util.number.Numbers; import freenet.keys.FreenetURI; @@ -81,6 +80,9 @@ public class Core implements IdentityListener { /** The options. */ private final Options options = new Options(); + /** The core listener manager. */ + private final CoreListenerManager coreListenerManager = new CoreListenerManager(this); + /** The configuration. */ private final Configuration configuration; @@ -90,9 +92,6 @@ public class Core implements IdentityListener { /** Interface to freenet. */ private final FreenetInterface freenetInterface; - /** The notification manager. */ - private final NotificationManager notificationManager = new NotificationManager(); - /** The Sone downloader. */ private final SoneDownloader soneDownloader; @@ -156,6 +155,30 @@ public class Core implements IdentityListener { } // + // LISTENER MANAGEMENT + // + + /** + * Adds a new core listener. + * + * @param coreListener + * The listener to add + */ + public void addCoreListener(CoreListener coreListener) { + coreListenerManager.addListener(coreListener); + } + + /** + * Removes a core listener. + * + * @param coreListener + * The listener to remove + */ + public void removeCoreListener(CoreListener coreListener) { + coreListenerManager.removeListener(coreListener); + } + + // // ACCESSORS // @@ -178,15 +201,6 @@ public class Core implements IdentityListener { } /** - * Returns the notification manager. - * - * @return The notification manager - */ - public NotificationManager getNotifications() { - return notificationManager; - } - - /** * Returns the status of the given Sone. * * @param sone @@ -665,7 +679,13 @@ public class Core implements IdentityListener { sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), (long) 0)); if (newSone) { synchronized (newSones) { - newSones.add(sone.getId()); + newSone = !knownSones.contains(sone.getId()); + if (newSone) { + newSones.add(sone.getId()); + } + } + if (newSone) { + coreListenerManager.fireNewSoneFound(sone); } } remoteSones.put(identity.getId(), sone);