Author: nextgens
Date: 2006-03-07 18:29:30 +0000 (Tue, 07 Mar 2006)
New Revision: 8180
Added:
trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
Modified:
trunk/freenet/src/freenet/clients/http/FproxyToadlet.java
trunk/freenet/src/freenet/clients/http/PageMaker.java
trunk/freenet/src/freenet/config/Option.java
trunk/freenet/src/freenet/config/SubConfig.java
trunk/freenet/src/freenet/node/Version.java
Log:
453:
Not yet working ConfigToadlet ... I have to figure out why POST doesn't work
Added: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-03-07
17:49:24 UTC (rev 8179)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-03-07
18:29:30 UTC (rev 8180)
@@ -0,0 +1,81 @@
+package freenet.clients.http;
+
+import java.io.IOException;
+import java.net.URI;
+
+import sun.net.dns.ResolverConfiguration.Options;
+
+import freenet.client.HighLevelSimpleClient;
+import freenet.config.Config;
+import freenet.config.FilePersistentConfig;
+import freenet.config.Option;
+import freenet.config.SubConfig;
+import freenet.support.Bucket;
+import freenet.support.HTMLEncoder;
+import freenet.support.MultiValueTable;
+import freenet.support.SimpleFieldSet;
+import freenet.node.Node;
+import freenet.node.Version;
+
+public class ConfigToadlet extends Toadlet {
+ private Config config;
+ private Node node;
+
+ ConfigToadlet(HighLevelSimpleClient client, Node n, Config conf) {
+ super(client);
+ config=conf;
+ node=n;
+ }
+
+ public void handleGet(URI uri, ToadletContext ctx) throws
ToadletContextClosedException, IOException {
+ StringBuffer buf = new StringBuffer();
+ SubConfig[] sc = config.getConfigs();
+
+ ctx.getPageMaker().makeHead(buf, "Freenet Node Configuration");
+ buf.append("<h1 class=\"title\">test</h1>\n");
+ buf.append("<div class=\"config\">\n");
+ buf.append(" <ul class=\"config\">\n");
+ String last = null;
+
+ for(int i=0; i<sc.length;i++){
+ Option[] o = sc[i].getOptions();
+ String prefix = new String(sc[i].getPrefix());
+
+ if(last == null || ! last.equalsIgnoreCase(prefix)){
+ buf.append("</p>\n");
+ buf.append("</span>\n");
+ buf.append("<span id=\""+prefix+"\">\n");
+ buf.append("<p>\n");
+ }
+
+ for(int j=0; j<o.length; j++){
+ String configName = new String(o[j].getName());
+ if(prefix.equals("node") &&
configName.equals("name")){
+ buf.append("<form
method=\"post\"><input alt=\"node name\" class=\"config\"" +
+ " type=\"text\"
name=\"__node_name\" value=\""+o[j].getValueString()+"\"/></form>\n");
+ }
+
+ buf.append(o[j].getShortDesc()+":\n");
+ buf.append("
<li>"+prefix+"."+configName+"=>"+o[j].getValueString()+"</li>\n");
+ }
+ }
+
+ buf.append(" </ul>\n");
+ buf.append("</div>\n");
+
+ ctx.getPageMaker().makeTail(buf);
+
+ this.writeReply(ctx, 200, "text/html", "OK", buf.toString());
+ }
+
+ public void handlePut(URI uri, ToadletContext ctx) throws
ToadletContextClosedException, IOException {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ok!\n");
+ buf.append(uri);
+ this.writeReply(ctx, 200, "text/html", "OK", buf.toString());
+ }
+
+ public String supportedMethods() {
+ return "GET, PUT";
+ }
+}
\ No newline at end of file
Modified: trunk/freenet/src/freenet/clients/http/FproxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FproxyToadlet.java 2006-03-07
17:49:24 UTC (rev 8179)
+++ trunk/freenet/src/freenet/clients/http/FproxyToadlet.java 2006-03-07
18:29:30 UTC (rev 8180)
@@ -27,7 +27,7 @@
import freenet.support.MultiValueTable;
public class FproxyToadlet extends Toadlet {
-
+
public FproxyToadlet(HighLevelSimpleClient client) {
super(client);
}
@@ -191,6 +191,9 @@
WelcomeToadlet welcometoadlet = new
WelcomeToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS));
server.register(welcometoadlet, "/welcome/", true);
+ ConfigToadlet configtoadlet = new
ConfigToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS), node,
config);
+ server.register(configtoadlet, "/config/", true);
+
StaticToadlet statictoadlet = new
StaticToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS));
server.register(statictoadlet, "/static/", true);
} catch (IOException ioe) {
Modified: trunk/freenet/src/freenet/clients/http/PageMaker.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PageMaker.java 2006-03-07
17:49:24 UTC (rev 8179)
+++ trunk/freenet/src/freenet/clients/http/PageMaker.java 2006-03-07
18:29:30 UTC (rev 8180)
@@ -71,6 +71,7 @@
+ "<ul id=\"navlist\">\n"
+ "<li><a href=\"/\"
title=\"Homepage\">Home</a></li>\n"
+ "<li><a href=\"/plugins/\" title=\"Configure
Plugins\">Plugins</a></li>\n"
+ + "<li><a href=\"/config/\" title=\"Configure
your node\">Configuration</a></li>\n"
+ "</ul>\n"
+ "</div>\n");
}
Modified: trunk/freenet/src/freenet/config/Option.java
===================================================================
--- trunk/freenet/src/freenet/config/Option.java 2006-03-07 17:49:24 UTC
(rev 8179)
+++ trunk/freenet/src/freenet/config/Option.java 2006-03-07 18:29:30 UTC
(rev 8180)
@@ -52,4 +52,12 @@
setValue(getValueString());
}
+ public String getName(){
+ return name;
+ }
+
+ public String getShortDesc(){
+ return shortDesc;
+ }
+
}
Modified: trunk/freenet/src/freenet/config/SubConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/SubConfig.java 2006-03-07 17:49:24 UTC
(rev 8179)
+++ trunk/freenet/src/freenet/config/SubConfig.java 2006-03-07 18:29:30 UTC
(rev 8180)
@@ -199,5 +199,9 @@
Option o = (Option) map.get(name);
o.setValue(value);
}
+
+ public String getPrefix(){
+ return prefix;
+ }
}
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-03-07 17:49:24 UTC (rev
8179)
+++ trunk/freenet/src/freenet/node/Version.java 2006-03-07 18:29:30 UTC (rev
8180)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 502;
+ private static final int buildNumber = 503;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 475;