}
// cache peer source
tps.add(
new TrackerPeerSourceAdapter()
{
private TrackerPeerSource _delegate;
private TRTrackerAnnouncer ta;
private boolean enabled;
private long ta_fixup;
private TrackerPeerSource
fixup()
{
long now = SystemTime.getMonotonousTime();
if ( now - ta_fixup > 1000 ){
TRTrackerAnnouncer current_ta = getTrackerClient();
if ( current_ta == ta ){
if ( current_ta != null && _delegate == null ){
_delegate = current_ta.getCacheTrackerPeerSource();
}
}else{
if ( current_ta == null ){
_delegate = null;
}else{
_delegate = current_ta.getCacheTrackerPeerSource();
}
ta = current_ta;
}
enabled = controller.isPeerSourceEnabled( PEPeerSource.PS_BT_TRACKER );
ta_fixup = now;
}
return( _delegate );
}
public int
getType()
{
return( TrackerPeerSource.TP_TRACKER );
}
public String
getName()
{
TrackerPeerSource delegate = fixup();
if ( delegate == null ){
return( MessageText.getString( "tps.tracker.cache" ));
}
return( delegate.getName());
}
public int
getStatus()
{
TrackerPeerSource delegate = fixup();
if ( !enabled ){
return( ST_DISABLED );
}
if ( delegate == null ){
return( ST_STOPPED );
}
return( ST_ONLINE );
}
public int
getPeers()
{
TrackerPeerSource delegate = fixup();
if ( delegate == null || !enabled ){
return( -1 );
}
return( delegate.getPeers());
}
});
}
// http seeds
try{
ExternalSeedPlugin esp = DownloadManagerController.getExternalSeedPlugin();
if ( esp != null ){
tps.add( esp.getTrackerPeerSource( PluginCoreUtils.wrap( this ) ));
}
}catch( Throwable e ){
}
// dht
try{
PluginInterface dht_pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(DHTTrackerPlugin.class);
if ( dht_pi != null ){
tps.add(((DHTTrackerPlugin)dht_pi.getPlugin()).getTrackerPeerSource( PluginCoreUtils.wrap( this )));
}
}catch( Throwable e ){
}
// LAN
try{
PluginInterface lt_pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(LocalTrackerPlugin.class);
if ( lt_pi != null ){
tps.add(((LocalTrackerPlugin)lt_pi.getPlugin()).getTrackerPeerSource( PluginCoreUtils.wrap( this )));
}
}catch( Throwable e ){
}
// Plugin
try{
tps.add(((DownloadImpl)PluginCoreUtils.wrap( this )).getTrackerPeerSource());
}catch( Throwable e ){
}
// PEX...
tps.add(
new TrackerPeerSourceAdapter()
{
private PEPeerManager _pm;
private TrackerPeerSource _delegate;
private TrackerPeerSource
fixup()
{
PEPeerManager pm = getPeerManager();
if ( pm == null ){
_delegate = null;
_pm = null;
}else if ( pm != _pm ){
_pm = pm;
_delegate = pm.getTrackerPeerSource();
}
return( _delegate );
}
public int
getType()
{
return( TP_PEX );
}
public int
getStatus()
{
TrackerPeerSource delegate = fixup();
if ( delegate == null ){
return( ST_STOPPED );
}else{
return( delegate.getStatus());
}
}
public String
getName()
{
TrackerPeerSource delegate = fixup();
if ( delegate == null ){
return( "" );
}else{
return( delegate.getName());
}
}
public int
getPeers()
{
TrackerPeerSource delegate = fixup();
if ( delegate == null ){
return( -1 );
}else{
return( delegate.getPeers());
}
}
});
// incoming
tps.add(
new TrackerPeerSourceAdapter()
{
private long fixup_time;
private PEPeerManager _pm;
private int tcp;