Convert “Sone locked” into EventBus-based event.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / CoreListenerManager.java
index 1e050ea..44fb67b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - CoreListenerManager.java - Copyright © 2010 David Roden
+ * Sone - CoreListenerManager.java - Copyright © 2010–2012 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,8 +18,6 @@
 package net.pterodactylus.sone.core;
 
 import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.util.event.AbstractListenerManager;
 import net.pterodactylus.util.version.Version;
@@ -46,156 +44,59 @@ public class CoreListenerManager extends AbstractListenerManager<Core, CoreListe
        //
 
        /**
-        * Notifies all listeners that the given Sone is now being rescued.
+        * Notifies all listeners that the given Sone was unlocked.
         *
-        * @see CoreListener#rescuingSone(Sone)
+        * @see CoreListener#soneUnlocked(Sone)
         * @param sone
-        *            The Sone that is being rescued
+        *            The Sone that was unlocked
         */
-       void fireRescuingSone(Sone sone) {
+       void fireSoneUnlocked(Sone sone) {
                for (CoreListener coreListener : getListeners()) {
-                       coreListener.rescuingSone(sone);
+                       coreListener.soneUnlocked(sone);
                }
        }
 
        /**
-        * Notifies all listeners that the given Sone was rescued.
+        * Notifies all listeners that the insert of the given Sone has started.
         *
-        * @see CoreListener#rescuedSone(Sone)
+        * @see SoneInsertListener#insertStarted(Sone)
         * @param sone
-        *            The Sone that was rescued
+        *            The Sone being inserted
         */
-       void fireRescuedSone(Sone sone) {
+       void fireSoneInserting(Sone sone) {
                for (CoreListener coreListener : getListeners()) {
-                       coreListener.rescuedSone(sone);
+                       coreListener.soneInserting(sone);
                }
        }
 
        /**
-        * Notifies all listeners that a new Sone has been discovered.
+        * Notifies all listeners that the insert of the given Sone has finished
+        * successfully.
         *
-        * @see CoreListener#newSoneFound(Sone)
+        * @see SoneInsertListener#insertFinished(Sone, long)
         * @param sone
-        *            The discovered sone
-        */
-       void fireNewSoneFound(Sone sone) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.newSoneFound(sone);
-               }
-       }
-
-       /**
-        * Notifies all listeners that a new post has been found.
-        *
-        * @see CoreListener#newPostFound(Post)
-        * @param post
-        *            The new post
+        *            The Sone that was inserted
+        * @param insertDuration
+        *            The insert duration (in milliseconds)
         */
-       void fireNewPostFound(Post post) {
+       void fireSoneInserted(Sone sone, long insertDuration) {
                for (CoreListener coreListener : getListeners()) {
-                       coreListener.newPostFound(post);
+                       coreListener.soneInserted(sone, insertDuration);
                }
        }
 
        /**
-        * Notifies all listeners that a new reply has been found.
+        * Notifies all listeners that the insert of the given Sone was aborted.
         *
-        * @see CoreListener#newReplyFound(Reply)
-        * @param reply
-        *            The new reply
-        */
-       void fireNewReplyFound(Reply reply) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.newReplyFound(reply);
-               }
-       }
-
-       /**
-        * Notifies all listeners that the given Sone is now marked as known.
-        *
-        * @see CoreListener#markSoneKnown(Sone)
+        * @see SoneInsertListener#insertStarted(Sone)
         * @param sone
-        *            The known Sone
-        */
-       void fireMarkSoneKnown(Sone sone) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.markSoneKnown(sone);
-               }
-       }
-
-       /**
-        * Notifies all listeners that the given post is now marked as known.
-        *
-        * @param post
-        *            The known post
-        */
-       void fireMarkPostKnown(Post post) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.markPostKnown(post);
-               }
-       }
-
-       /**
-        * Notifies all listeners that the given reply is now marked as known.
-        *
-        * @param reply
-        *            The known reply
-        */
-       void fireMarkReplyKnown(Reply reply) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.markReplyKnown(reply);
-               }
-       }
-
-       /**
-        * Notifies all listener that the given post was removed.
-        *
-        * @see CoreListener#postRemoved(Post)
-        * @param post
-        *            The removed post
-        */
-       void firePostRemoved(Post post) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.postRemoved(post);
-               }
-       }
-
-       /**
-        * Notifies all listener that the given reply was removed.
-        *
-        * @see CoreListener#replyRemoved(Reply)
-        * @param reply
-        *            The removed reply
-        */
-       void fireReplyRemoved(Reply reply) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.replyRemoved(reply);
-               }
-       }
-
-       /**
-        * Notifies all listeners that the given Sone was locked.
-        *
-        * @see CoreListener#soneLocked(Sone)
-        * @param sone
-        *            The Sone that was locked
-        */
-       void fireSoneLocked(Sone sone) {
-               for (CoreListener coreListener : getListeners()) {
-                       coreListener.soneLocked(sone);
-               }
-       }
-
-       /**
-        * Notifies all listeners that the given Sone was unlocked.
-        *
-        * @see CoreListener#soneUnlocked(Sone)
-        * @param sone
-        *            The Sone that was unlocked
+        *            The Sone being inserted
+        * @param cause
+        *            The cause for the abortion (may be {@code null}
         */
-       void fireSoneUnlocked(Sone sone) {
+       void fireSoneInsertAborted(Sone sone, Throwable cause) {
                for (CoreListener coreListener : getListeners()) {
-                       coreListener.soneUnlocked(sone);
+                       coreListener.soneInsertAborted(sone, cause);
                }
        }