}
});
COConfigurationManager.addAndFireParameterListener(
CONFIG_VERSION,
new ParameterListener()
{
public void
parameterChanged(
final String name )
{
dispatcher.dispatch(
new AERunnable()
{
public void
runSupport()
{
boolean do_reset = provider_version == -1;
int version = COConfigurationManager.getIntParameter( name );
if ( version != provider_version ){
provider_version = version;
if ( isEnabled()){
setEnabledSupport( false );
setEnabledSupport( true );
}
}
if ( do_reset ){
enableOrAlgChanged();
}
}
});
}
});
COConfigurationManager.setParameter( CONFIG_AVAIL, false );
SimpleTimer.addPeriodicEvent(
"SpeedManager:timer",
UPDATE_PERIOD_MILLIS,
new TimerEventPerformer()
{
private int tick_count;
public void
perform(
TimerEvent event )
{
// if enabled the ping stream drives the stats update for the ping mappers
// When not enabled we do it here instead
if ( !pm_enabled || contacts_array.length == 0 ){
int x = (adapter.getCurrentDataUploadSpeed(SPEED_AVERAGE_PERIOD) + adapter.getCurrentProtocolUploadSpeed(SPEED_AVERAGE_PERIOD));
int y = (adapter.getCurrentDataDownloadSpeed(SPEED_AVERAGE_PERIOD) + adapter.getCurrentProtocolDownloadSpeed(SPEED_AVERAGE_PERIOD));
for (int i=0;i<ping_mappers.length;i++){
ping_mappers[i].addSpeed( x, y );
}
}
tick_count++;
if ( tick_count % SAVE_PERIOD_TICKS == 0 ){
ping_mapper.saveHistory();
}
if ( tick_count % AUTO_ADJUST_PERIOD_TICKS == 0 ){
autoAdjust();
}
}
});
COConfigurationManager.addAndFireParameterListener(
"Auto Adjust Transfer Defaults",
new ParameterListener()
{
public void
parameterChanged(
String name )
{