propagate from branch 'i2p.i2p.zzz.test4' (head 7b50b6c3d48da68078a86a53e55e2c18f55685e8)

to branch 'i2p.i2p' (head ebce577e19b70c281daacc5277f98e9bb2bb9630)
This commit is contained in:
zzz
2011-03-08 13:31:57 +00:00
183 changed files with 30058 additions and 11421 deletions

View File

@ -1,17 +0,0 @@
#
# Update messages_xx.po and messages_xx.class files,
# from both java and jsp sources.
# Requires installed programs xgettext, msgfmt, msgmerge, and find.
# zzz - public domain
#
## launching sh.exe with -login parameter will open a shell with the current path always pointing to \bin\
## need to cd into our orignal path - where we call sh.exe from.
cd $CALLFROM
## echo $PWD
## except this everything is the same with bundle-message.sh
## walking - public domain :-D
source bundle-messages.sh $PARAS

View File

@ -46,6 +46,7 @@
<javac
srcdir="./src"
debug="true" deprecation="on" source="1.5" target="1.5"
includeAntRuntime="false"
destdir="./build/obj">
<compilerarg line="${javac.compilerargs}" />
<classpath>
@ -61,41 +62,68 @@
</classpath>
</javac>
</target>
<target name="jar" depends="compile">
<!-- the jar with the latest message classes from the jsps, and the war too -->
<target name="jar" depends="jar1, war, bundle" />
<!-- the jar without the latest message classes from the jsps -->
<target name="jar1" depends="compile, jarUpToDate" unless="jar.uptodate" >
<exec executable="mtn" outputproperty="workspace.changes.j" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="list" />
<arg value="changed" />
<arg value="." />
<arg value="../locale" />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes.j}" outputproperty="workspace.changes.j.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
</exec>
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class">
<manifest>
<!-- top level installer will rename to jrobin.jar -->
<!-- DTG added in 0.8.4, not in the classpath for very old installs, before we changed wrapper.config to specify * -->
<attribute name="Class-Path" value="i2p.jar router.jar jrobin.jar desktopgui.jar" />
<attribute name="Build-Date" value="${build.timestamp}" />
<attribute name="Base-Revision" value="${workspace.version}" />
<attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
</manifest>
</jar>
<delete dir="./tmpextract" />
<!-- jrobin taken out of routerconsole.jar in 0.7.12
<delete dir="./tmpextract" />
<unjar src="../../jrobin/jrobin-1.4.0.jar" dest="./tmpextract" />
<jar destfile="./build/routerconsole.jar" basedir="./tmpextract" update="true" />
<delete dir="./tmpextract" />
-->
<ant target="war" />
</target>
<!-- this is tricky because the message classes go in the jar, not in the war -->
<target name="bundle" depends="jar1, precompilejsp" >
<!-- Update the messages_*.po files.
We need to supply the bat file for windows, and then change the fail property to true -->
<exec executable="sh" osfamily="unix" failifexecutionfails="false" >
<exec executable="sh" osfamily="unix" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
</exec>
<exec executable="sh" osfamily="mac" failifexecutionfails="false" >
<exec executable="sh" osfamily="mac" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
</exec>
<exec executable="cmd" osfamily="windows" failifexecutionfails="false" >
<arg value="/c" />
<arg value="bundle-messages.bat" />
<!-- multi-lang is optional -->
<exec executable="sh" osfamily="windows" failifexecutionfails="false" >
<arg value="./bundle-messages.sh" />
</exec>
<!-- jar again to get the latest messages_*.class files -->
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
</target>
<target name="poupdate" depends="build">
<ant target="war" />
<target name="jarUpToDate">
<uptodate property="jar.uptodate" targetfile="build/routerconsole.jar" >
<srcfiles dir= "build/obj" includes="**/*.class" />
</uptodate>
</target>
<target name="poupdate" depends="precompilejsp">
<!-- Update the messages_*.po files.
We need to supply the bat file for windows, and then change the fail property to true -->
<exec executable="sh" osfamily="unix" failifexecutionfails="true" >
@ -106,19 +134,43 @@
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
<exec executable="cmd" osfamily="windows" failifexecutionfails="true" >
<arg value="/c" />
<arg value="bundle-messages.bat" />
<exec executable="sh" osfamily="windows" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
</target>
<target name="war" depends="precompilejsp">
<!-- does NOT update the message classes, as those go in the jar -->
<target name="war" depends="precompilejsp, warUpToDate" unless="war.uptodate" >
<exec executable="mtn" outputproperty="workspace.changes.w" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="list" />
<arg value="changed" />
<arg value="../jsp" />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes.w}" outputproperty="workspace.changes.w.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
</exec>
<!-- Don't include the css in the war, the main build.xml will copy it to docs/themes/console/ -->
<war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml"
basedir="../jsp/" excludes="web.xml, *.css, **/*.java, *.jsp, *.jsi, web-fragment.xml, web-out.xml">
<manifest>
<attribute name="Build-Date" value="${build.timestamp}" />
<attribute name="Base-Revision" value="${workspace.version}" />
<attribute name="Workspace-Changes" value="${workspace.changes.w.tr}" />
</manifest>
</war>
</target>
<target name="precompilejsp" unless="precompilejsp.uptodate">
<target name="warUpToDate">
<uptodate property="war.uptodate" targetfile="build/routerconsole.war" >
<srcfiles dir= "../jsp" excludes="web.xml, web-fragment.xml, *.css, **/*.java, *.jsp, *.jsi" />
</uptodate>
</target>
<target name="precompilejsp" depends="jar1" unless="precompilejsp.uptodate">
<delete dir="../jsp/WEB-INF/" />
<delete file="../jsp/web-fragment.xml" />
<delete file="../jsp/web-out.xml" />
@ -184,6 +236,7 @@
<javac debug="true" deprecation="on" source="1.5" target="1.5"
encoding="UTF-8"
includeAntRuntime="false"
destdir="../jsp/WEB-INF/classes/"
srcdir="../jsp/WEB-INF/classes" includes="**/*.java">
<compilerarg line="${javac.compilerargs}" />
@ -218,7 +271,7 @@
</target>
<uptodate property="precompilejsp.uptodate" targetfile="../jsp/web-out.xml">
<srcfiles dir= "../jsp" includes="**/*.jsp, **/*.html, *.css, susimail/susimail, web.xml"/>
<srcfiles dir= "../jsp" includes="**/*.jsp, *.jsi, **/*.html, *.css, susimail/susimail, web.xml"/>
</uptodate>
<target name="javadoc">

