Author: nextgens
Date: 2006-03-10 13:09:42 +0000 (Fri, 10 Mar 2006)
New Revision: 8210
Modified:
trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
trunk/freenet/src/freenet/clients/http/FproxyToadlet.java
trunk/freenet/src/freenet/clients/http/Toadlet.java
trunk/freenet/src/freenet/node/Version.java
Log:
517:
ConfigToadlet should be working by now ...
Some work on it is still to be done (mostly logging and commenting)
The CSS isn't changed on the fly yet :/
Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-03-10
11:42:31 UTC (rev 8209)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-03-10
13:09:42 UTC (rev 8210)
@@ -18,23 +18,23 @@
import freenet.node.Version;
import freenet.pluginmanager.HTTPRequest;
+
+// FIXME: add logging, comments
public class ConfigToadlet extends Toadlet {
private Config config;
- private Node node;
- ConfigToadlet(HighLevelSimpleClient client, Node n, Config conf, String
CSSName) {
+ ConfigToadlet(HighLevelSimpleClient client, Config conf, String
CSSName) {
super(client, CSSName);
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",
CSSName);
HTTPRequest request = new HTTPRequest(uri);
if (request.hasParameters() == false) {
+ ctx.getPageMaker().makeHead(buf, "Freenet Node
Configuration", CSSName);
buf.append("<h1 class=\"title\">Node
Configuration</h1>\n");
buf.append("<div class=\"config\">\n");
buf.append(" <ul class=\"config\">\n");
@@ -66,18 +66,22 @@
buf.append("
<li>"+prefix+"."+configName+"=><input alt=\""+o[j].getShortDesc()+"\"
class=\"config\"" +
" type=\"text\"
name=\""+prefix+"."+configName+"\"
value=\""+o[j].getValueString()+"\"></li>\n");
}
+
+ buf.append("<br><hr>");
}
- buf.append("<hr><br>");
+ buf.append("<br>");
buf.append("<input type=\"submit\" value=\"Apply\">");
buf.append("<input type=\"reset\" value=\"Cancel\">");
buf.append("</form>");
buf.append(" </ul>\n");
buf.append("</div>\n");
+
+ ctx.getPageMaker().makeTail(buf);
+
+ this.writeReply(ctx, 200, "text/html", "OK",
buf.toString());
} else {
- buf.append("Applying configuration");
-
for(int i=0; i<sc.length ; i++){
Option[] o = sc[i].getOptions();
String prefix = new String(sc[i].getPrefix());
@@ -88,17 +92,19 @@
// we ignore unreconized parameters
if(request.getParam(prefix+"."+configName) != ""){
- if(o[j].getValueString() !=
request.getParam(prefix+"."+configName))
-
buf.append(o[j].getShortDesc()+":\n");
+ if(o[j].getValueString() !=
request.getParam(prefix+"."+configName)){
+ try{
+
o[j].setValue(request.getParam(prefix+"."+configName));
+ }catch(Exception e){
+
buf.append(e+"\n");
+ }
+ }
}
}
}
+ config.store();
+ writeReply(ctx, 200, "text/html", "OK",
mkForwardPage(ctx, "Applying configuration", buf.toString(), "/config/", 10));
}
-
-
- ctx.getPageMaker().makeTail(buf);
-
- this.writeReply(ctx, 200, "text/html", "OK", buf.toString());
}
public void handlePut(URI uri, ToadletContext ctx) throws
ToadletContextClosedException, IOException {
Modified: trunk/freenet/src/freenet/clients/http/FproxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FproxyToadlet.java 2006-03-10
11:42:31 UTC (rev 8209)
+++ trunk/freenet/src/freenet/clients/http/FproxyToadlet.java 2006-03-10
13:09:42 UTC (rev 8210)
@@ -152,6 +152,7 @@
}
}
+ // FIXME: Not changed on the fly :-S Should be done in
SimpleToadletServer
static class FproxyCSSNameCallback implements StringCallback {
final Node node;
@@ -212,7 +213,7 @@
WelcomeToadlet welcometoadlet = new
WelcomeToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS),
node, CSSName);
server.register(welcometoadlet, "/welcome/", true);
- ConfigToadlet configtoadlet = new
ConfigToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS), node,
config, CSSName);
+ ConfigToadlet configtoadlet = new
ConfigToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS),
config, CSSName);
server.register(configtoadlet, "/config/", true);
StaticToadlet statictoadlet = new
StaticToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS),
CSSName);
Modified: trunk/freenet/src/freenet/clients/http/Toadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-03-10 11:42:31 UTC
(rev 8209)
+++ trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-03-10 13:09:42 UTC
(rev 8210)
@@ -3,6 +3,8 @@
import java.io.IOException;
import java.net.URI;
+import org.omg.CORBA.CTX_RESTRICT_SCOPE;
+
import freenet.client.FetchException;
import freenet.client.FetchResult;
import freenet.client.HighLevelSimpleClient;
@@ -142,9 +144,10 @@
return client;
}
- public String mkForwardPage(String title, String content, String
nextpage, int interval) {
+ public String mkForwardPage(ToadletContext ctx, String title, String
content, String nextpage, int interval) {
if (content == null) content = "null";
- return "<html><head><title>" + title + "</title>"+
+
+ return "<HTML><HEAD><link rel=\"stylesheet\"
href=\"/static/themes/"+ctx.getPageMaker().theme+"/theme.css\"
type=\"text/css\" /><head><title>" + title + "</title>"+
"<META HTTP-EQUIV=Refresh CONTENT=\"" + interval +
"; URL="+nextpage+"\"></head><body><h1>" + title +
"</h1>" + content.replaceAll("\n", "<br/>\n") + "</body>";
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-03-10 11:42:31 UTC (rev
8209)
+++ trunk/freenet/src/freenet/node/Version.java 2006-03-10 13:09:42 UTC (rev
8210)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 516;
+ private static final int buildNumber = 517;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 507;