Package org.gudy.azureus2.core3.download

Examples of org.gudy.azureus2.core3.download.DownloadManagerState


    throws TorrentException
  {   
    try{
      LocaleTorrentUtil.setDefaultTorrentEncoding( torrent );
   
      DownloadManagerState  download_manager_state =
        DownloadManagerStateFactory.getDownloadState( torrent );

      TorrentUtils.setResumeDataCompletelyValid( download_manager_state );

      download_manager_state.save();
     
      complete  = true;
     
    }catch( Throwable e ){
     
View Full Code Here


    return diskManager;
  }
 
  public DownloadManager  getDownloadManager()
  {
    DownloadManagerState  state = diskManager.getDownloadState();
   
    if ( state == null ){
      return( null );
    }
   
    return( state.getDownloadManager());
  }
View Full Code Here

  public void setPriority(int[] toChange) {
    if(toChange.length != files.length)
      throw new IllegalArgumentException("array length mismatches the number of files");

    DownloadManagerState dmState = diskManager.getDownloadState();
   
    try  {
      dmState.suppressStateSave(true);

   
      for(int i=0;i<files.length;i++)
        if(toChange[i] > 0)
          files[i].setPriority(toChange[i]);
    } finally {
      dmState.suppressStateSave(false);
    }
  }
View Full Code Here

  public void setSkipped(boolean[] toChange, boolean setSkipped) {
    if(toChange.length != files.length)
      throw new IllegalArgumentException("array length mismatches the number of files");

    DownloadManagerState dmState = diskManager.getDownloadState();
   
    try  {
      dmState.suppressStateSave(true);
     
      if (!setSkipped ){
       
        String[] types = diskManager.getStorageTypes();

        boolean[]  toLinear   = new boolean[toChange.length];
        boolean[]  toReorder   = new boolean[toChange.length];
       
        int  num_linear   = 0;
        int num_reorder  = 0;
       
        for ( int i=0;i<toChange.length;i++){
         
          if ( toChange[i] ){
           
            int old_type = DiskManagerUtil.convertDMStorageTypeFromString( types[i] );
           
            if ( old_type == DiskManagerFileInfo.ST_COMPACT ){
             
              toLinear[i] = true;
             
              num_linear++;
             
            }else if ( old_type == DiskManagerFileInfo.ST_REORDER_COMPACT ){
             
              toReorder[i] = true;
             
              num_reorder++;
            }
          } 
        }
       
        if ( num_linear > 0 ){
         
          if (!Arrays.equals(toLinear, setStorageTypes(toLinear, DiskManagerFileInfo.ST_LINEAR))){
           
            return;
          }
        }
     
        if ( num_reorder > 0 ){
         
          if (!Arrays.equals(toReorder, setStorageTypes(toReorder, DiskManagerFileInfo.ST_REORDER ))){
           
            return;
          }
        }
      }
      for (int i = 0; i < files.length; i++)
        if (toChange[i])
        {
          files[i].skipped = setSkipped;
          diskManager.skippedFileSetChanged(files[i]);
        }

      if(!setSkipped)
        DiskManagerUtil.doFileExistenceChecks(this, toChange, diskManager.getDownloadState().getDownloadManager(), true);
     
    } finally {
      dmState.suppressStateSave(false);
    }

  }
View Full Code Here

      return new boolean[0];
   
    String[] types = diskManager.getStorageTypes();
   
    boolean[] modified = new boolean[files.length];
    DownloadManagerState  dm_state = diskManager.getDownloadState();

    if (newStroageType == DiskManagerFileInfo.ST_COMPACT || newStroageType == DiskManagerFileInfo.ST_REORDER_COMPACT)
    {
      Debug.out("Download must be stopped for linear -> compact conversion");
      return modified;
    }
   
    try  {
      dm_state.suppressStateSave(true);

      for (int i = 0; i < files.length; i++)
      {
        if(!toChange[i])
          continue;
       
        int old_type = DiskManagerUtil.convertDMStorageTypeFromString( types[i] );
        if (newStroageType == old_type)
        {
          modified[i] = true;
          continue;
        }
     
        DiskManagerFileInfoImpl file = files[i];
       
        try  {
          file.getCacheFile().setStorageType( DiskManagerUtil.convertDMStorageTypeToCache( newStroageType ));
          modified[i] = true;
        } catch (Throwable e) {
          Debug.printStackTrace(e);
          diskManager.setFailed(file, "Failed to change storage type for '" + file.getFile(true) + "': " + Debug.getNestedExceptionMessage(e));
          break;
        } finally {
          types[i] = DiskManagerUtil.convertCacheStorageTypeToString( file.getCacheFile().getStorageType());
        }
      }
     
      dm_state.setListAttribute(DownloadManagerState.AT_FILE_STORE_TYPES, types);
     
      DiskManagerUtil.doFileExistenceChecks(this, toChange, dm_state.getDownloadManager(), true);
     
    } finally {
      dm_state.suppressStateSave(false);
      dm_state.save();
    }
   
    return modified;
  }
