Examples of Download


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

    byte[]  hash   = (byte[])attributes.get( AT_BTIH );
    int    index  = ((Integer)attributes.get( AT_FILE_INDEX )).intValue();
   
    try{

      Download download = PluginInitializer.getDefaultInterface().getDownloadManager().getDownload(hash);
   
      if ( download == null ){
       
        return( null );
      }
     
      Torrent  t_torrent = download.getTorrent();
     
      if ( t_torrent == null ){
       
        return( null );
      }

      String ud_key = "AzureusPlatformContentDirectory" + ":" + index;
     
      AzureusContentFile acf = (AzureusContentFile)download.getUserData( ud_key );
     
      if ( acf != null ){
       
        return( acf );
      }   
     
      final TOTorrent torrent = ((TorrentImpl)t_torrent).getTorrent();
     
      final DiskManagerFileInfo  file = download.getDiskManagerFileInfo()[index];

      if ( PlatformTorrentUtils.isContent( torrent, false )){
     
        acf =
          new AzureusContentFile()
          {
            public DiskManagerFileInfo
            getFile()
            {
              return( file );
            }
           
            public Object
            getProperty(
              String    name )
            {
              try{
                if ( name.equals( PT_DURATION )){
                 
                  long duration = PlatformTorrentUtils.getContentVideoRunningTime( torrent );
                 
                  if ( duration > 0 ){
                   
                      // secs -> millis
                   
                    return( new Long( duration*1000 ));
                  }
                }else if ( name.equals( PT_VIDEO_WIDTH )){
   
                  int[] res = PlatformTorrentUtils.getContentVideoResolution(torrent);
                 
                  if ( res != null ){
                   
                    return(new Long( res[0]));
                  }               
                }else if ( name.equals( PT_VIDEO_HEIGHT )){
   
                  int[] res = PlatformTorrentUtils.getContentVideoResolution(torrent);
                 
                  if ( res != null ){
                   
                    return(new Long( res[1] ));
                  }
                }else if ( name.equals( PT_DATE )){
   
                  return( new Long( file.getDownload().getCreationTime()));
                 
                }else if ( name.equals( PT_CATEGORIES )){

                  try{
                    String cat = file.getDownload().getCategoryName();
                   
                    if ( cat != null && cat.length() > 0 ){
                     
                      if ( !cat.equalsIgnoreCase( "Categories.uncategorized" )){
                     
                        return( new String[]{ cat });
                      }
                    }
                  }catch( Throwable e ){
                   
                  }
                 
                  return( new String[0] );
                 
                }else if ( name.equals( PT_PERCENT_DONE )){
                 
                  long  size = file.getLength();
                 
                  return( new Long( size==0?100:(1000*file.getDownloaded()/size )));
                 
                }else if ( name.equals( PT_ETA )){             
               
                  return( getETA( file ));
                }
              }catch( Throwable e ){             
              }
             
              return( null );
            }
          };
      }else{
        acf =
            new AzureusContentFile()
            {
              public DiskManagerFileInfo
              getFile()
              {
                return( file );
              }
             
              public Object
              getProperty(
                String    name )
              {
                try{
                  if ( name.equals( PT_DATE )){
 
                    return( new Long( file.getDownload().getCreationTime()));
                   
                  }else if ( name.equals( PT_CATEGORIES )){

                    try{
                      String cat = file.getDownload().getCategoryName();
                     
                      if ( cat != null && cat.length() > 0 ){
                       
                        if ( !cat.equalsIgnoreCase( "Categories.uncategorized" )){
                       
                          return( new String[]{ cat });
                        }
                      }
                    }catch( Throwable e ){
                     
                    }
                   
                    return( new String[0] );
                   
                  }else if ( name.equals( PT_PERCENT_DONE )){
                   
                    long  size = file.getLength();
                   
                    return( new Long( size==0?100:(1000*file.getDownloaded()/size )));
 
                  }else if ( name.equals( PT_ETA )){             
                 
                    return( getETA( file ));
                  }
                }catch( Throwable e ){             
                }
               
                return( null );
              }
            };
      }
     
      download.setUserData( ud_key, acf );
     
      final AzureusContentFile f_acf = acf;
     
      download.addAttributeListener(
        new DownloadAttributeListener()
        {
          public void
          attributeEventOccurred(
            Download       download,
View Full Code Here

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

      ImportExportUtils.exportString( map, "target", target.getID());
     
      ImportExportUtils.exportString( map, "profile", profile.getUID());
     
      try{
        Download download = file.getDownload();
       
        ImportExportUtils.exportString( map, "dl_hash", ByteFormatter.encodeString( download.getTorrent().getHash()));

        ImportExportUtils.exportInt( map, "file_index", file.getIndex());

      }catch( DownloadException e ){
       
View Full Code Here

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

     
      try{
        DiskManagerFileInfo sourceFile = getSourceFile();
       
        try {
          Download download = sourceFile.getDownload();
         
          if ( download == null ){
           
            text = sourceFile.getFile().getName();
           
          }else{
           
            text = download.getName();
           
            DiskManagerFileInfo[] fileInfo = download.getDiskManagerFileInfo();
           
            if (fileInfo.length > 1) {
             
              text += ": " + sourceFile.getFile().getName();
            }
View Full Code Here

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

    String  hash = getString( KEY_SOURCE_FILE_HASH );
   
    if ( hash != null ){
     
      try{
        Download download = PluginInitializer.getDefaultInterface().getDownloadManager().getDownload( Base32.decode(hash));
       
        if ( download != null ){
         
          int index = (int)getLong( KEY_SOURCE_FILE_INDEX );
         
          return( download.getDiskManagerFileInfo(index) );
        }
       
      }catch( Throwable e ){
       
      }
View Full Code Here

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

  protected void
  setSourceFile(
    DiskManagerFileInfo    file )
  {
    try{
      Download download = file.getDownload();
     
      if ( download != null && download.getTorrent() != null ){
       
        setString( KEY_SOURCE_FILE_HASH, Base32.encode( download.getTorrent().getHash() ));
       
        setLong( KEY_SOURCE_FILE_INDEX, file.getIndex());
      }
    }catch( Throwable e ){
    }
View Full Code Here

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

            {
              TableRow[]  rows = (TableRow[])target;
             
              if ( rows.length > 0 ){
               
                Download download = (Download)rows[0].getDataSource();
               
                new SubscriptionListWindow(PluginCoreUtils.unwrap(download), false);
              }
              /*
              for (int i=0;i<rows.length;i++){
               
                Download download = (Download)rows[i].getDataSource();
               
                Torrent t = download.getTorrent();
               
                if ( t != null ){
                 
                  try{
                    lookupAssociations(
                      t.getHash(),
                      new SubscriptionLookupListener()
                      {
                        public void
                        found(
                          byte[]          hash,
                          Subscription      subscription )
                        {
                          log( "    lookup: found " + ByteFormatter.encodeString( hash ) + " -> " + subscription.getName());
                        }
                       
                        public void
                        complete(
                          byte[]          hash,
                          Subscription[]      subscriptions )
                        {
                          log( "    lookup: complete " + ByteFormatter.encodeString( hash ) + " -> " +subscriptions.length );
   
                        }
                       
                        public void
                        failed(
                          byte[]          hash,
                          SubscriptionException  error )
                        {
                          log( "    lookup: failed", error );
                        }
                      });
                   
                  }catch( Throwable e ){
                   
                    log( "Lookup failed", e );
                  }
                } 
              }*/
            }
          };
       
        menu_item_itorrents.addMultiListener( listener );
        menu_item_ctorrents.addMultiListener( listener )
      }
     
        // make assoc - CVS only as for testing purposes
     
      if ( false ){
     
        final TableContextMenuItem menu_item_itorrents =
          table_manager.addContextMenuItem(TableManager.TABLE_MYTORRENTS_INCOMPLETE, "azsubs.contextmenu.addassoc");
        final TableContextMenuItem menu_item_ctorrents   =
          table_manager.addContextMenuItem(TableManager.TABLE_MYTORRENTS_COMPLETE, "azsubs.contextmenu.addassoc");
       
        menu_item_itorrents.setStyle(TableContextMenuItem.STYLE_MENU);
        menu_item_ctorrents.setStyle(TableContextMenuItem.STYLE_MENU);
       
        MenuItemFillListener  menu_fill_listener =
          new MenuItemFillListener()
          {
            public void
            menuWillBeShown(
              MenuItem  menu,
              Object    target )
            { 
              SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();

              if ( subs_man == null ){
               
                return;
              }
             
              TableRow[]  rows;
             
              if ( target instanceof TableRow[] ){
               
                rows = (TableRow[])target;
               
              }else{
               
                rows = new TableRow[]{ (TableRow)target };
              }
             
              final List<byte[]>  hashes = new ArrayList<byte[]>();
             
              for (int i=0;i<rows.length;i++){
               
                Download  download = (Download)rows[i].getDataSource();
             
                if ( download != null ){
                 
                  Torrent torrent = download.getTorrent();
                 
                  if ( torrent != null ){
                   
                    hashes.add( torrent.getHash());
                  }
View Full Code Here

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

          if ( subs_man == null ){
           
            return;
          }
         
          Download  dl = (Download)cell.getDataSource();
         
          if ( dl == null ){
           
            return;
          }
         
          Torrent  torrent = dl.getTorrent();
         
          if ( torrent != null ){
           
            Subscription[] subs = subs_man.getKnownSubscriptions( torrent.getHash());
                           
            int  num_subscribed    = 0;
            int  num_unsubscribed  = 0;
           
            for (int i=0;i<subs.length;i++){
             
              if ( subs[i].isSubscribed()){
                               
                num_subscribed++;
               
              }else{
               
                num_unsubscribed++;
              }
            }
           
            Graphic graphic;
            String  tooltip;
           
            int height = cell.getHeight();
           
            int  sort_order = 0;
           
            if ( subs.length == 0 ){
             
              graphic = null;
              tooltip  = null;
             
            }else{
           
              if ( num_subscribed == subs.length ){
               
                graphic = height >= 22?icon_rss_all_add_big:icon_rss_all_add_small;
               
                tooltip = MessageText.getString( "subscript.all.subscribed" );
               
              }else if ( num_subscribed > 0 ){
               
                graphic = height >= 22?icon_rss_some_add_big:icon_rss_some_add_small;

                tooltip = MessageText.getString( "subscript.some.subscribed" );

                sort_order  = 10000;
               
              }else{
               
                graphic = height >= 22?icon_rss_big:icon_rss_small;
               
                tooltip = MessageText.getString( "subscript.none.subscribed" );
               
                sort_order  = 1000000;
              }
            }
           
            sort_order += 1000*num_unsubscribed + num_subscribed;
           
            cell.setMarginHeight(0);
            cell.setGraphic( graphic );
            cell.setToolTip( tooltip );
           
            cell.setSortValue( sort_order );
           
            cell.setCursorID( graphic==null?SWT.CURSOR_ARROW:SWT.CURSOR_HAND );

          }else{
           
            cell.setCursorID( SWT.CURSOR_ARROW );
           
            cell.setSortValue( 0 );
          }
        }
      };
     
    final TableCellMouseListener  subs_mouse_listener =
      new TableCellMouseListener()
      {
        public void
        cellMouseTrigger(
          TableCellMouseEvent event )
        {
          if ( event.eventType == TableCellMouseEvent.EVENT_MOUSEDOWN ){
           
           
            TableCell cell = event.cell;
           
            Download  dl = (Download)cell.getDataSource();
           
            Torrent  torrent = dl.getTorrent();
           
            if ( torrent != null ){
             
              SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
              Subscription[] subs = subs_man.getKnownSubscriptions( torrent.getHash());
             
              if ( subs.length > 0 ){
               
                event.skipCoreFunctionality  = true;

                new SubscriptionWizard(PluginCoreUtils.unwrap(dl));
               
                COConfigurationManager.setParameter( "subscriptions.wizard.shown", true );

                refreshTitles( mdiEntryOverview );
               
                //new SubscriptionListWindow(PluginCoreUtils.unwrap(dl),true);
              }
            }
          }
        }
      };
     
    table_manager.registerColumn(
      Download.class,
      "azsubs.ui.column.subs",
      new TableColumnCreationListener()
      {
        public void tableColumnCreated(TableColumn result) {
          result.setAlignment(TableColumn.ALIGN_CENTER);
          result.setPosition(TableColumn.POSITION_LAST);
          result.setWidth(32);
          result.setRefreshInterval(TableColumn.INTERVAL_INVALID_ONLY);
          result.setType(TableColumn.TYPE_GRAPHIC);
       
          result.addCellRefreshListener( subs_refresh_listener );
          result.addCellMouseListener( subs_mouse_listener );
          result.setIconReference("image.subscription.column", true);
         
          synchronized (columns) {
            columns.add(result);
          }
        }
      });
   
    final TableCellRefreshListener  link_refresh_listener =
      new TableCellRefreshListener()
      {
        public void
        refresh(
          TableCell _cell )
        {
          TableCellSWT cell = (TableCellSWT)_cell;
         
          SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
          if ( subs_man == null ){
           
            return;
          }
         
          Download  dl = (Download)cell.getDataSource();
         
          if ( dl == null ){
           
            return;
          }
         
          String  str     = "";
         
          Torrent  torrent = dl.getTorrent();
         
          if ( torrent != null ){
           
            byte[]  hash = torrent.getHash();
           
            Subscription[] subs = subs_man.getKnownSubscriptions( hash );
                           
            for (int i=0;i<subs.length;i++){
             
              Subscription sub = subs[i];
             
              if ( sub.hasAssociation( hash )){
               
                str += (str.length()==0?"":"; ") + sub.getName();
              }
            }
          }
         
          cell.setCursorID( str.length() > 0?SWT.CURSOR_HAND:SWT.CURSOR_ARROW );
         
          cell.setText( str );
        }
      };
   
      final TableCellMouseListener  link_mouse_listener =
        new TableCellMouseListener()
        {
          public void
          cellMouseTrigger(
            TableCellMouseEvent event )
          {
            if ( event.eventType == TableCellMouseEvent.EVENT_MOUSEDOWN ){
                   
              TableCell cell = event.cell;
             
              Download  dl = (Download)cell.getDataSource();
             
              Torrent  torrent = dl.getTorrent();

              SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();

              if ( torrent != null && subs_man != null ){
               
View Full Code Here

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

  public void refresh(TableCell cell) {
    if (!(cell.getDataSource() instanceof Download)) {
      return;
    }
    Download dm = (Download)cell.getDataSource();
    long value;
    long sortValue;
    String prefix = "";
    if (dm == null) {
      sortValue = value = 0;
    } else {
      int iState;
      iState = dm.getState();
      if (iState == Download.ST_DOWNLOADING) {
        value = dm.getStats().getDownloadAverage();
        ((TableCellSWT)cell).setIcon(imgDown);
      } else if (iState == Download.ST_SEEDING) {
        value = dm.getStats().getUploadAverage();
        ((TableCellSWT)cell).setIcon(imgUp);
      } else {
        ((TableCellSWT)cell).setIcon(null);
        value = 0;
      }
View Full Code Here

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

      } else   if (ds instanceof TranscodeJob) {
        TranscodeJob tj = (TranscodeJob) ds;
        try {
          DiskManagerFileInfo file = tj.getFile();
          if (file != null) {
            Download download = tj.getFile().getDownload();
            if (download != null) {
              return PluginCoreUtils.unwrap(download);
            }
          }
        } catch (DownloadException e) {
        }
      } else if (ds instanceof TranscodeFile) {
        TranscodeFile tf = (TranscodeFile) ds;
        try {
          DiskManagerFileInfo file = tf.getSourceFile();
          if (file != null) {
            Download download = file.getDownload();
            if (download != null) {
              return PluginCoreUtils.unwrap(download);
            }
          }
        } catch (DownloadException e) {
View Full Code Here

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

    if (ds instanceof TranscodeFile) {
      TranscodeFile tf = (TranscodeFile) ds;
      try {
        DiskManagerFileInfo file = tf.getSourceFile();
        if (file != null) {
          Download download = file.getDownload();
          if (download != null) {
            Torrent torrent = download.getTorrent();
            if (torrent != null) {
              return PluginCoreUtils.unwrap(torrent);
            }
          }
        }
      } catch (Throwable e) {
      }
    }

    if (ds instanceof TranscodeJob) {
      TranscodeJob tj = (TranscodeJob) ds;
      try {
        DiskManagerFileInfo file = tj.getFile();
        if (file != null) {
          Download download = tj.getFile().getDownload();
         
          if (download != null) {
            Torrent torrent = download.getTorrent();
            if (torrent != null) {
              return PluginCoreUtils.unwrap(torrent);
            }
          }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.