Пример #1
0
 /*
  * Returns true if both rfd "have the same content".  Currently
  * rfd1~=rfd2 iff either of the following conditions hold:
  *
  * <ul>
  * <li>Both files have the same hash, i.e.,
  *     rfd1.getSHA1Urn().equals(rfd2.getSHA1Urn().  Note that this (almost)
  *     always means that rfd1.getSize()==rfd2.getSize(), though rfd1 and
  *     rfd2 may have different names.
  * <li>Both files have the same name and size and don't have conflicting
  *     hashes, i.e., rfd1.getName().equals(rfd2.getName()) &&
  *     rfd1.getSize()==rfd2.getSize() && (rfd1.getSHA1Urn()==null ||
  *     rfd2.getSHA1Urn()==null ||
  *     rfd1.getSHA1Urn().equals(rfd2.getSHA1Urn())).
  * </ul>
  * Note that the second condition allows risky resumes, i.e., resumes when
  * one (or both) of the files doesn't have a hash.
  *
  * @see getFile
  */
 static boolean same(RemoteFileDesc rfd1, RemoteFileDesc rfd2) {
   return same(
       rfd1.getFileName(),
       rfd1.getSize(),
       rfd1.getSHA1Urn(),
       rfd2.getFileName(),
       rfd2.getSize(),
       rfd2.getSHA1Urn());
 }
  /**
   * Creates a new LimeWire result.
   *
   * @param sha1 The hash of the file.
   * @param rfd The base descriptor for the file.
   * @param hd The host data.
   * @param ipPorts The endpoints for the file.
   * @throws URISyntaxException If there's an error creating any associated URIs.
   */
  public LimeWireResult(
      final URI sha1,
      final RemoteFileDesc rfd,
      final GUID queryGUID,
      final Set<? extends IpPort> ipPorts)
      throws URISyntaxException {
    super(
        rfd.getFileName(),
        sha1,
        createThumbnailUrl(rfd.getFileName()),
        -1,
        -1,
        rfd.getSize(),
        "limewire",
        sha1,
        null);

    this.m_queryGUID = queryGUID;
    this.m_alts.addAll(ipPorts);
    this.m_rfds.add(rfd);
  }
Пример #3
0
 /**
  * Constructs a new RemoteFileDesc exactly like the other one, but with a different push proxy
  * host. Will be handy when processing head pongs.
  */
 public RemoteFileDesc(RemoteFileDesc rfd, PushEndpoint pe) {
   this(
       rfd.getHost(), // host - ignored
       rfd.getPort(), // port -ignored
       COPY_INDEX, // index (unknown)
       rfd.getFileName(), // filename
       rfd.getSize(), // filesize
       rfd.getSpeed(), // speed
       false, // chat capable
       rfd.getQuality(), // quality
       false, // browse hostable
       rfd.getUrns(), // urns
       false, // reply to MCast
       true, // is firewalled
       AlternateLocation.ALT_VENDOR, // vendor
       System.currentTimeMillis(), // timestamp
       rfd.getCreationTime(), // creation time
       pe);
 }
Пример #4
0
 /**
  * Constructs a new RemoteFileDesc exactly like the other one, but with a different remote host.
  *
  * <p>It is okay to use the same internal structures for URNs because the Set is immutable.
  */
 public RemoteFileDesc(RemoteFileDesc rfd, IpPort ep) {
   this(
       ep.getAddress(), // host
       ep.getPort(), // port
       COPY_INDEX, // index (unknown)
       rfd.getFileName(), // filename
       rfd.getSize(), // filesize
       DataUtils.EMPTY_GUID, // client GUID
       0, // speed
       false, // chat capable
       2, // quality
       false, // browse hostable
       rfd.getUrns(), // urns
       false, // reply to MCast
       false, // is firewalled
       AlternateLocation.ALT_VENDOR, // vendor
       System.currentTimeMillis(), // timestamp
       Collections.EMPTY_SET, // push proxies
       rfd.getCreationTime(), // creation time
       0); // firewalled transfer
 }
Пример #5
0
 /**
  * Same as getFile(String, urn, int), except taking the values from the RFD. getFile(rfd) ==
  * getFile(rfd.getFileName(), rfd.getSHA1Urn(), rfd.getSize());
  */
 public synchronized File getFile(RemoteFileDesc rfd) throws IOException {
   return getFile(rfd.getFileName(), rfd.getSHA1Urn(), rfd.getSize());
 }