Package xnap.plugin.nap.net

Examples of xnap.plugin.nap.net.Upload


  if (NapPreferences.getInstance().getWhoisQueryOnTransfer()) {
      server.getUser(nick).update(true);
  }

  File file = NapFileHelper.getRepositoryFile(filename);
  Upload u = new Upload(nick, file, server, filename);
 
//    if (file == null || !server.getUser(nick).isAllowedToDownload()) {
//        logger.warn("rejecting leecher / invalid request: " + nick + " "
//        + filename);
//        u.reject();
//        return;

  if (file == null) {
        logger.warn("invalid request: " + nick + " " + filename);
        u.reject();
        return;
  }
 
  if (!server.getUser(nick).isAllowedToDownload()) {
        logger.warn("rejecting leecher" + nick + " " + filename);
        u.reject();
        return;
  }
 
  UploadQueue uq = UploadQueue.getInstance();
  logger.debug("upload: " + nick + " " + filename);

  boolean added = uq.add(u);
  if (added) {
      // give the download queue a chance to start the download
      // right away to avoid sending local queued responses
      try {
    Thread.currentThread().sleep(20);
      }
      catch (InterruptedException e) {
      }
  }

  int pos = uq.getLocalQueuePos(u);
  if (pos == -1 && !added) {
      if (uq.isRunning(u)) {
    // some clients need two confirmations before they start
    // downloading
    MessageHandler.send
        (server, new UploadAckMessage(nick, filename));
      }
      else {
    logger.warn("upload queue rejected " + filename);
    u.reject();
      }
  }
  else if (pos != -1) {
      // pos == 0 means busy, so we always send pos > 0
      QueueLimitMessage m = new QueueLimitMessage(nick, filename,
View Full Code Here

TOP

Related Classes of xnap.plugin.nap.net.Upload

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.