public void fileDescriptorReceived(DownloadConnection source, FileDescriptor fd) throws IOException { if (this.fd != null) { if (T.t) { T.info("Already has FD. Ignore the new one and start download for this connection."); } if (T.t) { T.ass(source.readyToStartDownload(), "Not ready to start download?"); } if (needsMoreDownloadConnections()) { source.startDownloadingBlock(); } return; } if (T.t) { T.debug("Received file descriptor " + fd); } this.fd = fd; setState(State.DOWNLOADING); ArrayList<DownloadConnection> al = new ArrayList<DownloadConnection>(); for (DownloadConnection c : connections.values()) { al.add(c); } for (DownloadConnection c : al) { if (c.readyToStartDownload() && needsMoreDownloadConnections()) { c.startDownloadingBlock(); } } }
public void abortAndRemovePerfmanently() throws IOException { for (DownloadConnection c : connections.values()) { if (c.isConnected()) { c.sendGracefulClose(); } } storage.removePermanently(root); }
public boolean isDownloadingFd() { for (DownloadConnection c : connections.values()) { if (c.isDownloadingFd()) { return true; } } return false; }
private Connection getConnectionByGUID(int srcGuid) { for (DownloadConnection c : connections.values()) { if (c.getRemoteUserGUID() == srcGuid) { return c; } } return null; }
public void connectionEstablished(DownloadConnection downloadConnection) { connections.put(downloadConnection.getRemoteFriend(), downloadConnection); if (T.t) { T.trace( "Connection established: " + downloadConnection + " connections: " + connections.size()); } }
public void removeConnection(DownloadConnection downloadConnection) throws IOException { connections.remove(downloadConnection.getRemoteFriend()); if (connections.size() == 0 && isComplete()) { if (T.t) { T.info("Download is complete"); } manager.downloadComplete(this); } }
public void addConnection(DownloadConnection con) { connections.put(con.getRemoteFriend(), con); }