View File

@ -1,26 +0,0 @@
@echo off
set Callfrom=%cd%
set Paras=%1
rem before calling make sure you have msys and mingw 's "bin" path
rem in your current searching path
rem type "set path" to check
if not exist ..\locale\*.only goto updateALL
rem put a messages_xx.only(eg messages_zh.only) into locale folder
rem this script will only touch the po file(eg zh) you specified, leaving other po files untact.
for %%i in (..\locale\*.only) do set PO=%%~ni
echo [Notice] Yu choose to Ony update the choosen file: %PO%.po
for %%i in (..\locale\*.po) do if not %%~ni==%PO% ren %%i %%~ni.po-
call sh --login %cd%\bmsg.sh
for %%i in (..\locale\*.po-) do if not %%~ni==%PO% ren %%i %%~ni.po
goto end
:updateALL
call sh --login %cd%\bmsg.sh
:end
echo End of Message Bundling

View File

@ -18,6 +18,14 @@ then
POUPDATE=1
fi
# on windows, one must specify the path of commnad find
# since windows has its own retarded version of find.
if which find|grep -q -i windows ; then
export PATH=.:/bin:/usr/local/bin:$PATH
fi
# Fast mode - update ondemond
# set LG2 to the language you need in envrionment varibales to enable this
#
# generate strings/Countries.java from ../../../installer/resources/countries.txt
#
@ -53,6 +61,11 @@ do
# get language
LG=${i#../locale/messages_}
LG=${LG%.po}
# skip, if specified
if [ $LG2 ]; then
[ $LG != $LG2 ] && continue || echo INFO: Language update is set to [$LG2] only.
fi
if [ "$POUPDATE" = "1" ]
then
@ -106,15 +119,19 @@ do
touch $i
fi
echo "Generating ${CLASS}_$LG ResourceBundle..."
if [ "$LG" != "en" ]
then
# only generate for non-source language
echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i
if [ $? -ne 0 ]
then
echo 'Warning - msgfmt failed, not updating translations'
break
fi
# convert to class files in build/obj
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i
if [ $? -ne 0 ]
then
echo 'Warning - msgfmt failed, not updating translations'
break
fi
fi
done
rm -f $TMPFILE
# todo: return failure

View File

@ -28,10 +28,13 @@ public class CSSHelper extends HelperBase {
return url;
}
/** change default language for the router but don't save it */
/** change default language for the router AND save it */
public void setLang(String lang) {
if (lang != null && lang.length() > 0)
// Protected with nonce in css.jsi
if (lang != null && lang.length() == 2 && !lang.equals(_context.getProperty(Messages.PROP_LANG))) {
_context.router().setConfigSetting(Messages.PROP_LANG, lang);
_context.router().saveConfig();
}
}
/** needed for conditional css loads for zh */
@ -60,4 +63,13 @@ public class CSSHelper extends HelperBase {
.append("</title>");
return buf.toString();
}
/**
* Should we allow a refreshing IFrame?
* @since 0.8.5
*/
public boolean allowIFrame(String ua) {
return ua == null || !(ua.startsWith("Lynx") || ua.startsWith("w3m") ||
ua.startsWith("ELinks") || ua.startsWith("Dillo"));
}
}

