propagate from branch 'i2p.i2p' (head 156f8e6137be3c25aa70176fe0a78218b898a684)

to branch 'i2p.i2p.str4d.i2ptunnel' (head 126c1c30c0c02fd95719ffeae6d4709abb7bf18d)
This commit is contained in:
str4d
2012-01-23 01:36:26 +00:00
9 changed files with 160 additions and 59 deletions

View File

@@ -210,54 +210,15 @@ public class SummaryBarRenderer {
.append(_("Network"))
.append(": ")
.append(_helper.getReachability())
.append("</a></h4><hr>\n");
.append("</a></h4><hr>\n")
// display all the time so we display the final failure message, and plugin update messages too
String status = UpdateHandler.getStatus();
if (status.length() > 0) {
buf.append("<h4>").append(status).append("</h4><hr>\n");
}
if (_helper.updateAvailable() || _helper.unsignedUpdateAvailable()) {
if ("true".equals(System.getProperty(UpdateHandler.PROP_UPDATE_IN_PROGRESS))) {
// nothing
} else if(
// isDone() is always false for now, see UpdateHandler
// ((!update.isDone()) &&
_helper.getAction() == null &&
_helper.getUpdateNonce() == null &&
ConfigRestartBean.getRestartTimeRemaining() > 12*60*1000) {
long nonce = _context.random().nextLong();
String prev = System.getProperty("net.i2p.router.web.UpdateHandler.nonce");
if (prev != null)
System.setProperty("net.i2p.router.web.UpdateHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
String uri = _helper.getRequestURI();
buf.append("<form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
if (_helper.updateAvailable()) {
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"signed\" >")
// Note to translators: parameter is a version, e.g. "0.8.4"
.append(_("Download {0} Update", _helper.getUpdateVersion()))
.append("</button><br>\n");
}
if (_helper.unsignedUpdateAvailable()) {
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"Unsigned\" >")
// Note to translators: parameter is a date and time, e.g. "02-Mar 20:34 UTC"
// <br> is optional, to help the browser make the lines even in the button
// If the translation is shorter than the English, you should probably not include <br>
.append(_("Download Unsigned<br>Update {0}", _helper.getUnsignedUpdateVersion()))
.append("</button><br>\n");
}
buf.append("</form>\n");
}
}
.append(_helper.getUpdateStatus())
.append(_helper.getRestartStatus())
buf.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
.append("<hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append(_("Show all current peer connections"))
.append("\">")
@@ -451,7 +412,9 @@ public class SummaryBarRenderer {
"</table><hr><h4>")
.append(_(_helper.getTunnelStatus()))
.append("</h4><hr>\n")
.append(_helper.getDestinations());
.append(_helper.getDestinations())
.append("<hr>\n");

View File

@@ -27,6 +27,8 @@ import net.i2p.stat.RateStat;
/**
* Simple helper to query the appropriate router for data necessary to render
* the summary sections on the router console.
*
* For the full summary bar use renderSummaryBar()
*/
public class SummaryHelper extends HelperBase {
@@ -412,7 +414,7 @@ public class SummaryHelper extends HelperBase {
} else {
buf.append("<center><i>").append(_("none")).append("</i></center>");
}
buf.append("</div><hr>\n");
buf.append("</div>\n");
return buf.toString();
}
@@ -604,6 +606,62 @@ public class SummaryHelper extends HelperBase {
return NewsFetcher.getInstance(_context).unsignedUpdateVersion();
}
/**
* The update status and buttons
* @since 0.8.13 moved from SummaryBarRenderer
*/
public String getUpdateStatus() {
StringBuilder buf = new StringBuilder(512);
// display all the time so we display the final failure message, and plugin update messages too
String status = UpdateHandler.getStatus();
if (status.length() > 0) {
buf.append("<h4>").append(status).append("</h4><hr>\n");
}
if (updateAvailable() || unsignedUpdateAvailable()) {
if ("true".equals(System.getProperty(UpdateHandler.PROP_UPDATE_IN_PROGRESS))) {
// nothing
} else if(
// isDone() is always false for now, see UpdateHandler
// ((!update.isDone()) &&
getAction() == null &&
getUpdateNonce() == null &&
ConfigRestartBean.getRestartTimeRemaining() > 12*60*1000) {
long nonce = _context.random().nextLong();
String prev = System.getProperty("net.i2p.router.web.UpdateHandler.nonce");
if (prev != null)
System.setProperty("net.i2p.router.web.UpdateHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
String uri = getRequestURI();
buf.append("<form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
if (updateAvailable()) {
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"signed\" >")
// Note to translators: parameter is a version, e.g. "0.8.4"
.append(_("Download {0} Update", getUpdateVersion()))
.append("</button><br>\n");
}
if (unsignedUpdateAvailable()) {
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"Unsigned\" >")
// Note to translators: parameter is a date and time, e.g. "02-Mar 20:34 UTC"
// <br> is optional, to help the browser make the lines even in the button
// If the translation is shorter than the English, you should probably not include <br>
.append(_("Download Unsigned<br>Update {0}", getUnsignedUpdateVersion()))
.append("</button><br>\n");
}
buf.append("</form>\n");
}
}
return buf.toString();
}
/**
* The restart status and buttons
* @since 0.8.13 moved from SummaryBarRenderer
*/
public String getRestartStatus() {
return ConfigRestartBean.renderStatus(getRequestURI(), getAction(), getConsoleNonce());
}
/** output the summary bar to _out */
public void renderSummaryBar() throws IOException {
SummaryBarRenderer renderer = new SummaryBarRenderer(_context, this);