public String getPerUserPluginDirectoryName() { String name; if (pluginDir == null) { name = getPluginID(); } else { name = new File(pluginDir).getName(); } String str = new File(new File(SystemProperties.getUserPath(), "plugins"), name).getAbsolutePath(); if (pluginDir == null) { return (str); } try { if (new File(pluginDir).getCanonicalPath().equals(new File(str).getCanonicalPath())) { return (pluginDir); } } catch (Throwable e) { } return (str); }
private void exportParameters() { synchronized (exported_parameters) { if (!exported_parameters_dirty) { return; } exported_parameters_dirty = false; try { TreeMap<String, String> tm = new TreeMap<String, String>(); Set<String> exported_keys = new HashSet<String>(); for (String[] entry : exported_parameters.values()) { String key = entry[0]; String value = entry[1]; exported_keys.add(key); if (value != null) { tm.put(key, value); } } for (Map.Entry<String, String> entry : imported_parameters.entrySet()) { String key = entry.getKey(); if (!exported_keys.contains(key)) { tm.put(key, entry.getValue()); } } File parent_dir = new File(SystemProperties.getUserPath()); File props = new File(parent_dir, "exported_params.properties"); PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(props), "UTF-8")); try { for (Map.Entry<String, String> entry : tm.entrySet()) { pw.println(entry.getKey() + "=" + entry.getValue()); } } finally { pw.close(); } } catch (Throwable e) { e.printStackTrace(); } } }
private void loadExportedParameters() { synchronized (exported_parameters) { try { File parent_dir = new File(SystemProperties.getUserPath()); File props = new File(parent_dir, "exported_params.properties"); if (props.exists()) { LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(props), "UTF-8")); try { while (true) { String line = lnr.readLine(); if (line == null) { break; } String[] bits = line.split("="); if (bits.length == 2) { String key = bits[0].trim(); String value = bits[1].trim(); if (key.length() > 0 && value.length() > 0) { imported_parameters.put(key, value); } } } } finally { lnr.close(); } } } catch (Throwable e) { e.printStackTrace(); } } COConfigurationManager.setIntDefault("instance.port", Constants.INSTANCE_PORT); registerExportedParameter("instance.port", "instance.port"); }
public static File getMetaInfoDir(byte[] torrentHash) throws TorrentException { String oneSwarmMetaInfoDir = SystemProperties.getMetaInfoPath(); String torrentHex = new String(Base32.encode(torrentHash)); char firstChar = torrentHex.charAt(0); String torrentMetaInfoDirString = oneSwarmMetaInfoDir + SystemProperties.SEP + firstChar + SystemProperties.SEP + torrentHex; File torrentMetaInfoDir = new File(torrentMetaInfoDirString); torrentMetaInfoDir.mkdirs(); if (torrentMetaInfoDir.isDirectory()) { return torrentMetaInfoDir; } return null; }
protected File getDevicesDir() throws IOException { File dir = new File(SystemProperties.getUserPath()); dir = new File(dir, "devices"); if (!dir.exists()) { if (!dir.mkdirs()) { throw (new IOException("Failed to create '" + dir + "'")); } } return (dir); }
public static String bind_audio_scan() { long start = System.currentTimeMillis(); StringBuilder out = new StringBuilder(); out.append("bind audio scan..."); String metainfoPath = SystemProperties.getMetaInfoPath(); UpdatingFileTree metainfo = new UpdatingFileTree(new File(metainfoPath)); List<UpdatingFileTree> q = new ArrayList<UpdatingFileTree>(); q.add(metainfo); while (q.isEmpty() == false) { UpdatingFileTree curr = q.remove(0); if (curr.isDirectory()) { q.addAll(curr.getChildren()); } else if (curr.getThisFile().getName().equals(PreviewImageGenerator.AUDIO_INFO_FILE)) { String hashStr = curr.getThisFile().getParentFile().getName(); byte[] hashBytes = Base32.decode(hashStr); DownloadManager dm = AzureusCoreImpl.getSingleton() .getGlobalManager() .getDownloadManager(new HashWrapper(hashBytes)); // old metainfo and/or bogus directory name if (dm == null) { continue; } logger.finest("rebind audio considering: " + dm.getDisplayName()); out.append("considered: " + dm.getDisplayName()); if (dm.getDownloadState().getAttribute(FileCollection.ONESWARM_ARTIST_ATTRIBUTE) == null && dm.getDownloadState().getAttribute(FileCollection.ONESWARM_ALBUM_ATTRIBUTE) == null) { logger.finer("should rebind audio " + dm.getDisplayName()); out.append("rebinding for: " + dm.getDisplayName()); bind_audio_xml(dm); } } } String str = "binding audio scan took: " + (System.currentTimeMillis() - start); logger.info(str); out.append(str); return out.toString(); }
public SpeedManagerImpl(AzureusCore _core, SpeedManagerAdapter _adapter) { core = _core; adapter = _adapter; AEDiagnostics.addEvidenceGenerator(this); logger = AEDiagnostics.getLogger("SpeedMan"); ping_mapper = new SpeedManagerPingMapperImpl(this, "Var", LONG_PERIOD_TICKS, true, false); if (Constants.isCVSVersion()) { SpeedManagerPingMapperImpl pm2 = new SpeedManagerPingMapperImpl(this, "Abs", LONG_PERIOD_TICKS, false, false); ping_mappers = new SpeedManagerPingMapperImpl[] {pm2, ping_mapper}; } else { ping_mappers = new SpeedManagerPingMapperImpl[] {ping_mapper}; } final File config_dir = new File(SystemProperties.getUserPath(), "net"); if (!config_dir.exists()) { config_dir.mkdirs(); } NetworkAdmin.getSingleton() .addAndFirePropertyChangeListener( new NetworkAdminPropertyChangeListener() { public void propertyChanged(String property) { if (property == NetworkAdmin.PR_AS) { NetworkAdminASN net_asn = NetworkAdmin.getSingleton().getCurrentASN(); String as = net_asn.getAS(); if (as.length() == 0) { as = "default"; } File history = new File(config_dir, "pm_" + FileUtil.convertOSSpecificChars(as) + ".dat"); ping_mapper.loadHistory(history); asn = net_asn.getASName(); if (asn.length() == 0) { asn = "Unknown"; } informListeners(SpeedManagerListener.PR_ASN); } } }); core.addLifecycleListener( new AzureusCoreLifecycleAdapter() { public void stopping(AzureusCore core) { ping_mapper.saveHistory(); } }); 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 (!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(); } } }); emulated_ping_source = false; if (emulated_ping_source) { Debug.out("Emulated ping source!!!!"); setSpeedTester(new TestPingSourceRandom(this)); } }
private static boolean changeLocale(Locale newLocale, boolean force) { // set locale for startup (will override immediately it on locale change anyway) Locale.setDefault(newLocale); if (!isCurrentLocale(newLocale) || force) { Locale.setDefault(LOCALE_DEFAULT); ResourceBundle newResourceBundle = null; String bundleFolder = BUNDLE_NAME.replace('.', '/'); final String prefix = BUNDLE_NAME.substring(BUNDLE_NAME.lastIndexOf('.') + 1); final String extension = ".properties"; if (newLocale.equals(LOCALE_ENGLISH)) newLocale = LOCALE_DEFAULT; try { File userBundleFile = new File(SystemProperties.getUserPath()); File appBundleFile = new File(SystemProperties.getApplicationPath()); // Get the jarURL // XXX Is there a better way to get the JAR name? ClassLoader cl = MessageText.class.getClassLoader(); String sJar = cl.getResource(bundleFolder + extension).toString(); sJar = sJar.substring(0, sJar.length() - prefix.length() - extension.length()); URL jarURL = new URL(sJar); // User dir overrides app dir which overrides jar file bundles URL[] urls = {userBundleFile.toURL(), appBundleFile.toURL(), jarURL}; /* This is debugging code, use it when things go wrong :) The line number * is approximate as the input stream is buffered by the reader... { LineNumberInputStream lnis = null; try{ ClassLoader fff = new URLClassLoader(urls); java.io.InputStream stream = fff.getResourceAsStream("MessagesBundle_th_TH.properties"); lnis = new LineNumberInputStream( stream ); new java.util.PropertyResourceBundle(lnis); }catch( Throwable e ){ System.out.println( lnis.getLineNumber()); e.printStackTrace(); } } */ newResourceBundle = getResourceBundle("MessagesBundle", newLocale, new URLClassLoader(urls)); // do more searches if getBundle failed, or if the language is not the // same and the user wanted a specific country if ((!newResourceBundle.getLocale().getLanguage().equals(newLocale.getLanguage()) && !newLocale.getCountry().equals(""))) { Locale foundLocale = newResourceBundle.getLocale(); System.out.println( "changeLocale: " + (foundLocale.toString().equals("") ? "*Default Language*" : foundLocale.getDisplayLanguage()) + " != " + newLocale.getDisplayName() + ". Searching without country.."); // try it without the country Locale localeJustLang = new Locale(newLocale.getLanguage()); newResourceBundle = getResourceBundle("MessagesBundle", localeJustLang, new URLClassLoader(urls)); if (newResourceBundle == null || !newResourceBundle .getLocale() .getLanguage() .equals(localeJustLang.getLanguage())) { // find first language we have in our list System.out.println( "changeLocale: Searching for language " + newLocale.getDisplayLanguage() + " in *any* country.."); Locale[] locales = getLocales(); for (int i = 0; i < locales.length; i++) { if (locales[i].getLanguage() == newLocale.getLanguage()) { newResourceBundle = getResourceBundle("MessagesBundle", locales[i], new URLClassLoader(urls)); break; } } } } } catch (MissingResourceException e) { System.out.println("changeLocale: no resource bundle for " + newLocale); Debug.printStackTrace(e); return false; } catch (Exception e) { Debug.printStackTrace(e); } if (newResourceBundle != null) { if (!newLocale.equals(LOCALE_DEFAULT) && !newResourceBundle.getLocale().equals(newLocale)) { String sNewLanguage = newResourceBundle.getLocale().getDisplayName(); if (sNewLanguage == null || sNewLanguage.trim().equals("")) sNewLanguage = "English (default)"; System.out.println( "changeLocale: no message properties for Locale '" + newLocale.getDisplayName() + "' (" + newLocale + "), using '" + sNewLanguage + "'"); } newLocale = newResourceBundle.getLocale(); Locale.setDefault(newLocale.equals(LOCALE_DEFAULT) ? LOCALE_ENGLISH : newLocale); LOCALE_CURRENT = newLocale; setResourceBundle(new IntegratedResourceBundle(newResourceBundle, pluginLocalizationPaths)); if (newLocale.equals(LOCALE_DEFAULT)) DEFAULT_BUNDLE = RESOURCE_BUNDLE; return true; } else return false; } return false; }
public static Locale[] getLocales() { String bundleFolder = BUNDLE_NAME.replace('.', '/'); final String prefix = BUNDLE_NAME.substring(BUNDLE_NAME.lastIndexOf('.') + 1); final String extension = ".properties"; String urlString = MessageText.class .getClassLoader() .getResource(bundleFolder.concat(extension)) .toExternalForm(); // System.out.println("urlString: " + urlString); String[] bundles = null; if (urlString.startsWith("jar:file:")) { File jar = FileUtil.getJarFileFromURL(urlString); if (jar != null) { try { // System.out.println("jar: " + jar.getAbsolutePath()); JarFile jarFile = new JarFile(jar); Enumeration entries = jarFile.entries(); ArrayList list = new ArrayList(250); while (entries.hasMoreElements()) { JarEntry jarEntry = (JarEntry) entries.nextElement(); if (jarEntry.getName().startsWith(bundleFolder) && jarEntry.getName().endsWith(extension)) { // System.out.println("jarEntry: " + jarEntry.getName()); list.add(jarEntry.getName().substring(bundleFolder.length() - prefix.length())); // "MessagesBundle_de_DE.properties" } } bundles = (String[]) list.toArray(new String[list.size()]); } catch (Exception e) { Debug.printStackTrace(e); } } } else { File bundleDirectory = new File(URI.create(urlString)).getParentFile(); // System.out.println("bundleDirectory: " + // bundleDirectory.getAbsolutePath()); bundles = bundleDirectory.list( new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith(prefix) && name.endsWith(extension); } }); } HashSet bundleSet = new HashSet(); // Add local first File localDir = new File(SystemProperties.getUserPath()); String localBundles[] = localDir.list( new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith(prefix) && name.endsWith(extension); } }); // can be null if user path is borked if (localBundles != null) { bundleSet.addAll(Arrays.asList(localBundles)); } // Add AppDir 2nd File appDir = new File(SystemProperties.getApplicationPath()); String appBundles[] = appDir.list( new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith(prefix) && name.endsWith(extension); } }); // can be null if app path is borked if (appBundles != null) { bundleSet.addAll(Arrays.asList(appBundles)); } // Any duplicates will be ignored bundleSet.addAll(Arrays.asList(bundles)); List foundLocalesList = new ArrayList(bundleSet.size()); foundLocalesList.add(LOCALE_ENGLISH); Iterator val = bundleSet.iterator(); while (val.hasNext()) { String sBundle = (String) val.next(); // System.out.println("ResourceBundle: " + bundles[i]); if (prefix.length() + 1 < sBundle.length() - extension.length()) { String locale = sBundle.substring(prefix.length() + 1, sBundle.length() - extension.length()); // System.out.println("Locale: " + locale); String[] sLocalesSplit = locale.split("_", 3); if (sLocalesSplit.length > 0 && sLocalesSplit[0].length() == 2) { if (sLocalesSplit.length == 3) { foundLocalesList.add(new Locale(sLocalesSplit[0], sLocalesSplit[1], sLocalesSplit[2])); } else if (sLocalesSplit.length == 2 && sLocalesSplit[1].length() == 2) { foundLocalesList.add(new Locale(sLocalesSplit[0], sLocalesSplit[1])); } else { foundLocalesList.add(new Locale(sLocalesSplit[0])); } } else { if (sLocalesSplit.length == 3 && sLocalesSplit[0].length() == 0 && sLocalesSplit[2].length() > 0) { foundLocalesList.add(new Locale(sLocalesSplit[0], sLocalesSplit[1], sLocalesSplit[2])); } } } } Locale[] foundLocales = new Locale[foundLocalesList.size()]; foundLocalesList.toArray(foundLocales); try { Arrays.sort( foundLocales, new Comparator() { public final int compare(Object a, Object b) { return ((Locale) a) .getDisplayName((Locale) a) .compareToIgnoreCase(((Locale) b).getDisplayName((Locale) b)); } }); } catch (Throwable e) { // user has a problem whereby a null-pointer exception occurs when sorting the // list - I've done some fixes to the locale list construction but am // putting this in here just in case Debug.printStackTrace(e); } return foundLocales; }
public static void launch(String[] args) { if (Launcher.checkAndLaunch(PluginLauncherImpl.class, args)) return; // This *has* to be done first as it sets system properties that are read and cached by Java COConfigurationManager.preInitialise(); final LoggerChannelListener listener = new LoggerChannelListener() { public void messageLogged(int type, String content) { log(content, false); } public void messageLogged(String str, Throwable error) { log(str, true); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); error.printStackTrace(pw); pw.flush(); log(sw.toString(), true); } protected synchronized void log(String str, boolean stdout) { File log_file = getApplicationFile("launch.log"); PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(log_file, true)); if (str.endsWith("\n")) { if (stdout) { System.err.print("PluginLauncher: " + str); } pw.print(str); } else { if (stdout) { System.err.println("PluginLauncher: " + str); } pw.println(str); } } catch (Throwable e) { } finally { if (pw != null) { pw.close(); } } } }; LaunchablePlugin[] launchables = findLaunchablePlugins(listener); if (launchables.length == 0) { listener.messageLogged(LoggerChannel.LT_ERROR, "No launchable plugins found"); return; } else if (launchables.length > 1) { listener.messageLogged( LoggerChannel.LT_ERROR, "Multiple launchable plugins found, running first"); } try { // set default details for restarter SystemProperties.setApplicationEntryPoint("org.gudy.azureus2.plugins.PluginLauncher"); launchables[0].setDefaults(args); // see if we're a secondary instance if (PluginSingleInstanceHandler.process(listener, args)) { return; } // we have to run the core startup on a separate thread and then effectively pass "this // thread" // through to the launchable "process" method Thread core_thread = new Thread("PluginLauncher") { public void run() { try { // give 'process' call below some time to start up Thread.sleep(500); AzureusCore azureus_core = AzureusCoreFactory.create(); azureus_core.start(); } catch (Throwable e) { listener.messageLogged("PluginLauncher: launch fails", e); } } }; core_thread.setDaemon(true); core_thread.start(); boolean restart = false; boolean process_succeeded = false; try { restart = launchables[0].process(); process_succeeded = true; } finally { try { if (restart) { AzureusCoreFactory.getSingleton().restart(); } else { AzureusCoreFactory.getSingleton().stop(); } } catch (Throwable e) { // only report this exception if we're not already failing if (process_succeeded) { throw (e); } } } } catch (Throwable e) { listener.messageLogged("PluginLauncher: launch fails", e); } }
public static synchronized void preInitialise() { if (!pre_initialised) { pre_initialised = true; try { if (System.getProperty("azureus.portable.enable", "false").equalsIgnoreCase("true")) { try { if (File.separatorChar != '\\') { throw (new Exception("Portable only supported on Windows")); } File portable_root; try { portable_root = new File(".").getCanonicalFile(); } catch (Throwable e) { portable_root = new File(".").getAbsoluteFile(); } if (!portable_root.canWrite()) { throw (new Exception("can't write to " + portable_root)); } File root_file = new File(portable_root, "portable.dat"); String str = portable_root.getAbsolutePath(); if (str.length() < 2 || str.charAt(1) != ':') { throw (new Exception("drive letter missing in '" + str + "'")); } String root_relative = str.substring(2); boolean write_file = true; if (root_file.exists()) { LineNumberReader lnr = new LineNumberReader( new InputStreamReader(new FileInputStream(root_file), "UTF-8")); try { String line = lnr.readLine(); if (line != null) { line = line.trim(); if (line.equalsIgnoreCase(root_relative)) { write_file = false; } else { throw (new Exception( "root changed - old='" + line + "', new='" + root_relative)); } } } finally { lnr.close(); } } if (write_file) { PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(root_file), "UTF-8")); try { pw.println(root_relative); } finally { pw.close(); } } System.setProperty("azureus.install.path", str); System.setProperty("azureus.config.path", str); System.setProperty("azureus.portable.root", str); System.out.println( "Portable setup OK - root=" + root_relative + " (current=" + str + ")"); } catch (Throwable e) { System.err.println("Portable setup failed: " + e.getMessage()); System.setProperty("azureus.portable.enable", "false"); System.setProperty("azureus.portable.root", ""); } } else { System.setProperty("azureus.portable.root", ""); } /* String handlers = System.getProperty( "java.protocol.handler.pkgs" ); if ( handlers == null ){ handlers = "org.gudy.azureus2.core3.util.protocol"; }else{ handlers += "|org.gudy.azureus2.core3.util.protocol"; } System.setProperty( "java.protocol.handler.pkgs", handlers ); */ /* for the moment disable this as it is causing some users to get an SSL exception on * trackers with Java 7 due to the tracker hostname setup * See http://stackoverflow.com/questions/7615645/ssl-handshake-alert-unrecognized-name-error-since-upgrade-to-java-1-7-0 */ System.setProperty("jsse.enableSNIExtension", "false"); System.setProperty("sun.net.maxDatagramSockets", "4096"); URL.setURLStreamHandlerFactory(new AzURLStreamHandlerFactory()); // DNS cache timeouts System.setProperty("sun.net.inetaddr.ttl", "60"); System.setProperty("networkaddress.cache.ttl", "60"); // flick AWT into headless mode, which is supposed to make it more lightweight // don't do this as it borks (for example) swing based plugins, java webstart installer, // swing webui plugin, .... // System.setProperty("java.awt.headless", "true"); // defaults, overridden later if needed System.setProperty("sun.net.client.defaultConnectTimeout", "120000"); System.setProperty("sun.net.client.defaultReadTimeout", "60000"); // see // http://developer.apple.com/releasenotes/Java/Java142RN/ResolvedIssues/chapter_3_section_7.html // fixes the osx kernel panic bug caused by Apple's faulty kqueue implementation (as of // 10.3.6) if (Constants.isOSX) { // things seem good in 10.6 // if ( !Constants.isOSX_10_6_OrHigher ){ System.setProperty("java.nio.preferSelect", "true"); // } } SystemProperties.determineApplicationName(); } catch (Throwable e) { // can happen in applet if (e instanceof AccessControlException) { } else { e.printStackTrace(); } } } }
/** * Construct the default version check message. * * @return message to send */ public static Map constructVersionCheckMessage(String reason) { // only send if anonymous-check flag is not set boolean send_info = COConfigurationManager.getBooleanParameter("Send Version Info"); Map message = new HashMap(); // always send message.put("appid", SystemProperties.getApplicationIdentifier()); message.put("appname", SystemProperties.getApplicationName()); message.put("version", Constants.AZUREUS_VERSION); String sub_ver = Constants.AZUREUS_SUBVER; if (sub_ver.length() > 0) { message.put("subver", sub_ver); } if (COConfigurationManager.getBooleanParameter("Beta Programme Enabled")) { message.put("beta_prog", "true"); } message.put("ui", COConfigurationManager.getStringParameter("ui", "unknown")); message.put("os", Constants.OSName); message.put("os_version", System.getProperty("os.version")); message.put( "os_arch", System.getProperty("os.arch")); // see http://lopica.sourceforge.net/os.html boolean using_phe = COConfigurationManager.getBooleanParameter("network.transport.encrypted.require"); message.put("using_phe", using_phe ? new Long(1) : new Long(0)); // swt stuff try { Class c = Class.forName("org.eclipse.swt.SWT"); String swt_platform = (String) c.getMethod("getPlatform", new Class[] {}).invoke(null, new Object[] {}); message.put("swt_platform", swt_platform); Integer swt_version = (Integer) c.getMethod("getVersion", new Class[] {}).invoke(null, new Object[] {}); message.put("swt_version", new Long(swt_version.longValue())); if (send_info) { c = Class.forName("org.gudy.azureus2.ui.swt.mainwindow.MainWindow"); if (c != null) { c.getMethod("addToVersionCheckMessage", new Class[] {Map.class}) .invoke(null, new Object[] {message}); } } } catch (ClassNotFoundException e) { /* ignore */ } catch (NoClassDefFoundError er) { /* ignore */ } catch (InvocationTargetException err) { /* ignore */ } catch (Throwable t) { t.printStackTrace(); } int last_send_time = COConfigurationManager.getIntParameter("Send Version Info Last Time", -1); int current_send_time = (int) (SystemTime.getCurrentTime() / 1000); COConfigurationManager.setParameter("Send Version Info Last Time", current_send_time); String id = COConfigurationManager.getStringParameter("ID", null); if (id != null && send_info) { message.put("id", id); try { byte[] id2 = CryptoManagerFactory.getSingleton().getSecureID(); message.put("id2", id2); } catch (Throwable e) { } if (last_send_time != -1 && last_send_time < current_send_time) { // time since last message.put("tsl", new Long(current_send_time - last_send_time)); } message.put("reason", reason); String java_version = System.getProperty("java.version"); if (java_version == null) { java_version = "unknown"; } message.put("java", java_version); String java_vendor = System.getProperty("java.vm.vendor"); if (java_vendor == null) { java_vendor = "unknown"; } message.put("javavendor", java_vendor); long max_mem = Runtime.getRuntime().maxMemory() / (1024 * 1024); message.put("javamx", new Long(max_mem)); String java_rt_name = System.getProperty("java.runtime.name"); if (java_rt_name != null) { message.put("java_rt_name", java_rt_name); } String java_rt_version = System.getProperty("java.runtime.version"); if (java_rt_version != null) { message.put("java_rt_version", java_rt_version); } OverallStats stats = StatsFactory.getStats(); if (stats != null) { // long total_bytes_downloaded = stats.getDownloadedBytes(); // long total_bytes_uploaded = stats.getUploadedBytes(); long total_uptime = stats.getTotalUpTime(); // removed due to complaints about anonymous stats collection // message.put( "total_bytes_downloaded", new Long( total_bytes_downloaded ) ); // message.put( "total_bytes_uploaded", new Long( total_bytes_uploaded ) ); message.put("total_uptime", new Long(total_uptime)); // message.put( "dlstats", stats.getDownloadStats()); } try { NetworkAdminASN current_asn = NetworkAdmin.getSingleton().getCurrentASN(); String as = current_asn.getAS(); message.put("ip_as", current_asn.getAS()); String asn = current_asn.getASName(); if (asn.length() > 64) { asn = asn.substring(0, 64); } message.put("ip_asn", asn); } catch (Throwable e) { Debug.out(e); } // send locale, so we can determine which languages need attention message.put("locale", Locale.getDefault().toString()); String originalLocale = System.getProperty("user.language") + "_" + System.getProperty("user.country"); String variant = System.getProperty("user.variant"); if (variant != null && variant.length() > 0) { originalLocale += "_" + variant; } message.put("orig_locale", originalLocale); // We may want to reply differently if the user is in Beginner mode vs Advanced message.put("user_mode", COConfigurationManager.getIntParameter("User Mode", -1)); Set<String> features = UtilitiesImpl.getFeaturesInstalled(); if (features.size() > 0) { String str = ""; for (String f : features) { str += (str.length() == 0 ? "" : ",") + f; } message.put("vzfeatures", str); } try { if (AzureusCoreFactory.isCoreAvailable()) { // installed plugin IDs PluginInterface[] plugins = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaces(); List pids = new ArrayList(); List vs_data = new ArrayList(); for (int i = 0; i < plugins.length; i++) { PluginInterface plugin = plugins[i]; String pid = plugin.getPluginID(); String info = plugin.getPluginconfig().getPluginStringParameter("plugin.info"); // filter out built-in and core ones if ((info != null && info.length() > 0) || (!pid.startsWith("<") && !pid.startsWith("azbp") && !pid.startsWith("azupdater") && !pid.startsWith("azplatform") && !pids.contains(pid))) { if (info != null && info.length() > 0) { if (info.length() < 256) { pid += ":" + info; } else { Debug.out("Plugin '" + pid + "' reported excessive info string '" + info + "'"); } } pids.add(pid); } Map data = plugin.getPluginconfig().getPluginMapParameter("plugin.versionserver.data", null); if (data != null) { Map payload = new HashMap(); byte[] data_bytes = BEncoder.encode(data); if (data_bytes.length > 16 * 1024) { Debug.out( "Plugin '" + pid + "' reported excessive version server data (length=" + data_bytes.length + ")"); payload.put("error", "data too long: " + data_bytes.length); } else { payload.put("data", data_bytes); } payload.put("id", pid); payload.put("version", plugin.getPluginVersion()); vs_data.add(payload); } } message.put("plugins", pids); if (vs_data.size() > 0) { message.put("plugin_data", vs_data); } } } catch (Throwable e) { Debug.out(e); } } return message; }