forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 6706bab853107973d7d0ff28212aae65bd098591)
to branch 'i2p.i2p.str4d.ui' (head 645f60a4d23af4116ae660b09dfff32d19a65c32)
This commit is contained in:
@@ -145,6 +145,7 @@
|
||||
|
||||
<!-- this is tricky because the message classes go in the jar, not in the war -->
|
||||
<target name="bundle" depends="jar1, precompilejsp" unless="no.bundle">
|
||||
<mkdir dir="build/messages-src" />
|
||||
<!-- 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" failonerror="${require.gettext}" >
|
||||
@@ -158,6 +159,11 @@
|
||||
<exec executable="sh" osfamily="windows" failifexecutionfails="false" >
|
||||
<arg value="./bundle-messages.sh" />
|
||||
</exec>
|
||||
<javac source="${javac.version}" target="${javac.version}"
|
||||
includeAntRuntime="false"
|
||||
srcdir="build/messages-src" destdir="build/obj">
|
||||
<compilerarg line="${javac.compilerargs}" />
|
||||
</javac>
|
||||
<!-- jar again to get the latest messages_*.class files -->
|
||||
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
|
||||
</target>
|
||||
@@ -194,6 +200,7 @@
|
||||
</target>
|
||||
|
||||
<target name="bundle-news" unless="no.bundle">
|
||||
<mkdir dir="build/messages-news-src" />
|
||||
<exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
|
||||
<env key="JAVA_HOME" value="${java.home}" />
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
@@ -204,9 +211,15 @@
|
||||
<exec executable="sh" osfamily="windows" failifexecutionfails="false" >
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
</exec>
|
||||
<javac source="${javac.version}" target="${javac.version}"
|
||||
includeAntRuntime="false"
|
||||
srcdir="build/messages-news-src" destdir="build/obj">
|
||||
<compilerarg line="${javac.compilerargs}" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="bundle-countries" unless="no.bundle">
|
||||
<mkdir dir="build/messages-countries-src" />
|
||||
<exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
|
||||
<env key="JAVA_HOME" value="${java.home}" />
|
||||
<arg value="./bundle-messages-countries.sh" />
|
||||
@@ -217,6 +230,11 @@
|
||||
<exec executable="sh" osfamily="windows" failifexecutionfails="false" >
|
||||
<arg value="./bundle-messages-countries.sh" />
|
||||
</exec>
|
||||
<javac source="${javac.version}" target="${javac.version}"
|
||||
includeAntRuntime="false"
|
||||
srcdir="build/messages-countries-src" destdir="build/obj">
|
||||
<compilerarg line="${javac.compilerargs}" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="extractProxyTags">
|
||||
|
@@ -112,15 +112,40 @@ do
|
||||
# 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
|
||||
msgfmt -V | grep -q '0\.19'
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
# slow way
|
||||
# convert to class files in build/obj
|
||||
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
else
|
||||
# fast way
|
||||
# convert to java files in build/messages-countries-src
|
||||
TD=build/messages-countries-src-tmp
|
||||
TDX=$TD/net/i2p/router/countries
|
||||
TD2=build/messages-countries-src
|
||||
TDY=$TD2/net/i2p/router/countries
|
||||
rm -rf $TD
|
||||
mkdir -p $TD $TDY
|
||||
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
mv $TDX/messages_$LG.java $TDY
|
||||
rm -rf $TD
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@@ -98,15 +98,40 @@ do
|
||||
# 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
|
||||
msgfmt -V | grep -q '0\.19'
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
# slow way
|
||||
# convert to class files in build/obj
|
||||
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
else
|
||||
# fast way
|
||||
# convert to java files in build/messages-news-src
|
||||
TD=build/messages-news-src-tmp
|
||||
TDX=$TD/net/i2p/router/news
|
||||
TD2=build/messages-news-src
|
||||
TDY=$TD2/net/i2p/router/news
|
||||
rm -rf $TD
|
||||
mkdir -p $TD $TDY
|
||||
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
mv $TDX/messages_$LG.java $TDY
|
||||
rm -rf $TD
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@@ -125,15 +125,40 @@ do
|
||||
# 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
|
||||
msgfmt -V | grep -q '0\.19'
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
# slow way
|
||||
# convert to class files in build/obj
|
||||
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
else
|
||||
# fast way
|
||||
# convert to java files in build/messages-src
|
||||
TD=build/messages-src-tmp
|
||||
TDX=$TD/net/i2p/router/web
|
||||
TD2=build/messages-src
|
||||
TDY=$TD2/net/i2p/router/web
|
||||
rm -rf $TD
|
||||
mkdir -p $TD $TDY
|
||||
msgfmt --java --statistics --source -r $CLASS -l $LG -d $TD $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
mv $TDX/messages_$LG.java $TDY
|
||||
rm -rf $TD
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@@ -5,6 +5,9 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.app.ClientApp;
|
||||
import net.i2p.app.ClientAppManager;
|
||||
import net.i2p.app.ClientAppState;
|
||||
import net.i2p.apps.systray.UrlLauncher;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
@@ -191,6 +194,26 @@ public class ConfigServiceHandler extends FormHandler {
|
||||
return _context.router().gracefulShutdownInProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we show the systray controls?
|
||||
*
|
||||
* @since 0.9.26
|
||||
*/
|
||||
public boolean shouldShowSystray() {
|
||||
return !
|
||||
(RouterConsoleRunner.DAEMON_USER.equals(System.getProperty("user.name")) ||
|
||||
(SystemVersion.isWindows() && _context.hasWrapper() && WrapperManager.isLaunchedAsService()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the systray enabled?
|
||||
*
|
||||
* @since 0.9.26
|
||||
*/
|
||||
public boolean isSystrayEnabled() {
|
||||
return _context.getBooleanProperty(RouterConsoleRunner.PROP_DTG_ENABLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processForm() {
|
||||
if (_action == null) return;
|
||||
@@ -249,6 +272,10 @@ public class ConfigServiceHandler extends FormHandler {
|
||||
} else if (_t("Force GC").equals(_action)) {
|
||||
Runtime.getRuntime().gc();
|
||||
addFormNotice(_t("Full garbage collection requested"));
|
||||
} else if (_t("Show systray icon").equals(_action)) {
|
||||
changeSystray(true);
|
||||
} else if (_t("Hide systray icon").equals(_action)) {
|
||||
changeSystray(false);
|
||||
} else {
|
||||
//addFormNotice("Blah blah blah. whatever. I'm not going to " + _action);
|
||||
}
|
||||
@@ -292,4 +319,41 @@ public class ConfigServiceHandler extends FormHandler {
|
||||
}
|
||||
ClientAppConfig.writeClientAppConfig(_context, clients);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable and start/stop systray
|
||||
*
|
||||
* @since 0.9.26
|
||||
*/
|
||||
private void changeSystray(boolean enable) {
|
||||
ClientAppManager mgr = _context.clientAppManager();
|
||||
if (mgr != null) {
|
||||
try {
|
||||
ClientApp dtg = mgr.getRegisteredApp("desktopgui");
|
||||
if (dtg != null) {
|
||||
if (enable) {
|
||||
if (dtg.getState() == ClientAppState.STOPPED)
|
||||
dtg.startup();
|
||||
} else {
|
||||
if (dtg.getState() == ClientAppState.RUNNING)
|
||||
dtg.shutdown(null);
|
||||
}
|
||||
} else if (enable) {
|
||||
dtg = new net.i2p.desktopgui.Main(_context, mgr, null);
|
||||
dtg.startup();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
if (enable)
|
||||
addFormError(_t("Failed to start systray") + ": " + t);
|
||||
else
|
||||
addFormError(_t("Failed to stop systray") + ": " + t);
|
||||
}
|
||||
}
|
||||
|
||||
boolean saved = _context.router().saveConfig(RouterConsoleRunner.PROP_DTG_ENABLED, Boolean.toString(enable));
|
||||
if (saved)
|
||||
addFormNotice(_t("Configuration saved successfully"));
|
||||
else
|
||||
addFormError(_t("Error saving the configuration (applied but not saved) - please see the error logs"));
|
||||
}
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@ import net.i2p.util.PortMapper;
|
||||
import net.i2p.util.SecureDirectory;
|
||||
import net.i2p.util.I2PSSLSocketFactory;
|
||||
import net.i2p.util.SystemVersion;
|
||||
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
@@ -69,6 +70,8 @@ import org.eclipse.jetty.util.thread.ExecutorThreadPool;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
import org.tanukisoftware.wrapper.WrapperManager;
|
||||
|
||||
/**
|
||||
* Start the router console.
|
||||
*/
|
||||
@@ -128,6 +131,8 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
private static final int MAX_THREADS = 24;
|
||||
private static final int MAX_IDLE_TIME = 90*1000;
|
||||
private static final String THREAD_NAME = "RouterConsole Jetty";
|
||||
public static final String DAEMON_USER = "i2psvc";
|
||||
public static final String PROP_DTG_ENABLED = "desktopgui.enabled";
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
@@ -213,7 +218,7 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
public synchronized void startup() {
|
||||
changeState(STARTING);
|
||||
checkJavaVersion();
|
||||
startTrayApp(_context);
|
||||
startTrayApp();
|
||||
startConsole();
|
||||
}
|
||||
|
||||
@@ -265,18 +270,23 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
return _server;
|
||||
}
|
||||
|
||||
private static void startTrayApp(I2PAppContext ctx) {
|
||||
private void startTrayApp() {
|
||||
// if no permissions, don't even try
|
||||
// isLaunchedAsService() always returns true on Linux
|
||||
if (DAEMON_USER.equals(System.getProperty("user.name")) ||
|
||||
(SystemVersion.isWindows() && _context.hasWrapper() && WrapperManager.isLaunchedAsService())) {
|
||||
// required true for jrobin to work
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
//TODO: move away from routerconsole into a separate application.
|
||||
//ApplicationManager?
|
||||
boolean recentJava = SystemVersion.isJava6();
|
||||
// default false for now
|
||||
boolean desktopguiEnabled = ctx.getBooleanProperty("desktopgui.enabled");
|
||||
if (recentJava && desktopguiEnabled) {
|
||||
boolean desktopguiEnabled = _context.getBooleanProperty(PROP_DTG_ENABLED);
|
||||
if (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);
|
||||
net.i2p.desktopgui.Main dtg = new net.i2p.desktopgui.Main(_context, _mgr, null);
|
||||
dtg.startup();
|
||||
} else {
|
||||
// required true for jrobin to work
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
|
Reference in New Issue
Block a user