add PersistentRequestRemoved
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Apr 2008 15:54:11 +0000 (15:54 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Apr 2008 15:54:11 +0000 (15:54 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@729 c3eda9e8-030b-0410-8277-bc7414b0a119

TODO
src/net/pterodactylus/util/fcp/FcpAdapter.java
src/net/pterodactylus/util/fcp/FcpConnection.java
src/net/pterodactylus/util/fcp/FcpListener.java
src/net/pterodactylus/util/fcp/PersistentRequestRemoved.java [new file with mode: 0644]

diff --git a/TODO b/TODO
index b036859..7ffd8e8 100644 (file)
--- a/TODO
+++ b/TODO
@@ -6,7 +6,6 @@ GetRequestStatus
 ModifyConfig (since 1027)
 ModifyPersistentRequest
 PersistentRequestModified (since 1016)
-PersistentRequestRemoved (since 1016)
 PluginInfo (since 1075)
 PutFetchable
 PutSuccessful
index e7afce4..4fe3a07 100644 (file)
@@ -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. */
        }
index fa3673d..420e5ea 100644 (file)
@@ -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)) {
index b4b1094..bdbd6ca 100644 (file)
@@ -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 (file)
index 0000000..7c7c63c
--- /dev/null
@@ -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 &lt;bombe@freenetproject.org&gt;
+ * @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 <code>true</code> if the request was removed from the global
+        *         queue, <code>false</code> if it was removed from the
+        *         client-local queue
+        */
+       public boolean isGlobal() {
+               return Boolean.valueOf(getField("Global"));
+       }
+
+}