Package org.eclipse.ecf.protocol.bittorrent

Examples of org.eclipse.ecf.protocol.bittorrent.TorrentFile


  PeerConnection(ConnectionPool pool, TorrentManager manager)
      throws UnsupportedEncodingException {
    this.pool = pool;
    this.manager = manager;
    TorrentFile torrent = manager.getTorrentFile();
    StringBuffer buffer = new StringBuffer(PROTOCOL_STRING);
    synchronized (buffer) {
      buffer.append(torrent.getInfoHash());
      buffer.append(manager.getPeerID());
    }
    handshake = buffer.toString().getBytes("ISO-8859-1"); //$NON-NLS-1$
    peerPieces = new boolean[torrent.getNumPieces()];
    haveMessages = new boolean[peerPieces.length];
    Arrays.fill(peerPieces, false);
    Arrays.fill(haveMessages, false);
  }
View Full Code Here


    super(url);
  }

  public void connect() throws IOException {
    if (torrent == null) {
      torrent = TorrentFactory.createTorrent(new TorrentFile(new File(url
          .getFile())));
      torrent.start();
    }
  }
View Full Code Here

        if (localFileToSave.exists() && !localFileToSave.canWrite()) {
          throw new IOException("file="+localFileToSave.getAbsolutePath()+" does not exist or cannot be written to"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        final TorrentFile file = new TorrentFile(((TorrentID) remoteFileReference).getFile());
        file.setTargetFile(localFileToSave);
        final Torrent torrent = TorrentFactory.createTorrent(file);
        transfer = new TorrentFileTransfer(remoteFileReference, transferListener, torrent);
        return transfer;
      }

      public IIncomingFileTransfer receive(File localFileToSave, FileTransferJob fileTransferJob) throws IOException {
        if (cancelled) {
          throw new RuntimeException(new UserCancelledException());
        }

        Assert.isNotNull(localFileToSave, "localFileToSave must not be null"); //$NON-NLS-1$

        if (localFileToSave.exists() && !localFileToSave.canWrite()) {
          throw new IOException("file="+localFileToSave.getAbsolutePath()+" does not exist or cannot be written to"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        final TorrentFile file = new TorrentFile(((TorrentID) remoteFileReference).getFile());
        file.setTargetFile(localFileToSave);
        final Torrent torrent = TorrentFactory.createTorrent(file);
        transfer = new TorrentFileTransfer(remoteFileReference, transferListener, torrent);
        return transfer;
      }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.protocol.bittorrent.TorrentFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.