diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java new file mode 100644 index 000000000..5a9d991c9 --- /dev/null +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java @@ -0,0 +1,59 @@ +package net.i2p.router.web; + +import java.util.HashMap; +import java.util.Map; +import net.i2p.data.DataFormatException; +import net.i2p.util.Log; + +/** + * + */ +public class ConfigClientsHandler extends FormHandler { + private Log _log; + private Map _settings; + private boolean _shouldSave; + + public ConfigClientsHandler() { + _shouldSave = false; + } + + protected void processForm() { + if (_shouldSave) { + saveChanges(); + } else { + // noop + addFormError("Unimplemented"); + } + } + + public void setShouldsave(String moo) { + if ( (moo != null) && (moo.equals("Save changes")) ) + _shouldSave = true; + } + + public void setSettings(Map settings) { _settings = new HashMap(settings); } + + /** + * The user made changes to the network config and wants to save them, so + * lets go ahead and do so. + * + */ + private void saveChanges() { + _log = _context.logManager().getLog(ConfigClientsHandler.class); + boolean saveRequired = false; + + int updated = 0; + int index = 0; + + if (updated > 0) + addFormNotice("Updated settings"); + + if (saveRequired) { + boolean saved = _context.router().saveConfig(); + if (saved) + addFormNotice("Exploratory tunnel configuration saved successfully"); + else + addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs"); + } + } +} diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java new file mode 100644 index 000000000..715899c20 --- /dev/null +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java @@ -0,0 +1,83 @@ +package net.i2p.router.web; + +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.TreeSet; +import net.i2p.router.RouterContext; +import net.i2p.router.startup.ClientAppConfig; + +public class ConfigClientsHelper { + private RouterContext _context; + /** + * Configure this bean to query a particular router context + * + * @param contextId begging few characters of the routerHash, or null to pick + * the first one we come across. + */ + public void setContextId(String contextId) { + try { + _context = ContextHelper.getContext(contextId); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + public ConfigClientsHelper() {} + + + public String getForm1() { + StringBuffer buf = new StringBuffer(1024); + buf.append("
| Client | Enabled? | Class and arguments |
| WebApp | Enabled? | Description |