- Replaced RouterContext with I2PAppContext.

- Detect I2P location using I2PAppContext.
This commit is contained in:
mathiasdm
2010-12-20 21:31:17 +00:00
parent e247e959f3
commit 867286b47b
3 changed files with 10 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ HIGH PRIORITY:
- Correct logging system - DONE
- Internationalisation:
* Add strings - DONE
* Add Windows support
* Add Windows support - NEED TO CHECK
* Might need some kind of trigger to reload the menu (for live language switching)
* Language choice is not actually set as a parameter in I2P config?
As a result, desktopgui always starts with the default, unless you manually set the language.

View File

@@ -1,26 +1,26 @@
package net.i2p.desktopgui.i18n;
import net.i2p.router.RouterContext;
import net.i2p.I2PAppContext;
import net.i2p.util.Translate;
public class DesktopguiTranslator {
private static final String BUNDLE_NAME = "net.i2p.desktopgui.messages";
private static RouterContext ctx;
private static I2PAppContext ctx;
private static RouterContext getRouterContext() {
private static I2PAppContext getRouterContext() {
if(ctx == null) {
ctx = RouterContext.listContexts().get(0);
ctx = I2PAppContext.getCurrentContext();
}
return ctx;
}
public static String _(String s) {
return Translate.getString(s, getRouterContext(), BUNDLE_NAME);
return Translate.getString(s, getRouterContext(), BUNDLE_NAME);
}
public static String _(String s, Object o) {
return Translate.getString(s, o, getRouterContext(), BUNDLE_NAME);
return Translate.getString(s, o, getRouterContext(), BUNDLE_NAME);
}
}

View File

@@ -2,6 +2,7 @@ package net.i2p.desktopgui.router;
import java.io.IOException;
import net.i2p.I2PAppContext;
import net.i2p.desktopgui.i18n.DesktopguiTranslator;
import net.i2p.desktopgui.util.ConfigurationManager;
import net.i2p.router.Router;
@@ -31,14 +32,11 @@ public class RouterManager {
*/
public static void start() {
try {
//TODO: detect I2P directory
//TODO: set/get PID
String separator = System.getProperty("file.separator");
String homeDirectory = System.getProperty("user.home");
String location = ConfigurationManager.getInstance()
.getStringConfiguration("I2PLocation", homeDirectory + separator + "i2p");
String location = I2PAppContext.getCurrentContext().getBaseDir().getAbsolutePath();
Runtime.getRuntime().exec(location + separator + "i2psvc" + location + separator + "wrapper.config");
Runtime.getRuntime().exec(location + separator + "i2psvc " + location + separator + "wrapper.config");
} catch (IOException e) {
log.log(Log.WARN, "Failed to start I2P", e);
}