Package org.jmule.core.jkad.publisher

Examples of org.jmule.core.jkad.publisher.Publisher$PublishTaskListener


        kad_task.task_info = keyword_search_task.getKeyword();
      }
    }
    if (task.getRequestType() == RequestType.STORE) {
      kad_task.task_type = _._("mainwindow.kadtab.store");
      Publisher publisher = _jkad.getPublisher();
      if (publisher.getPublishKeywordTask(task.getTargetID())!=null) {
        PublishKeywordTask publish_keyword = publisher.getPublishKeywordTask(task.getTargetID());
        StringTag file_name = (StringTag)publish_keyword.getTagList().getTag(JKadConstants.TAG_FILENAME);
        kad_task.task_info = (String)file_name.getValue();
      } else
      if (publisher.getPublishSourceTask(task.getTargetID())!=null) {
        PublishSourceTask publish_keyword = publisher.getPublishSourceTask(task.getTargetID());
        StringTag file_name = (StringTag)publish_keyword.getTagList().getTag(JKadConstants.TAG_FILENAME);
        kad_task.task_info = (String)file_name.getValue();
      }
    }
   
View Full Code Here


      public void run() {
        if (getStatus() != JKadStatus.CONNECTED) return;
        SharingManager sharing_manager = SharingManagerSingleton
            .getInstance();
        Publisher publisher = Publisher.getInstance();
        ConfigurationManager config_manager = ConfigurationManagerSingleton
            .getInstance();
        Iterable<SharedFile> shared_files = sharing_manager
            .getSharedFiles();
        long filesToPublish = 0;
        for (SharedFile file : shared_files) {
          if (publisher.getPublishKeywordCount() > JKadConstants.MAX_CONCURRENT_PUBLISH_FILES) {
            break;
          }
          if (publishedFiles.contains(file.getFileHash()))
            continue;
          if (filesToPublish > JKadConstants.ITERATION_MAX_PUBLISH_FILES)
            break;
          if (file instanceof PartialFile) {
            PartialFile p_file = (PartialFile) file;
            if (p_file.getAvailablePartCount()==0) continue;
          }
          publishedFiles.add(file.getFileHash());

          byte[] hash = file.getFileHash().getHash().clone();
          Convert.updateSearchID(hash);
          Int128 id = new Int128(hash);

          if (!publisher.isPublishingSource(id)) {
            filesToPublish++;
            List<Tag> tagList = new LinkedList<Tag>();
            tagList.add(new StringTag(TAG_FILENAME, file
                .getSharingName()));
            tagList.add(new IntTag(TAG_FILESIZE, (int) file
                .length()));
            tagList
                .add(new IntTag(TAG_SOURCEIP,
                    org.jmule.core.utils.Convert
                        .byteToInt(getIPAddress()
                            .getAddress())));
            try {
              tagList.add(new IntTag(TAG_SOURCEPORT,
                  config_manager.getTCP()));
            } catch (ConfigurationManagerException e) {
              e.printStackTrace();
            }

            publisher.publishSource(id, tagList);
          }
          if (!publisher.isPublishingKeyword(id)) {
            filesToPublish++;
            List<Tag> tagList = new LinkedList<Tag>();
            tagList.add(new StringTag(TAG_FILENAME, file
                .getSharingName()));
            tagList.add(new IntTag(TAG_FILESIZE, (int) file
                .length()));

            publisher.publishKeyword(id, tagList);
          }

          if (file.getTagList().hasTag(TAG_FILERATING))
            if (!publisher.isPublishingNote(id)) {
              filesToPublish++;
              List<Tag> tagList = new LinkedList<Tag>();
              tagList.add(new StringTag(TAG_FILENAME, file
                  .getSharingName()));
              tagList.add(new IntTag(TAG_FILESIZE, (int) file
                  .length()));
              tagList.add(new IntTag(TAG_FILERATING, file
                  .getFileQuality().getAsInt()));

              publisher.publishNote(id, tagList);
            }
        }
      }
    };
View Full Code Here

TOP

Related Classes of org.jmule.core.jkad.publisher.Publisher$PublishTaskListener

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.