示例#1
0
  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();
      }
    }
  }
示例#2
0
 public void abortAndRemovePerfmanently() throws IOException {
   for (DownloadConnection c : connections.values()) {
     if (c.isConnected()) {
       c.sendGracefulClose();
     }
   }
   storage.removePermanently(root);
 }
示例#3
0
 public boolean isDownloadingFd() {
   for (DownloadConnection c : connections.values()) {
     if (c.isDownloadingFd()) {
       return true;
     }
   }
   return false;
 }
示例#4
0
 private Connection getConnectionByGUID(int srcGuid) {
   for (DownloadConnection c : connections.values()) {
     if (c.getRemoteUserGUID() == srcGuid) {
       return c;
     }
   }
   return null;
 }
示例#5
0
 public void connectionEstablished(DownloadConnection downloadConnection) {
   connections.put(downloadConnection.getRemoteFriend(), downloadConnection);
   if (T.t) {
     T.trace(
         "Connection established: " + downloadConnection + " connections: " + connections.size());
   }
 }
示例#6
0
 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);
   }
 }
示例#7
0
 public void addConnection(DownloadConnection con) {
   connections.put(con.getRemoteFriend(), con);
 }