diff --git a/apps/desktopgui/README b/apps/desktopgui/README
new file mode 100644
index 000000000..2a4f3a40c
--- /dev/null
+++ b/apps/desktopgui/README
@@ -0,0 +1,13 @@
+Current setup:
+* Build desktopgui:
+ * 'ant jar' in the desktopgui directory
+ OR
+ * 'ant desktopgui' in the i2p.i2p directory
+* Place desktopgui.jar in the $I2P/lib/ directory.
+* Add to .i2p/clients.config:
+ #Desktopgui
+ clientApp.6.args=--startWithI2P --I2PLocation=/SOME_LOCATION
+ clientApp.6.delay=5
+ clientApp.6.main=net.i2p.desktopgui.Main
+ clientApp.6.name=desktopgui
+ clientApp.6.startOnLoad=true
diff --git a/apps/desktopgui/TODO b/apps/desktopgui/TODO
index d47410b65..5583a0068 100644
--- a/apps/desktopgui/TODO
+++ b/apps/desktopgui/TODO
@@ -1,8 +1,17 @@
+HIGH PRIORITY:
+- Allow desktopgui to start, stop and restart I2P. - DONE
+- Internationalisation
+- Correct logging system
+UNKNOWN:
- API to allow applications to add themselves to the menu?
* registerApplication(); -- should return a positive number on success, -1 on failure
* unregisterApplication(int); -- should return nothing (or bool for success?), and the parameter should be the number given when registering the application
-- Internationalisation
- Fetch I2P localhost from the core I2P application?
-- Correct logging system
- Use I2PAppContext::appDir (something like that) for desktopgui data.
-- Check core/java/src/net/i2p/util/FileUtil.java for dynamic jar loading
+- Consider SWT as option
+ * Check core/java/src/net/i2p/util/FileUtil.java for dynamic jar loading
+ * Possible logic:
+ - First try to load SWT (has the most options and is not ugly)
+ - Then load AWT
+- Access router.jar from other JVM? Is this possible? -- no: use I2CP with auth (not ready yet)
+- Start desktopgui with another user than the user starting I2P (required for daemon usage).
diff --git a/apps/desktopgui/build.xml b/apps/desktopgui/build.xml
index 0d38f0f5d..5c7f2f496 100644
--- a/apps/desktopgui/build.xml
+++ b/apps/desktopgui/build.xml
@@ -43,7 +43,8 @@
-
+
+
diff --git a/apps/desktopgui/src/net/i2p/desktopgui/Main.java b/apps/desktopgui/src/net/i2p/desktopgui/Main.java
index 221de0b06..f4c1948aa 100644
--- a/apps/desktopgui/src/net/i2p/desktopgui/Main.java
+++ b/apps/desktopgui/src/net/i2p/desktopgui/Main.java
@@ -9,6 +9,7 @@ import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.i2p.desktopgui.util.*;
/**
* The main class of the application.
@@ -39,7 +40,10 @@ public class Main {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
+ ConfigurationManager.getInstance().loadArguments(args);
+
final Main main = new Main();
+
main.launchForeverLoop();
//We'll be doing GUI work, so let's stay in the event dispatcher thread.
SwingUtilities.invokeLater(new Runnable() {
diff --git a/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java b/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java
index c7c33d7cd..fac120e06 100644
--- a/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java
+++ b/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java
@@ -9,6 +9,7 @@ import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.Desktop.Action;
+import java.awt.TrayIcon.MessageType;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
@@ -20,6 +21,7 @@ import java.util.Properties;
import javax.swing.SwingWorker;
import net.i2p.desktopgui.router.RouterManager;
+import net.i2p.desktopgui.util.*;
import net.i2p.router.Router;
/**
@@ -54,6 +56,8 @@ public class TrayManager {
* @return popup menu
*/
public PopupMenu getMainMenu() {
+ boolean inI2P = ConfigurationManager.getInstance().getBooleanConfiguration("startWithI2P", false);
+
PopupMenu popup = new PopupMenu();
MenuItem browserLauncher = new MenuItem("Launch I2P Browser");
browserLauncher.addActionListener(new ActionListener() {
@@ -95,6 +99,32 @@ public class TrayManager {
});
popup.add(browserLauncher);
popup.addSeparator();
+ MenuItem startItem = new MenuItem("Start I2P");
+ startItem.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ new SwingWorker