public static void preInitialise() { VuzeFileHandler.getSingleton() .addProcessor( new VuzeFileProcessor() { public void process(VuzeFile[] files, int expected_types) { for (int i = 0; i < files.length; i++) { VuzeFile vf = files[i]; VuzeFileComponent[] comps = vf.getComponents(); for (int j = 0; j < comps.length; j++) { VuzeFileComponent comp = comps[j]; if (comp.getType() == VuzeFileComponent.COMP_TYPE_CONTENT_NETWORK) { try { ((ContentNetworkManagerImpl) getSingleton()) .importNetwork(comp.getContent()); comp.setProcessed(); } catch (Throwable e) { log("Failed to import from vuze file", e); Debug.out(e); } } } } } }); }
protected ContentNetworkManagerImpl() { loadConfig(); addNetwork(new ContentNetworkVuze(this)); AEDiagnostics.addEvidenceGenerator(this); CustomizationManager cust_man = CustomizationManagerFactory.getSingleton(); Customization cust = cust_man.getActiveCustomization(); if (cust != null) { String cust_name = COConfigurationManager.getStringParameter("cnetworks.custom.name", ""); String cust_version = COConfigurationManager.getStringParameter("cnetworks.custom.version", "0"); boolean new_name = !cust_name.equals(cust.getName()); boolean new_version = Constants.compareVersions(cust_version, cust.getVersion()) < 0; if (new_name || new_version) { try { InputStream[] streams = cust.getResources(Customization.RT_CNETWORKS); 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]; int type = comp.getType(); if (type == VuzeFileComponent.COMP_TYPE_CONTENT_NETWORK) { try { // change here as we always add all networks upfront so // we always set the customisation flag regardless of // whether existing or not ContentNetwork imported = importNetwork(comp.getContent()); imported.setPersistentProperty(ContentNetwork.PP_IS_CUSTOMIZATION, true); comp.setProcessed(); } catch (Throwable e) { log("Failed to import customisation network", e); } } } } } finally { try { is.close(); } catch (Throwable e) { } } } } finally { COConfigurationManager.setParameter("cnetworks.custom.name", cust.getName()); COConfigurationManager.setParameter("cnetworks.custom.version", cust.getVersion()); } } } SimpleTimer.addPeriodicEvent( "MetaSearchRefresh", 23 * 60 * 60 * 1000, new TimerEventPerformer() { public void perform(TimerEvent event) { checkForUpdates(); } }); if (networks.size() > 1 || LOAD_ALL_NETWORKS) { new AEThread2("CNetwork:init", true) { public void run() { checkForUpdates(); } }.start(); } }