{
// use a facade here to delay loading the actual torrent until the
// download is activated
TRTrackerAnnouncer result = TRTrackerAnnouncerFactory.create( torrent_facade, true );
result.addListener(
new TRTrackerAnnouncerListener()
{
public void
receivedTrackerResponse(
TRTrackerAnnouncerResponse response )
{
TRTrackerAnnouncerResponsePeer[] peers = response.getPeers();
// tracker shouldn't return seeds to seeds to we can assume
// that if peers returned this means we have someone to talk to
if ( peers != null && peers.length > 0 ){
ensureActive( "Tracker[" + peers[0].getAddress()+ "]", ACT_TRACKER_ANNOUNCE );
}else if ( response.getScrapeIncompleteCount() > 0 ){
ensureActive( "Tracker[scrape]", ACT_TRACKER_SCRAPE );
}
PEPeerManager pm = peer_manager;
if ( pm != null ){
pm.processTrackerResponse( response );
}
}
public void
urlChanged(
TRTrackerAnnouncer announcer,
URL old_url,
URL new_url,
boolean explicit )
{
}
public void
urlRefresh()
{
}
});
result.setAnnounceDataProvider(
new TRTrackerAnnouncerDataProvider()
{
public String
getName()
{