From 6ca0a375e32d42c68b7c84222d66a049dff192f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 1 Jul 2011 09:04:11 +0200 Subject: [PATCH] Fire appropriate Sone insert events from core. --- .../java/net/pterodactylus/sone/core/Core.java | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index ea36aad..fb687f8 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -66,7 +66,7 @@ import freenet.keys.FreenetURI; * * @author David ‘Bombe’ Roden */ -public class Core implements IdentityListener, UpdateListener, SoneProvider, PostProvider { +public class Core implements IdentityListener, UpdateListener, SoneProvider, PostProvider, SoneInsertListener { /** * Enumeration for the possible states of a {@link Sone}. @@ -882,6 +882,7 @@ public class Core implements IdentityListener, UpdateListener, SoneProvider, Pos /* TODO - load posts ’n stuff */ localSones.put(ownIdentity.getId(), sone); final SoneInserter soneInserter = new SoneInserter(this, freenetInterface, sone); + soneInserter.addSoneInsertListener(this); soneInserters.put(sone, soneInserter); setSoneStatus(sone, SoneStatus.idle); loadSone(sone); @@ -1171,7 +1172,9 @@ public class Core implements IdentityListener, UpdateListener, SoneProvider, Pos return; } localSones.remove(sone.getId()); - soneInserters.remove(sone).stop(); + SoneInserter soneInserter = soneInserters.remove(sone); + soneInserter.removeSoneInsertListener(this); + soneInserter.stop(); } try { ((OwnIdentity) sone.getIdentity()).removeContext("Sone"); @@ -1732,6 +1735,7 @@ public class Core implements IdentityListener, UpdateListener, SoneProvider, Pos public void stop() { synchronized (localSones) { for (SoneInserter soneInserter : soneInserters.values()) { + soneInserter.removeSoneInsertListener(this); soneInserter.stop(); } for (Sone localSone : localSones.values()) { @@ -2087,6 +2091,33 @@ public class Core implements IdentityListener, UpdateListener, SoneProvider, Pos coreListenerManager.fireUpdateFound(version, releaseTime, latestEdition); } + // + // SONEINSERTLISTENER METHODS + // + + /** + * {@inheritDoc} + */ + public void insertStarted(Sone sone) { + coreListenerManager.fireSoneInserting(sone); + } + + /** + * {@inheritDoc} + */ + @Override + public void insertFinished(Sone sone, long insertDuration) { + coreListenerManager.fireSoneInserted(sone, insertDuration); + } + + /** + * {@inheritDoc} + */ + @Override + public void insertAborted(Sone sone, Throwable cause) { + coreListenerManager.fireSoneInsertAborted(sone, cause); + } + /** * Convenience interface for external classes that want to access the core’s * configuration. -- 2.7.4