StandardPlugin[] sps = installer.getStandardPlugins();
for (int j=0;j<sps.length;j++){
final StandardPlugin sp = sps[j];
if ( sp.getId().equals( rp_id )){
found_one = true;
checker.getCheckInstance().addListener(
new UpdateCheckInstanceListener()
{
public void
cancelled(
UpdateCheckInstance instance )
{
}
public void
complete(
UpdateCheckInstance instance )
{
if ( instance.getUpdates().length == 0 ){
installRecommendedPlugin( installer, sp );
plugin_config.setPluginParameter( config_key, true );
}
}
});
break;
}
}
}catch( Throwable e ){
}
}
if ( found_one ){
break;
}
}
if ( !found_one ){
Set<String> auto_install = vc.getAutoInstallPluginIDs();
final List<String> to_do = new ArrayList<String>();
for ( String pid: auto_install ){
if ( plugin_manager.getPluginInterfaceByID( pid, false ) == null ){
to_do.add( pid );
}
}
if ( to_do.size() > 0 ){
new AEThread2( "pup:autoinst" )
{
public void
run()
{
try{
Thread.sleep( 120*1000 );
}catch( Throwable e ){
Debug.out( e );
return;
}
UpdateManager update_manager = plugin_interface.getUpdateManager();
final List<UpdateCheckInstance> l_instances = new ArrayList<UpdateCheckInstance>();
update_manager.addListener(
new UpdateManagerListener()
{
public void
checkInstanceCreated(
UpdateCheckInstance instance )
{
synchronized( l_instances ){
l_instances.add( instance );
}
}
});
UpdateCheckInstance[] instances = update_manager.getCheckInstances();
l_instances.addAll( Arrays.asList( instances ));
long start = SystemTime.getMonotonousTime();
while( true ){
if ( SystemTime.getMonotonousTime() - start >= 5*60*1000 ){
break;
}
try{
Thread.sleep(5000);
}catch( Throwable e ){
Debug.out( e );
return;
}
if ( l_instances.size() > 0 ){
boolean all_done = true;
for ( UpdateCheckInstance instance: l_instances ){
if ( !instance.isCompleteOrCancelled()){
all_done = false;
break;
}
}
if ( all_done ){
break;
}
}
}
if ( update_manager.getInstallers().length > 0 ){
return;
}
PluginInstaller installer = plugin_interface.getPluginManager().getPluginInstaller();
List<InstallablePlugin> sps = new ArrayList<InstallablePlugin>();
for ( String pid: to_do ){
try{
StandardPlugin sp = installer.getStandardPlugin( pid );
if ( sp != null ){
log.log( "Auto-installing " + pid );