public void addAndFireListener(COConfigurationListener listener) { synchronized (listenerz) { listenerz.add(listener); } try { listener.configurationSaved(); } catch (Throwable e) { Debug.printStackTrace(e); } }
public boolean setParameter(String parameter, StringList value) { try { List encoded = new ArrayList(); List l = ((StringListImpl) value).getList(); for (int i = 0; i < l.size(); i++) { encoded.add(stringToBytes((String) l.get(i))); } propertiesMap.put(parameter, encoded); notifyParameterListeners(parameter); } catch (Exception e) { Debug.printStackTrace(e); return false; } return true; }
protected static List stringToPorts(String str) { str = str.replace(',', ';'); StringTokenizer tok = new StringTokenizer(str, ";"); List res = new ArrayList(); while (tok.hasMoreTokens()) { try { res.add(new Integer(tok.nextToken().trim())); } catch (Throwable e) { Debug.out("Invalid port entry in '" + str + "'", e); } } return (res); }
public static URL[][] getAnnounceURLs() { String tracker_host = COConfigurationManager.getStringParameter("Tracker IP", ""); List urls = new ArrayList(); if (tracker_host.length() > 0) { if (COConfigurationManager.getBooleanParameter("Tracker Port Enable")) { int port = COConfigurationManager.getIntParameter("Tracker Port", TRHost.DEFAULT_PORT); try { List l = new ArrayList(); l.add( new URL( "http://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + port + "/announce")); List ports = stringToPorts(COConfigurationManager.getStringParameter("Tracker Port Backups")); for (int i = 0; i < ports.size(); i++) { l.add( new URL( "http://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + ((Integer) ports.get(i)).intValue() + "/announce")); } urls.add(l); } catch (MalformedURLException e) { Debug.printStackTrace(e); } } if (COConfigurationManager.getBooleanParameter("Tracker Port SSL Enable")) { int port = COConfigurationManager.getIntParameter("Tracker Port SSL", TRHost.DEFAULT_PORT_SSL); try { List l = new ArrayList(); l.add( new URL( "https://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + port + "/announce")); List ports = stringToPorts(COConfigurationManager.getStringParameter("Tracker Port SSL Backups")); for (int i = 0; i < ports.size(); i++) { l.add( new URL( "https://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + ((Integer) ports.get(i)).intValue() + "/announce")); } urls.add(l); } catch (MalformedURLException e) { Debug.printStackTrace(e); } } if (COConfigurationManager.getBooleanParameter("Tracker Port UDP Enable")) { int port = COConfigurationManager.getIntParameter("Tracker Port", TRHost.DEFAULT_PORT); boolean auth = COConfigurationManager.getBooleanParameter("Tracker Password Enable Torrent"); try { List l = new ArrayList(); l.add( new URL( "udp://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + port + "/announce" + (auth ? "?auth" : ""))); urls.add(l); } catch (MalformedURLException e) { Debug.printStackTrace(e); } } } URL[][] res = new URL[urls.size()][]; for (int i = 0; i < urls.size(); i++) { List l = (List) urls.get(i); URL[] u = new URL[l.size()]; l.toArray(u); res[i] = u; } return (res); }
public void addResetToDefaultsListener(ResetToDefaultsListener l) { synchronized (reset_to_def_listeners) { reset_to_def_listeners.add(l); } }
public void addListener(COConfigurationListener listener) { synchronized (listenerz) { listenerz.add(listener); } }