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