From 7efea8c164769901ab87ae77864935d2351942d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 11 Apr 2008 09:59:29 +0000 Subject: [PATCH] add UnknownPeerNoteType git-svn-id: http://trooper/svn/projects/jSite/trunk@713 c3eda9e8-030b-0410-8277-bc7414b0a119 --- TODO | 1 - src/net/pterodactylus/util/fcp/FcpAdapter.java | 76 ++++++++++------------ src/net/pterodactylus/util/fcp/FcpConnection.java | 15 +++++ src/net/pterodactylus/util/fcp/FcpListener.java | 10 +++ .../util/fcp/UnknownPeerNoteType.java | 51 +++++++++++++++ 5 files changed, 110 insertions(+), 43 deletions(-) create mode 100644 src/net/pterodactylus/util/fcp/UnknownPeerNoteType.java diff --git a/TODO b/TODO index 2bcf015..8863f31 100644 --- a/TODO +++ b/TODO @@ -21,7 +21,6 @@ RemovePersistentRequest SubscribedUSKUpdate SubscribeUSK UnknownNodeIdentifier -UnknownPeerNoteType ManageNodesDialog * prevent deletion of currently connected nodes diff --git a/src/net/pterodactylus/util/fcp/FcpAdapter.java b/src/net/pterodactylus/util/fcp/FcpAdapter.java index fd4fb76..8348c44 100644 --- a/src/net/pterodactylus/util/fcp/FcpAdapter.java +++ b/src/net/pterodactylus/util/fcp/FcpAdapter.java @@ -12,64 +12,58 @@ package net.pterodactylus.util.fcp; public class FcpAdapter implements FcpListener { /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedNodeHello(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.NodeHello) + * @see FcpListener#receivedNodeHello(FcpConnection, NodeHello) */ public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedCloseConnectionDuplicateClientName(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.CloseConnectionDuplicateClientName) + * @see FcpListener#receivedCloseConnectionDuplicateClientName(FcpConnection, + * CloseConnectionDuplicateClientName) */ public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedSSKKeypair(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.SSKKeypair) + * @see FcpListener#receivedSSKKeypair(FcpConnection, SSKKeypair) */ public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedPeer(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.Peer) + * @see FcpListener#receivedPeer(FcpConnection, Peer) */ public void receivedPeer(FcpConnection fcpConnection, Peer peer) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedEndListPeers(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.EndListPeers) + * @see FcpListener#receivedEndListPeers(FcpConnection, EndListPeers) */ public void receivedEndListPeers(FcpConnection fcpConnection, EndListPeers endListPeers) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedPeerNote(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.PeerNote) + * @see FcpListener#receivedPeerNote(FcpConnection, PeerNote) */ public void receivedPeerNote(FcpConnection fcpConnection, PeerNote peerNote) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedEndListPeerNotes(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.EndListPeerNotes) + * @see FcpListener#receivedEndListPeerNotes(FcpConnection, + * EndListPeerNotes) */ public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedPeerRemoved(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.PeerRemoved) + * @see FcpListener#receivedPeerRemoved(FcpConnection, PeerRemoved) */ public void receivedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved) { /* empty. */ @@ -78,8 +72,7 @@ public class FcpAdapter implements FcpListener { /** * {@inheritDoc} * - * @see FcpListener#receivedNodeData(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.NodeData) + * @see FcpListener#receivedNodeData(FcpConnection, NodeData) */ public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData) { /* empty. */ @@ -88,48 +81,43 @@ public class FcpAdapter implements FcpListener { /** * {@inheritDoc} * - * @see net.pterodactylus.util.fcp.FcpListener#receivedTestDDAReply(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.TestDDAReply) + * @see FcpListener#receivedTestDDAReply(FcpConnection, TestDDAReply) */ public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedTestDDAComplete(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.TestDDAComplete) + * @see FcpListener#receivedTestDDAComplete(FcpConnection, TestDDAComplete) */ public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedPersistentGet(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.PersistentGet) + * @see FcpListener#receivedPersistentGet(FcpConnection, PersistentGet) */ public void receivedPersistentGet(FcpConnection fcpConnection, PersistentGet persistentGet) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedPersistentPut(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.PersistentPut) + * @see FcpListener#receivedPersistentPut(FcpConnection, PersistentPut) */ public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedEndListPersistentRequests(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.EndListPersistentRequests) + * @see FcpListener#receivedEndListPersistentRequests(FcpConnection, + * EndListPersistentRequests) */ public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedURIGenerated(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.URIGenerated) + * @see FcpListener#receivedURIGenerated(FcpConnection, URIGenerated) */ public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated) { /* empty. */ @@ -143,48 +131,52 @@ public class FcpAdapter implements FcpListener { } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedAllData(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.AllData) + * @see FcpListener#receivedAllData(FcpConnection, AllData) */ public void receivedAllData(FcpConnection fcpConnection, AllData allData) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedSimpleProgress(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.SimpleProgress) + * @see FcpListener#receivedSimpleProgress(FcpConnection, SimpleProgress) */ public void receivedSimpleProgress(FcpConnection fcpConnection, SimpleProgress simpleProgress) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedStartedCompression(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.StartedCompression) + * @see FcpListener#receivedStartedCompression(FcpConnection, + * StartedCompression) */ public void receivedStartedCompression(FcpConnection fcpConnection, StartedCompression startedCompression) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receviedFinishedCompression(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.FinishedCompression) + * @see FcpListener#receviedFinishedCompression(FcpConnection, + * FinishedCompression) */ public void receviedFinishedCompression(FcpConnection fcpConnection, FinishedCompression finishedCompression) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedProtocolError(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.ProtocolError) + * @see FcpListener#receivedUnknownPeerNoteType(FcpConnection, + * UnknownPeerNoteType) + */ + public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, UnknownPeerNoteType unknownPeerNoteType) { + /* empty. */ + } + + /** + * @see FcpListener#receivedProtocolError(FcpConnection, ProtocolError) */ public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError) { /* empty. */ } /** - * @see net.pterodactylus.util.fcp.FcpListener#receivedMessage(net.pterodactylus.util.fcp.FcpConnection, - * net.pterodactylus.util.fcp.FcpMessage) + * @see FcpListener#receivedMessage(FcpConnection, FcpMessage) */ public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage) { /* empty. */ diff --git a/src/net/pterodactylus/util/fcp/FcpConnection.java b/src/net/pterodactylus/util/fcp/FcpConnection.java index fd6add0..9a83f4e 100644 --- a/src/net/pterodactylus/util/fcp/FcpConnection.java +++ b/src/net/pterodactylus/util/fcp/FcpConnection.java @@ -402,6 +402,19 @@ public class FcpConnection { } /** + * Notifies all listeners that an “UnknownPeerNoteType” message was + * received. + * + * @param unknownPeerNoteType + * The “UnknownPeerNoteType” message + */ + private void fireReceivedUnknownPeerNoteType(UnknownPeerNoteType unknownPeerNoteType) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedUnknownPeerNoteType(this, unknownPeerNoteType); + } + } + + /** * Notifies all listeners that a “ProtocolError” message was received. * * @param protocolError @@ -533,6 +546,8 @@ public class FcpConnection { fireReceivedSSKKeypair(new SSKKeypair(fcpMessage)); } else if ("PeerRemoved".equals(messageName)) { fireReceivedPeerRemoved(new PeerRemoved(fcpMessage)); + } else if ("UnknownPeerNoteType".equals(messageName)) { + fireReceivedUnknownPeerNoteType(new UnknownPeerNoteType(fcpMessage)); } else if ("NodeData".equals(messageName)) { fireReceivedNodeData(new NodeData(fcpMessage)); } else if ("TestDDAReply".equals(messageName)) { diff --git a/src/net/pterodactylus/util/fcp/FcpListener.java b/src/net/pterodactylus/util/fcp/FcpListener.java index a9c3809..93e3b8b 100644 --- a/src/net/pterodactylus/util/fcp/FcpListener.java +++ b/src/net/pterodactylus/util/fcp/FcpListener.java @@ -231,6 +231,16 @@ public interface FcpListener extends EventListener { public void receviedFinishedCompression(FcpConnection fcpConnection, FinishedCompression finishedCompression); /** + * Notifies a listener that an “UnknownPeerNoteType” was received. + * + * @param fcpConnection + * The connection that received the message + * @param unknownPeerNoteType + * The “UnknownPeerNoteType” message + */ + public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, UnknownPeerNoteType unknownPeerNoteType); + + /** * Notifies a listener that a “ProtocolError” was received. * * @param fcpConnection diff --git a/src/net/pterodactylus/util/fcp/UnknownPeerNoteType.java b/src/net/pterodactylus/util/fcp/UnknownPeerNoteType.java new file mode 100644 index 0000000..bd3f663 --- /dev/null +++ b/src/net/pterodactylus/util/fcp/UnknownPeerNoteType.java @@ -0,0 +1,51 @@ +/* + * jSite2 - UnknownPeerNoteType.java - + * Copyright \u00A9 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; + +/** + * The ”UnknownPeerNoteType” message signals the client that the type of peer + * note used in a previous {@link ModifyPeerNote} is unknown. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + * @version $Id$ + */ +public class UnknownPeerNoteType extends BaseMessage { + + /** + * Creates a new ”UnknownPeerNoteType” message that wraps the received + * message. + * + * @param receivedMessage + * The received message + */ + public UnknownPeerNoteType(FcpMessage receivedMessage) { + super(receivedMessage); + } + + /** + * Returns the type of peer note that is unkown. + * + * @return The unknown peer note type + */ + public int getPeerNoteType() { + return FcpUtils.safeParseInt(getField("PeerNoteType")); + } + +} -- 2.7.4