}
}
}
});
DelayedTask delayed_task = UtilitiesImpl.addDelayedTask( "Subscriptions",
new Runnable()
{
public void
run()
{
new AEThread2( "Subscriptions:delayInit", true )
{
public void
run()
{
asyncInit();
}
}.start();
}
protected void
asyncInit()
{
Download[] downloads = default_pi.getDownloadManager().getDownloads();
for (int i=0;i<downloads.length;i++){
Download download = downloads[i];
if ( download.getBooleanAttribute( ta_subs_download )){
Map rd = download.getMapAttribute( ta_subs_download_rd );
boolean delete_it;
if ( rd == null ){
delete_it = true;
}else{
delete_it = !recoverSubscriptionUpdate( download, rd );
}
if ( delete_it ){
removeDownload( download, true );
}
}
}
default_pi.getDownloadManager().addListener(
new DownloadManagerListener()
{
public void
downloadAdded(
final Download download )
{
// if ever changed to handle non-persistent then you need to fix init deadlock
// potential with share-hoster plugin
if ( download.isPersistent()){
if ( !dht_plugin.isInitialising()){
// if new download then we want to check out its subscription status
lookupAssociations( download.getMapAttribute( ta_subscription_info ) == null );
}else{
new AEThread2( "Subscriptions:delayInit", true )
{
public void
run()
{
lookupAssociations( download.getMapAttribute( ta_subscription_info ) == null );
}
}.start();
}
}
}
public void
downloadRemoved(
Download download )
{
}
},
false );
for (int i=0;i<PUB_ASSOC_CONC_MAX;i++){
if ( publishAssociations()){
break;
}
}
publishSubscriptions();
COConfigurationManager.addParameterListener(
CONFIG_MAX_RESULTS,
new ParameterListener()
{
public void
parameterChanged(
String name )
{
final int max_results = COConfigurationManager.getIntParameter( CONFIG_MAX_RESULTS );
new AEThread2( "Subs:max results changer", true )
{
public void
run()
{
checkMaxResults( max_results );
}
}.start();
}
});
SimpleTimer.addPeriodicEvent(
"SubscriptionChecker",
TIMER_PERIOD,
new TimerEventPerformer()
{
private int ticks;
public void
perform(
TimerEvent event )
{
ticks++;
checkStuff( ticks );
}
});
}
});
delayed_task.queue();
}
if ( isSearchEnabled()){
try{