implement node addition and removal events
[jSite2.git] / src / net / pterodactylus / jsite / core / CoreListener.java
index 812ce89..fb109d7 100644 (file)
@@ -21,7 +21,7 @@ package net.pterodactylus.jsite.core;
 
 /**
  * Interface definition for user interfaces.
- *
+ * 
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
  * @version $Id$
  */
@@ -33,7 +33,7 @@ public interface CoreListener {
 
        /**
         * Notifies a listener that loading the projects finished successfully.
-        *
+        * 
         * @param directory
         *            The directory the nodes were loaded from
         */
@@ -41,7 +41,7 @@ public interface CoreListener {
 
        /**
         * Notifies all listeners that loading the projects has failed.
-        *
+        * 
         * @param directory
         *            The directory the projects were tried to load from
         * @param throwable
@@ -52,7 +52,7 @@ public interface CoreListener {
        /**
         * Notifies a listener that the projects were successfully saved to the
         * given directory.
-        *
+        * 
         * @param directory
         *            The directory the projects were saved to
         */
@@ -60,7 +60,7 @@ public interface CoreListener {
 
        /**
         * Notifies a listener that saving the projects has failed.
-        *
+        * 
         * @param directory
         *            The directory the projects were to be saved to
         * @param throwable
@@ -74,7 +74,7 @@ public interface CoreListener {
 
        /**
         * Notifies a listener that the nodes were successfully loaded.
-        *
+        * 
         * @param directory
         *            The directory the nodes were loaded from
         */
@@ -82,7 +82,7 @@ public interface CoreListener {
 
        /**
         * Notifies a listener that loading the nodes has failed.
-        *
+        * 
         * @param directory
         *            The directory the nodes were loaded from
         * @param throwable
@@ -92,7 +92,7 @@ public interface CoreListener {
 
        /**
         * Notifies a listener that the nodes were successfully saved.
-        *
+        * 
         * @param directory
         *            The directory the nodes were saved to
         */
@@ -100,7 +100,7 @@ public interface CoreListener {
 
        /**
         * Notifies a listener that saving the nodes has failed.
-        *
+        * 
         * @param directory
         *            The directory the nodes were saved to
         * @param throwable
@@ -127,9 +127,28 @@ public interface CoreListener {
        //
 
        /**
+        * Notifies a listener that a node was added to the core.
+        * 
+        * @param node
+        *            The node that was added.
+        */
+       public void nodeAdded(Node node);
+
+       /**
+        * Notifies a listener that a node was removed from the core. Before a node
+        * is removed, it will be disconnected (and
+        * {@link #nodeDisconnected(Node, Throwable)} will be called).
+        * 
+        * @param node
+        *            The node that was removed
+        */
+       public void nodeRemoved(Node node);
+
+       /**
         * Notifies all listeners that the core started connecting to the given
-        * node.
-        *
+        * node. Before a node is connected, it will be added (and
+        * {@link #nodeAdded(Node)} will be called).
+        * 
         * @param node
         *            The node that is being connected
         */
@@ -137,7 +156,7 @@ public interface CoreListener {
 
        /**
         * Notifies all listeners that the core connected to the given node.
-        *
+        * 
         * @param node
         *            The node that is connected
         */
@@ -145,10 +164,48 @@ public interface CoreListener {
 
        /**
         * Notifies all listeners that the core disconnected from the given node.
-        *
+        * 
         * @param node
         *            The node that was diconnected
+        * @param throwable
+        *            The exception that caused the disconnect, or <code>null</code>
+        *            if there was no exception
+        */
+       public void nodeDisconnected(Node node, Throwable throwable);
+
+       //
+       // request stuff
+       //
+
+       /**
+        * Notifies a listener that a request was added to a node.
+        * 
+        * @param node
+        *            The node the request was added to
+        * @param request
+        *            The request that was added
+        */
+       public void requestAdded(Node node, Request request);
+
+       /**
+        * Notifies a listener that a request made some progress.
+        * 
+        * @param request
+        *            The request that made the progress
+        * @param totalBlocks
+        *            The total number of blocks
+        * @param requiredBlocks
+        *            The number of required blocks
+        * @param successfulBlocks
+        *            The number of successful blocks
+        * @param failedBlocks
+        *            The number of failed blocks
+        * @param fatallyFailedBlocks
+        *            The number of fatally failed blocks
+        * @param finalizedTotal
+        *            <code>true</code> if the number of total blocks is
+        *            finalized, <code>false</code> if it is not
         */
-       public void nodeDisconnected(Node node);
+       public void requestProgressed(Request request, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
 
 }