@Override public Map getAdditionalMapProperty( String name ) { Map c = cache_attributes; if ( c != null && name.equals( ATTRIBUTE_KEY )){ return( c ); } c = cache_azp; if ( c != null && name.equals( AZUREUS_PROPERTIES_KEY )){ return( c ); } c = cache_azpp; if ( c != null && name.equals( AZUREUS_PRIVATE_PROPERTIES_KEY )){ return( c ); } if ( fixup()){ return( delegate.getAdditionalMapProperty( name )); } return( null ); }
@Override public String getAdditionalStringProperty( String name ) { Map c = cache; if ( c != null && ( name.equals( "encoding") || name.equals( "torrent filename" ))){ byte[] res = (byte[])c.get( name ); if ( res == null ){ return( null ); } try{ return( new String( res, "UTF8" )); }catch( Throwable e ){ Debug.printStackTrace( e ); return( null ); } } if ( fixup()){ return( delegate.getAdditionalStringProperty( name )); } return( null ); }
@Override public byte[] getComment() { Map c = cache; if ( c != null ){ return((byte[])c.get( "comment" )); } if ( fixup()){ return( delegate.getComment()); } return( null ); }
torrent = _torrent; attributes = torrent.getAdditionalMapProperty( ATTRIBUTE_KEY ); IpFilterManagerFactory.getSingleton().getIPFilter().addExcludedHash( torrent.getHash());
@Override public void setAnnounceURLSets( TOTorrentAnnounceURLSet[] toSet ) { if ( fixup()){ TOTorrentAnnounceURLSet[] modToSet = new TOTorrentAnnounceURLSet[toSet.length]; for (int i = 0; i < toSet.length; i++){ TOTorrentAnnounceURLSet set = toSet[i]; if ( set instanceof cacheSet ){ modToSet[i] = ((cacheSet) set).delegateSet; } if ( modToSet[i] == null ){ modToSet[i] = set; } } delegate.getAnnounceURLGroup().setAnnounceURLSets( modToSet ); } }
void fixGroup() { TOTorrentAnnounceURLSet[] realSets = delegate.getAnnounceURLGroup().getAnnounceURLSets(); if ( realSets.length != sets.length ){ // not a major issue - since we now allow the cached groups and persisted ones to // drift (see DNS changes) the cached ones will be accurate and the persisted ones // will be re-adjusted should they become visible // Debug.out("Cached announce group state does not match real state"); }else{ for (int i=0;i<realSets.length;i++){ if ( sets[i] instanceof cacheSet ){ ((cacheSet)sets[i]).delegateSet = realSets[i]; } } sets = null; } }
@Override public void addListener( TOTorrentListener l ) { if ( fixup()){ delegate.addListener( l ); } }
@Override public Object getAdditionalProperty( String name ) { if ( fixup()){ return( delegate.getAdditionalProperty( name )); } return( null ); }
@Override public TOTorrentAnnounceURLGroup getAnnounceURLGroup() { if ( announce_group != null ){ return( announce_group ); } if ( fixup()){ return( delegate.getAnnounceURLGroup()); } return( null ); }
@Override public URL getAnnounceURL() { if ( announce_url != null ){ return( announce_url ); } if ( fixup()){ return( delegate.getAnnounceURL()); } return( null ); }
@Override public List getAdditionalListProperty( String name ) { if ( fixup()){ return( delegate.getAdditionalListProperty( name )); } return( null ); }
@Override public byte[] getAdditionalByteArrayProperty( String name ) { if ( fixup()){ return( delegate.getAdditionalByteArrayProperty( name )); } return( null ); }
@Override public TOTorrentAnnounceURLSet[] getAnnounceURLSets() { if ( announce_group == null && fixup()){ return delegate.getAnnounceURLGroup().getAnnounceURLSets(); } return( sets ); }
@Override public Map getTrackerResponseCache() { Map tracker_response_cache = null; tracker_response_cache = torrent.getAdditionalMapProperty(TRACKER_CACHE_KEY); if (tracker_response_cache == null) tracker_response_cache = new HashMap(); return (tracker_response_cache); }
@Override public Long getAdditionalLongProperty( String name ) { if ( fixup()){ return( delegate.getAdditionalLongProperty( name )); } return( null ); }
@Override public TOTorrentAnnounceURLSet createAnnounceURLSet( URL[] urls ) { if ( fixup()){ return( delegate.getAnnounceURLGroup().createAnnounceURLSet( urls )); } return( null ); }
@Override public Map getResumeData() { try{ this_mon.enter(); return( torrent.getAdditionalMapProperty(RESUME_KEY)); }finally{ this_mon.exit(); } }