I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 867286b4 authored by mathiasdm's avatar mathiasdm
Browse files

- Replaced RouterContext with I2PAppContext.

- Detect I2P location using I2PAppContext.
parent e247e959
Branches
Tags
No related merge requests found
...@@ -3,7 +3,7 @@ HIGH PRIORITY: ...@@ -3,7 +3,7 @@ HIGH PRIORITY:
- Correct logging system - DONE - Correct logging system - DONE
- Internationalisation: - Internationalisation:
* Add strings - DONE * 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) * 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? * 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. As a result, desktopgui always starts with the default, unless you manually set the language.
......
package net.i2p.desktopgui.i18n; package net.i2p.desktopgui.i18n;
import net.i2p.router.RouterContext; import net.i2p.I2PAppContext;
import net.i2p.util.Translate; import net.i2p.util.Translate;
public class DesktopguiTranslator { public class DesktopguiTranslator {
private static final String BUNDLE_NAME = "net.i2p.desktopgui.messages"; 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) { if(ctx == null) {
ctx = RouterContext.listContexts().get(0); ctx = I2PAppContext.getCurrentContext();
} }
return ctx; return ctx;
} }
public static String _(String s) { 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) { public static String _(String s, Object o) {
return Translate.getString(s, o, getRouterContext(), BUNDLE_NAME); return Translate.getString(s, o, getRouterContext(), BUNDLE_NAME);
} }
} }
...@@ -2,6 +2,7 @@ package net.i2p.desktopgui.router; ...@@ -2,6 +2,7 @@ package net.i2p.desktopgui.router;
import java.io.IOException; import java.io.IOException;
import net.i2p.I2PAppContext;
import net.i2p.desktopgui.i18n.DesktopguiTranslator; import net.i2p.desktopgui.i18n.DesktopguiTranslator;
import net.i2p.desktopgui.util.ConfigurationManager; import net.i2p.desktopgui.util.ConfigurationManager;
import net.i2p.router.Router; import net.i2p.router.Router;
...@@ -31,14 +32,11 @@ public class RouterManager { ...@@ -31,14 +32,11 @@ public class RouterManager {
*/ */
public static void start() { public static void start() {
try { try {
//TODO: detect I2P directory
//TODO: set/get PID //TODO: set/get PID
String separator = System.getProperty("file.separator"); String separator = System.getProperty("file.separator");
String homeDirectory = System.getProperty("user.home"); String location = I2PAppContext.getCurrentContext().getBaseDir().getAbsolutePath();
String location = ConfigurationManager.getInstance()
.getStringConfiguration("I2PLocation", homeDirectory + separator + "i2p");
Runtime.getRuntime().exec(location + separator + "i2psvc" + location + separator + "wrapper.config"); Runtime.getRuntime().exec(location + separator + "i2psvc " + location + separator + "wrapper.config");
} catch (IOException e) { } catch (IOException e) {
log.log(Log.WARN, "Failed to start I2P", e); log.log(Log.WARN, "Failed to start I2P", e);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment