Author: toad
Date: 2007-07-20 17:06:59 +0000 (Fri, 20 Jul 2007)
New Revision: 14206

Modified:
   trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
   trunk/freenet/src/freenet/config/SubConfig.java
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/support/Fields.java
Log:
First step asks the user whether they want to enable opennet. Not tested yet.

Modified: trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java  
2007-07-20 16:50:21 UTC (rev 14205)
+++ trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java  
2007-07-20 17:06:59 UTC (rev 14206)
@@ -17,6 +17,7 @@
 import freenet.node.Node;
 import freenet.node.NodeClientCore;
 import freenet.support.Base64;
+import freenet.support.Fields;
 import freenet.support.HTMLNode;
 import freenet.support.Logger;
 import freenet.support.api.HTTPRequest;
@@ -50,7 +51,23 @@
                int currentStep = request.getIntParam("step");

                if(currentStep == 1) {
+                       HTMLNode pageNode = 
ctx.getPageMaker().getPageNode(l10n("step1Title"), false, ctx);
+                       HTMLNode contentNode = 
ctx.getPageMaker().getContentNode(pageNode);

+                       HTMLNode opennetInfobox = contentNode.addChild("div", 
"class", "infobox infobox-normal");
+                       HTMLNode opennetInfoboxHeader = 
opennetInfobox.addChild("div", "class", "infobox-header");
+                       HTMLNode opennetInfoboxContent = 
opennetInfobox.addChild("div", "class", "infobox-content");
+                       
+                       opennetInfoboxHeader.addChild("#", 
l10n("connectToStrangers"));
+                       opennetInfoboxContent.addChild("#", 
l10n("connectToStrangersLong"));
+                       HTMLNode opennetForm = 
ctx.addFormChild(opennetInfoboxContent, ".", "opennetForm");
+                       
+                       HTMLNode opennetDiv = opennetForm.addChild("div", 
"class", "opennetDiv");
+                       opennetDiv.addChild("#", l10n("enableOpennet"));
+                       opennetDiv.addChild("input", new String[] { "type", 
"name", "value" }, new String[] { "radio", "enableOpennet", "true" }, 
L10n.getString("Toadlet.yes"));
+                       opennetDiv.addChild("input", new String[] { "type", 
"name", "value" }, new String[] { "radio", "enableOpennet", "false" }, 
L10n.getString("Toadlet.no"));
+                       this.writeReply(ctx, 200, "text/html; charset=utf-8", 
"OK", pageNode.generate());
+                       return;
                } else if(currentStep == 2) {
                        HTMLNode pageNode = 
ctx.getPageMaker().getPageNode(l10n("step2Title"), false, ctx);
                        HTMLNode contentNode = 
ctx.getPageMaker().getContentNode(pageNode);
@@ -211,7 +228,27 @@
                        return;
                }

