Package org.gudy.azureus2.core3.html

Examples of org.gudy.azureus2.core3.html.HTMLChunk


      public int compare(DownloadManager a, DownloadManager b) {
        return a.getPosition() - b.getPosition();
      }
    });
    for (int i = dms.length - 1; i >= 0; i--) {
      DownloadManager dm = dms[i];
      if (dm.getGlobalManager().isMoveableDown(dm)) {
        dm.getGlobalManager().moveDown(dm);
      }
    }

    boolean bForceSort = tv.getSortColumn().getName().equals("#");
    tv.columnInvalidate("#");
View Full Code Here


      public int compare(DownloadManager a, DownloadManager b) {
        return a.getPosition() - b.getPosition();
      }
    });
    for (int i = 0; i < dms.length; i++) {
      DownloadManager dm = dms[i];
      if (dm.getGlobalManager().isMoveableUp(dm)) {
        dm.getGlobalManager().moveUp(dm);
      }
    }

    boolean bForceSort = tv.getSortColumn().getName().equals("#");
    tv.columnInvalidate("#");
View Full Code Here

      });
    }

    int count = globalManager.downloadManagerCount(isSeedingView);
    for (int i = 0; i < dms.length; i++) {
      DownloadManager dm = dms[i];
      int pos = dm.getPosition() + by;
      if (pos < i + 1)
        pos = i + 1;
      else if (pos > count - i)
        pos = count - i;

      newPositions[i] = pos;
    }

    for (int i = 0; i < dms.length; i++) {
      DownloadManager dm = dms[i];
      globalManager.moveTo(dm, newPositions[i]);
    }

    boolean bForceSort = tv.getSortColumn().getName().equals("#");
    tv.columnInvalidate("#");
