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;
/** 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;
/** Interface to freenet. */
private final FreenetInterface freenetInterface;
- /** The notification manager. */
- private final NotificationManager notificationManager = new NotificationManager();
-
/** The Sone downloader. */
private final SoneDownloader soneDownloader;
}
//
+ // 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
//
}
/**
- * Returns the notification manager.
- *
- * @return The notification manager
- */
- public NotificationManager getNotifications() {
- return notificationManager;
- }
-
- /**
* Returns the status of the given Sone.
*
* @param sone
synchronized (newSones) {
boolean isNew = !knownSones.contains(sone.getId()) && newSones.remove(sone.getId());
knownSones.add(sone.getId());
+ if (isNew) {
+ coreListenerManager.fireMarkSoneKnown(sone);
+ }
return isNew;
}
}
synchronized (newPosts) {
boolean isNew = !knownPosts.contains(postId) && newPosts.remove(postId);
knownPosts.add(postId);
+ if (isNew) {
+ coreListenerManager.fireMarkPostKnown(getPost(postId));
+ }
return isNew;
}
}
synchronized (newReplies) {
boolean isNew = !knownReplies.contains(replyId) && newReplies.remove(replyId);
knownReplies.add(replyId);
+ if (isNew) {
+ coreListenerManager.fireMarkReplyKnown(getReply(replyId));
+ }
return isNew;
}
}
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);
}
synchronized (newPosts) {
for (Post post : sone.getPosts()) {
- if (!storedSone.getPosts().contains(post) && !knownSones.contains(post.getId())) {
+ if (!storedSone.getPosts().contains(post) && !knownPosts.contains(post.getId())) {
newPosts.add(post.getId());
}
posts.put(post.getId(), post);
}
synchronized (newReplies) {
for (Reply reply : sone.getReplies()) {
- if (!storedSone.getReplies().contains(reply) && !knownSones.contains(reply.getId())) {
+ if (!storedSone.getReplies().contains(reply) && !knownReplies.contains(reply.getId())) {
newReplies.add(reply.getId());
}
replies.put(reply.getId(), reply);