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