stubs for su3 news

This commit is contained in:
zzz
2014-08-31 14:12:18 +00:00
parent 053ce88743
commit 6826ba05e7
7 changed files with 23 additions and 4 deletions

View File

@ -158,6 +158,8 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
// right at instantiation if the news is already indicating a new version // right at instantiation if the news is already indicating a new version
Checker c = new NewsHandler(_context, this); Checker c = new NewsHandler(_context, this);
register(c, NEWS, HTTP, 0); register(c, NEWS, HTTP, 0);
// TODO
//register(c, NEWS_SU3, HTTP, 0);
register(c, ROUTER_SIGNED, HTTP, 0); // news is an update checker for the router register(c, ROUTER_SIGNED, HTTP, 0); // news is an update checker for the router
Updater u = new UpdateHandler(_context, this); Updater u = new UpdateHandler(_context, this);
register(u, ROUTER_SIGNED, HTTP, 0); register(u, ROUTER_SIGNED, HTTP, 0);
@ -734,9 +736,9 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
UpdateType type, String id, UpdateType type, String id,
Map<UpdateMethod, List<URI>> sourceMap, Map<UpdateMethod, List<URI>> sourceMap,
String newVersion, String minVersion) { String newVersion, String minVersion) {
if (type == NEWS) { if (type == NEWS || type == NEWS_SU3) {
// shortcut // shortcut
notifyInstalled(NEWS, "", newVersion); notifyInstalled(type, "", newVersion);
return true; return true;
} }
UpdateItem ui = new UpdateItem(type, id); UpdateItem ui = new UpdateItem(type, id);
@ -806,6 +808,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
String msg = null; String msg = null;
switch (type) { switch (type) {
case NEWS: case NEWS:
case NEWS_SU3:
break; break;
case ROUTER_UNSIGNED: case ROUTER_UNSIGNED:
@ -900,6 +903,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
String msg = null; String msg = null;
switch (task.getType()) { switch (task.getType()) {
case NEWS: case NEWS:
case NEWS_SU3:
case ROUTER_SIGNED: case ROUTER_SIGNED:
case ROUTER_SIGNED_SU3: case ROUTER_SIGNED_SU3:
case ROUTER_UNSIGNED: case ROUTER_UNSIGNED:
@ -1009,6 +1013,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
switch (task.getType()) { switch (task.getType()) {
case TYPE_DUMMY: case TYPE_DUMMY:
case NEWS: case NEWS:
case NEWS_SU3:
rv = true; rv = true;
break; break;
@ -1132,6 +1137,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
switch (type) { switch (type) {
case NEWS: case NEWS:
case NEWS_SU3:
// handled in NewsHandler // handled in NewsHandler
break; break;

View File

@ -124,6 +124,7 @@ class NewsFetcher extends UpdateRunner {
* Parse the installed (not the temp) news file for the latest version. * Parse the installed (not the temp) news file for the latest version.
* TODO: Real XML parsing * TODO: Real XML parsing
* TODO: Check minVersion, use backup URLs specified * TODO: Check minVersion, use backup URLs specified
* TODO: SU3
*/ */
void checkForUpdates() { void checkForUpdates() {
FileInputStream in = null; FileInputStream in = null;

View File

@ -29,6 +29,7 @@ class NewsHandler extends UpdateHandler implements Checker {
* @since 0.7.14 not configurable * @since 0.7.14 not configurable
*/ */
private static final String BACKUP_NEWS_URL = "http://avviiexdngd32ccoy4kuckvc3mkf53ycvzbz6vz75vzhv4tbpk5a.b32.i2p/news.xml"; private static final String BACKUP_NEWS_URL = "http://avviiexdngd32ccoy4kuckvc3mkf53ycvzbz6vz75vzhv4tbpk5a.b32.i2p/news.xml";
private static final String BACKUP_NEWS_URL_SU3 = "http://avviiexdngd32ccoy4kuckvc3mkf53ycvzbz6vz75vzhv4tbpk5a.b32.i2p/news.su3";
public NewsHandler(RouterContext ctx, ConsoleUpdateManager mgr) { public NewsHandler(RouterContext ctx, ConsoleUpdateManager mgr) {
super(ctx, mgr); super(ctx, mgr);
@ -41,14 +42,17 @@ class NewsHandler extends UpdateHandler implements Checker {
*/ */
public UpdateTask check(UpdateType type, UpdateMethod method, public UpdateTask check(UpdateType type, UpdateMethod method,
String id, String currentVersion, long maxTime) { String id, String currentVersion, long maxTime) {
if ((type != ROUTER_SIGNED && type != NEWS) || if ((type != ROUTER_SIGNED && type != NEWS && type != NEWS_SU3) ||
method != HTTP) method != HTTP)
return null; return null;
List<URI> updateSources = new ArrayList<URI>(2); List<URI> updateSources = new ArrayList<URI>(2);
try { try {
// TODO SU3
updateSources.add(new URI(ConfigUpdateHelper.getNewsURL(_context))); updateSources.add(new URI(ConfigUpdateHelper.getNewsURL(_context)));
} catch (URISyntaxException use) {} } catch (URISyntaxException use) {}
try { try {
// TODO
//updateSources.add(new URI(BACKUP_NEWS_URL_SU3));
updateSources.add(new URI(BACKUP_NEWS_URL)); updateSources.add(new URI(BACKUP_NEWS_URL));
} catch (URISyntaxException use) {} } catch (URISyntaxException use) {}
UpdateRunner update = new NewsFetcher(_context, _mgr, updateSources); UpdateRunner update = new NewsFetcher(_context, _mgr, updateSources);

View File

@ -32,6 +32,7 @@ public class ConfigUpdateHandler extends FormHandler {
// public static final String DEFAULT_NEWS_URL = "http://dev.i2p.net/cgi-bin/cvsweb.cgi/i2p/news.xml?rev=HEAD"; // public static final String DEFAULT_NEWS_URL = "http://dev.i2p.net/cgi-bin/cvsweb.cgi/i2p/news.xml?rev=HEAD";
public static final String OLD_DEFAULT_NEWS_URL = "http://complication.i2p/news.xml"; public static final String OLD_DEFAULT_NEWS_URL = "http://complication.i2p/news.xml";
public static final String DEFAULT_NEWS_URL = "http://echelon.i2p/i2p/news.xml"; public static final String DEFAULT_NEWS_URL = "http://echelon.i2p/i2p/news.xml";
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 String PROP_REFRESH_FREQUENCY = "router.newsRefreshFrequency";
public static final long DEFAULT_REFRESH_FREQ = 36*60*60*1000l; public static final long DEFAULT_REFRESH_FREQ = 36*60*60*1000l;
public static final String DEFAULT_REFRESH_FREQUENCY = Long.toString(DEFAULT_REFRESH_FREQ); public static final String DEFAULT_REFRESH_FREQUENCY = Long.toString(DEFAULT_REFRESH_FREQ);

View File

@ -32,6 +32,7 @@ public class ConfigUpdateHelper extends HelperBase {
/** hack to replace the old news location with the new one, even if they have saved /** hack to replace the old news location with the new one, even if they have saved
the update page at some point */ the update page at some point */
public static String getNewsURL(I2PAppContext ctx) { public static String getNewsURL(I2PAppContext ctx) {
// TODO SU3
String url = ctx.getProperty(ConfigUpdateHandler.PROP_NEWS_URL); 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))
return url; return url;

View File

@ -67,12 +67,16 @@ public class SU3File {
private static final int VERSION_OFFSET = 40; // Signature.SIGNATURE_BYTES; avoid early ctx init private static final int VERSION_OFFSET = 40; // Signature.SIGNATURE_BYTES; avoid early ctx init
public static final int TYPE_ZIP = 0; public static final int TYPE_ZIP = 0;
/** @since 0.9.15 */
public static final int TYPE_XML = 1; public static final int TYPE_XML = 1;
/** @since 0.9.15 */
public static final int TYPE_HTML = 2;
public static final int CONTENT_UNKNOWN = 0; public static final int CONTENT_UNKNOWN = 0;
public static final int CONTENT_ROUTER = 1; public static final int CONTENT_ROUTER = 1;
public static final int CONTENT_PLUGIN = 2; public static final int CONTENT_PLUGIN = 2;
public static final int CONTENT_RESEED = 3; public static final int CONTENT_RESEED = 3;
/** @since 0.9.15 */
public static final int CONTENT_NEWS = 4; public static final int CONTENT_NEWS = 4;
private enum ContentType { private enum ContentType {

View File

@ -23,5 +23,7 @@ public enum UpdateType {
/** unused */ /** unused */
ADDRESSBOOK, ADDRESSBOOK,
/** @since 0.9.9 */ /** @since 0.9.9 */
ROUTER_SIGNED_SU3 ROUTER_SIGNED_SU3,
/** @since 0.9.15 */
NEWS_SU3
} }