TOTorrent torrent ) if ( TorrentUtils.isDecentralised( torrent )){ TorrentUtils.setDecentralised( torrent ); if ( TorrentUtils.announceGroupsContainsURL( torrent, url_str )){ TorrentUtils.announceGroupsSetFirst( torrent, url_str ); TorrentUtils.announceGroupsInsertFirst( torrent, url_str );
List<List<String>> existing_trackers = TorrentUtils.announceGroupsToList( torrent ); new_trackers = TorrentUtils.mergeAnnounceURLs( existing_trackers, template_trackers ); new_trackers = TorrentUtils.removeAnnounceURLs( existing_trackers, template_trackers, true ); if ( !TorrentUtils.areIdentical( new_trackers, existing_trackers )){ TorrentUtils.listToAnnounceGroups( new_trackers, torrent ); TorrentUtils.writeToFile(torrent);
public static void runTorrentDelete( DownloadManager[] dms, Runnable target ) { DownloadManager[] current_dms = dms.clone(); try{ startTorrentDelete( current_dms ); target.run(); }finally{ endTorrentDelete( current_dms ); } }
@Override public void delete() { List<List<String>> lists = TorrentUtils.announceGroupsToList( t ); List<String> rem = new ArrayList<>(); for ( URL u: urls ){ rem.add( u.toExternalForm()); } lists = TorrentUtils.removeAnnounceURLs2( lists, rem, false ); TorrentUtils.listToAnnounceGroups( lists, t ); } });
public static List<List<String>> removeAnnounceURLs2( List<List<String>> base_urls, List<String> remove_urls, boolean use_prefix_match ) { if ( remove_urls == null ){ // general semantics are to return a clone so caller can modify return( getClone( base_urls ) ); } List<List<String>> temp = new ArrayList<>(1); temp.add( remove_urls ); return( removeAnnounceURLs( base_urls, temp, use_prefix_match )); }
TorrentUtils.setDecentralised( torrent ); TorrentUtils.setDHTBackupEnabled( torrent, wizard.permitDHT ); TorrentUtils.setPrivate( torrent, wizard.getPrivateTorrent()); TorrentUtils.listToAnnounceGroups(wizard.trackers, torrent); reportCurrentTask( TorrentUtils.exceptionToText( te ));
String new_str = new_url.toString(); List l = announceGroupsToList( torrent ); listToAnnounceGroups( l, torrent ); writeToFile( torrent );
display_name = FileUtil.convertOSSpecificChars(TorrentUtils.getLocalisedName(torrent),false); boolean low_noise = TorrentUtils.getFlag( torrent, TorrentUtils.TORRENT_FLAG_LOW_NOISE ); boolean metadata_dl = TorrentUtils.getFlag( torrent, TorrentUtils.TORRENT_FLAG_METADATA_TORRENT ); Map peer_cache = TorrentUtils.getPeerCache( torrent ); setFailed( TorrentUtils.exceptionToText( e ));
TorrentUtils.copyToFile( torrent_file, state_file ); LogAlert.REPEATABLE, LogAlert.AT_ERROR, "Recovered download from original torrent: " + TorrentUtils.getLocalisedName(torrent_file))); String file_str = TorrentUtils.getTorrentFileName( torrent_file, false );
public static void announceGroupsSetFirst( TOTorrent torrent, String first_url ) { List groups = announceGroupsToList( torrent ); boolean found = false; outer: for (int i=0;i<groups.size();i++){ List set = (List)groups.get(i); for (int j=0;j<set.size();j++){ if ( first_url.equals(set.get(j))){ set.remove(j); set.add(0, first_url); groups.remove(set); groups.add(0,set); found = true; break outer; } } } if ( !found ){ System.out.println( "TorrentUtils::announceGroupsSetFirst - failed to find '" + first_url + "'" ); } listToAnnounceGroups( groups, torrent ); }
if ( !filename.toLowerCase().endsWith(".torrent" )){ TOTorrent torrent = TorrentUtils.readFromFile( file, false ); String name = TorrentUtils.getLocalisedName( torrent ) + ".torrent"; TorrentUtils.setObtainedFrom( file, original_url );
public class Checker extends AEThread { int loopFactor; private static final int waitTime = 10*1000; // 5 minutes save resume data interval (default) private int saveResumeLoopCount = 5*60*1000 / waitTime; private static final int initSaveResumeLoopCount = 60*1000 / waitTime; private static final int natCheckLoopCount = 30*1000 / waitTime; private static final int seedPieceCheckCount = 30*1000 / waitTime; private static final int oneMinuteThingCount = 60*1000 / waitTime; private final AESemaphore run_sem = new AESemaphore( "GM:Checker:run"); public Checker() { super("Global Status Checker"); loopFactor = 0; setPriority(Thread.MIN_PRIORITY); //determineSaveResumeDataInterval(); } private void determineSaveResumeDataInterval() { int saveResumeInterval = COConfigurationManager.getIntParameter("Save Resume Interval", 5); if (saveResumeInterval >= 1 && saveResumeInterval <= 90) saveResumeLoopCount = saveResumeInterval * 60000 / waitTime; } @Override public void runSupport() { while ( true ){
public static DNSTXTEntry getDNSTXTEntry( URL url ) { if ( isDecentralised( url )){ return( null ); } String host = url.getHost(); String tracker_network = AENetworkClassifier.categoriseAddress( host ); if ( tracker_network != AENetworkClassifier.AT_PUBLIC ){ return( null ); } return( getDNSTXTEntry( host, false, null )); }
public String getTorrentName() { return TorrentUtils.getLocalisedName(torrent); }
List<List<String>> group = TorrentUtils.announceGroupsToList(torrent); URL url = new URL( url_str ); if ( TorrentUtils.isDecentralised( url )){
@Override public void handleEvent(Event e) { if (e.widget instanceof MenuItem) { String text = ((MenuItem) e.widget).getText(); TOTorrent torrent = manager.getTorrent(); TorrentUtils.announceGroupsSetFirst(torrent, text); try { TorrentUtils.writeToFile(torrent); } catch (TOTorrentException f) { Debug.printStackTrace(f); } TRTrackerAnnouncer tc = manager.getTrackerClient(); if (tc != null) { tc.resetTrackerUrl(false); } } } };
TorrentUtils.announceGroupsInsertFirst( torrent, url ); TorrentUtils.writeToFile( torrent );
public List<List<String>> getTrackers( boolean if_updated ) { if ( updatedTrackers != null ){ return( updatedTrackers ); } if ( if_updated ){ return( null ); } if ( torrent == null ){ return(new ArrayList<>(0)); }else{ return( TorrentUtils.announceGroupsToList(torrent)); } }
while (torrent.hasNext()) { dm = (DownloadManager) torrent.next(); if (hash.equals(TorrentUtils.nicePrintTorrentHash(dm.getTorrent(), true))) { if (dm.getDisplayName() == null) name = "?"; if (hash.equals(TorrentUtils.nicePrintTorrentHash(ht.getTorrent(), true))) { name = TorrentUtils.getLocalisedName( ht.getTorrent());
protected void save( boolean force ) { if ( supressWrites > 0 && !force ){ return; } boolean do_write; try{ this_mon.enter(); do_write = write_required; write_required = false; }finally{ this_mon.exit(); } if ( do_write ){ try { // System.out.println( "writing download state for '" + new String(torrent.getName())); if (Logger.isEnabled()) Logger.log(new LogEvent(torrent, LOGID, "Saving state for download '" + TorrentUtils.getLocalisedName(torrent) + "'")); torrent.setAdditionalMapProperty( ATTRIBUTE_KEY, attributes ); TorrentUtils.writeToFile(torrent, true); } catch (Throwable e) { Logger.log(new LogEvent(torrent, LOGID, "Saving state", e)); } } else { // System.out.println( "not writing download state for '" + new String(torrent.getName())); } }