View Full Code Here

         
          TOTorrent to_torrent = PluginCoreUtils.unwrap( torrent );
         
          if ( public_net && !TorrentUtils.isReallyPrivate( to_torrent )){
           
            DownloadManagerState state = PluginCoreUtils.unwrap( download ).getDownloadState();

            if ( state.getFlag(DownloadManagerState.FLAG_LOW_NOISE )){
             
              continue;
            }
           
            long rand = global_random_id ^ state.getLongParameter( DownloadManagerState.PARAM_RANDOM_SEED );           
           
            long cache = state.getLongAttribute( DownloadManagerState.AT_SCRAPE_CACHE );

            int  seeds_leechers;
           
            if ( cache == -1 ){
             
View Full Code Here

    for (final DownloadManager dm : dms) {
      if (dm == null) {
        continue;
      }

      DownloadManagerState dmState = dm.getDownloadState();

      final TOTorrent torrent = dm.getTorrent();
      if (torrent == null) {
        continue;
      }

      String title = PlatformTorrentUtils.getContentTitle(torrent);
      if (title != null && title.length() > 0
          && dmState.getDisplayName() == null) {
        dmState.setDisplayName(title);
      }

      if (ConfigurationChecker.isNewVersion() && dm.getAssumedComplete()) {
        String lastVersion = COConfigurationManager.getStringParameter("Last Version");
        if (org.gudy.azureus2.core3.util.Constants.compareVersions(lastVersion,
            "3.1.1.1") <= 0) {
          long completedTime = dmState.getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_COMPLETED_TIME);
          if (completedTime < SystemTime.getOffsetTime(-(1000 * 60))) {
            PlatformTorrentUtils.setHasBeenOpened(dm, true);
          }
        }
      }

      boolean isContent = PlatformTorrentUtils.isContent(torrent, true)
          || PlatformTorrentUtils.getContentNetworkID(torrent) == ContentNetwork.CONTENT_NETWORK_VHDNL;

      if (!oneIsNotPlatformAndPersistent && !isContent
          && !dmState.getFlag(DownloadManagerState.FLAG_LOW_NOISE) && dm.isPersistent()) {
        oneIsNotPlatformAndPersistent = true;
      }

      if (isContent) {
        long now = SystemTime.getCurrentTime();
View Full Code Here

          TableRowCore row = (TableRowCore) target;
          Object dataSource = row.getDataSource(true);
          if (dataSource instanceof DownloadManager) {
            DownloadManager dm = (DownloadManager) dataSource;

            DownloadManagerState state = dm.getDownloadState();

            try {
              long add_time = new File(dm.getTorrentFileName()).lastModified();

              if (add_time >= 0) {
                state.setLongParameter(
                    DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME, add_time);
              }

            } catch (Throwable e) {
            }
View Full Code Here

      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);
View Full Code Here

          AzureusCore          core,
          AzureusCoreComponent    comp )
          {
            if ( comp instanceof GlobalManager ){
             
              GlobalManager  gm  = (GlobalManager)comp;
             
              gm.addListener( PluginInitializer.this );
            }
          }
      });
   
    core_operation   = _core_operation;
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.download.DownloadManagerState

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.