2efb24e7460385be99b4874e2b4ab78d36a62538
[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  */
29 public interface FcpListener extends EventListener {
30
31         /**
32          * Notifies a listener that a “NodeHello” message was received.
33          *
34          * @param fcpConnection
35          *            The connection that received the message
36          * @param nodeHello
37          *            The “NodeHello” message
38          */
39         public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello);
40
41         /**
42          * Notifies a listener that a “CloseConnectionDuplicateClientName” message
43          * was received.
44          *
45          * @param fcpConnection
46          *            The connection that received the message
47          * @param closeConnectionDuplicateClientName
48          *            The “CloseConnectionDuplicateClientName” message
49          */
50         public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName);
51
52         /**
53          * Notifies a listener that a “SSKKeypair” message was received.
54          *
55          * @param fcpConnection
56          *            The connection that received themessage
57          * @param sskKeypair
58          *            The “SSKKeypair” message
59          */
60         public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair);
61
62         /**
63          * Notifies a listener that a “Peer” message was received.
64          *
65          * @param fcpConnection
66          *            The connection that received the message
67          * @param peer
68          *            The “Peer” message
69          */
70         public void receivedPeer(FcpConnection fcpConnection, Peer peer);
71
72         /**
73          * Notifies a listener that an “EndListPeers” message was received.
74          *
75          * @param fcpConnection
76          *            The connection that recevied the message
77          * @param endListPeers
78          *            The “EndListPeers” message
79          */
80         public void receivedEndListPeers(FcpConnection fcpConnection, EndListPeers endListPeers);
81
82         /**
83          * Notifies a listener that a “PeerNote” message was received.
84          *
85          * @param fcpConnection
86          *            The connection that received the message
87          * @param peerNote
88          *            The “PeerNote” message
89          */
90         public void receivedPeerNote(FcpConnection fcpConnection, PeerNote peerNote);
91
92         /**
93          * Notifies a listener that an “EndListPeerNotes” message was received.
94          *
95          * @param fcpConnection
96          *            The connection that received the message
97          * @param endListPeerNotes
98          *            The “EndListPeerNotes” message
99          */
100         public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes);
101
102         /**
103          * Notifies a listener that a “PeerRemoved” message was received.
104          *
105          * @param fcpConnection
106          *            The connection that received the message
107          * @param peerRemoved
108          *            The “PeerRemoved” message
109          */
110         public void receivedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved);
111
112         /**
113          * Notifies a listener that a “NodeData” message was received.
114          *
115          * @param fcpConnection
116          *            The connection that received the message
117          * @param nodeData
118          *            The “NodeData” message
119          */
120         public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData);
121
122         /**
123          * Notifies a listener that a “TestDDAReply” message was received.
124          *
125          * @param fcpConnection
126          *            The connection that received the message
127          * @param testDDAReply
128          *            The “TestDDAReply” message
129          */
130         public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply);
131
132         /**
133          * Notifies a listener that a “TestDDAComplete” was received.
134          *
135          * @param fcpConnection
136          *            The connection that received the message
137          * @param testDDAComplete
138          *            The “TestDDAComplete” message
139          */
140         public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete);
141
142         /**
143          * Notifies a listener that a “PersistentGet” was received.
144          *
145          * @param fcpConnection
146          *            The connection that received the message
147          * @param persistentGet
148          *            The “PersistentGet” message
149          */
150         public void receivedPersistentGet(FcpConnection fcpConnection, PersistentGet persistentGet);
151
152         /**
153          * Notifies a listener that a “PersistentPut” was received.
154          *
155          * @param fcpConnection
156          *            The connection that received the message
157          * @param persistentPut
158          *            The “PersistentPut” message
159          */
160         public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut);
161
162         /**
163          * Notifies a listener that a “EndListPersistentRequests” was received.
164          *
165          * @param fcpConnection
166          *            The connection that received the message
167          * @param endListPersistentRequests
168          *            The “EndListPersistentRequests” message
169          */
170         public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests);
171
172         /**
173          * Notifies a listener that a “URIGenerated” was received.
174          *
175          * @param fcpConnection
176          *            The connection that received the message
177          * @param uriGenerated
178          *            The “URIGenerated” message
179          */
180         public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated);
181
182         /**
183          * Notifies a listener that a “DataFound” was received.
184          *
185          * @param fcpConnection
186          *            The connection that received the message
187          * @param dataFound
188          *            The “DataFound” message
189          */
190         public void receivedDataFound(FcpConnection fcpConnection, DataFound dataFound);
191
192         /**
193          * Notifies a listener that an “AllData” was received.
194          *
195          * @param fcpConnection
196          *            The connection that received the message
197          * @param allData
198          *            The “AllData” message
199          */
200         public void receivedAllData(FcpConnection fcpConnection, AllData allData);
201
202         /**
203          * Notifies a listener that a “SimpleProgress” was received.
204          *
205          * @param fcpConnection
206          *            The connection that received the message
207          * @param simpleProgress
208          *            The “SimpleProgress” message
209          */
210         public void receivedSimpleProgress(FcpConnection fcpConnection, SimpleProgress simpleProgress);
211
212         /**
213          * Notifies a listener that a “StartedCompression” was received.
214          *
215          * @param fcpConnection
216          *            The connection that received the message
217          * @param startedCompression
218          *            The “StartedCompression” message
219          */
220         public void receivedStartedCompression(FcpConnection fcpConnection, StartedCompression startedCompression);
221
222         /**
223          * Notifies a listener that a “FinishedCompression” was received.
224          *
225          * @param fcpConnection
226          *            The connection that received the message
227          * @param finishedCompression
228          *            The “FinishedCompression” message
229          */
230         public void receivedFinishedCompression(FcpConnection fcpConnection, FinishedCompression finishedCompression);
231
232         /**
233          * Notifies a listener that an “UnknownPeerNoteType” was received.
234          *
235          * @param fcpConnection
236          *            The connection that received the message
237          * @param unknownPeerNoteType
238          *            The “UnknownPeerNoteType” message
239          */
240         public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, UnknownPeerNoteType unknownPeerNoteType);
241
242         /**
243          * Notifies a listener that a “UnknownNodeIdentifier” message was received.
244          *
245          * @param fcpConnection
246          *            The connection that received the message
247          * @param unknownNodeIdentifier
248          *            The “UnknownNodeIdentifier” message
249          */
250         public void receivedUnknownNodeIdentifier(FcpConnection fcpConnection, UnknownNodeIdentifier unknownNodeIdentifier);
251
252         /**
253          * Notifies a listener that a “ConfigData” message was received.
254          *
255          * @param fcpConnection
256          *            The connection that received the message
257          * @param configData
258          *            The “ConfigData” message
259          */
260         public void receivedConfigData(FcpConnection fcpConnection, ConfigData configData);
261
262         /**
263          * Notifies a listener that a “GetFailed” message was recevied.
264          *
265          * @param fcpConnection
266          *            The connection that received the message
267          * @param getFailed
268          *            The “GetFailed” message
269          */
270         public void receivedGetFailed(FcpConnection fcpConnection, GetFailed getFailed);
271
272         /**
273          * Notifies a listener that a “PutFailed” message was received.
274          *
275          * @param fcpConnection
276          *            The connection that received the message
277          * @param putFailed
278          *            The “PutFailed” message
279          */
280         public void receivedPutFailed(FcpConnection fcpConnection, PutFailed putFailed);
281
282         /**
283          * Notifies a listener that an “IdentifierCollision” message was receied.
284          *
285          * @param fcpConnection
286          *            The connection that received the message
287          * @param identifierCollision
288          *            The “IdentifierCollision” message
289          */
290         public void receivedIdentifierCollision(FcpConnection fcpConnection, IdentifierCollision identifierCollision);
291
292         /**
293          * Notifies a listener that a “PersistentPutDir” message was received.
294          *
295          * @param fcpConnection
296          *            The connection that received the message
297          * @param persistentPutDir
298          *            The “PersistentPutDir” message
299          */
300         public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir);
301
302         /**
303          * Notifies a listener that a “PersistentRequestRemoved” message was
304          * received.
305          *
306          * @param fcpConnection
307          *            The connection that received the message
308          * @param persistentRequestRemoved
309          *            The “PersistentRequestRemoved” message
310          */
311         public void receivedPersistentRequestRemoved(FcpConnection fcpConnection, PersistentRequestRemoved persistentRequestRemoved);
312
313         /**
314          * Notifies a listener that a “SubscribedUSKUpdate” message was received.
315          *
316          * @param fcpConnection
317          *            The connection that recevied the message
318          * @param subscribedUSKUpdate
319          *            The “SubscribedUSKUpdate” message
320          */
321         public void receivedSubscribedUSKUpdate(FcpConnection fcpConnection, SubscribedUSKUpdate subscribedUSKUpdate);
322
323         /**
324          * Notifies a listener that a “PluginInfo” message was received.
325          *
326          * @param fcpConnection
327          *            The connection that received the message
328          * @param pluginInfo
329          *            The “PluginInfo” message
330          */
331         public void receivedPluginInfo(FcpConnection fcpConnection, PluginInfo pluginInfo);
332
333         /**
334          * Notifies a listener that an “FCPPluginReply“ message was received.
335          *
336          * @param fcpConnection
337          *            The connection that received the message
338          * @param fcpPluginReply
339          *            The “FCPPluginReply” message
340          */
341         public void receivedFCPPluginReply(FcpConnection fcpConnection, FCPPluginReply fcpPluginReply);
342
343         /**
344          * Notifies a listener that a “PersistentRequestModified” message was
345          * received.
346          *
347          * @param fcpConnection
348          *            The connection that received the message
349          * @param persistentRequestModified
350          *            The “PersistentRequestModified” message
351          */
352         public void receivedPersistentRequestModified(FcpConnection fcpConnection, PersistentRequestModified persistentRequestModified);
353
354         /**
355          * Notifies a listener that a “PutSuccessful” message was received.
356          *
357          * @param fcpConnection
358          *            The connection that received the message
359          * @param putSuccessful
360          *            The “PutSuccessful” message
361          */
362         public void receivedPutSuccessful(FcpConnection fcpConnection, PutSuccessful putSuccessful);
363
364         /**
365          * Notifies a listener that a “PutFetchable” message was received.
366          *
367          * @param fcpConnection
368          *            The connection that received the message
369          * @param putFetchable
370          *            The “PutFetchable” message
371          */
372         public void receivedPutFetchable(FcpConnection fcpConnection, PutFetchable putFetchable);
373
374         /**
375          * Notifies a listener that a bookmark was updated.
376          *
377          * @param fcpConnection
378          *            The connection that received the message
379          * @param receivedBookmarkFeed
380          *            The “ReceivedBookmarkFeed” message
381          */
382         public void receivedBookmarkFeed(FcpConnection fcpConnection, ReceivedBookmarkFeed receivedBookmarkFeed);
383
384         /**
385          * Notifies a listener that a “ProtocolError” was received.
386          *
387          * @param fcpConnection
388          *            The connection that received the message
389          * @param protocolError
390          *            The “ProtocolError” message
391          */
392         public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError);
393
394         /**
395          * Notifies a listener that a message has been received. This method is only
396          * called if {@link FcpConnection#handleMessage(FcpMessage)} does not
397          * recognize the message. Should that ever happen, please file a bug report!
398          *
399          * @param fcpConnection
400          *            The connection that received the message
401          * @param fcpMessage
402          *            The message that was received
403          */
404         public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage);
405
406         /**
407          * Notifies a listener that a connection was closed. A closed connection can
408          * be reestablished by calling {@link FcpConnection#connect()} on the same
409          * object again.
410          *
411          * @param fcpConnection
412          *            The connection that was closed.
413          * @param throwable
414          *            The exception that caused the disconnect, or <code>null</code>
415          *            if there was no exception
416          */
417         public void connectionClosed(FcpConnection fcpConnection, Throwable throwable);
418
419 }