propagate from branch 'i2p.i2p.zzz.test2' (head 8fa44268a1dd2b7baaf01806e6994281ab031870)

to branch 'i2p.i2p' (head 44afdaa15ce8a95c112c7d58a5908f401c1a0145)
This commit is contained in:
zzz
2015-11-22 16:00:16 +00:00
148 changed files with 1130 additions and 638 deletions

View File

@ -10,13 +10,13 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import net.i2p.I2PAppContext;
import net.i2p.app.ClientApp;
import net.i2p.app.ClientAppManager;
import net.i2p.app.ClientAppState;
import static net.i2p.app.ClientAppState.*;
import net.i2p.router.app.RouterApp;
import net.i2p.data.DataHelper;
import net.i2p.util.FileUtil;
import net.i2p.util.Log;
import net.i2p.util.TranslateReader;
@ -30,7 +30,7 @@ import org.cybergarage.xml.Node;
*
* @since 0.9.23
*/
public class NewsManager implements RouterApp {
public class NewsManager implements ClientApp {
private final I2PAppContext _context;
private final Log _log;
@ -233,9 +233,7 @@ public class NewsManager implements RouterApp {
// Doesn't work if the date has a : in it, but SHORT hopefully does not
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
// the router sets the JVM time zone to UTC but saves the original here so we can get it
String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
try {
Date date = fmt.parse(newsContent.substring(0, colon));
entry.updated = date.getTime();

View File

@ -19,7 +19,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TimeZone;
import net.i2p.app.ClientAppManager;
import net.i2p.crypto.SU3File;
@ -226,6 +225,18 @@ class NewsFetcher extends UpdateRunner {
_mgr.notifyVersionConstraint(this, _currentURI, ROUTER_SIGNED, "", ver, msg);
return;
}
if (!FileUtil.isPack200Supported()) {
String msg = _mgr._t("No Pack200 support in Java runtime.");
_log.logAlways(Log.WARN, "Cannot update to version " + ver + ": " + msg);
_mgr.notifyVersionConstraint(this, _currentURI, ROUTER_SIGNED, "", ver, msg);
return;
}
if (!ConfigUpdateHandler.USE_SU3_UPDATE) {
String msg = _mgr._t("No update certificates installed.");
_log.logAlways(Log.WARN, "Cannot update to version " + ver + ": " + msg);
_mgr.notifyVersionConstraint(this, _currentURI, ROUTER_SIGNED, "", ver, msg);
return;
}
String minRouter = args.get(MIN_VERSION_KEY);
if (minRouter != null) {
if (VersionComparator.comp(RouterVersion.VERSION, minRouter) < 0) {
@ -252,7 +263,7 @@ class NewsFetcher extends UpdateRunner {
// TODO clearnet URLs, notify with HTTP_CLEARNET and/or HTTPS_CLEARNET
Map<UpdateMethod, List<URI>> sourceMap = new HashMap<UpdateMethod, List<URI>>(4);
// Must do su3 first
if (ConfigUpdateHandler.USE_SU3_UPDATE) {
//if (ConfigUpdateHandler.USE_SU3_UPDATE) {
sourceMap.put(HTTP, _mgr.getUpdateURLs(ROUTER_SIGNED_SU3, "", HTTP));
addMethod(TORRENT, args.get(SU3_KEY), sourceMap);
addMethod(HTTP_CLEARNET, args.get(CLEARNET_HTTP_SU3_KEY), sourceMap);
@ -261,14 +272,14 @@ class NewsFetcher extends UpdateRunner {
_mgr.notifyVersionAvailable(this, _currentURI, ROUTER_SIGNED_SU3,
"", sourceMap, ver, "");
sourceMap.clear();
}
// now do sud/su2
sourceMap.put(HTTP, _mgr.getUpdateURLs(ROUTER_SIGNED, "", HTTP));
String key = FileUtil.isPack200Supported() ? SU2_KEY : SUD_KEY;
addMethod(TORRENT, args.get(key), sourceMap);
//}
// now do sud/su2 - DISABLED
//sourceMap.put(HTTP, _mgr.getUpdateURLs(ROUTER_SIGNED, "", HTTP));
//String key = FileUtil.isPack200Supported() ? SU2_KEY : SUD_KEY;
//addMethod(TORRENT, args.get(key), sourceMap);
// notify about all sources at once
_mgr.notifyVersionAvailable(this, _currentURI, ROUTER_SIGNED,
"", sourceMap, ver, "");
//_mgr.notifyVersionAvailable(this, _currentURI, ROUTER_SIGNED,
// "", sourceMap, ver, "");
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Our version is current");
@ -415,9 +426,8 @@ class NewsFetcher extends UpdateRunner {
if (_tempFile.exists() && _tempFile.length() > 0) {
File from;
// TODO check magic number instead?
// But then a corrupt file would be displayed as-is...
if (url.endsWith(".su3") || url.contains(".su3?")) {
// sud/su2 disabled
//if (url.endsWith(".su3") || url.contains(".su3?")) {
try {
from = processSU3();
} catch (IOException ioe) {
@ -425,9 +435,9 @@ class NewsFetcher extends UpdateRunner {
_tempFile.delete();
return;
}
} else {
from = _tempFile;
}
//} else {
// from = _tempFile;
//}
boolean copied = FileUtil.rename(from, _newsFile);
_tempFile.delete();
if (copied) {
@ -579,9 +589,7 @@ class NewsFetcher extends UpdateRunner {
return;
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
// the router sets the JVM time zone to UTC but saves the original here so we can get it
String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
for (NewsEntry e : entries) {
if (e.title == null || e.content == null)
continue;

View File

@ -107,7 +107,7 @@ public class CSSHelper extends HelperBase {
if (Integer.parseInt(r) < MIN_REFRESH)
r = "" + MIN_REFRESH;
_context.router().saveConfig(PROP_REFRESH, r);
} catch (Exception e) {
} catch (RuntimeException e) {
}
}
@ -117,7 +117,7 @@ public class CSSHelper extends HelperBase {
try {
if (Integer.parseInt(r) < MIN_REFRESH)
r = "" + MIN_REFRESH;
} catch (Exception e) {
} catch (RuntimeException e) {
r = "" + MIN_REFRESH;
}
return r;

View File

@ -207,7 +207,7 @@ public class ConfigNetHelper extends HelperBase {
configs = Collections.emptySet();
} else {
configs = new HashSet<String>(4);
String[] ca = cs.split("[,; \r\n\t]");
String[] ca = DataHelper.split(cs, "[,; \r\n\t]");
for (int i = 0; i < ca.length; i++) {
String c = ca[i];
if (c.length() > 0) {

View File

@ -2,8 +2,8 @@ package net.i2p.router.web;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -37,10 +37,10 @@ public class ConfigReseedHandler extends FormHandler {
addFormError(_t("You must enter a URL"));
return;
}
URL url;
URI url;
try {
url = new URL(val);
} catch (MalformedURLException mue) {
url = new URI(val);
} catch (URISyntaxException mue) {
addFormError(_t("Bad URL {0}", val));
return;
}

View File

@ -108,7 +108,7 @@ public class ConfigSummaryHandler extends FormHandler {
}
}
} else if (moving) {
String parts[] = _action.split("_");
String parts[] = DataHelper.split(_action, "_");
try {
int from = Integer.parseInt(parts[1]);
int to = 0;

View File

@ -12,7 +12,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.TreeMap;
import net.i2p.data.DataHelper;
@ -189,9 +188,7 @@ public class EventLogHelper extends FormHandler {
SimpleDateFormat fmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
// the router sets the JVM time zone to UTC but saves the original here so we can get it
String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
List<Map.Entry<Long, String>> entries = new ArrayList<Map.Entry<Long, String>>(events.entrySet());
Collections.reverse(entries);
@ -202,7 +199,7 @@ public class EventLogHelper extends FormHandler {
buf.append(fmt.format(new Date(time)));
buf.append("</td><td>");
if (isAll) {
String[] s = event.split(" ", 2);
String[] s = DataHelper.split(event, " ", 2);
String xs = _xevents.get(s[0]);
if (xs == null)
xs = s[0];

View File

@ -135,8 +135,10 @@ public class HomeHelper extends HelperBase {
return renderConfig(apps);
}
private static final String SS = Character.toString(S);
static Collection<App> buildApps(RouterContext ctx, String config) {
String[] args = config.split("" + S);
String[] args = DataHelper.split(config, SS);
Set<App> apps = new TreeSet<App>(new AppComparator());
for (int i = 0; i < args.length - 3; i += 4) {
String name = Messages.getString(args[i], ctx);
@ -149,7 +151,7 @@ public class HomeHelper extends HelperBase {
}
static Collection<App> buildSearchApps(String config) {
String[] args = config.split("" + S);
String[] args = DataHelper.split(config, SS);
Set<App> apps = new TreeSet<App>(new AppComparator());
for (int i = 0; i < args.length - 1; i += 2) {
String name = args[i];

View File

@ -4,7 +4,6 @@ import java.text.DateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import net.i2p.I2PAppContext;
import net.i2p.app.ClientAppManager;
@ -56,9 +55,7 @@ public class NewsFeedHelper extends HelperBase {
if (!entries.isEmpty()) {
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
// the router sets the JVM time zone to UTC but saves the original here so we can get it
String systemTimeZone = ctx.getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
fmt.setTimeZone(DataHelper.getSystemTimeZone(ctx));
int i = 0;
for (NewsEntry entry : entries) {
if (i++ < start)

View File

@ -423,7 +423,7 @@ public class PluginStarter implements Runnable {
addPath(f.toURI().toURL());
log.error("INFO: Adding translation plugin to classpath: " + f);
added = true;
} catch (Exception e) {
} catch (RuntimeException e) {
log.error("Plugin " + appName + " bad classpath element: " + f, e);
}
}
@ -961,7 +961,7 @@ public class PluginStarter implements Runnable {
urls.add(f.toURI().toURL());
if (log.shouldLog(Log.WARN))
log.warn("INFO: Adding plugin to classpath: " + f);
} catch (Exception e) {
} catch (IOException e) {
log.error("Plugin client " + clientName + " bad classpath element: " + f, e);
}
}

View File

@ -43,9 +43,11 @@ public class SearchHelper extends HelperBase {
_query = s;
}
private static final String SS = Character.toString(S);
private void buildEngineMap() {
String config = _context.getProperty(PROP_ENGINES, ENGINES_DEFAULT);
String[] args = config.split("" + S);
String[] args = DataHelper.split(config, SS);
for (int i = 0; i < args.length - 1; i += 2) {
String name = args[i];
String url = args[i+1];

View File

@ -9,7 +9,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import net.i2p.app.ClientAppManager;
import net.i2p.crypto.SigType;
@ -634,9 +633,7 @@ public class SummaryBarRenderer {
buf.append("<ul>\n");
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
// the router sets the JVM time zone to UTC but saves the original here so we can get it
String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
int i = 0;
final int max = 2;
for (NewsEntry entry : entries) {

View File

@ -861,6 +861,8 @@ public class SummaryHelper extends HelperBase {
public void storeNewsHelper(NewsHelper n) { _newshelper = n; }
public NewsHelper getNewsHelper() { return _newshelper; }
private static final String SS = Character.toString(S);
public List<String> getSummaryBarSections(String page) {
String config = "";
if ("home".equals(page)) {
@ -870,7 +872,7 @@ public class SummaryHelper extends HelperBase {
if (config == null)
config = _context.getProperty(PROP_SUMMARYBAR + "default", DEFAULT_FULL);
}
return Arrays.asList(config.split("" + S));
return Arrays.asList(DataHelper.split(config, SS));
}
static void saveSummaryBarSections(RouterContext ctx, String page, Map<Integer, String> sections) {

View File

@ -84,7 +84,8 @@ public class UpdateHandler {
} else if (ConfigUpdateHandler.USE_SU3_UPDATE) {
update(ROUTER_SIGNED_SU3);
} else {
update(ROUTER_SIGNED);
// disabled, shouldn't get here
//update(ROUTER_SIGNED);
}
}
}