public LongTermStatsImpl(AzureusCore _core, GlobalManagerStats _gm_stats) { core = _core; gm_stats = _gm_stats; stats_dir = FileUtil.getUserFile("stats"); COConfigurationManager.addParameterListener( "long.term.stats.enable", new ParameterListener() { public void parameterChanged(String name) { boolean enabled = COConfigurationManager.getBooleanParameter(name); synchronized (LongTermStatsImpl.this) { if (enabled) { if (!active) { sessionStart(); } } else { if (active) { sessionEnd(); } } } } }); _core.addLifecycleListener( new AzureusCoreLifecycleAdapter() { public void componentCreated(AzureusCore core, AzureusCoreComponent component) { if (component instanceof GlobalManager) { synchronized (LongTermStatsImpl.this) { sessionStart(); } } } public void stopped(AzureusCore core) { synchronized (LongTermStatsImpl.this) { closing = true; if (active) { sessionEnd(); } } } }); }
protected void generateEvidence(IndentWriter writer) { writer.println(getPluginName()); try { writer.indent(); writer.println("id:" + getPluginID() + ",version:" + getPluginVersion()); String user_dir = FileUtil.getUserFile("plugins").toString(); String shared_dir = FileUtil.getApplicationFile("plugins").toString(); String plugin_dir = getPluginDirectoryName(); String type; boolean built_in = false; if (plugin_dir.startsWith(shared_dir)) { type = "shared"; } else if (plugin_dir.startsWith(user_dir)) { type = "per-user"; } else { built_in = true; type = "built-in"; } PluginState ps = getPluginState(); String info = getPluginconfig().getPluginStringParameter("plugin.info"); writer.println( "type:" + type + ",enabled=" + !ps.isDisabled() + ",load_at_start=" + ps.isLoadedAtStartup() + ",operational=" + ps.isOperational() + (info == null || info.length() == 0 ? "" : (",info=" + info))); if (ps.isOperational()) { Plugin plugin = getPlugin(); if (plugin instanceof AEDiagnosticsEvidenceGenerator) { try { writer.indent(); ((AEDiagnosticsEvidenceGenerator) plugin).generate(writer); } catch (Throwable e) { writer.println( "Failed to generate plugin-specific info: " + Debug.getNestedExceptionMessage(e)); } finally { writer.exdent(); } } } else { if (!built_in) { File dir = new File(plugin_dir); if (dir.exists()) { String[] files = dir.list(); if (files != null) { String files_str = ""; for (String f : files) { files_str += (files_str.length() == 0 ? "" : ", ") + f; } writer.println(" files: " + files_str); } } } } } finally { writer.exdent(); } }