X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FCoreListener.java;h=4da2ec84476dc4104a21e318fa530505f0e881ed;hb=c63257e8cc0ba1a5aca9364b22171abe7279d479;hp=7ded200c1b4e48402f1dceb138061aecc6eedb3b;hpb=c7561c631f4bbb94ee0ac9047e953ce56f1df8bb;p=jSite2.git
diff --git a/src/net/pterodactylus/jsite/core/CoreListener.java b/src/net/pterodactylus/jsite/core/CoreListener.java
index 7ded200..4da2ec8 100644
--- a/src/net/pterodactylus/jsite/core/CoreListener.java
+++ b/src/net/pterodactylus/jsite/core/CoreListener.java
@@ -23,15 +23,22 @@ package net.pterodactylus.jsite.core;
* Interface definition for user interfaces.
*
* @author David âBombeâ Roden <bombe@freenetproject.org>
- * @version $Id$
*/
public interface CoreListener {
//
- // configuration stuff
+ // project configuration
//
/**
+ * Notifies a listener that loading the projects finished successfully.
+ *
+ * @param directory
+ * The directory the nodes were loaded from
+ */
+ public void loadingProjectsDone(String directory);
+
+ /**
* Notifies all listeners that loading the projects has failed.
*
* @param directory
@@ -60,6 +67,72 @@ public interface CoreListener {
*/
public void savingProjectsFailed(String directory, Throwable throwable);
+ /**
+ * Notifies a listener that the given project was added.
+ *
+ * @param project
+ * The project that was added.
+ */
+ public void projectAdded(Project project);
+
+ /**
+ * Notifies a listener that a project was cloned.
+ *
+ * @param clonedProject
+ * The clones project
+ * @param projectClone
+ * The clone of the project
+ */
+ public void projectCloned(Project clonedProject, Project projectClone);
+
+ /**
+ * Notifies a listener that the given project was removed.
+ *
+ * @param project
+ * The project that was removed.
+ */
+ public void projectRemoved(Project project);
+
+ //
+ // node configuration
+ //
+
+ /**
+ * Notifies a listener that the nodes were successfully loaded.
+ *
+ * @param directory
+ * The directory the nodes were loaded from
+ */
+ public void loadingNodesDone(String directory);
+
+ /**
+ * Notifies a listener that loading the nodes has failed.
+ *
+ * @param directory
+ * The directory the nodes were loaded from
+ * @param throwable
+ * The exception that occured while loading the nodes
+ */
+ public void loadingNodesFailed(String directory, Throwable throwable);
+
+ /**
+ * Notifies a listener that the nodes were successfully saved.
+ *
+ * @param directory
+ * The directory the nodes were saved to
+ */
+ public void savingNodesDone(String directory);
+
+ /**
+ * Notifies a listener that saving the nodes has failed.
+ *
+ * @param directory
+ * The directory the nodes were saved to
+ * @param throwable
+ * The exception that occured while saving the nodes
+ */
+ public void savingNodesFailed(String directory, Throwable throwable);
+
//
// basic core functionality
//
@@ -79,8 +152,27 @@ 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
@@ -96,11 +188,79 @@ public interface CoreListener {
public void nodeConnected(Node node);
/**
+ * Notifies a listener that a connection to a node has failed.
+ *
+ * @param node
+ * The node that could not be connected
+ * @param cause
+ * The cause of the failure
+ */
+ public void nodeConnectionFailed(Node node, Throwable cause);
+
+ /**
* 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 null
+ * if there was no exception
+ */
+ public void nodeDisconnected(Node node, Throwable throwable);
+
+ //
+ // project insertion stuff
+ //
+
+ /**
+ * Notifies a listener that a project insert started.
+ *
+ * @param project
+ * The project that is now inserting
+ */
+ public void projectInsertStarted(Project project);
+
+ /**
+ * Notifies a listener that a project insert made progress.
+ *
+ * @param project
+ * The project that made progress
+ * @param totalBlocks
+ * The number of total blocks
+ * @param requiredBlocks
+ * The number of required blocks
+ * @param successfulBlocks
+ * The number of successfully inserted blocks
+ * @param failedBlocks
+ * The number of blocks that could not be inserted
+ * @param fatallyFailedBlocks
+ * The number of blocks that can not be inserted even with
+ * retries
+ * @param finalizedTotal
+ * true
if the number of total blocks is already
+ * finalized, false
otherwise
+ */
+ public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
+
+ /**
+ * Notifies a listener that a project insert has generated a URI.
+ *
+ * @param project
+ * The project that generated a URI
+ * @param uri
+ * The URI that was generated
+ */
+ public void projectInsertGeneratedURI(Project project, String uri);
+
+ /**
+ * Notifies a listener that a project insert has finished.
+ *
+ * @param project
+ * The project that has finished
+ * @param success
+ * true
if the project was inserted successfully,
+ * false
otherwise
*/
- public void nodeDisconnected(Node node);
+ public void projectInsertFinished(Project project, boolean success);
}