a09b289b51251602c2cf93fb74522552fc3d868f
[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.BufferedReader;
23 import java.io.File;
24 import java.io.FileReader;
25 import java.io.FileWriter;
26 import java.io.IOException;
27 import java.net.InetAddress;
28 import java.net.URL;
29 import java.net.UnknownHostException;
30 import java.util.ArrayList;
31 import java.util.Collections;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Map.Entry;
36 import java.util.logging.Level;
37 import java.util.logging.Logger;
38
39 import net.pterodactylus.fcp.AddPeer;
40 import net.pterodactylus.fcp.AllData;
41 import net.pterodactylus.fcp.ClientGet;
42 import net.pterodactylus.fcp.ClientHello;
43 import net.pterodactylus.fcp.CloseConnectionDuplicateClientName;
44 import net.pterodactylus.fcp.ConfigData;
45 import net.pterodactylus.fcp.DataFound;
46 import net.pterodactylus.fcp.EndListPeerNotes;
47 import net.pterodactylus.fcp.EndListPeers;
48 import net.pterodactylus.fcp.EndListPersistentRequests;
49 import net.pterodactylus.fcp.FCPPluginReply;
50 import net.pterodactylus.fcp.FcpConnection;
51 import net.pterodactylus.fcp.FcpListener;
52 import net.pterodactylus.fcp.FcpMessage;
53 import net.pterodactylus.fcp.FcpUtils;
54 import net.pterodactylus.fcp.FinishedCompression;
55 import net.pterodactylus.fcp.GenerateSSK;
56 import net.pterodactylus.fcp.GetFailed;
57 import net.pterodactylus.fcp.IdentifierCollision;
58 import net.pterodactylus.fcp.ListPeers;
59 import net.pterodactylus.fcp.ListPersistentRequests;
60 import net.pterodactylus.fcp.NodeData;
61 import net.pterodactylus.fcp.NodeHello;
62 import net.pterodactylus.fcp.NodeRef;
63 import net.pterodactylus.fcp.Peer;
64 import net.pterodactylus.fcp.PeerNote;
65 import net.pterodactylus.fcp.PeerRemoved;
66 import net.pterodactylus.fcp.PersistentGet;
67 import net.pterodactylus.fcp.PersistentPut;
68 import net.pterodactylus.fcp.PersistentPutDir;
69 import net.pterodactylus.fcp.PersistentRequestModified;
70 import net.pterodactylus.fcp.PersistentRequestRemoved;
71 import net.pterodactylus.fcp.PluginInfo;
72 import net.pterodactylus.fcp.ProtocolError;
73 import net.pterodactylus.fcp.PutFailed;
74 import net.pterodactylus.fcp.PutFetchable;
75 import net.pterodactylus.fcp.PutSuccessful;
76 import net.pterodactylus.fcp.ReturnType;
77 import net.pterodactylus.fcp.SSKKeypair;
78 import net.pterodactylus.fcp.SimpleProgress;
79 import net.pterodactylus.fcp.StartedCompression;
80 import net.pterodactylus.fcp.SubscribedUSKUpdate;
81 import net.pterodactylus.fcp.TestDDAComplete;
82 import net.pterodactylus.fcp.TestDDAReply;
83 import net.pterodactylus.fcp.TestDDARequest;
84 import net.pterodactylus.fcp.TestDDAResponse;
85 import net.pterodactylus.fcp.URIGenerated;
86 import net.pterodactylus.fcp.UnknownNodeIdentifier;
87 import net.pterodactylus.fcp.UnknownPeerNoteType;
88 import net.pterodactylus.fcp.WatchGlobal;
89
90 /**
91  * A high-level client that allows simple yet full-featured access to a Freenet
92  * node.
93  * 
94  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
95  * @version $Id$
96  */
97 public class HighLevelClient {
98
99         /** Logger. */
100         private static final Logger logger = Logger.getLogger(HighLevelClient.class.getName());
101
102         /** Object for internal synchronization. */
103         private final Object syncObject = new Object();
104
105         /** The name of the client. */
106         private final String clientName;
107
108         /** The address of the node. */
109         private InetAddress address;
110
111         /** The port number of the node. */
112         private int port;
113
114         /** The FCP connection to the node. */
115         private FcpConnection fcpConnection;
116
117         /** Listeners for high-level client events. */
118         private List<HighLevelClientListener> highLevelClientListeners = Collections.synchronizedList(new ArrayList<HighLevelClientListener>());
119
120         /** The listener for the connection. */
121         private HighLevelClientFcpListener highLevelClientFcpListener = new HighLevelClientFcpListener();
122
123         /** The listeners for progress events. */
124         private List<HighLevelProgressListener> highLevelProgressListeners = Collections.synchronizedList(new ArrayList<HighLevelProgressListener>());
125
126         /** The callback for {@link #connect()}. */
127         private HighLevelCallback<ConnectResult> connectCallback;
128
129         /** Mapping from request identifiers to callbacks. */
130         private Map<String, HighLevelCallback<KeyGenerationResult>> keyGenerationCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelCallback<KeyGenerationResult>>());
131
132         /** Mapping from request identifier to peer list callbacks. */
133         private Map<String, HighLevelCallback<PeerListResult>> peerListCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelCallback<PeerListResult>>());
134
135         /** Mapping from request identifier to peer callbacks. */
136         private Map<String, HighLevelCallback<PeerResult>> peerCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelCallback<PeerResult>>());
137
138         /** Mapping from directories to DDA callbacks. */
139         private Map<String, HighLevelCallback<DirectDiskAccessResult>> directDiskAccessCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelCallback<DirectDiskAccessResult>>());
140
141         /** Mapping from request identifiers to download callbacks. */
142         private Map<String, HighLevelProgressCallback<DownloadResult>> downloadCallbacks = Collections.synchronizedMap(new HashMap<String, HighLevelProgressCallback<DownloadResult>>());
143
144         /** The callback for {@link #getRequests()}. */
145         private HighLevelCallback<RequestListResult> requestListCallback;
146
147         /**
148          * Creates a new high-level client that connects to a node on
149          * <code>localhost</code>.
150          * 
151          * @param clientName
152          *            The name of the client
153          * @throws UnknownHostException
154          *             if the hostname of the node can not be resolved.
155          */
156         public HighLevelClient(String clientName) throws UnknownHostException {
157                 this(clientName, "localhost");
158         }
159
160         /**
161          * Creates a new high-level client that connects to a node on the given
162          * host.
163          * 
164          * @param clientName
165          *            The name of the client
166          * @param host
167          *            The hostname of the node
168          * @throws UnknownHostException
169          *             if the hostname of the node can not be resolved.
170          */
171         public HighLevelClient(String clientName, String host) throws UnknownHostException {
172                 this(clientName, host, FcpConnection.DEFAULT_PORT);
173         }
174
175         /**
176          * Creates a new high-level client that connects to a node on the given
177          * host.
178          * 
179          * @param clientName
180          *            The name of the client
181          * @param host
182          *            The hostname of the node
183          * @param port
184          *            The port number of the node
185          * @throws UnknownHostException
186          *             if the hostname of the node can not be resolved.
187          */
188         public HighLevelClient(String clientName, String host, int port) throws UnknownHostException {
189                 this(clientName, InetAddress.getByName(host), port);
190         }
191
192         /**
193          * Creates a new high-level client that connects to a node at the given
194          * address.
195          * 
196          * @param clientName
197          *            The name of the client
198          * @param address
199          *            The address of the node
200          * @param port
201          *            The port number of the node
202          */
203         public HighLevelClient(String clientName, InetAddress address, int port) {
204                 this.clientName = clientName;
205                 this.address = address;
206                 this.port = port;
207         }
208
209         //
210         // EVENT MANAGEMENT
211         //
212
213         /**
214          * Adds the given high-level client listener to list of listeners.
215          * 
216          * @param highLevelClientListener
217          *            The listener to add
218          */
219         public void addHighLevelClientListener(HighLevelClientListener highLevelClientListener) {
220                 highLevelClientListeners.add(highLevelClientListener);
221         }
222
223         /**
224          * Removes the given high-level client listener from the list of listeners.
225          * 
226          * @param highLevelClientListener
227          *            The listener to remove
228          */
229         public void removeHighLevelClientListener(HighLevelClientListener highLevelClientListener) {
230                 highLevelClientListeners.remove(highLevelClientListener);
231         }
232
233         /**
234          * Notifies all listeners that a client has connected.
235          */
236         private void fireClientConnected() {
237                 for (HighLevelClientListener highLevelClientListener: highLevelClientListeners) {
238                         highLevelClientListener.clientConnected(this);
239                 }
240         }
241
242         /**
243          * Notifies all listeners that a client has disconnected.
244          * 
245          * @param throwable
246          *            The exception that caused the disconnect, or <code>null</code>
247          *            if there was no exception
248          */
249         private void fireClientDisconnected(Throwable throwable) {
250                 for (HighLevelClientListener highLevelClientListener: highLevelClientListeners) {
251                         highLevelClientListener.clientDisconnected(this, throwable);
252                 }
253         }
254
255         /**
256          * Adds a high-level progress listener.
257          * 
258          * @param highLevelProgressListener
259          *            The high-level progress listener to add
260          */
261         public void addHighLevelProgressListener(HighLevelProgressListener highLevelProgressListener) {
262                 highLevelProgressListeners.add(highLevelProgressListener);
263         }
264
265         /**
266          * Removes a high-level progress listener.
267          * 
268          * @param highLevelProgressListener
269          *            The high-level progress listener to remove
270          */
271         public void removeHighLevelProgressListener(HighLevelProgressListener highLevelProgressListener) {
272                 highLevelProgressListeners.remove(highLevelProgressListener);
273         }
274
275         /**
276          * Notifies all listeners that the request with the given identifier made
277          * some progress.
278          * 
279          * @param identifier
280          *            The identifier of the request
281          * @param highLevelProgress
282          *            The progress of the request
283          */
284         private void fireProgressReceived(String identifier, HighLevelProgress highLevelProgress) {
285                 for (HighLevelProgressListener highLevelProgressListener: highLevelProgressListeners) {
286                         highLevelProgressListener.progressReceived(identifier, highLevelProgress);
287                 }
288         }
289
290         //
291         // ACCESSORS
292         //
293
294         /**
295          * Returns the FCP connection that backs this high-level client. This method
296          * should be used with care as fiddling around with the FCP connection can
297          * easily break the high-level client if you don’t know what you’re doing!
298          * 
299          * @return The FCP connection of this client
300          */
301         public FcpConnection getFcpConnection() {
302                 return fcpConnection;
303         }
304
305         //
306         // ACTIONS
307         //
308
309         /**
310          * Connects the client.
311          * 
312          * @return A callback with a connection result
313          * @throws IOException
314          *             if an I/O error occurs communicating with the node
315          */
316         public HighLevelCallback<ConnectResult> connect() throws IOException {
317                 fcpConnection = new FcpConnection(address, port);
318                 fcpConnection.addFcpListener(highLevelClientFcpListener);
319                 fcpConnection.connect();
320                 ClientHello clientHello = new ClientHello(clientName);
321                 connectCallback = new HighLevelCallback<ConnectResult>(new ConnectResult());
322                 fcpConnection.sendMessage(clientHello);
323                 return connectCallback;
324         }
325
326         /**
327          * Disconnects the client from the node.
328          */
329         public void disconnect() {
330                 disconnect(null);
331         }
332
333         /**
334          * Generates a new SSK keypair.
335          * 
336          * @return A callback with the keypair
337          * @throws IOException
338          *             if an I/O error occurs communicating with the node
339          */
340         public HighLevelCallback<KeyGenerationResult> generateKey() throws IOException {
341                 String identifier = generateIdentifier("generateSSK");
342                 GenerateSSK generateSSK = new GenerateSSK(identifier);
343                 HighLevelCallback<KeyGenerationResult> keyGenerationCallback = new HighLevelCallback<KeyGenerationResult>(new KeyGenerationResult(identifier));
344                 keyGenerationCallbacks.put(identifier, keyGenerationCallback);
345                 fcpConnection.sendMessage(generateSSK);
346                 return keyGenerationCallback;
347         }
348
349         /**
350          * Sets whether to watch the global queue.
351          * 
352          * @param enabled
353          *            <code>true</code> to watch the global queue in addition to
354          *            the client-local queue, <code>false</code> to only watch the
355          *            client-local queue
356          * @throws IOException
357          *             if an I/O error occurs communicating with the node
358          */
359         public void setWatchGlobal(boolean enabled) throws IOException {
360                 WatchGlobal watchGlobal = new WatchGlobal(enabled);
361                 fcpConnection.sendMessage(watchGlobal);
362         }
363
364         /**
365          * Gets a list of all peers from the node.
366          * 
367          * @return A callback with the peer list
368          * @throws IOException
369          *             if an I/O error occurs with the node
370          */
371         public HighLevelCallback<PeerListResult> getPeers() throws IOException {
372                 String identifier = generateIdentifier("listPeers");
373                 ListPeers listPeers = new ListPeers(identifier, true, true);
374                 HighLevelCallback<PeerListResult> peerListCallback = new HighLevelCallback<PeerListResult>(new PeerListResult(identifier));
375                 peerListCallbacks.put(identifier, peerListCallback);
376                 fcpConnection.sendMessage(listPeers);
377                 return peerListCallback;
378         }
379
380         /**
381          * Adds the peer whose noderef is stored in the given file.
382          * 
383          * @param nodeRefFile
384          *            The name of the file the peer’s noderef is stored in
385          * @return A peer callback
386          * @throws IOException
387          *             if an I/O error occurs communicating with the node
388          */
389         public HighLevelCallback<PeerResult> addPeer(String nodeRefFile) throws IOException {
390                 String identifier = generateIdentifier("addPeer");
391                 AddPeer addPeer = new AddPeer(nodeRefFile);
392                 HighLevelCallback<PeerResult> peerCallback = new HighLevelCallback<PeerResult>(new PeerResult(identifier));
393                 peerCallbacks.put(identifier, peerCallback);
394                 fcpConnection.sendMessage(addPeer);
395                 return peerCallback;
396         }
397
398         /**
399          * Adds the peer whose noderef is stored in the given file.
400          * 
401          * @param nodeRefURL
402          *            The URL where the peer’s noderef is stored
403          * @return A peer callback
404          * @throws IOException
405          *             if an I/O error occurs communicating with the node
406          */
407         public HighLevelCallback<PeerResult> addPeer(URL nodeRefURL) throws IOException {
408                 String identifier = generateIdentifier("addPeer");
409                 AddPeer addPeer = new AddPeer(nodeRefURL);
410                 HighLevelCallback<PeerResult> peerCallback = new HighLevelCallback<PeerResult>(new PeerResult(identifier));
411                 peerCallbacks.put(identifier, peerCallback);
412                 fcpConnection.sendMessage(addPeer);
413                 return peerCallback;
414         }
415
416         /**
417          * Adds the peer whose noderef is stored in the given file.
418          * 
419          * @param nodeRef
420          *            The peer’s noderef
421          * @return A peer callback
422          * @throws IOException
423          *             if an I/O error occurs communicating with the node
424          */
425         public HighLevelCallback<PeerResult> addPeer(NodeRef nodeRef) throws IOException {
426                 String identifier = generateIdentifier("addPeer");
427                 AddPeer addPeer = new AddPeer(nodeRef);
428                 HighLevelCallback<PeerResult> peerCallback = new HighLevelCallback<PeerResult>(new PeerResult(identifier));
429                 peerCallbacks.put(identifier, peerCallback);
430                 fcpConnection.sendMessage(addPeer);
431                 return peerCallback;
432         }
433
434         /**
435          * Checks whether direct disk access for the given directory is possible.
436          * You have to perform this check before you can upload or download anything
437          * from or the disk directly!
438          * 
439          * @param directory
440          *            The directory to check
441          * @param wantRead
442          *            Whether you want to read the given directory
443          * @param wantWrite
444          *            Whether you want to write to the given directory
445          * @return A direct disk access callback
446          * @throws IOException
447          */
448         public HighLevelCallback<DirectDiskAccessResult> checkDirectDiskAccess(String directory, boolean wantRead, boolean wantWrite) throws IOException {
449                 TestDDARequest testDDARequest = new TestDDARequest(directory, wantRead, wantWrite);
450                 HighLevelCallback<DirectDiskAccessResult> directDiskAccessCallback = new HighLevelCallback<DirectDiskAccessResult>(new DirectDiskAccessResult(directory));
451                 directDiskAccessCallbacks.put(directory, directDiskAccessCallback);
452                 fcpConnection.sendMessage(testDDARequest);
453                 return directDiskAccessCallback;
454         }
455
456         /**
457          * Starts a download. Files can either be download to disk or streamed from
458          * the node. When downloading to disk you have to perform a direct disk
459          * access check for the directory you want to put the downloaded file in!
460          * 
461          * @see #checkDirectDiskAccess(String, boolean, boolean)
462          * @param uri
463          *            The URI to get
464          * @param filename
465          *            The filename to save the data to, or <code>null</code> to
466          *            retrieve the data as InputStream from the
467          *            {@link DownloadResult}
468          * @param global
469          *            Whether to put the download on the global queue
470          * @return A download result
471          * @throws IOException
472          *             if an I/O error occurs communicating with the node
473          */
474         public HighLevelProgressCallback<DownloadResult> download(String uri, String filename, boolean global) throws IOException {
475                 String identifier = generateIdentifier("download");
476                 ClientGet clientGet = new ClientGet(uri, identifier, (filename == null) ? ReturnType.direct : ReturnType.disk);
477                 clientGet.setGlobal(global);
478                 HighLevelProgressCallback<DownloadResult> downloadCallback = new HighLevelProgressCallback<DownloadResult>(new DownloadResult(identifier));
479                 downloadCallbacks.put(identifier, downloadCallback);
480                 fcpConnection.sendMessage(clientGet);
481                 return downloadCallback;
482         }
483
484         /**
485          * Requests a list of all running requests from the node.
486          * 
487          * @return The request list result
488          * @throws IOException
489          *             if an I/O errors communicating with the node
490          */
491         public HighLevelCallback<RequestListResult> getRequests() throws IOException {
492                 String identifier = generateIdentifier("list-persistent-requests");
493                 ListPersistentRequests listPersistentRequests = new ListPersistentRequests();
494                 synchronized (syncObject) {
495                         if (requestListCallback != null) {
496                                 logger.log(Level.SEVERE, "getRequests() called with request still running!");
497                         }
498                         requestListCallback = new HighLevelCallback<RequestListResult>(new RequestListResult(identifier));
499                 }
500                 fcpConnection.sendMessage(listPersistentRequests);
501                 return requestListCallback;
502         }
503
504         //
505         // PRIVATE METHODS
506         //
507
508         /**
509          * Generates an identifier for the given function.
510          * 
511          * @param function
512          *            The name of the function
513          * @return An identifier
514          */
515         private String generateIdentifier(String function) {
516                 return "jFCPlib-" + function + "-" + System.currentTimeMillis();
517         }
518
519         /**
520          * Disconnects the client from the node, handing the given Throwable to
521          * {@link #fireClientDisconnected(Throwable)}.
522          * 
523          * @param throwable
524          *            The exception that caused the disconnect, or <code>null</code>
525          *            if there was no exception
526          */
527         private void disconnect(Throwable throwable) {
528                 fcpConnection.close();
529                 fireClientDisconnected(throwable);
530         }
531
532         /**
533          * FCP listener for {@link HighLevelClient}.
534          * 
535          * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
536          * @version $Id$
537          */
538         private class HighLevelClientFcpListener implements FcpListener {
539
540                 /** Mapping from directory to written file (for cleanup). */
541                 private final Map<DirectDiskAccessResult, String> writtenFiles = new HashMap<DirectDiskAccessResult, String>();
542
543                 /**
544                  * Creates a new FCP listener for {@link HighLevelClient}.
545                  */
546                 HighLevelClientFcpListener() {
547                         /* do nothing. */
548                 }
549
550                 //
551                 // PRIVATE METHODS
552                 //
553
554                 /**
555                  * Searches all callback collections for a callback with the given
556                  * identifier and cancels it.
557                  * 
558                  * @param identifier
559                  *            The identifier to search for, or <code>null</code> to
560                  *            cancel all pending requests
561                  */
562                 @SuppressWarnings("synthetic-access")
563                 private void cancelIdentifier(String identifier) {
564                         synchronized (syncObject) {
565                                 if (connectCallback != null) {
566                                         connectCallback.getIntermediaryResult().setFailed(true);
567                                         connectCallback.setDone();
568                                         connectCallback = null;
569                                 }
570                                 if (requestListCallback != null) {
571                                         requestListCallback.getIntermediaryResult().setFailed(true);
572                                         requestListCallback.setDone();
573                                         requestListCallback = null;
574                                 }
575                         }
576                         if (identifier == null) {
577                                 /* key generation callbacks */
578                                 for (Entry<String, HighLevelCallback<KeyGenerationResult>> keyGenerationEntry: keyGenerationCallbacks.entrySet()) {
579                                         keyGenerationEntry.getValue().getIntermediaryResult().setFailed(true);
580                                         keyGenerationEntry.getValue().setDone();
581                                 }
582                                 keyGenerationCallbacks.clear();
583                                 /* peer list callbacks. */
584                                 for (Entry<String, HighLevelCallback<PeerListResult>> peerListEntry: peerListCallbacks.entrySet()) {
585                                         peerListEntry.getValue().getIntermediaryResult().setFailed(true);
586                                         peerListEntry.getValue().setDone();
587                                 }
588                                 peerListCallbacks.clear();
589                                 /* peer callbacks. */
590                                 for (Entry<String, HighLevelCallback<PeerResult>> peerEntry: peerCallbacks.entrySet()) {
591                                         peerEntry.getValue().getIntermediaryResult().setFailed(true);
592                                         peerEntry.getValue().setDone();
593                                 }
594                                 peerCallbacks.clear();
595                                 /* direct disk access callbacks. */
596                                 for (Entry<String, HighLevelCallback<DirectDiskAccessResult>> directDiskAccessEntry: directDiskAccessCallbacks.entrySet()) {
597                                         directDiskAccessEntry.getValue().getIntermediaryResult().setFailed(true);
598                                         directDiskAccessEntry.getValue().setDone();
599                                 }
600                                 directDiskAccessCallbacks.clear();
601                                 /* download callbacks. */
602                                 for (Entry<String, HighLevelProgressCallback<DownloadResult>> downloadEntry: downloadCallbacks.entrySet()) {
603                                         downloadEntry.getValue().getIntermediaryResult().setFailed(true);
604                                         downloadEntry.getValue().setDone();
605                                 }
606                                 downloadCallbacks.clear();
607                         } else {
608                                 HighLevelCallback<KeyGenerationResult> keyGenerationCallback = keyGenerationCallbacks.remove(identifier);
609                                 if (keyGenerationCallback != null) {
610                                         keyGenerationCallback.getIntermediaryResult().setFailed(true);
611                                         keyGenerationCallback.setDone();
612                                         return;
613                                 }
614                                 HighLevelCallback<PeerListResult> peerListCallback = peerListCallbacks.remove(identifier);
615                                 if (peerListCallback != null) {
616                                         peerListCallback.getIntermediaryResult().setFailed(true);
617                                         peerListCallback.setDone();
618                                         return;
619                                 }
620                                 HighLevelCallback<PeerResult> peerCallback = peerCallbacks.remove(identifier);
621                                 if (peerCallback != null) {
622                                         peerCallback.getIntermediaryResult().setFailed(true);
623                                         peerCallback.setDone();
624                                         return;
625                                 }
626                                 HighLevelCallback<DirectDiskAccessResult> directDiskAccessCallback = directDiskAccessCallbacks.remove(identifier);
627                                 if (directDiskAccessCallback != null) {
628                                         directDiskAccessCallback.getIntermediaryResult().setFailed(true);
629                                         directDiskAccessCallback.setDone();
630                                         return;
631                                 }
632                                 HighLevelProgressCallback<DownloadResult> downloadCallback = downloadCallbacks.remove(identifier);
633                                 if (downloadCallback != null) {
634                                         downloadCallback.getIntermediaryResult().setFailed(true);
635                                         downloadCallback.setDone();
636                                         return;
637                                 }
638                         }
639                 }
640
641                 /**
642                  * Reads the given file and returns the first line of the file.
643                  * 
644                  * @param readFilename
645                  *            The name of the file to read
646                  * @return The content of the file
647                  */
648                 private String readContent(String readFilename) {
649                         FileReader fileReader = null;
650                         BufferedReader bufferedFileReader = null;
651                         try {
652                                 fileReader = new FileReader(readFilename);
653                                 bufferedFileReader = new BufferedReader(fileReader);
654                                 String content = bufferedFileReader.readLine();
655                                 return content;
656                         } catch (IOException ioe1) {
657                                 /* swallow. */
658                         } finally {
659                                 FcpUtils.close(bufferedFileReader);
660                                 FcpUtils.close(fileReader);
661                         }
662                         return null;
663                 }
664
665                 /**
666                  * Writes the given content to the given file.
667                  * 
668                  * @param directDiskAccessResult
669                  *            The DDA result
670                  * @param writeFilename
671                  *            The name of the file to write to
672                  * @param writeContent
673                  *            The content to write to the file
674                  */
675                 private void writeContent(DirectDiskAccessResult directDiskAccessResult, String writeFilename, String writeContent) {
676                         if ((writeFilename == null) || (writeContent == null)) {
677                                 return;
678                         }
679                         writtenFiles.put(directDiskAccessResult, writeFilename);
680                         FileWriter fileWriter = null;
681                         try {
682                                 fileWriter = new FileWriter(writeFilename);
683                                 fileWriter.write(writeContent);
684                         } catch (IOException ioe1) {
685                                 /* swallow. */
686                         } finally {
687                                 FcpUtils.close(fileWriter);
688                         }
689                 }
690
691                 /**
692                  * Cleans up any files that written for the given result.
693                  * 
694                  * @param directDiskAccessResult
695                  *            The direct disk access result
696                  */
697                 @SuppressWarnings("synthetic-access")
698                 private void cleanFiles(DirectDiskAccessResult directDiskAccessResult) {
699                         String writeFilename = writtenFiles.remove(directDiskAccessResult);
700                         if (writeFilename != null) {
701                                 if (!new File(writeFilename).delete()) {
702                                         logger.warning("could not delete " + writeFilename);
703                                 }
704                         }
705                 }
706
707                 //
708                 // INTERFACE FcpListener
709                 //
710
711                 /**
712                  * @see net.pterodactylus.fcp.FcpListener#connectionClosed(net.pterodactylus.fcp.FcpConnection,
713                  *      Throwable)
714                  */
715                 @SuppressWarnings("synthetic-access")
716                 public void connectionClosed(FcpConnection fcpConnection, Throwable throwable) {
717                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
718                                 return;
719                         }
720                         cancelIdentifier(null);
721                         disconnect(throwable);
722                 }
723
724                 /**
725                  * @see net.pterodactylus.fcp.FcpListener#receivedAllData(net.pterodactylus.fcp.FcpConnection,
726                  *      net.pterodactylus.fcp.AllData)
727                  */
728                 public void receivedAllData(FcpConnection fcpConnection, AllData allData) {
729                         /* TODO */
730                 }
731
732                 /**
733                  * @see net.pterodactylus.fcp.FcpListener#receivedCloseConnectionDuplicateClientName(net.pterodactylus.fcp.FcpConnection,
734                  *      net.pterodactylus.fcp.CloseConnectionDuplicateClientName)
735                  */
736                 public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName) {
737                         /* TODO */
738                 }
739
740                 /**
741                  * @see net.pterodactylus.fcp.FcpListener#receivedConfigData(net.pterodactylus.fcp.FcpConnection,
742                  *      net.pterodactylus.fcp.ConfigData)
743                  */
744                 public void receivedConfigData(FcpConnection fcpConnection, ConfigData configData) {
745                         /* TODO */
746                 }
747
748                 /**
749                  * @see net.pterodactylus.fcp.FcpListener#receivedDataFound(net.pterodactylus.fcp.FcpConnection,
750                  *      net.pterodactylus.fcp.DataFound)
751                  */
752                 public void receivedDataFound(FcpConnection fcpConnection, DataFound dataFound) {
753                         /* TODO */
754                 }
755
756                 /**
757                  * @see net.pterodactylus.fcp.FcpListener#receivedEndListPeerNotes(net.pterodactylus.fcp.FcpConnection,
758                  *      net.pterodactylus.fcp.EndListPeerNotes)
759                  */
760                 public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes) {
761                         /* TODO */
762                 }
763
764                 /**
765                  * @see net.pterodactylus.fcp.FcpListener#receivedEndListPeers(net.pterodactylus.fcp.FcpConnection,
766                  *      net.pterodactylus.fcp.EndListPeers)
767                  */
768                 @SuppressWarnings("synthetic-access")
769                 public void receivedEndListPeers(FcpConnection fcpConnection, EndListPeers endListPeers) {
770                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
771                                 return;
772                         }
773                         String identifier = endListPeers.getIdentifier();
774                         HighLevelCallback<PeerListResult> peerListCallback = peerListCallbacks.remove(identifier);
775                         if (peerListCallback == null) {
776                                 return;
777                         }
778                         peerListCallback.setDone();
779                 }
780
781                 /**
782                  * @see net.pterodactylus.fcp.FcpListener#receivedEndListPersistentRequests(net.pterodactylus.fcp.FcpConnection,
783                  *      net.pterodactylus.fcp.EndListPersistentRequests)
784                  */
785                 @SuppressWarnings("synthetic-access")
786                 public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests) {
787                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
788                                 return;
789                         }
790                         synchronized (syncObject) {
791                                 if (HighLevelClient.this.requestListCallback == null) {
792                                         logger.log(Level.WARNING, "got EndListPersistentRequests without running request!");
793                                         return;
794                                 }
795                                 requestListCallback.setDone();
796                                 requestListCallback = null;
797                         }
798                 }
799
800                 /**
801                  * @see net.pterodactylus.fcp.FcpListener#receivedFCPPluginReply(net.pterodactylus.fcp.FcpConnection,
802                  *      net.pterodactylus.fcp.FCPPluginReply)
803                  */
804                 public void receivedFCPPluginReply(FcpConnection fcpConnection, FCPPluginReply fcpPluginReply) {
805                         /* TODO */
806                 }
807
808                 /**
809                  * @see net.pterodactylus.fcp.FcpListener#receivedGetFailed(net.pterodactylus.fcp.FcpConnection,
810                  *      net.pterodactylus.fcp.GetFailed)
811                  */
812                 @SuppressWarnings("synthetic-access")
813                 public void receivedGetFailed(FcpConnection fcpConnection, GetFailed getFailed) {
814                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
815                                 return;
816                         }
817                         String identifier = getFailed.getIdentifier();
818                         HighLevelProgressCallback<DownloadResult> downloadCallback = downloadCallbacks.remove(identifier);
819                         if (downloadCallback != null) {
820                                 downloadCallback.getIntermediaryResult().setFailed(true);
821                                 downloadCallback.setDone();
822                                 return;
823                         }
824                         /* unknown identifier? */
825                         logger.warning("unknown identifier for GetFailed: " + identifier);
826                 }
827
828                 /**
829                  * @see net.pterodactylus.fcp.FcpListener#receivedIdentifierCollision(net.pterodactylus.fcp.FcpConnection,
830                  *      net.pterodactylus.fcp.IdentifierCollision)
831                  */
832                 public void receivedIdentifierCollision(FcpConnection fcpConnection, IdentifierCollision identifierCollision) {
833                         /* TODO */
834                 }
835
836                 /**
837                  * @see net.pterodactylus.fcp.FcpListener#receivedMessage(net.pterodactylus.fcp.FcpConnection,
838                  *      net.pterodactylus.fcp.FcpMessage)
839                  */
840                 public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage) {
841                         /* TODO */
842                 }
843
844                 /**
845                  * @see net.pterodactylus.fcp.FcpListener#receivedNodeData(net.pterodactylus.fcp.FcpConnection,
846                  *      net.pterodactylus.fcp.NodeData)
847                  */
848                 public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData) {
849                         /* TODO */
850                 }
851
852                 /**
853                  * @see net.pterodactylus.fcp.FcpListener#receivedNodeHello(net.pterodactylus.fcp.FcpConnection,
854                  *      net.pterodactylus.fcp.NodeHello)
855                  */
856                 @SuppressWarnings("synthetic-access")
857                 public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello) {
858                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
859                                 return;
860                         }
861                         synchronized (syncObject) {
862                                 connectCallback.getIntermediaryResult().setFailed(false);
863                                 connectCallback.setDone();
864                                 connectCallback = null;
865                         }
866                         fireClientConnected();
867                 }
868
869                 /**
870                  * @see net.pterodactylus.fcp.FcpListener#receivedPeer(net.pterodactylus.fcp.FcpConnection,
871                  *      net.pterodactylus.fcp.Peer)
872                  */
873                 @SuppressWarnings("synthetic-access")
874                 public void receivedPeer(FcpConnection fcpConnection, Peer peer) {
875                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
876                                 return;
877                         }
878                         String identifier = peer.getIdentifier();
879                         if (identifier == null) {
880                                 return;
881                         }
882                         HighLevelCallback<PeerListResult> peerListCallback = peerListCallbacks.get(identifier);
883                         if (peerListCallback != null) {
884                                 peerListCallback.getIntermediaryResult().addPeer(peer);
885                                 return;
886                         }
887                         HighLevelCallback<PeerResult> peerResult = peerCallbacks.remove(identifier);
888                         if (peerResult != null) {
889                                 peerResult.getIntermediaryResult().setPeer(peer);
890                                 peerResult.setDone();
891                                 return;
892                         }
893                         logger.warning("got Peer message with unknown identifier: " + identifier);
894                 }
895
896                 /**
897                  * @see net.pterodactylus.fcp.FcpListener#receivedPeerNote(net.pterodactylus.fcp.FcpConnection,
898                  *      net.pterodactylus.fcp.PeerNote)
899                  */
900                 public void receivedPeerNote(FcpConnection fcpConnection, PeerNote peerNote) {
901                         /* TODO */
902                 }
903
904                 /**
905                  * @see net.pterodactylus.fcp.FcpListener#receivedPeerRemoved(net.pterodactylus.fcp.FcpConnection,
906                  *      net.pterodactylus.fcp.PeerRemoved)
907                  */
908                 public void receivedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved) {
909                         /* TODO */
910                 }
911
912                 /**
913                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentGet(net.pterodactylus.fcp.FcpConnection,
914                  *      net.pterodactylus.fcp.PersistentGet)
915                  */
916                 @SuppressWarnings("synthetic-access")
917                 public void receivedPersistentGet(FcpConnection fcpConnection, PersistentGet persistentGet) {
918                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
919                                 return;
920                         }
921                         synchronized (syncObject) {
922                                 if (requestListCallback != null) {
923                                         RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
924                                         requestListResult.addRequestResult(new GetRequestResult(persistentGet));
925                                         return;
926                                 }
927                         }
928                         String identifier = persistentGet.getIdentifier();
929                         if (downloadCallbacks.containsKey(identifier)) {
930                                 /* TODO */
931                                 return;
932                         }
933                 }
934
935                 /**
936                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentPut(net.pterodactylus.fcp.FcpConnection,
937                  *      net.pterodactylus.fcp.PersistentPut)
938                  */
939                 @SuppressWarnings("synthetic-access")
940                 public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut) {
941                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
942                                 return;
943                         }
944                         synchronized (syncObject) {
945                                 if (requestListCallback != null) {
946                                         RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
947                                         requestListResult.addRequestResult(new PutRequestResult(persistentPut));
948                                         return;
949                                 }
950                         }
951                 }
952
953                 /**
954                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentPutDir(net.pterodactylus.fcp.FcpConnection,
955                  *      net.pterodactylus.fcp.PersistentPutDir)
956                  */
957                 @SuppressWarnings("synthetic-access")
958                 public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir) {
959                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
960                                 return;
961                         }
962                         synchronized (syncObject) {
963                                 if (requestListCallback != null) {
964                                         RequestListResult requestListResult = requestListCallback.getIntermediaryResult();
965                                         requestListResult.addRequestResult(new PutDirRequestResult(persistentPutDir));
966                                         return;
967                                 }
968                         }
969                 }
970
971                 /**
972                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentRequestModified(net.pterodactylus.fcp.FcpConnection,
973                  *      net.pterodactylus.fcp.PersistentRequestModified)
974                  */
975                 public void receivedPersistentRequestModified(FcpConnection fcpConnection, PersistentRequestModified persistentRequestModified) {
976                         /* TODO */
977                 }
978
979                 /**
980                  * @see net.pterodactylus.fcp.FcpListener#receivedPersistentRequestRemoved(net.pterodactylus.fcp.FcpConnection,
981                  *      net.pterodactylus.fcp.PersistentRequestRemoved)
982                  */
983                 public void receivedPersistentRequestRemoved(FcpConnection fcpConnection, PersistentRequestRemoved persistentRequestRemoved) {
984                         /* TODO */
985                 }
986
987                 /**
988                  * @see net.pterodactylus.fcp.FcpListener#receivedPluginInfo(net.pterodactylus.fcp.FcpConnection,
989                  *      net.pterodactylus.fcp.PluginInfo)
990                  */
991                 public void receivedPluginInfo(FcpConnection fcpConnection, PluginInfo pluginInfo) {
992                         /* TODO */
993                 }
994
995                 /**
996                  * @see net.pterodactylus.fcp.FcpListener#receivedProtocolError(net.pterodactylus.fcp.FcpConnection,
997                  *      net.pterodactylus.fcp.ProtocolError)
998                  */
999                 @SuppressWarnings("synthetic-access")
1000                 public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError) {
1001                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
1002                                 return;
1003                         }
1004                         String identifier = protocolError.getIdentifier();
1005                         if (identifier == null) {
1006                                 return;
1007                         }
1008                         cancelIdentifier(identifier);
1009                 }
1010
1011                 /**
1012                  * @see net.pterodactylus.fcp.FcpListener#receivedPutFailed(net.pterodactylus.fcp.FcpConnection,
1013                  *      net.pterodactylus.fcp.PutFailed)
1014                  */
1015                 public void receivedPutFailed(FcpConnection fcpConnection, PutFailed putFailed) {
1016                         /* TODO */
1017                 }
1018
1019                 /**
1020                  * @see net.pterodactylus.fcp.FcpListener#receivedPutFetchable(net.pterodactylus.fcp.FcpConnection,
1021                  *      net.pterodactylus.fcp.PutFetchable)
1022                  */
1023                 public void receivedPutFetchable(FcpConnection fcpConnection, PutFetchable putFetchable) {
1024                         /* TODO */
1025                 }
1026
1027                 /**
1028                  * @see net.pterodactylus.fcp.FcpListener#receivedPutSuccessful(net.pterodactylus.fcp.FcpConnection,
1029                  *      net.pterodactylus.fcp.PutSuccessful)
1030                  */
1031                 public void receivedPutSuccessful(FcpConnection fcpConnection, PutSuccessful putSuccessful) {
1032                         /* TODO */
1033                 }
1034
1035                 /**
1036                  * @see net.pterodactylus.fcp.FcpListener#receivedSSKKeypair(net.pterodactylus.fcp.FcpConnection,
1037                  *      net.pterodactylus.fcp.SSKKeypair)
1038                  */
1039                 @SuppressWarnings("synthetic-access")
1040                 public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair) {
1041                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
1042                                 return;
1043                         }
1044                         HighLevelCallback<KeyGenerationResult> keyGenerationCallback = keyGenerationCallbacks.remove(sskKeypair.getIdentifier());
1045                         if (keyGenerationCallback == null) {
1046                                 return;
1047                         }
1048                         KeyGenerationResult keyGenerationResult = keyGenerationCallback.getIntermediaryResult();
1049                         keyGenerationResult.setInsertURI(sskKeypair.getInsertURI());
1050                         keyGenerationResult.setRequestURI(sskKeypair.getRequestURI());
1051                         keyGenerationCallback.setDone();
1052                 }
1053
1054                 /**
1055                  * @see net.pterodactylus.fcp.FcpListener#receivedSimpleProgress(net.pterodactylus.fcp.FcpConnection,
1056                  *      net.pterodactylus.fcp.SimpleProgress)
1057                  */
1058                 @SuppressWarnings("synthetic-access")
1059                 public void receivedSimpleProgress(FcpConnection fcpConnection, SimpleProgress simpleProgress) {
1060                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
1061                                 return;
1062                         }
1063                         String identifier = simpleProgress.getIdentifier();
1064                         HighLevelProgressCallback<DownloadResult> downloadCallback = downloadCallbacks.get(identifier);
1065                         if (downloadCallback != null) {
1066                                 DownloadResult downloadResult = downloadCallback.getIntermediaryResult();
1067                                 downloadResult.setTotalBlocks(simpleProgress.getTotal());
1068                                 downloadResult.setRequiredBlocks(simpleProgress.getRequired());
1069                                 downloadResult.setSuccessfulBlocks(simpleProgress.getSucceeded());
1070                                 downloadResult.setFailedBlocks(simpleProgress.getFailed());
1071                                 downloadResult.setFatallyFailedBlocks(simpleProgress.getFatallyFailed());
1072                                 downloadResult.setTotalFinalized(simpleProgress.isFinalizedTotal());
1073                                 downloadCallback.progressUpdated();
1074                                 return;
1075                         }
1076                         HighLevelProgress highLevelProgress = new HighLevelProgress(identifier, simpleProgress.getTotal(), simpleProgress.getRequired(), simpleProgress.getSucceeded(), simpleProgress.getFailed(), simpleProgress.getFatallyFailed(), simpleProgress.isFinalizedTotal());
1077                         fireProgressReceived(identifier, highLevelProgress);
1078                 }
1079
1080                 /**
1081                  * @see net.pterodactylus.fcp.FcpListener#receivedStartedCompression(net.pterodactylus.fcp.FcpConnection,
1082                  *      net.pterodactylus.fcp.StartedCompression)
1083                  */
1084                 public void receivedStartedCompression(FcpConnection fcpConnection, StartedCompression startedCompression) {
1085                         /* TODO */
1086                 }
1087
1088                 /**
1089                  * @see net.pterodactylus.fcp.FcpListener#receivedSubscribedUSKUpdate(net.pterodactylus.fcp.FcpConnection,
1090                  *      net.pterodactylus.fcp.SubscribedUSKUpdate)
1091                  */
1092                 public void receivedSubscribedUSKUpdate(FcpConnection fcpConnection, SubscribedUSKUpdate subscribedUSKUpdate) {
1093                         /* TODO */
1094                 }
1095
1096                 /**
1097                  * @see net.pterodactylus.fcp.FcpListener#receivedTestDDAComplete(net.pterodactylus.fcp.FcpConnection,
1098                  *      net.pterodactylus.fcp.TestDDAComplete)
1099                  */
1100                 @SuppressWarnings("synthetic-access")
1101                 public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete) {
1102                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
1103                                 return;
1104                         }
1105                         String directory = testDDAComplete.getDirectory();
1106                         if (directory == null) {
1107                                 return;
1108                         }
1109                         HighLevelCallback<DirectDiskAccessResult> directDiskAccessCallback = directDiskAccessCallbacks.remove(directory);
1110                         DirectDiskAccessResult directDiskAccessResult = directDiskAccessCallback.getIntermediaryResult();
1111                         cleanFiles(directDiskAccessResult);
1112                         directDiskAccessResult.setReadAllowed(testDDAComplete.isReadDirectoryAllowed());
1113                         directDiskAccessResult.setWriteAllowed(testDDAComplete.isWriteDirectoryAllowed());
1114                         directDiskAccessCallback.setDone();
1115                 }
1116
1117                 /**
1118                  * @see net.pterodactylus.fcp.FcpListener#receivedTestDDAReply(net.pterodactylus.fcp.FcpConnection,
1119                  *      net.pterodactylus.fcp.TestDDAReply)
1120                  */
1121                 @SuppressWarnings("synthetic-access")
1122                 public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply) {
1123                         if (fcpConnection != HighLevelClient.this.fcpConnection) {
1124                                 return;
1125                         }
1126                         String directory = testDDAReply.getDirectory();
1127                         if (directory == null) {
1128                                 return;
1129                         }
1130                         DirectDiskAccessResult directDiskAccessResult = directDiskAccessCallbacks.get(directory).getIntermediaryResult();
1131                         String readFilename = testDDAReply.getReadFilename();
1132                         String readContent = readContent(readFilename);
1133                         String writeFilename = testDDAReply.getWriteFilename();
1134                         String writeContent = testDDAReply.getContentToWrite();
1135                         writeContent(directDiskAccessResult, writeFilename, writeContent);
1136                         TestDDAResponse testDDAResponse = new TestDDAResponse(directory, readContent);
1137                         try {
1138                                 fcpConnection.sendMessage(testDDAResponse);
1139                         } catch (IOException e) {
1140                                 /* swallow. I’m verry unhappy about this. */
1141                         }
1142                 }
1143
1144                 /**
1145                  * @see net.pterodactylus.fcp.FcpListener#receivedURIGenerated(net.pterodactylus.fcp.FcpConnection,
1146                  *      net.pterodactylus.fcp.URIGenerated)
1147                  */
1148                 public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated) {
1149                         /* TODO */
1150                 }
1151
1152                 /**
1153                  * @see net.pterodactylus.fcp.FcpListener#receivedUnknownNodeIdentifier(net.pterodactylus.fcp.FcpConnection,
1154                  *      net.pterodactylus.fcp.UnknownNodeIdentifier)
1155                  */
1156                 public void receivedUnknownNodeIdentifier(FcpConnection fcpConnection, UnknownNodeIdentifier unknownNodeIdentifier) {
1157                         /* TODO */
1158                 }
1159
1160                 /**
1161                  * @see net.pterodactylus.fcp.FcpListener#receivedUnknownPeerNoteType(net.pterodactylus.fcp.FcpConnection,
1162                  *      net.pterodactylus.fcp.UnknownPeerNoteType)
1163                  */
1164                 public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, UnknownPeerNoteType unknownPeerNoteType) {
1165                         /* TODO */
1166                 }
1167
1168                 /**
1169                  * @see net.pterodactylus.fcp.FcpListener#receviedFinishedCompression(net.pterodactylus.fcp.FcpConnection,
1170                  *      net.pterodactylus.fcp.FinishedCompression)
1171                  */
1172                 public void receviedFinishedCompression(FcpConnection fcpConnection, FinishedCompression finishedCompression) {
1173                         /* TODO */
1174                 }
1175
1176         }
1177
1178 }