checked_customization = true;
CustomizationManager cust_man = CustomizationManagerFactory.getSingleton();
Customization cust = cust_man.getActiveCustomization();
if ( cust != null ){
String cust_name = COConfigurationManager.getStringParameter( "metasearch.custom.name", "" );
String cust_version = COConfigurationManager.getStringParameter( "metasearch.custom.version", "0" );
boolean new_name = !cust_name.equals( cust.getName());
boolean new_version = org.gudy.azureus2.core3.util.Constants.compareVersions( cust_version, cust.getVersion() ) < 0;
if ( new_name || new_version ){
log( "Customization: checking templates for " + cust.getName() + "/" + cust.getVersion());
try{
InputStream[] streams = cust.getResources( Customization.RT_META_SEARCH_TEMPLATES );
if ( streams.length > 0 && new_name ){
// reset engines
log( " setting auto-mode to false" );
setAutoMode( false );
/*
Engine[] engines = meta_search.getEngines( false, false );
for (int i=0;i<engines.length;i++){
Engine engine = engines[i];
if ( engine.getSelectionState()) == Engine.SEL_STATE_MANUAL_SELECTED ){
}
}
*/
}
for (int i=0;i<streams.length;i++){
InputStream is = streams[i];
try{
VuzeFile vf = VuzeFileHandler.getSingleton().loadVuzeFile(is);
if ( vf != null ){
VuzeFileComponent[] comps = vf.getComponents();
for (int j=0;j<comps.length;j++){
VuzeFileComponent comp = comps[j];
if ( comp.getType() == VuzeFileComponent.COMP_TYPE_METASEARCH_TEMPLATE ){
try{
Engine e =
getSingleton().importEngine( comp.getContent(), false );
log( " updated " + e.getName());
e.setSelectionState( Engine.SEL_STATE_MANUAL_SELECTED );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
}
}
}finally{
try{
is.close();
}catch( Throwable e ){
}
}
}
}finally{
COConfigurationManager.setParameter( "metasearch.custom.name", cust.getName());
COConfigurationManager.setParameter( "metasearch.custom.version", cust.getVersion());
}
}
}
}