From 239fe518a9ba7f66efb0a137fd53d7aad0b617dd Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 21 Oct 2014 18:35:06 +0000 Subject: [PATCH] Update: Partial implementation of su3 news with atom feed. No spec yet, just followed str4d's testnews.atom.xml proposal. Atom parsing is tested, su3 part is incomplete and untested. Todo: add spec to http://i2p-projekt.i2p/en/docs/spec/updates, finish su3 and test. --- apps/routerconsole/java/build.xml | 24 ++ .../src/net/i2p/router/news/NewsEntry.java | 27 ++ .../src/net/i2p/router/news/NewsMetadata.java | 28 ++ .../net/i2p/router/news/NewsXMLParser.java | 352 ++++++++++++++++++ .../src/net/i2p/router/news/RFC3339Date.java | 122 ++++++ .../java/src/net/i2p/router/news/package.html | 14 + .../router/update/ConsoleUpdateManager.java | 3 +- .../net/i2p/router/update/NewsFetcher.java | 128 +++++++ .../net/i2p/router/update/NewsHandler.java | 7 +- .../i2p/router/web/ConfigUpdateHandler.java | 3 + .../i2p/router/web/ConfigUpdateHelper.java | 6 +- build.xml | 7 +- core/java/src/net/i2p/crypto/SU3File.java | 2 + core/java/src/net/i2p/update/UpdateType.java | 4 +- 14 files changed, 716 insertions(+), 11 deletions(-) create mode 100644 apps/routerconsole/java/src/net/i2p/router/news/NewsEntry.java create mode 100644 apps/routerconsole/java/src/net/i2p/router/news/NewsMetadata.java create mode 100644 apps/routerconsole/java/src/net/i2p/router/news/NewsXMLParser.java create mode 100644 apps/routerconsole/java/src/net/i2p/router/news/RFC3339Date.java create mode 100644 apps/routerconsole/java/src/net/i2p/router/news/package.html diff --git a/apps/routerconsole/java/build.xml b/apps/routerconsole/java/build.xml index 8d9e9ec99..f897cff20 100644 --- a/apps/routerconsole/java/build.xml +++ b/apps/routerconsole/java/build.xml @@ -81,6 +81,24 @@ + + + + + + + + + + + + + @@ -119,6 +137,12 @@ + + + + + + \n"); + for (NewsEntry e : entries) { + if (e.title == null || e.content == null) + continue; + out.write("

"); + out.write(e.title); + out.write("

\n"); + out.write(e.content); + out.write("\n\n"); + } + } finally { + if (out != null) try { + out.close(); + } catch (IOException ioe) {} + } + } } diff --git a/apps/routerconsole/java/src/net/i2p/router/update/NewsHandler.java b/apps/routerconsole/java/src/net/i2p/router/update/NewsHandler.java index 1209cc49d..373d9dac4 100644 --- a/apps/routerconsole/java/src/net/i2p/router/update/NewsHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/update/NewsHandler.java @@ -47,13 +47,12 @@ class NewsHandler extends UpdateHandler implements Checker { return null; List updateSources = new ArrayList(2); try { - // TODO SU3 + // This may be su3 or xml updateSources.add(new URI(ConfigUpdateHelper.getNewsURL(_context))); } catch (URISyntaxException use) {} try { - // TODO - //updateSources.add(new URI(BACKUP_NEWS_URL_SU3)); - updateSources.add(new URI(BACKUP_NEWS_URL)); + //updateSources.add(new URI(BACKUP_NEWS_URL)); + updateSources.add(new URI(BACKUP_NEWS_URL_SU3)); } catch (URISyntaxException use) {} UpdateRunner update = new NewsFetcher(_context, _mgr, updateSources); return update; diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java index e33ab2bc7..42f7279b0 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java @@ -30,8 +30,11 @@ public class ConfigUpdateHandler extends FormHandler { public static final String PROP_NEWS_URL = "router.newsURL"; // public static final String DEFAULT_NEWS_URL = "http://dev.i2p.net/cgi-bin/cvsweb.cgi/i2p/news.xml?rev=HEAD"; + /** very old default */ public static final String OLD_DEFAULT_NEWS_URL = "http://complication.i2p/news.xml"; + /** old default */ public static final String DEFAULT_NEWS_URL = "http://echelon.i2p/i2p/news.xml"; + /** current default */ public static final String DEFAULT_NEWS_URL_SU3 = "http://echelon.i2p/i2p/news.su3"; public static final String PROP_REFRESH_FREQUENCY = "router.newsRefreshFrequency"; public static final long DEFAULT_REFRESH_FREQ = 36*60*60*1000l; diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java index 4f5daab18..716524fbf 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java @@ -32,12 +32,12 @@ public class ConfigUpdateHelper extends HelperBase { /** hack to replace the old news location with the new one, even if they have saved the update page at some point */ public static String getNewsURL(I2PAppContext ctx) { - // TODO SU3 String url = ctx.getProperty(ConfigUpdateHandler.PROP_NEWS_URL); - if (url != null && !url.equals(ConfigUpdateHandler.OLD_DEFAULT_NEWS_URL)) + if (url != null && !url.equals(ConfigUpdateHandler.OLD_DEFAULT_NEWS_URL) && + !url.equals(ConfigUpdateHandler.DEFAULT_NEWS_URL)) return url; else - return ConfigUpdateHandler.DEFAULT_NEWS_URL; + return ConfigUpdateHandler.DEFAULT_NEWS_URL_SU3; } public String getUpdateURL() { diff --git a/build.xml b/build.xml index 404c72245..200d86b4a 100644 --- a/build.xml +++ b/build.xml @@ -197,6 +197,11 @@
+ + + + + @@ -554,7 +559,7 @@ - + diff --git a/core/java/src/net/i2p/crypto/SU3File.java b/core/java/src/net/i2p/crypto/SU3File.java index ef56d8bdd..254433d7f 100644 --- a/core/java/src/net/i2p/crypto/SU3File.java +++ b/core/java/src/net/i2p/crypto/SU3File.java @@ -71,6 +71,8 @@ public class SU3File { public static final int TYPE_XML = 1; /** @since 0.9.15 */ public static final int TYPE_HTML = 2; + /** @since 0.9.17 */ + public static final int TYPE_XML_GZ = 3; public static final int CONTENT_UNKNOWN = 0; public static final int CONTENT_ROUTER = 1; diff --git a/core/java/src/net/i2p/update/UpdateType.java b/core/java/src/net/i2p/update/UpdateType.java index 4c699785b..cf26bec08 100644 --- a/core/java/src/net/i2p/update/UpdateType.java +++ b/core/java/src/net/i2p/update/UpdateType.java @@ -25,5 +25,7 @@ public enum UpdateType { /** @since 0.9.9 */ ROUTER_SIGNED_SU3, /** @since 0.9.15 */ - NEWS_SU3 + NEWS_SU3, + /** @since 0.9.17 */ + ROUTER_DEV_SU3 }