Added desktopgui documentation.

This commit is contained in:
mathiasdm
2010-11-25 18:22:28 +00:00
parent b885046c64
commit 02c3abfc4c
3 changed files with 24 additions and 7 deletions

View File

@ -26,7 +26,6 @@ import net.i2p.router.Router;
/**
* Manages the tray icon life.
*
*/
public class TrayManager {
@ -115,6 +114,9 @@ public class TrayManager {
@Override
protected void done() {
trayIcon.displayMessage("Starting", "I2P is starting!", TrayIcon.MessageType.INFO);
//Hide the tray icon.
//We cannot stop the desktopgui program entirely,
//since that risks killing the I2P process as well.
tray.remove(trayIcon);
}

View File

@ -12,6 +12,14 @@ public class RouterManager {
return RouterContext.listContexts().get(0).router();
}
/**
* Start an I2P router instance.
* This method has limited knowledge
* (there is no I2P instance running to collect information from).
*
* It needs to determine itself where the I2P instance is located,
* except if the location has been given through command-line arguments.
*/
public static void start() {
try {
String location = ConfigurationManager.getInstance().getStringConfiguration("I2PLocation", "/home/i2p");
@ -24,10 +32,16 @@ public class RouterManager {
}
}
/**
* Restart the running I2P instance.
*/
public static void restart() {
getRouter().restart();
}
/**
* Stop the running I2P instance.
*/
public static void shutDown() {
getRouter().shutdownGracefully();
}

View File

@ -12,7 +12,9 @@ import java.util.regex.Pattern;
public class ConfigurationManager {
private static ConfigurationManager instance;
///Configurations with a String as value
private Map<String, String> stringConfigurations = new HashMap<String, String>();
///Configurations with a Boolean as value
private Map<String, Boolean> booleanConfigurations = new HashMap<String, Boolean>();
private ConfigurationManager() {}
@ -24,13 +26,12 @@ public class ConfigurationManager {
return instance;
}
/**
* Collects arguments of the form --word, --word=otherword and -blah
* to determine user parameters.
* @param args Command line arguments to the application
*/
public void loadArguments(String[] args) {
//Match pattern of the form --word=true or --word=false
Pattern booleanConfiguration = Pattern.compile("--(\\w)");
//Match pattern of the form --word=word
Pattern stringConfiguration = Pattern.compile("--(\\w)=(\\w)");
//Match pattern of the form --word
Pattern existsConfiguration = Pattern.compile("--(\\w)");
for(int i=0; i<args.length; i++) {
String arg = args[i];
if(arg.startsWith("--")) {