09a5f2a43ede96b0a0480cd2255e3412fb86453e
[jFCPlib.git] / src / net / pterodactylus / fcp / FcpListener.java
1 /*
2  * jSite2 - FpcListener.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.fcp;
21
22 import java.util.EventListener;
23
24 /**
25  * Interface for objects that want to be notified on certain FCP events.
26  *
27  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28  * @version $Id$
29  */
30 public interface FcpListener extends EventListener {
31
32         /**
33          * Notifies a listener that a “NodeHello” message was received.
34          *
35          * @param fcpConnection
36          *            The connection that received the message
37          * @param nodeHello
38          *            The “NodeHello” message
39          */
40         public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello);
41
42         /**
43          * Notifies a listener that a “CloseConnectionDuplicateClientName” message
44          * was received.
45          *
46          * @param fcpConnection
47          *            The connection that received the message
48          * @param closeConnectionDuplicateClientName
49          *            The “CloseConnectionDuplicateClientName” message
50          */
51         public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName);
52
53         /**
54          * Notifies a listener that a “SSKKeypair” message was received.
55          *
56          * @param fcpConnection
57          *            The connection that received themessage
58          * @param sskKeypair
59          *            The “SSKKeypair” message
60          */
61         public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair);
62
63         /**
64          * Notifies a listener that a “Peer” message was received.
65          *
66          * @param fcpConnection
67          *            The connection that received the message
68          * @param peer
69          *            The “Peer” message
70          */
71         public void receivedPeer(FcpConnection fcpConnection, Peer peer);
72
73         /**
74          * Notifies a listener that an “EndListPeers” message was received.
75          *
76          * @param fcpConnection
77          *            The connection that recevied the message
78          * @param endListPeers
79          *            The “EndListPeers” message
80          */
81         public void receivedEndListPeers(FcpConnection fcpConnection, EndListPeers endListPeers);
82
83         /**
84          * Notifies a listener that a “PeerNote” message was received.
85          *
86          * @param fcpConnection
87          *            The connection that received the message
88          * @param peerNote
89          *            The “PeerNote” message
90          */
91         public void receivedPeerNote(FcpConnection fcpConnection, PeerNote peerNote);
92
93         /**
94          * Notifies a listener that an “EndListPeerNotes” message was received.
95          *
96          * @param fcpConnection
97          *            The connection that received the message
98          * @param endListPeerNotes
99          *            The “EndListPeerNotes” message
100          */
101         public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes);
102
103         /**
104          * Notifies a listener that a “PeerRemoved” message was received.
105          *
106          * @param fcpConnection
107          *            The connection that received the message
108          * @param peerRemoved
109          *            The “PeerRemoved” message
110          */
111         public void receivedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved);
112
113         /**
114          * Notifies a listener that a “NodeData” message was received.
115          *
116          * @param fcpConnection
117          *            The connection that received the message
118          * @param nodeData
119          *            The “NodeData” message
120          */
121         public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData);
122
123         /**
124          * Notifies a listener that a “TestDDAReply” message was received.
125          *
126          * @param fcpConnection
127          *            The connection that received the message
128          * @param testDDAReply
129          *            The “TestDDAReply” message
130          */
131         public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply);
132
133         /**
134          * Notifies a listener that a “TestDDAComplete” was received.
135          *
136          * @param fcpConnection
137          *            The connection that received the message
138          * @param testDDAComplete
139          *            The “TestDDAComplete” message
140          */
141         public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete);
142
143         /**
144          * Notifies a listener that a “PersistentGet” was received.
145          *
146          * @param fcpConnection
147          *            The connection that received the message
148          * @param persistentGet
149          *            The “PersistentGet” message
150          */
151         public void receivedPersistentGet(FcpConnection fcpConnection, PersistentGet persistentGet);
152
153         /**
154          * Notifies a listener that a “PersistentPut” was received.
155          *
156          * @param fcpConnection
157          *            The connection that received the message
158          * @param persistentPut
159          *            The “PersistentPut” message
160          */
161         public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut);
162
163         /**
164          * Notifies a listener that a “EndListPersistentRequests” was received.
165          *
166          * @param fcpConnection
167          *            The connection that received the message
168          * @param endListPersistentRequests
169          *            The “EndListPersistentRequests” message
170          */
171         public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests);
172
173         /**
174          * Notifies a listener that a “URIGenerated” was received.
175          *
176          * @param fcpConnection
177          *            The connection that received the message
178          * @param uriGenerated
179          *            The “URIGenerated” message
180          */
181         public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated);
182
183         /**
184          * Notifies a listener that a “DataFound” was received.
185          *
186          * @param fcpConnection
187          *            The connection that received the message
188          * @param dataFound
189          *            The “DataFound” message
190          */
191         public void receivedDataFound(FcpConnection fcpConnection, DataFound dataFound);
192
193         /**
194          * Notifies a listener that an “AllData” was received.
195          *
196          * @param fcpConnection
197          *            The connection that received the message
198          * @param allData
199          *            The “AllData” message
200          */
201         public void receivedAllData(FcpConnection fcpConnection, AllData allData);
202
203         /**
204          * Notifies a listener that a “SimpleProgress” was received.
205          *
206          * @param fcpConnection
207          *            The connection that received the message
208          * @param simpleProgress
209          *            The “SimpleProgress” message
210          */
211         public void receivedSimpleProgress(FcpConnection fcpConnection, SimpleProgress simpleProgress);
212
213         /**
214          * Notifies a listener that a “StartedCompression” was received.
215          *
216          * @param fcpConnection
217          *            The connection that received the message
218          * @param startedCompression
219          *            The “StartedCompression” message
220          */
221         public void receivedStartedCompression(FcpConnection fcpConnection, StartedCompression startedCompression);
222
223         /**
224          * Notifies a listener that a “FinishedCompression” was received.
225          *
226          * @param fcpConnection
227          *            The connection that received the message
228          * @param finishedCompression
229          *            The “FinishedCompression” message
230          */
231         public void receviedFinishedCompression(FcpConnection fcpConnection, FinishedCompression finishedCompression);
232
233         /**
234          * Notifies a listener that an “UnknownPeerNoteType” was received.
235          *
236          * @param fcpConnection
237          *            The connection that received the message
238          * @param unknownPeerNoteType
239          *            The “UnknownPeerNoteType” message
240          */
241         public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, UnknownPeerNoteType unknownPeerNoteType);
242
243         /**
244          * Notifies a listener that a “UnknownNodeIdentifier” message was received.
245          *
246          * @param fcpConnection
247          *            The connection that received the message
248          * @param unknownNodeIdentifier
249          *            The “UnknownNodeIdentifier” message
250          */
251         public void receivedUnknownNodeIdentifier(FcpConnection fcpConnection, UnknownNodeIdentifier unknownNodeIdentifier);
252
253         /**
254          * Notifies a listener that a “ConfigData” message was received.
255          *
256          * @param fcpConnection
257          *            The connection that received the message
258          * @param configData
259          *            The “ConfigData” message
260          */
261         public void receivedConfigData(FcpConnection fcpConnection, ConfigData configData);
262
263         /**
264          * Notifies a listener that a “GetFailed” message was recevied.
265          *
266          * @param fcpConnection
267          *            The connection that received the message
268          * @param getFailed
269          *            The “GetFailed” message
270          */
271         public void receivedGetFailed(FcpConnection fcpConnection, GetFailed getFailed);
272
273         /**
274          * Notifies a listener that a “PutFailed” message was received.
275          *
276          * @param fcpConnection
277          *            The connection that received the message
278          * @param putFailed
279          *            The “PutFailed” message
280          */
281         public void receivedPutFailed(FcpConnection fcpConnection, PutFailed putFailed);
282
283         /**
284          * Notifies a listener that an “IdentifierCollision” message was receied.
285          *
286          * @param fcpConnection
287          *            The connection that received the message
288          * @param identifierCollision
289          *            The “IdentifierCollision” message
290          */
291         public void receivedIdentifierCollision(FcpConnection fcpConnection, IdentifierCollision identifierCollision);
292
293         /**
294          * Notifies a listener that a “PersistentPutDir” message was received.
295          *
296          * @param fcpConnection
297          *            The connection that received the message
298          * @param persistentPutDir
299          *            The “PersistentPutDir” message
300          */
301         public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir);
302
303         /**
304          * Notifies a listener that a “PersistentRequestRemoved” message was
305          * received.
306          *
307          * @param fcpConnection
308          *            The connection that received the message
309          * @param persistentRequestRemoved
310          *            The “PersistentRequestRemoved” message
311          */
312         public void receivedPersistentRequestRemoved(FcpConnection fcpConnection, PersistentRequestRemoved persistentRequestRemoved);
313
314         /**
315          * Notifies a listener that a “SubscribedUSKUpdate” message was received.
316          *
317          * @param fcpConnection
318          *            The connection that recevied the message
319          * @param subscribedUSKUpdate
320          *            The “SubscribedUSKUpdate” message
321          */
322         public void receivedSubscribedUSKUpdate(FcpConnection fcpConnection, SubscribedUSKUpdate subscribedUSKUpdate);
323
324         /**
325          * Notifies a listener that a “PluginInfo” message was received.
326          *
327          * @param fcpConnection
328          *            The connection that received the message
329          * @param pluginInfo
330          *            The “PluginInfo” message
331          */
332         public void receivedPluginInfo(FcpConnection fcpConnection, PluginInfo pluginInfo);
333
334         /**
335          * Notifies a listener that an “FCPPluginReply“ message was received.
336          *
337          * @param fcpConnection
338          *            The connection that received the message
339          * @param fcpPluginReply
340          *            The “FCPPluginReply” message
341          */
342         public void receivedFCPPluginReply(FcpConnection fcpConnection, FCPPluginReply fcpPluginReply);
343
344         /**
345          * Notifies a listener that a “PersistentRequestModified” message was
346          * received.
347          *
348          * @param fcpConnection
349          *            The connection that received the message
350          * @param persistentRequestModified
351          *            The “PersistentRequestModified” message
352          */
353         public void receivedPersistentRequestModified(FcpConnection fcpConnection, PersistentRequestModified persistentRequestModified);
354
355         /**
356          * Notifies a listener that a “PutSuccessful” message was received.
357          *
358          * @param fcpConnection
359          *            The connection that received the message
360          * @param putSuccessful
361          *            The “PutSuccessful” message
362          */
363         public void receivedPutSuccessful(FcpConnection fcpConnection, PutSuccessful putSuccessful);
364
365         /**
366          * Notifies a listener that a “PutFetchable” message was received.
367          *
368          * @param fcpConnection
369          *            The connection that received the message
370          * @param putFetchable
371          *            The “PutFetchable” message
372          */
373         public void receivedPutFetchable(FcpConnection fcpConnection, PutFetchable putFetchable);
374
375         /**
376          * Notifies a listener that a “ProtocolError” was received.
377          *
378          * @param fcpConnection
379          *            The connection that received the message
380          * @param protocolError
381          *            The “ProtocolError” message
382          */
383         public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError);
384
385         /**
386          * Notifies a listener that a message has been received. This method is only
387          * called if {@link FcpConnection#handleMessage(FcpMessage)} does not
388          * recognize the message. Should that ever happen, please file a bug report!
389          *
390          * @param fcpConnection
391          *            The connection that received the message
392          * @param fcpMessage
393          *            The message that was received
394          */
395         public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage);
396
397         /**
398          * Notifies a listener that a connection was closed. A closed connection can
399          * be reestablished by calling {@link FcpConnection#connect()} on the same
400          * object again.
401          *
402          * @param fcpConnection
403          *            The connection that was closed.
404          * @param throwable
405          *            The exception that caused the disconnect, or <code>null</code>
406          *            if there was no exception
407          */
408         public void connectionClosed(FcpConnection fcpConnection, Throwable throwable);
409
410 }