4671245507af03ffab8ee4410337e34d55a28639
[jFCPlib.git] / src / net / pterodactylus / fcp / highlevel / HighLevelClient.java
1 /*
2  * fcplib - HighLevelClient.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.highlevel;
21
22 import java.io.IOException;
23 import java.net.InetAddress;
24 import java.net.URL;
25 import java.net.UnknownHostException;
26 import java.util.Collections;
27 import java.util.HashMap;
28 import java.util.Map;
29 import java.util.Map.Entry;
30
31 import net.pterodactylus.fcp.AddPeer;
32 import net.pterodactylus.fcp.AllData;
33 import net.pterodactylus.fcp.ClientHello;
34 import net.pterodactylus.fcp.CloseConnectionDuplicateClientName;
35 import net.pterodactylus.fcp.ConfigData;
36 import net.pterodactylus.fcp.DataFound;
37 import net.pterodactylus.fcp.EndListPeerNotes;
38 import net.pterodactylus.fcp.EndListPeers;
39 import net.pterodactylus.fcp.EndListPersistentRequests;
40 import net.pterodactylus.fcp.FCPPluginReply;
41 import net.pterodactylus.fcp.FcpConnection;
42 import net.pterodactylus.fcp.FcpListener;
43 import net.pterodactylus.fcp.FcpMessage;
44 import net.pterodactylus.fcp.FinishedCompression;
45 import net.pterodactylus.fcp.GenerateSSK;
46 import net.pterodactylus.fcp.GetFailed;
47 import net.pterodactylus.fcp.IdentifierCollision;
48 import net.pterodactylus.fcp.ListPeers;
49 import net.pterodactylus.fcp.NodeData;
50 import net.pterodactylus.fcp.NodeHello;
51 import net.pterodactylus.fcp.NodeRef;
52 import net.pterodactylus.fcp.Peer;
53 import net.pterodactylus.fcp.PeerNote;
54 import net.pterodactylus.fcp.PeerRemoved;
55 import net.pterodactylus.fcp.PersistentGet;
56 import net.pterodactylus.fcp.PersistentPut;
57 import net.pterodactylus.fcp.PersistentPutDir;
58 import net.pterodactylus.fcp.PersistentRequestModified;
59 import net.pterodactylus.fcp.PersistentRequestRemoved;
60 import net.pterodactylus.fcp.PluginInfo;
61 import net.pterodactylus.fcp.ProtocolError;
62 import net.pterodactylus.fcp.PutFailed;
63 import net.pterodactylus.fcp.PutFetchable;
64 import net.pterodactylus.fcp.PutSuccessful;
65 import net.pterodactylus.fcp.SSKKeypair;
66 import net.pterodactylus.fcp.SimpleProgress;
67 import net.pterodactylus.fcp.StartedCompression;
68 import net.pterodactylus.fcp.SubscribedUSKUpdate;
69 import net.pterodactylus.fcp.TestDDAComplete;
70 import net.pterodactylus.fcp.TestDDAReply;
71 import net.pterodactylus.fcp.URIGenerated;
72 import net.pterodactylus.fcp.UnknownNodeIdentifier;
73 import net.pterodactylus.fcp.UnknownPeerNoteType;
74
75 /**
76  * A high-level client that allows simple yet full-featured access to a Freenet
77  * node.
78  * 
79  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
80  * @version $Id$
81  */
82 public class HighLevelClient {
83
84         /** Object for internal synchronization. */
85         private final Object syncObject = new Object();
86
87         /** The name of the client. */
88         private final String clientName;
89
90         /** The address of the node. */
91         private InetAddress address;
92
93         /** The port number of the node. */
94         private int port;
95
96         /** The FCP connection to the node. */
97         private FcpConnection fcpConnection;
98
99         /** The listener for the connection. */
100         private HighLevelClientFcpListener highLevelClientFcpListener = new HighLevelClientFcpListener();
101
102         /** The callback for {@link #connect()}. */
103         private HighLevelCallback<ConnectResult> connectCallback;
104
105         /** Mapping from request identifiers to callbacks. */
106         private Map<String, HighLevelCallback<KeyGenerationResult>> keyGenerationCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelCallback<KeyGenerationResult>>());
107
108         /** Mapping from request identifier to peer list callbacks. */
109         private Map<String, HighLevelCallback<PeerListResult>> peerListCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelCallback<PeerListResult>>());
110
111         /** Mapping from request identifier to peer callbacks. */
112         private Map<String, HighLevelCallback<PeerResult>> peerCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelCallback<PeerResult>>());
113
114         /**
115          * Creates a new high-level client that connects to a node on
116          * <code>localhost</code>.
117          * 
118          * @param clientName
119          *            The name of the client
120          * @throws UnknownHostException
121          *             if the hostname of the node can not be resolved.
122          */
123         public HighLevelClient(String clientName) throws UnknownHostException {
124                 this(clientName, "localhost");
125         }
126
127         /**
128          * Creates a new high-level client that connects to a node on the given
129          * host.
130          * 
131          * @param clientName
132          *            The name of the client
133          * @param host
134          *            The hostname of the node
135          * @throws UnknownHostException
136          *             if the hostname of the node can not be resolved.
137          */
138         public HighLevelClient(String clientName, String host) throws UnknownHostException {
139                 this(clientName, host, FcpConnection.DEFAULT_PORT);
140         }
141
142         /**
143          * Creates a new high-level client that connects to a node on the given
144          * host.
145          * 
146          * @param clientName
147          *            The name of the client
148          * @param host
149          *            The hostname of the node
150          * @param port
151          *            The port number of the node
152          * @throws UnknownHostException
153          *             if the hostname of the node can not be resolved.
154          */
155         public HighLevelClient(String clientName, String host, int port) throws UnknownHostException {
156                 this(clientName, InetAddress.getByName(host), port);
157         }
158
159         /**
160          * Creates a new high-level client that connects to a node at the given
161          * address.
162          * 
163          * @param clientName
164          *            The name of the client
165          * @param address
166          *            The address of the node
167          * @param port
168          *            The port number of the node
169          */
170         public HighLevelClient(String clientName, InetAddress address, int port) {
171                 this.clientName = clientName;
172                 this.address = address;
173                 this.port = port;
174         }
175
176         //
177         // ACCESSORS
178         //
179
180         //
181         // ACTIONS
182         //
183
184         /**
185          * Connects the client.
186          * 
187          * @return A callback with a connection result
188          * @throws IOException
189          *             if an I/O error occurs communicating with the node
190          */
191         public HighLevelCallback<ConnectResult> connect() throws IOException {
192                 fcpConnection = new FcpConnection(address, port);
193                 fcpConnection.addFcpListener(highLevelClientFcpListener);
194                 ClientHello clientHello = new ClientHello(clientName);
195                 connectCallback = new HighLevelCallback<ConnectResult>(new ConnectResult());
196                 fcpConnection.sendMessage(clientHello);
197                 return connectCallback;
198         }
199
200         /**
201          * Disconnects the client from the node.
202          */
203         public void disconnect() {
204         }
205
206         /**
207          * Generates a new SSK keypair.
208          * 
209          * @return A callback with the keypair
210          * @throws IOException
211          *             if an I/O error occurs communicating with the node
212          */
213         public HighLevelCallback<KeyGenerationResult> generateKey() throws IOException {
214                 String identifier = generateIdentifier("generateSSK");
215                 GenerateSSK generateSSK = new GenerateSSK(identifier);
216                 HighLevelCallback<KeyGenerationResult> keyGenerationCallback = new HighLevelCallback<KeyGenerationResult>(new KeyGenerationResult());
217                 keyGenerationCallbacks.put(identifier, keyGenerationCallback);
218                 fcpConnection.sendMessage(generateSSK);
219                 return keyGenerationCallback;
220         }
221
222         /**
223          * Gets a list of all peers from the node.
224          * 
225          * @return A callback with the peer list
226          * @throws IOException
227          *             if an I/O error occurs with the node
228          */
229         public HighLevelCallback<PeerListResult> getPeers() throws IOException {
230                 String identifier = generateIdentifier("listPeers");
231                 ListPeers listPeers = new ListPeers(identifier, true, true);
232                 HighLevelCallback<PeerListResult> peerListCallback = new HighLevelCallback<PeerListResult>(new PeerListResult());
233                 peerListCallbacks.put(identifier, peerListCallback);
234                 fcpConnection.sendMessage(listPeers);
235                 return peerListCallback;
236         }
237
238         /**
239          * Adds the peer whose noderef is stored in the given file.
240          * 
241          * @param nodeRefFile
242          *            The name of the file the peer’s noderef is stored in
243          * @return A peer callback
244          * @throws IOException
245          *             if an I/O error occurs communicating with the node
246          */
247         public HighLevelCallback<PeerResult> addPeer(String nodeRefFile) throws IOException {
248                 String identifier = generateIdentifier("addPeer");
249                 AddPeer addPeer = new AddPeer(nodeRefFile);
250                 HighLevelCallback<PeerResult> peerCallback = new HighLevelCallback<PeerResult>(new PeerResult());
251                 peerCallbacks.put(identifier, peerCallback);
252                 fcpConnection.sendMessage(addPeer);
253                 return peerCallback;
254         }
255
256         /**
257          * Adds the peer whose noderef is stored in the given file.
258          * 
259          * @param nodeRefURL
260          *            The URL where the peer’s noderef is stored
261          * @return A peer callback
262          * @throws IOException
263          *             if an I/O error occurs communicating with the node
264          */
265         public HighLevelCallback<PeerResult> addPeer(URL nodeRefURL) throws IOException {
266                 String identifier = generateIdentifier("addPeer");
267                 AddPeer addPeer = new AddPeer(nodeRefURL);
268                 HighLevelCallback<PeerResult> peerCallback = new HighLevelCallback<PeerResult>(new PeerResult());
269                 peerCallbacks.put(identifier, peerCallback);
270                 fcpConnection.sendMessage(addPeer);
271                 return peerCallback;
272         }
273
274         /**
275          * Adds the peer whose noderef is stored in the given file.
276          * 
277          * @param nodeRef
278          *            The peer’s noderef
279          * @return A peer callback
280          * @throws IOException
281          *             if an I/O error occurs communicating with the node
282          */
283         public HighLevelCallback<PeerResult> addPeer(NodeRef nodeRef) throws IOException {
284                 String identifier = generateIdentifier("addPeer");
285                 AddPeer addPeer = new AddPeer(nodeRef);
286                 HighLevelCallback<PeerResult> peerCallback = new HighLevelCallback<PeerResult>(new PeerResult());
287                 peerCallbacks.put(identifier, peerCallback);
288                 fcpConnection.sendMessage(addPeer);
289                 return peerCallback;
290         }
291
292         //
293         // PRIVATE METHODS
294         //
295
296         /**
297          * Generates an identifier for the given function.
298          * 
299          * @param function
300          *            The name of the function
301          * @return An identifier
302          */
303         private String generateIdentifier(String function) {
304                 return "jFCPlib-" + function + "-" + System.currentTimeMillis();
305         }
306
307         /**
308          * FCP listener for {@link HighLevelClient}.
309          * 
310          * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
311          * @version $Id$
312          */
313         private class HighLevelClientFcpListener implements FcpListener {
314
315                 /**
316                  * Creates a new FCP listener for {@link HighLevelClient}.
317                  */
318                 HighLevelClientFcpListener() {
319                 }
320
321                 //
322                 // PRIVATE METHODS
323                 //
324
325                 /**
326                  * Searches all callback collections for a callback with the given
327                  * identifier and cancels it.
328                  * 
329                  * @param identifier
330                  *            The identifier to search for, or <code>null</code> to
331                  *            cancel all pending requests
332                  */
333                 @SuppressWarnings("synthetic-access")
334                 private void cancelIdentifier(String identifier) {
335                         synchronized (syncObject) {
336                                 if (connectCallback != null) {
337                                         connectCallback.getIntermediaryResult().setFailed(true);
338                                         connectCallback.setDone();
339                                         connectCallback = null;
340                                 }
341                         }
342                         if (identifier == null) {
343                                 /* key generation callbacks */
344                                 for (Entry<String, HighLevelCallback<KeyGenerationResult>> keyGenerationEntry: keyGenerationCallbacks.entrySet()) {
345                                         keyGenerationEntry.getValue().getIntermediaryResult().setFailed(true);
346                                         keyGenerationEntry.getValue().setDone();
347                                 }
348                                 keyGenerationCallbacks.clear();
349                                 /* peer list callbacks. */
350                                 for (Entry<String, HighLevelCallback<PeerListResult>> peerListEntry: peerListCallbacks.entrySet()) {
351                                         peerListEntry.getValue().getIntermediaryResult().setFailed(true);
352                                         peerListEntry.getValue().setDone();
353                                 }
354                                 peerListCallbacks.clear();
355                                 /* peer callbacks. */
356                                 for (Entry<String, HighLevelCallback<PeerResult>> peerEntry: peerCallbacks.entrySet()) {
357                                         peerEntry.getValue().getIntermediaryResult().setFailed(true);
358                                         peerEntry.getValue().setDone();
359                                 }
360                                 peerCallbacks.clear();
361                         } else {
362                                 HighLevelCallback<KeyGenerationResult> keyGenerationCallback = keyGenerationCallbacks.remove(identifier);
363                                 if (keyGenerationCallback != null) {
364                                         keyGenerationCallback.getIntermediaryResult().setFailed(true);
365                                         keyGenerationCallback.setDone();
366                                         return;
367                                 }
368                                 HighLevelCallback<PeerListResult> peerListCallback = peerListCallbacks.remove(identifier);
369                                 if (peerListCallback != null) {
370                                         peerListCallback.getIntermediaryResult().setFailed(true);
371                                         peerListCallback.setDone();
372                                         return;
373                                 }
374                                 HighLevelCallback<PeerResult> peerCallback = peerCallbacks.remove(identifier);
375                                 if (peerCallback != null) {
376                                         peerCallback.getIntermediaryResult().setFailed(true);
377                                         peerCallback.setDone();
378                                         return;
379                                 }
380                         }
381                 }
382
383                 //
384                 // INTERFACE FcpListener
385                 //
386
387                 /**
388                  * @see net.pterodactylus.fcp.FcpListener#connectionClosed(net.pterodactylus.fcp.FcpConnection)
389                  */
390                 @SuppressWarnings("synthetic-access")
391                 public void connectionClosed(FcpConnection fcpConnection) {
392                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
393                                 return;
394                         }
395                         cancelIdentifier(null);
396                 }
397
398                 /**
399                  * @see net.pterodactylus.fcp.FcpListener#receivedAllData(net.pterodactylus.fcp.FcpConnection,
400                  *      net.pterodactylus.fcp.AllData)
401                  */
402                 public void receivedAllData(FcpConnection fcpConnection, AllData allData) {
403                 }
404
405                 /**
406                  * @see net.pterodactylus.fcp.FcpListener#receivedCloseConnectionDuplicateClientName(net.pterodactylus.fcp.FcpConnection,
407                  *      net.pterodactylus.fcp.CloseConnectionDuplicateClientName)
408                  */
409                 public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName) {
410                 }
411
412                 /**
413                  * @see net.pterodactylus.fcp.FcpListener#receivedConfigData(net.pterodactylus.fcp.FcpConnection,
414                  *      net.pterodactylus.fcp.ConfigData)
415                  */
416                 public void receivedConfigData(FcpConnection fcpConnection, ConfigData configData) {
417                 }
418
419                 /**
420                  * @see net.pterodactylus.fcp.FcpListener#receivedDataFound(net.pterodactylus.fcp.FcpConnection,
421                  *      net.pterodactylus.fcp.DataFound)
422                  */
423                 public void receivedDataFound(FcpConnection fcpConnection, DataFound dataFound) {
424                 }
425
426                 /**
427                  * @see net.pterodactylus.fcp.FcpListener#receivedEndListPeerNotes(net.pterodactylus.fcp.FcpConnection,
428                  *      net.pterodactylus.fcp.EndListPeerNotes)
429                  */
430                 public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes) {
431                 }
432
433                 /**
434                  * @see net.pterodactylus.fcp.FcpListener#receivedEndListPeers(net.pterodactylus.fcp.FcpConnection,
435                  *      net.pterodactylus.fcp.EndListPeers)
436                  */
437                 @SuppressWarnings("synthetic-access")
438                 public void receivedEndListPeers(FcpConnection fcpConnection, EndListPeers endListPeers) {
439                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
440                                 return;
441                         }
442                         String identifier = endListPeers.getIdentifier();
443                         HighLevelCallback<PeerListResult> peerListCallback = peerListCallbacks.remove(identifier);
444                         if (peerListCallback == null) {
445                                 return;
446                         }
447                         peerListCallback.setDone();
448                 }
449
450                 /**
451                  * @see net.pterodactylus.fcp.FcpListener#receivedEndListPersistentRequests(net.pterodactylus.fcp.FcpConnection,
452                  *      net.pterodactylus.fcp.EndListPersistentRequests)
453                  */
454                 public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests) {
455                 }
456
457                 /**
458                  * @see net.pterodactylus.fcp.FcpListener#receivedFCPPluginReply(net.pterodactylus.fcp.FcpConnection,
459                  *      net.pterodactylus.fcp.FCPPluginReply)
460                  */
461                 public void receivedFCPPluginReply(FcpConnection fcpConnection, FCPPluginReply fcpPluginReply) {
462                 }
463
464                 /**
465                  * @see net.pterodactylus.fcp.FcpListener#receivedGetFailed(net.pterodactylus.fcp.FcpConnection,
466                  *      net.pterodactylus.fcp.GetFailed)
467                  */
468                 public void receivedGetFailed(FcpConnection fcpConnection, GetFailed getFailed) {
469                 }
470
471                 /**
472                  * @see net.pterodactylus.fcp.FcpListener#receivedIdentifierCollision(net.pterodactylus.fcp.FcpConnection,
473                  *      net.pterodactylus.fcp.IdentifierCollision)
474                  */
475                 public void receivedIdentifierCollision(FcpConnection fcpConnection, IdentifierCollision identifierCollision) {
476                 }
477
478                 /**
479                  * @see net.pterodactylus.fcp.FcpListener#receivedMessage(net.pterodactylus.fcp.FcpConnection,
480                  *      net.pterodactylus.fcp.FcpMessage)
481                  */
482                 public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage) {
483                 }
484
485                 /**
486                  * @see net.pterodactylus.fcp.FcpListener#receivedNodeData(net.pterodactylus.fcp.FcpConnection,
487                  *      net.pterodactylus.fcp.NodeData)
488                  */
489                 public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData) {
490                 }
491
492                 /**
493                  * @see net.pterodactylus.fcp.FcpListener#receivedNodeHello(net.pterodactylus.fcp.FcpConnection,
494                  *      net.pterodactylus.fcp.NodeHello)
495                  */
496                 @SuppressWarnings("synthetic-access")
497                 public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello) {
498                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
499                                 return;
500                         }
501                         synchronized (syncObject) {
502                                 connectCallback.getIntermediaryResult().setFailed(false);
503                                 connectCallback.setDone();
504                                 connectCallback = null;
505                         }
506                 }
507
508                 /**
509                  * @see net.pterodactylus.fcp.FcpListener#receivedPeer(net.pterodactylus.fcp.FcpConnection,
510                  *      net.pterodactylus.fcp.Peer)
511                  */
512                 @SuppressWarnings("synthetic-access")
513                 public void receivedPeer(FcpConnection fcpConnection, Peer peer) {
514                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
515                                 return;
516                         }
517                         String identifier = peer.getIdentifier();
518                         if (identifier == null) {
519                                 return;
520                         }
521                         HighLevelCallback<PeerListResult> peerListCallback = peerListCallbacks.get(identifier);
522                         if (peerListCallback != null) {
523                                 peerListCallback.getIntermediaryResult().addPeer(peer);
524                                 return;
525                         }
526                         HighLevelCallback<PeerResult> peerResult = peerCallbacks.remove(identifier);
527                         if (peerResult != null) {
528                                 peerResult.getIntermediaryResult().setPeer(peer);
529                                 peerResult.setDone();
530                         }
531                 }
532
533                 /**
534                  * @see net.pterodactylus.fcp.FcpListener#receivedPeerNote(net.pterodactylus.fcp.FcpConnection,
535                  *      net.pterodactylus.fcp.PeerNote)
536                  */
537                 public void receivedPeerNote(FcpConnection fcpConnection, PeerNote peerNote) {
538                 }
539
540                 /**
541                  * @see net.pterodactylus.fcp.FcpListener#receivedPeerRemoved(net.pterodactylus.fcp.FcpConnection,
542                  *      net.pterodactylus.fcp.PeerRemoved)
543                  */
544                 public void receivedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved) {
545                 }
546
547                 /**
548                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentGet(net.pterodactylus.fcp.FcpConnection,
549                  *      net.pterodactylus.fcp.PersistentGet)
550                  */
551                 public void receivedPersistentGet(FcpConnection fcpConnection, PersistentGet persistentGet) {
552                 }
553
554                 /**
555                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentPut(net.pterodactylus.fcp.FcpConnection,
556                  *      net.pterodactylus.fcp.PersistentPut)
557                  */
558                 public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut) {
559                 }
560
561                 /**
562                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentPutDir(net.pterodactylus.fcp.FcpConnection,
563                  *      net.pterodactylus.fcp.PersistentPutDir)
564                  */
565                 public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir) {
566                 }
567
568                 /**
569                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentRequestModified(net.pterodactylus.fcp.FcpConnection,
570                  *      net.pterodactylus.fcp.PersistentRequestModified)
571                  */
572                 public void receivedPersistentRequestModified(FcpConnection fcpConnection, PersistentRequestModified persistentRequestModified) {
573                 }
574
575                 /**
576                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentRequestRemoved(net.pterodactylus.fcp.FcpConnection,
577                  *      net.pterodactylus.fcp.PersistentRequestRemoved)
578                  */
579                 public void receivedPersistentRequestRemoved(FcpConnection fcpConnection, PersistentRequestRemoved persistentRequestRemoved) {
580                 }
581
582                 /**
583                  * @see net.pterodactylus.fcp.FcpListener#receivedPluginInfo(net.pterodactylus.fcp.FcpConnection,
584                  *      net.pterodactylus.fcp.PluginInfo)
585                  */
586                 public void receivedPluginInfo(FcpConnection fcpConnection, PluginInfo pluginInfo) {
587                 }
588
589                 /**
590                  * @see net.pterodactylus.fcp.FcpListener#receivedProtocolError(net.pterodactylus.fcp.FcpConnection,
591                  *      net.pterodactylus.fcp.ProtocolError)
592                  */
593                 @SuppressWarnings("synthetic-access")
594                 public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError) {
595                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
596                                 return;
597                         }
598                         String identifier = protocolError.getIdentifier();
599                         if (identifier == null) {
600                                 return;
601                         }
602                         cancelIdentifier(identifier);
603                 }
604
605                 /**
606                  * @see net.pterodactylus.fcp.FcpListener#receivedPutFailed(net.pterodactylus.fcp.FcpConnection,
607                  *      net.pterodactylus.fcp.PutFailed)
608                  */
609                 public void receivedPutFailed(FcpConnection fcpConnection, PutFailed putFailed) {
610                 }
611
612                 /**
613                  * @see net.pterodactylus.fcp.FcpListener#receivedPutFetchable(net.pterodactylus.fcp.FcpConnection,
614                  *      net.pterodactylus.fcp.PutFetchable)
615                  */
616                 public void receivedPutFetchable(FcpConnection fcpConnection, PutFetchable putFetchable) {
617                 }
618
619                 /**
620                  * @see net.pterodactylus.fcp.FcpListener#receivedPutSuccessful(net.pterodactylus.fcp.FcpConnection,
621                  *      net.pterodactylus.fcp.PutSuccessful)
622                  */
623                 public void receivedPutSuccessful(FcpConnection fcpConnection, PutSuccessful putSuccessful) {
624                 }
625
626                 /**
627                  * @see net.pterodactylus.fcp.FcpListener#receivedSSKKeypair(net.pterodactylus.fcp.FcpConnection,
628                  *      net.pterodactylus.fcp.SSKKeypair)
629                  */
630                 @SuppressWarnings("synthetic-access")
631                 public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair) {
632                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
633                                 return;
634                         }
635                         HighLevelCallback<KeyGenerationResult> keyGenerationCallback = keyGenerationCallbacks.remove(sskKeypair.getIdentifier());
636                         if (keyGenerationCallback == null) {
637                                 return;
638                         }
639                         KeyGenerationResult keyGenerationResult = keyGenerationCallback.getIntermediaryResult();
640                         keyGenerationResult.setInsertURI(sskKeypair.getInsertURI());
641                         keyGenerationResult.setRequestURI(sskKeypair.getRequestURI());
642                         keyGenerationCallback.setDone();
643                 }
644
645                 /**
646                  * @see net.pterodactylus.fcp.FcpListener#receivedSimpleProgress(net.pterodactylus.fcp.FcpConnection,
647                  *      net.pterodactylus.fcp.SimpleProgress)
648                  */
649                 public void receivedSimpleProgress(FcpConnection fcpConnection, SimpleProgress simpleProgress) {
650                 }
651
652                 /**
653                  * @see net.pterodactylus.fcp.FcpListener#receivedStartedCompression(net.pterodactylus.fcp.FcpConnection,
654                  *      net.pterodactylus.fcp.StartedCompression)
655                  */
656                 public void receivedStartedCompression(FcpConnection fcpConnection, StartedCompression startedCompression) {
657                 }
658
659                 /**
660                  * @see net.pterodactylus.fcp.FcpListener#receivedSubscribedUSKUpdate(net.pterodactylus.fcp.FcpConnection,
661                  *      net.pterodactylus.fcp.SubscribedUSKUpdate)
662                  */
663                 public void receivedSubscribedUSKUpdate(FcpConnection fcpConnection, SubscribedUSKUpdate subscribedUSKUpdate) {
664                 }
665
666                 /**
667                  * @see net.pterodactylus.fcp.FcpListener#receivedTestDDAComplete(net.pterodactylus.fcp.FcpConnection,
668                  *      net.pterodactylus.fcp.TestDDAComplete)
669                  */
670                 public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete) {
671                 }
672
673                 /**
674                  * @see net.pterodactylus.fcp.FcpListener#receivedTestDDAReply(net.pterodactylus.fcp.FcpConnection,
675                  *      net.pterodactylus.fcp.TestDDAReply)
676                  */
677                 public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply) {
678                 }
679
680                 /**
681                  * @see net.pterodactylus.fcp.FcpListener#receivedURIGenerated(net.pterodactylus.fcp.FcpConnection,
682                  *      net.pterodactylus.fcp.URIGenerated)
683                  */
684                 public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated) {
685                 }
686
687                 /**
688                  * @see net.pterodactylus.fcp.FcpListener#receivedUnknownNodeIdentifier(net.pterodactylus.fcp.FcpConnection,
689                  *      net.pterodactylus.fcp.UnknownNodeIdentifier)
690                  */
691                 public void receivedUnknownNodeIdentifier(FcpConnection fcpConnection, UnknownNodeIdentifier unknownNodeIdentifier) {
692                 }
693
694                 /**
695                  * @see net.pterodactylus.fcp.FcpListener#receivedUnknownPeerNoteType(net.pterodactylus.fcp.FcpConnection,
696                  *      net.pterodactylus.fcp.UnknownPeerNoteType)
697                  */
698                 public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, UnknownPeerNoteType unknownPeerNoteType) {
699                 }
700
701                 /**
702                  * @see net.pterodactylus.fcp.FcpListener#receviedFinishedCompression(net.pterodactylus.fcp.FcpConnection,
703                  *      net.pterodactylus.fcp.FinishedCompression)
704                  */
705                 public void receviedFinishedCompression(FcpConnection fcpConnection, FinishedCompression finishedCompression) {
706                 }
707
708         }
709
710 }