View File

@ -22,7 +22,7 @@ public class ConfigReseedHelper extends HelperBase {
public String modeChecked(int mode) {
boolean required = _context.getBooleanProperty(Reseeder.PROP_SSL_REQUIRED);
boolean disabled = _context.getBooleanProperty(Reseeder.PROP_SSL_DISABLE);
boolean disabled = _context.getBooleanPropertyDefaultTrue(Reseeder.PROP_SSL_DISABLE);
if ((mode == 0 && (!disabled) && (!required)) ||
(mode == 1 && (!disabled) && required) ||
(mode == 2 && disabled))

View File

@ -46,9 +46,10 @@ public class ConfigUIHelper extends HelperBase {
return rv;
}
private static final String langs[] = {"de", "en", "es", "fr", "nl", "pt", "ru", "sv", "zh"};
private static final String flags[] = {"de", "us", "es", "fr", "nl", "pt", "ru", "se", "cn"};
private static final String xlangs[] = {_x("German"), _x("English"), _x("Spanish"),_x("French"),
private static final String langs[] = {"ar", "de", "en", "es", "fr", "nl", "pt", "ru", "sv", "zh"};
private static final String flags[] = {"lang_ar", "de", "us", "es", "fr", "nl", "pt", "ru", "se", "cn"};
private static final String xlangs[] = {_x("Arabic"),
_x("German"), _x("English"), _x("Spanish"),_x("French"),
_x("Dutch"), _x("Portuguese"), _x("Russian"),
_x("Swedish"), _x("Chinese")};

View File

@ -19,19 +19,26 @@ public class ContentHelper extends HelperBase {
_startAtBeginning = Boolean.valueOf(""+moo).booleanValue();
}
public void setLang(String l) {
/*****
if((_lang == null || !_lang.equals(l)) && (l != null)) {
//Set language for router console
_lang = l;
TODO - Temporary for 0.8.4
Needed for desktopgui. But there's no nonce protection.
Move the following to CSSHelper setLang(), or disable completely,
See comments in CSSHelper
if(_context == null) {
setContextId(null);
}
//Set language persistently throughout I2P
_context.router().setConfigSetting(Messages.PROP_LANG, _lang);
_context.router().saveConfig();
_context.setProperty(Messages.PROP_LANG, _lang);
if (_context.getBooleanProperty("desktopgui.enabled")) {
//Set language persistently throughout I2P
_context.router().setConfigSetting(Messages.PROP_LANG, _lang);
_context.router().saveConfig();
_context.setProperty(Messages.PROP_LANG, _lang);
}
}
*****/
}
public void setMaxLines(String lines) {

View File

@ -213,10 +213,15 @@ public class PluginUpdateHandler extends UpdateHandler {
if (up.haveKey(pubkey)) {
// the key is already in the TrustedUpdate keyring
// verify the sig and verify that it is signed by the signer in the plugin.config file
// Allow "" as the previously-known signer
String signingKeyName = up.verifyAndGetSigner(f);
if (!signer.equals(signingKeyName)) {
if (!(signer.equals(signingKeyName) || "".equals(signingKeyName))) {
f.delete();
to.delete();
if (signingKeyName == null)
_log.error("Failed to verify plugin signature, corrupt plugin or bad signature, signed by: " + signer);
else
_log.error("Plugin signer \"" + signer + "\" does not match existing signer in plugin.config file \"" + signingKeyName + "\"");
statusDone("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
return;
}
@ -226,6 +231,7 @@ public class PluginUpdateHandler extends UpdateHandler {
// bad or duplicate key
f.delete();
to.delete();
_log.error("Bad key or key mismatch - Failed to add plugin key \"" + pubkey + "\" for plugin signer \"" + signer + "\"");
statusDone("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
return;
}
@ -235,6 +241,11 @@ public class PluginUpdateHandler extends UpdateHandler {
if (!signer.equals(signingKeyName)) {
f.delete();
to.delete();
if (signingKeyName == null)
_log.error("Failed to verify plugin signature, corrupt plugin or bad signature, signed by: " + signer);
else
// shouldn't happen
_log.error("Plugin signer \"" + signer + "\" does not match new signer in plugin.config file \"" + signingKeyName + "\"");
statusDone("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
return;
}

View File

@ -1,6 +1,7 @@
package net.i2p.router.web;
import java.util.ArrayList;
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
@ -10,9 +11,10 @@ import java.util.Properties;
import java.util.StringTokenizer;
import net.i2p.I2PAppContext;
import net.i2p.desktopgui.Main;
import net.i2p.apps.systray.SysTray;
import net.i2p.data.Base32;
import net.i2p.data.DataHelper;
import net.i2p.desktopgui.Main;
import net.i2p.router.RouterContext;
import net.i2p.util.FileUtil;
import net.i2p.util.I2PAppThread;
@ -57,7 +59,6 @@ public class RouterConsoleRunner {
static {
System.setProperty("org.mortbay.http.Version.paranoid", "true");
System.setProperty("java.awt.headless", "true");
}
/**
@ -128,10 +129,34 @@ public class RouterConsoleRunner {
}
public static void main(String args[]) {
startTrayApp();
RouterConsoleRunner runner = new RouterConsoleRunner(args);
runner.startConsole();
}
private static void startTrayApp() {
try {
//TODO: move away from routerconsole into a separate application.
//ApplicationManager?
VersionComparator v = new VersionComparator();
boolean recentJava = v.compare(System.getProperty("java.runtime.version"), "1.6") >= 0;
// default false for now
boolean desktopguiEnabled = I2PAppContext.getGlobalContext().getBooleanProperty("desktopgui.enabled");
if (recentJava && desktopguiEnabled) {
//Check if we are in a headless environment, set properties accordingly
System.setProperty("java.awt.headless", Boolean.toString(GraphicsEnvironment.isHeadless()));
String[] args = new String[0];
net.i2p.desktopgui.Main.beginStartup(args);
} else {
// required true for jrobin to work
System.setProperty("java.awt.headless", "true");
SysTray.getInstance();
}
} catch (Throwable t) {
t.printStackTrace();
}
}
public void startConsole() {
File workDir = new SecureDirectory(I2PAppContext.getGlobalContext().getTempDir(), "jetty-work");
boolean workDirRemoved = FileUtil.rmdir(workDir, false);
@ -316,18 +341,6 @@ public class RouterConsoleRunner {
}
}
try {
//TODO: move away from routerconsole into a separate application.
//ApplicationManager?
VersionComparator v = new VersionComparator();
if(v.compare(System.getProperty("java.runtime.version"), "1.6") >= 0) {
String[] args = new String[0];
net.i2p.desktopgui.Main.beginStartup(args);
}
} catch (Throwable t) {
t.printStackTrace();
}
NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext());
Thread t = new I2PAppThread(fetcher, "NewsFetcher", true);
t.start();

View File

@ -197,9 +197,10 @@ public class StatsGenerator {
buf.append("; ");
}
buf.append(ngettext((int) curRate.getLastEventCount(), "There was 1 event", "There were {0} events"));
buf.append(' ');
buf.append(_("in this period which ended {0} ago.", DataHelper.formatDuration2(now - curRate.getLastCoalesceDate())));
// breaking the sentence like before makes translation in my language impossible.
buf.append(_("There were {0} event(s) in this period", curRate.getLastEventCount()));
// buf.append(' ');
buf.append(_(" which ended {0} ago.", DataHelper.formatDuration2(now - curRate.getLastCoalesceDate())));
} else {
buf.append(" <i>").append(_("No events")).append("</i> ");
}

View File

@ -224,25 +224,21 @@ public class SummaryBarRenderer {
System.setProperty("net.i2p.router.web.UpdateHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
String uri = _helper.getRequestURI();
buf.append("<p><form action=\"").append(uri).append("\" method=\"POST\">\n");
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\" name=\"updateAction\" value=\"signed\" >")
.append(_("Download"))
.append(' ')
.append(_helper.getUpdateVersion())
.append(' ')
.append(_("Update"))
.append("</button>\n");
// 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\" name=\"updateAction\" value=\"Unsigned\" >")
.append(_("Download Unsigned"))
.append("<br>")
.append(_("Update"))
.append(' ')
.append(_helper.getUnsignedUpdateVersion())
.append("</button>\n");
// 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");
}
@ -251,10 +247,9 @@ public class SummaryBarRenderer {
buf.append("<p>")
.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
buf.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
.append("</p><hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append("<hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append(_("Show all current peer connections"))
.append("\">")
.append(_("Peers"))
@ -456,4 +451,9 @@ public class SummaryBarRenderer {
private String _(String s) {
return Messages.getString(s, _context);
}
/** translate a string with a parameter */
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}