-               if(request.isPartSet("nnameF")) {
+               
+               if(request.isPartSet("enableOpennet")) {
+                       String isOpennetEnabled = 
request.getPartAsString("opennet", 255);
+                       boolean enable;
+                       try {
+                               enable = Fields.stringToBool(isOpennetEnabled);
+                       } catch (NumberFormatException e) {
+                               Logger.error(this, "Invalid opennetEnabled: 
"+isOpennetEnabled);
+                               super.writeTemporaryRedirect(ctx, "step1", 
TOADLET_URL+"?step=1");
+                               return;
+                       }
+                       try {
+                               config.get("node.opennet").set("enabled", 
enable);
+                       } catch (InvalidConfigValueException e) {
+                               Logger.error(this, "Should not happen setting 
opennet.enabled="+enable+" please repot: "+e, e);
+                               super.writeTemporaryRedirect(ctx, "step1", 
TOADLET_URL+"?step=1");
+                               return;
+                       }
+                       super.writeTemporaryRedirect(ctx, "step1", 
TOADLET_URL+"?step=2");
+                       return;
+               } else if(request.isPartSet("nnameF")) {
                        String selectedNName = request.getPartAsString("nname", 
255);

                        try {
@@ -220,7 +257,7 @@
                        } catch (InvalidConfigValueException e) {
                                Logger.error(this, "Should not happen, please 
report!" + e);
                        }
-                       super.writeTemporaryRedirect(ctx, "step2", 
TOADLET_URL+"?step=3");
+                       super.writeTemporaryRedirect(ctx, "step3", 
TOADLET_URL+"?step=3");
                        return;
                } else if(request.isPartSet("bwF")) {
                        String selectedUploadSpeed 
=request.getPartAsString("bw", 6);
@@ -231,7 +268,7 @@
                        } catch (InvalidConfigValueException e) {
                                Logger.error(this, "Should not happen, please 
report!" + e);
                        }
-                       super.writeTemporaryRedirect(ctx, "step3", 
TOADLET_URL+"?step=4");
+                       super.writeTemporaryRedirect(ctx, "step4", 
TOADLET_URL+"?step=4");
                        return;
                } else if(request.isPartSet("dsF")) {
                        String selectedStoreSize =request.getPartAsString("ds", 
6);
@@ -242,7 +279,7 @@
                        } catch (InvalidConfigValueException e) {
                                Logger.error(this, "Should not happen, please 
report!" + e);
                        }
-                       super.writeTemporaryRedirect(ctx, "step3", 
TOADLET_URL+"?step=5");
+                       super.writeTemporaryRedirect(ctx, "step5", 
TOADLET_URL+"?step=5");
                        return;
                } else if(request.isPartSet("networkF")) {
                        StringBuffer sb = new StringBuffer();
@@ -294,7 +331,7 @@
                                }
                        }

-                       super.writeTemporaryRedirect(ctx, "step4", 
TOADLET_URL+"?step=6");
+                       super.writeTemporaryRedirect(ctx, "step6", 
TOADLET_URL+"?step=6");
                        return;
                }


Modified: trunk/freenet/src/freenet/config/SubConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/SubConfig.java     2007-07-20 16:50:21 UTC 
(rev 14205)
+++ trunk/freenet/src/freenet/config/SubConfig.java     2007-07-20 17:06:59 UTC 
(rev 14206)
@@ -265,6 +265,11 @@
                o.setValue(value);
        }

+       public void set(String name, boolean value) throws 
InvalidConfigValueException {
+               BooleanOption o = (BooleanOption) map.get(name);
+               o.set(value);
+       }
+
        /**
         * If the option's value is equal to the provided old default, then set 
it to the
         * new default. Used to deal with changes to important options where 
this is not

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2007-07-20 
16:50:21 UTC (rev 14205)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2007-07-20 
17:06:59 UTC (rev 14206)
@@ -173,7 +173,10 @@
 ExtOldAgeUserAlert.extTooOldTitle=Freenet-ext too old
 FirstTimeWizardToadlet.homepageTitle=Freenet first time wizard!
 FirstTimeWizardToadlet.chooseNodeName=Node name required!
-FirstTimeWizardToadlet.chooseNodeNameLong=Please enter a node name in the 
field below. This name won't be published to anyone except the peers you are 
connected to. We recommend to put your real-name or IRC nick in there possibly 
with some contact information so that you can be reached in case there is a 
problem ("John Doe <noname at nowhere.com>"). 
+FirstTimeWizardToadlet.chooseNodeNameLong=Please enter a node name in the 
field below. This name won't be published to anyone except the peers you are 
connected to. We recommend to put your real-name or IRC nick in there possibly 
with some contact information so that you can be reached in case there is a 
problem ("John Doe <noname at nowhere.com>").
+FirstTimeWizardToadlet.connectToStrangers=Connect to strangers?
+FirstTimeWizardToadlet.connectToStrangersLong=Your node can either 
automatically find untrusted nodes to connect to ("Strangers"), or you can 
manually add connections to trusted nodes ("Friends") run by people you already 
know. Connecting to total strangers is far less secure (in particular, your 
node can be found relatively easily, and anyone can connect to it), but it 
means your node will start working immediately, rather than you having to find 
some friends to connect to. Even if you do enable connecting to untrusted 
nodes, you should try to get some friend connections when your friends start 
using Freenet.
+FirstTimeWizardToadlet.enableOpennet=Automatically connect to untrusted 
strangers' nodes?
 FirstTimeWizardToadlet.welcomeInfoboxTitle=Welcome to freenet first time 
wizard!
 FirstTimeWizardToadlet.welcomeInfoboxContent1=Welcome to freenet first time 
wizard. This tool will enable you to configure your node quickly and easily to 
get you started. Please
 FirstTimeWizardToadlet.bandwidthLimit=Bandwidth limits
@@ -188,11 +191,12 @@
 FirstTimeWizardToadlet.iDoTrust=Do you trust people connected to ${interface} 
(${ip}) ?
 FirstTimeWizardToadlet.congratz=Welcome on board!
 FirstTimeWizardToadlet.congratzLong=Congratulations, the base configuration of 
your freenet node is now done. You can change and edit any of the parameters 
you have just set going to the "configuration" page, reachable anytime from the 
menu on the left of the interface. We wish you a pleasant freenet experience.
-FirstTimeWizardToadlet.step1Title=Freenet first time wizard! - Choose a node 
name
-FirstTimeWizardToadlet.step2Title=Freenet first time wizard! - Bandwidth limits
-FirstTimeWizardToadlet.step3Title=Freenet first time wizard! - Datastore size
-FirstTimeWizardToadlet.step4Title=Freenet first time wizard! - Network 
configuration
-FirstTimeWizardToadlet.step5Title=Freenet first time wizard! - 
Congratulations, your node is now configured
+FirstTimeWizardToadlet.step1Title=Freenet first time wizard! - Friends and 
strangers
+FirstTimeWizardToadlet.step2Title=Freenet first time wizard! - Choose a node 
name
+FirstTimeWizardToadlet.step3Title=Freenet first time wizard! - Bandwidth limits
+FirstTimeWizardToadlet.step4Title=Freenet first time wizard! - Datastore size
+FirstTimeWizardToadlet.step5Title=Freenet first time wizard! - Network 
configuration
+FirstTimeWizardToadlet.step6Title=Freenet first time wizard! - 
Congratulations, your node is now configured
 FirstTimeWizardToadlet.skipWizard=I am not a newbie, please skip the wizard!
 FProxyToadlet.abortToHomepage=Abort and return to the FProxy home page
 FProxyToadlet.backToFProxy=${link}Click here${/link} to go to the FProxy home 
page.

Modified: trunk/freenet/src/freenet/support/Fields.java
===================================================================
--- trunk/freenet/src/freenet/support/Fields.java       2007-07-20 16:50:21 UTC 
(rev 14205)
+++ trunk/freenet/src/freenet/support/Fields.java       2007-07-20 17:06:59 UTC 
(rev 14206)
@@ -145,6 +145,18 @@
        }

        /**
+        * Find the boolean value of the field. Throw if the string is neither 
"yes"/"true" nor "no"/"false".
+        * @param s
+        * @return
+        */
+       public static boolean stringToBool(String s) throws 
NumberFormatException {
+               if(s == null) throw new NumberFormatException("Null");
+               if(s.equalsIgnoreCase("false") || s.equalsIgnoreCase("no")) 
return false;
+               if(s.equalsIgnoreCase("true") || s.equalsIgnoreCase("yes")) 
return true;
+               throw new NumberFormatException("Invalid boolean: "+s);
+       }
+
+       /**
         * Converts a boolean to a String of either "true" or "false".
         * 
         * @param b


Reply via email to