From: David ‘Bombe’ Roden Date: Sat, 12 Apr 2008 15:54:11 +0000 (+0000) Subject: add PersistentRequestRemoved X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=54aaf29fbe1e4e2073ea5c76b30936d07eabed32;p=jSite2.git add PersistentRequestRemoved git-svn-id: http://trooper/svn/projects/jSite/trunk@729 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/TODO b/TODO index b036859..7ffd8e8 100644 --- a/TODO +++ b/TODO @@ -6,7 +6,6 @@ GetRequestStatus ModifyConfig (since 1027) ModifyPersistentRequest PersistentRequestModified (since 1016) -PersistentRequestRemoved (since 1016) PluginInfo (since 1075) PutFetchable PutSuccessful diff --git a/src/net/pterodactylus/util/fcp/FcpAdapter.java b/src/net/pterodactylus/util/fcp/FcpAdapter.java index e7afce4..4fe3a07 100644 --- a/src/net/pterodactylus/util/fcp/FcpAdapter.java +++ b/src/net/pterodactylus/util/fcp/FcpAdapter.java @@ -207,6 +207,13 @@ public class FcpAdapter implements FcpListener { /** * {@inheritDoc} */ + public void receivedPersistentRequestRemoved(FcpConnection fcpConnection, PersistentRequestRemoved persistentRequestRemoved) { + /* empty. */ + } + + /** + * {@inheritDoc} + */ public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError) { /* empty. */ } diff --git a/src/net/pterodactylus/util/fcp/FcpConnection.java b/src/net/pterodactylus/util/fcp/FcpConnection.java index fa3673d..420e5ea 100644 --- a/src/net/pterodactylus/util/fcp/FcpConnection.java +++ b/src/net/pterodactylus/util/fcp/FcpConnection.java @@ -500,6 +500,19 @@ public class FcpConnection { } /** + * Notifies all listeners that a “PersistentRequestRemoved” message was + * received. + * + * @param persistentRequestRemoved + * The “PersistentRequestRemoved” message + */ + private void fireReceivedPersistentRequestRemoved(PersistentRequestRemoved persistentRequestRemoved) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedPersistentRequestRemoved(this, persistentRequestRemoved); + } + } + + /** * Notifies all listeners that a “ProtocolError” message was received. * * @param protocolError @@ -639,6 +652,8 @@ public class FcpConnection { fireReceivedSSKKeypair(new SSKKeypair(fcpMessage)); } else if ("PeerRemoved".equals(messageName)) { fireReceivedPeerRemoved(new PeerRemoved(fcpMessage)); + } else if ("PersistentRequestRemoved".equals(messageName)) { + fireReceivedPersistentRequestRemoved(new PersistentRequestRemoved(fcpMessage)); } else if ("UnknownPeerNoteType".equals(messageName)) { fireReceivedUnknownPeerNoteType(new UnknownPeerNoteType(fcpMessage)); } else if ("UnknownNodeIdentifier".equals(messageName)) { diff --git a/src/net/pterodactylus/util/fcp/FcpListener.java b/src/net/pterodactylus/util/fcp/FcpListener.java index b4b1094..bdbd6ca 100644 --- a/src/net/pterodactylus/util/fcp/FcpListener.java +++ b/src/net/pterodactylus/util/fcp/FcpListener.java @@ -301,6 +301,17 @@ public interface FcpListener extends EventListener { public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir); /** + * Notifies a listener that a “PersistentRequestRemoved” message was + * received. + * + * @param fcpConnection + * The connection that received the message + * @param persistentRequestRemoved + * The “PersistentRequestRemoved” message + */ + public void receivedPersistentRequestRemoved(FcpConnection fcpConnection, PersistentRequestRemoved persistentRequestRemoved); + + /** * Notifies a listener that a “ProtocolError” was received. * * @param fcpConnection diff --git a/src/net/pterodactylus/util/fcp/PersistentRequestRemoved.java b/src/net/pterodactylus/util/fcp/PersistentRequestRemoved.java new file mode 100644 index 0000000..7c7c63c --- /dev/null +++ b/src/net/pterodactylus/util/fcp/PersistentRequestRemoved.java @@ -0,0 +1,62 @@ +/* + * jSite2 - PersistentRequestRemoved.java - + * Copyright © 2008 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package net.pterodactylus.util.fcp; + +/** + * A “PersistentRequestRemoved” message signals that a persistent request was + * removed from either the global or the client-local queue. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + * @version $Id$ + */ +public class PersistentRequestRemoved extends BaseMessage { + + /** + * Creates a new “PersistentRequestRemoved” message that wraps the received + * message. + * + * @param receivedMessage + * The received message + */ + PersistentRequestRemoved(FcpMessage receivedMessage) { + super(receivedMessage); + } + + /** + * Returns the identifier of the request. + * + * @return The identifier of the request + */ + public String getIdentifier() { + return getField("Identifier"); + } + + /** + * Returns whether the request was removed from the global queue. + * + * @return true if the request was removed from the global + * queue, false if it was removed from the + * client-local queue + */ + public boolean isGlobal() { + return Boolean.valueOf(getField("Global")); + } + +}