View Full Code Here

    Object[] managers = globalManager.getDownloadManagers().toArray();
    List<DownloadManager> listRemoves = new ArrayList<DownloadManager>();
    List<DownloadManager> listAdds = new ArrayList<DownloadManager>();
   
    for (int i = 0; i < managers.length; i++) {
      DownloadManager dm = (DownloadManager) managers[i];
   
      boolean bHave = tv.isUnfilteredDataSourceAdded(dm);
      if (!isOurDownloadManager(dm)) {
        if (bHave) {
          listRemoves.add(dm);
View Full Code Here

    Object ds = rowCore.getDataSource(true);
    if (!(ds instanceof DownloadManager)) {
      return;
    }

    DownloadManager dm = (DownloadManager) ds;
    if (rowCore.getSubItemCount() == 0 && dm.getTorrent() != null
        && !dm.getTorrent().isSimpleTorrent() && rowCore.isVisible()
        && dm.getNumFileInfos() > 0) {
      DiskManagerFileInfoSet fileInfos = dm.getDiskManagerFileInfoSet();
      if (fileInfos != null) {
        DiskManagerFileInfo[] files = fileInfos.getFiles();
        boolean copied = false;
        int pos = 0;
        for (int i = 0; i < files.length; i++) {
View Full Code Here

    // required a core, so we assume there's a core here

    List dms = AzureusCoreFactory.getSingleton().getGlobalManager().getDownloadManagers();

    for (int i = 0; i < dms.size(); i++) {
      DownloadManager dm = (DownloadManager) dms.get(i);

      try {
        byte[] share_hash = null;

        if (share.getType() == ShareResource.ST_DIR) {

          share_hash = ((ShareResourceDir) share).getItem().getTorrent().getHash();

        } else if (share.getType() == ShareResource.ST_FILE) {

          share_hash = ((ShareResourceFile) share).getItem().getTorrent().getHash();
        }

        if (Arrays.equals(share_hash, dm.getTorrent().getHash())) {

          UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
          if (uiFunctions != null) {
            uiFunctions.openView(UIFunctions.VIEW_DM_DETAILS, dm);
          }
View Full Code Here

        }
      }
    } catch (Exception e) {
    }

    DownloadManager existingDownload = null;
    if (sExistingName == null) {
      // Check if torrent already exists in gm, and add if not
      existingDownload = (gm == null) ? null : gm.getDownloadManager(torrent);
      if (existingDownload != null) {
        sExistingName = existingDownload.getDisplayName();
      }
    }

    if (sExistingName == null) {
      info = new TorrentInfo(torrentFile.getAbsolutePath(), torrent,
          bDeleteFileOnCancel);
      info.sOriginatingLocation = sOriginatingLocation;
      torrentList.add(info);

    } else {

      final String sfExistingName = sExistingName;
      final DownloadManager fExistingDownload = existingDownload;
      Utils.execSWTThread(new AERunnable() {
        public void runSupport() {
          Shell mainShell = UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell();
          if (Display.getDefault().getActiveShell() == null || !mainShell.isVisible() || mainShell.getMinimized() ) {
            new MessageSlideShell(Display.getCurrent(), SWT.ICON_INFORMATION,
View Full Code Here

        try {
          hash = info.torrent.getHash();
        } catch (TOTorrentException e1) {
        }

        DownloadManager dm = gm.addDownloadManager(info.sFileName, hash, info.sDestDir, info.sDestSubDir, iStartState, true, info.iStartID == STARTMODE_SEEDING, new DownloadManagerInitialisationAdapter()
        {
          public void initialised(DownloadManager dm) {
            DiskManagerFileInfo[] fileInfos = dm.getDiskManagerFileInfo();
           
            boolean  reorder_mode     = COConfigurationManager.getBooleanParameter( "Enable reorder storage mode" );
            int    reorder_mode_min_mb = COConfigurationManager.getIntParameter( "Reorder storage mode min MB" );
           
            try
            {
              dm.getDownloadState().suppressStateSave(true);
             
              boolean[] toSkip       = new boolean[fileInfos.length];
              boolean[] toCompact     = new boolean[fileInfos.length];
              boolean[] toReorderCompact   = new boolean[fileInfos.length];
             
              int  comp_num       = 0;
              int reorder_comp_num  = 0;
             
              for (int iIndex = 0; iIndex < fileInfos.length; iIndex++)
              {
                DiskManagerFileInfo fileInfo = fileInfos[iIndex];
                if (iIndex >= 0 && iIndex < files.length && files[iIndex].lSize == fileInfo.getLength())
                {
                  // Always pull destination file from fileInfo and not from
                  // TorrentFileInfo because the destination may have changed
                  // by magic code elsewhere
                  File fDest = fileInfo.getFile(true);
                  if (files[iIndex].isLinked()){
                 
                    fDest = files[iIndex].getDestFileFullName();
                   
                      // Can't use fileInfo.setLink(fDest) as it renames
                      // the existing file if there is one
                   
                    dm.getDownloadState().setFileLink( fileInfo.getFile(false), fDest);
                  }
                 
                  if (!files[iIndex].bDownload){
                 
                    toSkip[iIndex] = true;
                   
                    if (!fDest.exists()){
                     
                      if ( reorder_mode && ( fileInfo.getLength()/(1024*1024)) >= reorder_mode_min_mb ){
                       
                        toReorderCompact[iIndex] = true;
                       
                        reorder_comp_num++;
                       
                      }else{
                       
                        toCompact[iIndex] = true;
                       
                        comp_num++;
                      }
                    }
                  }
                }
              }
             
              if ( comp_num > 0 ){
               
                dm.getDiskManagerFileInfoSet().setStorageTypes(toCompact, DiskManagerFileInfo.ST_COMPACT);
              }
             
              if ( reorder_comp_num > 0 ){
               
                dm.getDiskManagerFileInfoSet().setStorageTypes(toReorderCompact, DiskManagerFileInfo.ST_REORDER_COMPACT );
              }
             
              dm.getDiskManagerFileInfoSet().setSkipped(toSkip, true);
             
            }finally{
           
              dm.getDownloadState().suppressStateSave(false);
            }
          }
        });

        // If dm is null, most likely there was an error printed.. let's hope
        // the user was notified and skip the error quietly.
        // We don't have to worry about deleting the file (info.bDelete..)
        // since gm.addDown.. will handle it.
        if (dm == null)
          continue;

        if (info.iQueueLocation == QUEUELOCATION_TOP)
          addedTorrentsTop.add(dm);

        if (info.iStartID == STARTMODE_FORCESTARTED) {
          dm.setForceStart(true);
        }

      } catch (Exception e) {
        if (shell == null)
          new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
View Full Code Here

    int number = Math.abs(ncommand);
    if (number == 0 || number > ci.torrents.size()) {
      ci.out.println("> Command 'move': Torrent #" + Integer.toString(number) + " unknown.");
      return;
    }
    DownloadManager dm = (DownloadManager) ci.torrents.get(number - 1);
    String name = dm.getDisplayName();
    if (name == null)
      name = "?";
   
    GlobalManager  gm = dm.getGlobalManager();

    if (moveto) {
      gm.moveTo(dm, nmoveto - 1);
      gm.fixUpDownloadManagerPositions();
      ci.out.println("> Torrent #" + Integer.toString(number) + " (" + name + ") moved to #" + Integer.toString(nmoveto) + ".");
View Full Code Here

     
      List shown_torrents = new ArrayList();

      while (torrent.hasNext()) {
               
        DownloadManager dm = (DownloadManager) torrent.next();
               
        DownloadManagerStats stats = dm.getStats();

        boolean bDownloadCompleted = stats.getDownloadCompleted(false) == 1000;
        boolean bCanShow = ((bShowOnlyComplete == bShowOnlyIncomplete) || (bDownloadCompleted && bShowOnlyComplete) || (!bDownloadCompleted && bShowOnlyIncomplete));

        if (bCanShow && bShowOnlyActive) {
          int dmstate = dm.getState();
          bCanShow = (dmstate == DownloadManager.STATE_SEEDING) || (dmstate == DownloadManager.STATE_DOWNLOADING) || (dmstate == DownloadManager.STATE_CHECKING) || (dmstate == DownloadManager.STATE_INITIALIZING) || (dmstate == DownloadManager.STATE_ALLOCATING);
        }
       
        if (bCanShow && bShowOnlyTransferring) {
          try {
            ps = dm.getPeerManager().getStats();
            bCanShow = ps.getDataSendRate() > 0 || ps.getDataReceiveRate() > 0;
          }
          catch (Exception e) {}
        }

        if (bCanShow) {
         
          shown_torrents.add( dm );

          try {
            ps = dm.getPeerManager().getStats();
          } catch (Exception e) {
            ps = null;
          }
          if (ps != null) {
            totalReceived += dm.getStats().getTotalDataBytesReceived();
            totalSent += dm.getStats().getTotalDataBytesSent();
            totalDiscarded += ps.getTotalDiscarded();
            connectedSeeds += dm.getNbSeeds();
            connectedPeers += dm.getNbPeers();
          }       
          ci.out.print(((shown_torrents.size() < 10) ? " " : "") + shown_torrents.size() + " ");
          ci.out.println(getTorrentSummary(dm));
          ci.out.println();
        }
      }
     
      ci.torrents.clear();
      ci.torrents.addAll( shown_torrents );
     
      GlobalManager  gm = ci.getGlobalManager();
     
      ci.out.println("Total Speed (down/up): " + DisplayFormatters.formatByteCountToKiBEtcPerSec(gm.getStats().getDataReceiveRate() + gm.getStats().getProtocolReceiveRate() ) + " / " + DisplayFormatters.formatByteCountToKiBEtcPerSec(gm.getStats().getDataSendRate() + gm.getStats().getProtocolSendRate() ));

      ci.out.println("Transferred Volume (down/up/discarded): " + DisplayFormatters.formatByteCountToKiBEtc(totalReceived) + " / " + DisplayFormatters.formatByteCountToKiBEtc(totalSent) + " / " + DisplayFormatters.formatByteCountToKiBEtc(totalDiscarded));
      ci.out.println("Total Connected Peers (seeds/peers): " + Integer.toString(connectedSeeds) + " / " + Integer.toString(connectedPeers));
      ci.out.println("> -----");
    } else if (subCommand.equalsIgnoreCase("dht") || subCommand.equalsIgnoreCase("d")) {

      showDHTStats( ci );
   
    } else if (subCommand.equalsIgnoreCase("nat") || subCommand.equalsIgnoreCase("n")) {

      IndentWriter  iw = new IndentWriter( new PrintWriter( ci.out ));
     
      iw.setForce( true );
     
      NetworkAdmin.getSingleton().logNATStatus( iw );
   
    } else if (subCommand.equalsIgnoreCase("stats") || subCommand.equalsIgnoreCase("s")) {

      String  pattern = AzureusCoreStats.ST_ALL;
     
      if( args.size() > 0 ){
       
        pattern = (String)args.get(0);
       
        if ( pattern.equals("*")){
         
          pattern = ".*";
        }
      }
   
      if ( args.size() > 1 ){
       
        AzureusCoreStats.setEnableAverages(((String)args.get(1)).equalsIgnoreCase( "on" ));
      }
     
      java.util.Set  types = new HashSet();
     
      types.add( pattern );
     
      Map  reply = AzureusCoreStats.getStats( types );
     
      Iterator  it = reply.entrySet().iterator();
     
      List  lines = new ArrayList();
     
      while( it.hasNext()){
       
        Map.Entry  entry = (Map.Entry)it.next();
       
        lines.add( entry.getKey() + " -> " + entry.getValue());
      }
     
      Collections.sort( lines );
     
      for ( int i=0;i<lines.size();i++){
       
        ci.out.println( lines.get(i));
      }
    } else if (subCommand.equalsIgnoreCase("diag") || subCommand.equalsIgnoreCase("z")) {

      try{
        ci.out.println( "Writing diagnostics to file 'az.diag'" );
       
        FileWriter  fw = new FileWriter( "az.diag" );
       
        PrintWriter  pw = new PrintWriter( fw );
       
        AEDiagnostics.generateEvidence( pw );
       
        pw.flush();
       
        fw.close();
     
      }catch( Throwable e ){
       
        ci.out.println( e );
      }
     
    } else {
      if ((ci.torrents == null) || (ci.torrents != null) && ci.torrents.isEmpty()) {
        ci.out.println("> Command 'show': No torrents in list (try 'show torrents' first).");
        return;
      }
      try {
        int number = Integer.parseInt(subCommand);
        if ((number == 0) || (number > ci.torrents.size())) {
          ci.out.println("> Command 'show': Torrent #" + number + " unknown.");
          return;
        }
        DownloadManager dm = (DownloadManager) ci.torrents.get(number - 1);
        printTorrentDetails(ci.out, dm, number, args.size() > );
      }
      catch (Exception e) {
        ci.out.println("> Command 'show': Subcommand '" + subCommand + "' unknown.");
        return;
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.html.HTMLChunk

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.