Package org.gudy.azureus2.plugins.download

Examples of org.gudy.azureus2.plugins.download.Download


     
      Iterator it = actively_tracking.iterator();
     
      while( it.hasNext()){
       
        Download download = (Download)it.next();
       
        PeerManager pm = download.getPeerManager();
       
        if ( pm != null ){
         
          Peer[] peers = pm.getPeers();
         
View Full Code Here


         
          while( it.hasNext()){
           
            Map.Entry  entry = (Map.Entry)it.next();
           
            Download d = (Download)entry.getKey();

            buddyDownloadData  bdd = (buddyDownloadData)entry.getValue();
           
            boolean  local_complete = d.isComplete( false );
           
            if ( local_complete != bdd.isLocalComplete()){
             
              bdd.setLocalComplete( local_complete );
             
              comp_changed.add( d );
            }
          }
        }
      }
     
      if ( comp_changed.size() > 0 ){
       
        byte[][] change_details = exportFullIDs( comp_changed );
       
        if( change_details[0].length > 0 ){
         
          Map  msg = new HashMap();
                   
          msg.put( "seeding", new Long( seeding_only?1:0 ));
         
          msg.put( "change",     change_details[0] );
          msg.put( "change_s",   change_details[1] );

          sendMessage( buddy, REQUEST_TRACKER_CHANGE, msg );
        }
      }
     
      if ( id == downloads_sent_id ){
       
        return;
      }
     
      Long  key = new Long(((long)id) << 32 | (long)downloads_sent_id);
       
      Object[]  diffs = (Object[])diff_map.get( key );
     
      boolean  incremental = downloads_sent != null;
     
      byte[]  added_bytes;
      byte[]  removed_bytes;
     
      if ( diffs == null ){
       
        List  added;
        List  removed  = new ArrayList();
       

        if ( downloads_sent == null ){
         
          added   = new ArrayList( downloads );
         
        }else{
         
          added  = new ArrayList();

          Iterator  it1 = downloads.iterator();
         
          while( it1.hasNext()){
         
            Download download = (Download)it1.next();
           
            if ( okToTrack( download )){
             
              if ( !downloads_sent.contains( download )){
               
                added.add( download );
              }
            }
          }
         
          Iterator  it2 = downloads_sent.iterator();
         
          while( it2.hasNext()){
         
            Download download = (Download)it2.next();
           
            if ( !downloads.contains( download )){
             
              removed.add( download );
            }
View Full Code Here

         
          Iterator it = removed.keySet().iterator();
         
          while( it.hasNext()){
           
            Download d = (Download)it.next();
           
            if ( downloads_in_common.remove( d ) != null ){
             
              log( "Removed " + d.getName() + " common download", false, true );
            }
          }
       
          if ( downloads_in_common.size() == 0 ){
           
View Full Code Here

           
            Iterator it = downloads_in_common.keySet().iterator();
           
            while( it.hasNext()){
             
              Download download = (Download)it.next();
             
              if ( !downloads.containsKey( download )){
               
                log( "Removing " + download.getName() + " from common downloads", false, true );

                it.remove();
              }
            }
          }
        }
       
        Iterator it = downloads.entrySet().iterator();
       
        while( it.hasNext()){
         
          Map.Entry  entry = (Map.Entry)it.next();
     
          Download d = (Download)entry.getKey();

          buddyDownloadData  bdd = (buddyDownloadData)entry.getValue();
         
          buddyDownloadData existing = (buddyDownloadData)downloads_in_common.get( d );
         
          if ( existing == null ){
           
            log( "Adding " + d.getName() + " to common downloads (bdd=" + bdd.getString() + ")", false, true );
           
            downloads_in_common.put( d, bdd );
           
          }else{
           
            boolean  old_rc = existing.isRemoteComplete();
            boolean  new_rc = bdd.isRemoteComplete();
           
            if ( old_rc != new_rc ){
           
              existing.setRemoteComplete( new_rc );
             
              log( "Changing " + d.getName() + " common downloads (bdd=" + existing.getString() + ")", false, true );
            }       
          }
        }
       
        if ( downloads_in_common.size() == 0 ){
View Full Code Here

    {
      byte[]  res = new byte[ SHORT_ID_SIZE * downloads.size() ];
     
      for (int i=0;i<downloads.size();i++ ){
       
        Download download = (Download)downloads.get(i);
       
        downloadData download_data = (downloadData)download.getUserData( BuddyPluginTracker.class );
       
        if ( download_data != null ){

          System.arraycopy(
            download_data.getID().getBytes(),
View Full Code Here

         byte[]  hashes   = new byte[ FULL_ID_SIZE * downloads.size() ];
         byte[]   states  = new byte[ downloads.size()];
        
         for (int i=0;i<downloads.size();i++ ){
          
           Download download = (Download)downloads.get(i);
          
           downloadData download_data = (downloadData)download.getUserData( BuddyPluginTracker.class );
          
           if ( download_data != null ){

             System.arraycopy(
               download_data.getID().getBytes(),
               0,
               hashes,
               i * FULL_ID_SIZE,
               FULL_ID_SIZE );
            
             states[i] = download.isComplete( false )?(byte)0x01:(byte)0x00;
           }
         }
        
         return( new byte[][]{ hashes, states });
       }
View Full Code Here

       
        synchronized( tracked_downloads ){

          for (int i=0;i<ids.length;i+= FULL_ID_SIZE ){
         
            Download dl = (Download)full_id_map.get( new HashWrapper( ids, i, FULL_ID_SIZE ));
           
            if ( dl != null ){
             
              buddyDownloadData bdd = new buddyDownloadData( dl );
             
View Full Code Here

       
        while( it.hasNext()){
         
          Map.Entry  entry = (Map.Entry)it.next();
     
          Download d = (Download)entry.getKey();

          buddyDownloadData  bdd = (buddyDownloadData)entry.getValue();
         
          if ( d.isComplete( false ) && bdd.isRemoteComplete()){
           
              // both complete, nothing to do!
           
            log( d.getName() + " - not tracking, both complete", true, true );
           
          }else{
           
            long  last_track = bdd.getTrackTime();
           
            if (   last_track == 0 ||
                now - last_track >= TRACK_INTERVAL ){
             
              log( d.getName() + " - tracking", false, true );

              bdd.setTrackTime( now );
             
              res.put( d, new Boolean( true ));
             
View Full Code Here

          List<Torrent>    torrents,
          TableRow      row )
        {
          Object obj = row.getDataSource();
         
          Download  download;
         
          if ( obj instanceof Download ){
           
            download = (Download)obj;
           
          }else{
           
            DiskManagerFileInfo file = (DiskManagerFileInfo)obj;
           
            try{
              download  = file.getDownload();
             
            }catch( DownloadException e ){ 
             
              Debug.printStackTrace(e);
             
              return;
            }
          }
         
          Torrent torrent = download.getTorrent();
         
          if ( torrent != null && !TorrentUtils.isReallyPrivate( PluginCoreUtils.unwrap( torrent ))){
           
            torrents.add( torrent );
          }
View Full Code Here

   
    long  fingerprint  = 0;
   
    for (int i=0;i<downloads.length;i++){
     
      Download download = downloads[i];
     
      Torrent torrent = download.getTorrent();
     
      if ( torrent == null ){
       
        continue;
      }
     
      String dl_cat = download.getAttribute( ta_category );
   
      if (   category.equalsIgnoreCase( "all" ) ||
          ( dl_cat != null && dl_cat.equals( category ))){
       
        if ( !TorrentUtils.isReallyPrivate( PluginCoreUtils.unwrap( torrent ))){
         
          selected_dls.add( download );
         
          byte[] hash = torrent.getHash();
         
          int  num = (hash[0]<<24)&0xff000000 | (hash[1] << 16)&0x00ff0000 | (hash[2] << 8)&0x0000ff00 | hash[3]&0x000000ff;

          fingerprint += num;
        }
      }
    }
   
    PluginConfig pc = plugin_interface.getPluginconfig();

    String  feed_finger_key = "feed_finger.category." + category;
    String  feed_date_key   = "feed_date.category." + category;

    long  existing_fingerprint   = pc.getPluginLongParameter( feed_finger_key, 0 );
    long  feed_date         = pc.getPluginLongParameter( feed_date_key, 0 );

    long  now = SystemTime.getCurrentTime();

    if ( existing_fingerprint == fingerprint ){
     
        // update every now and then to pick up new peer/seed values
     
      if ( selected_dls.size() > 0 ){

        if (   now < feed_date ||
            now - feed_date > FEED_UPDATE_MIN_MILLIS ){
         
          feed_date = now;
       
          pc.setPluginParameter( feed_date_key, feed_date );
        }
      }
    }else{
     
      pc.setPluginParameter( feed_finger_key, fingerprint );
     
     
        // ensure feed date goes up
     
      if ( now <= feed_date ){
       
        feed_date++;
       
      }else{
       
        feed_date = now;
      }
     
      pc.setPluginParameter( feed_date_key, feed_date );
    }
   
    String last_modified = TimeFormatter.getHTTPDate( feed_date );

    if ( if_mod != null && if_mod.equals( last_modified )){
     
      return( new feedDetails( new byte[0], last_modified ));
    }
       
    ByteArrayOutputStream  os = new ByteArrayOutputStream();
     
    try{
      PrintWriter pw = new PrintWriter(new OutputStreamWriter( os, "UTF-8" ));
     
      pw.println( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
     
      pw.println( "<rss version=\"2.0\" xmlns:vuze=\"http://www.vuze.com\">" );
     
      pw.println( "<channel>" );
     
      pw.println( "<title>" + escape( category ) + "</title>" );
     
      Collections.sort(
        selected_dls,
        new Comparator<Download>()
        {
          public int
          compare(
            Download d1,
            Download d2)
          {
            long  added1 = getAddedTime( d1 )/1000;
            long  added2 = getAddedTime( d2 )/1000;
   
            return((int)(added2 - added1 ));
          }
        });
               
             
      pw.println"<pubDate>" + last_modified + "</pubDate>" );
   
      for (int i=0;i<selected_dls.size();i++){
       
        Download download = (Download)selected_dls.get( i );
       
        DownloadManager  core_download = PluginCoreUtils.unwrap( download );
       
        Torrent torrent = download.getTorrent();
       
        String  hash_str = Base32.encode( torrent.getHash());
       
        pw.println( "<item>" );
       
        pw.println( "<title>" + escape( download.getName()) + "</title>" );
       
        pw.println( "<guid>" + hash_str + "</guid>" );
       
        long added = core_download.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME);
       
        pw.println"<pubDate>" + TimeFormatter.getHTTPDate( added ) + "</pubDate>" );
       
        pw.println"<vuze:size>" + torrent.getSize()+ "</vuze:size>" );
        pw.println"<vuze:assethash>" + hash_str + "</vuze:assethash>" );
       
        String url = "azplug:?id=azbuddy&name=Friends&arg=";
       
        String arg = "pk=" + getPublicKey() + "&cat=" + category + "&hash=" + Base32.encode(torrent.getHash());

        url += URLEncoder.encode( arg, "UTF-8" );
     
        pw.println( "<vuze:downloadurl>" + escape( url ) + "</vuze:downloadurl>" );
   
        DownloadScrapeResult scrape = download.getLastScrapeResult();
       
        if ( scrape != null && scrape.getResponseType() == DownloadScrapeResult.RT_SUCCESS ){
         
          pw.println"<vuze:seeds>" + scrape.getSeedCount() + "</vuze:seeds>" );
          pw.println"<vuze:peers>" + scrape.getNonSeedCount() + "</vuze:peers>" );
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.download.Download

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.