Author: nextgens
Date: 2006-05-07 09:38:32 +0000 (Sun, 07 May 2006)
New Revision: 8634

Modified:
   trunk/freenet/src/freenet/config/Config.java
   trunk/freenet/src/freenet/config/SubConfig.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/TextModeClientInterface.java
   trunk/freenet/src/freenet/node/Version.java
Log:
686:
        * Small tweakings on the TMCI
        * new methods to access the config ;)
        * Small changes to Node to disable eclipse's warnings

Modified: trunk/freenet/src/freenet/config/Config.java
===================================================================
--- trunk/freenet/src/freenet/config/Config.java        2006-05-07 09:02:22 UTC 
(rev 8633)
+++ trunk/freenet/src/freenet/config/Config.java        2006-05-07 09:38:32 UTC 
(rev 8634)
@@ -42,4 +42,8 @@
                return (SubConfig[]) configsByPrefix.values().toArray(new 
SubConfig[configsByPrefix.size()]);
        }

+       public synchronized SubConfig get(String subConfig){
+               return (SubConfig)configsByPrefix.get(subConfig);
+       }
+       
 }

Modified: trunk/freenet/src/freenet/config/SubConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/SubConfig.java     2006-05-07 09:02:22 UTC 
(rev 8633)
+++ trunk/freenet/src/freenet/config/SubConfig.java     2006-05-07 09:38:32 UTC 
(rev 8634)
@@ -30,10 +30,14 @@
         * Return all the options registered. Each includes its name.
         * Used by e.g. webconfig.
         */
-       public Option[] getOptions() {
+       public synchronized Option[] getOptions() {
                return (Option[]) map.values().toArray(new Option[map.size()]);
        }

+       public synchronized Option getOption(String option){
+               return (Option)map.get(option);
+       }
+       
        public void register(Option o) {
                synchronized(this) {
                        if(o.name.indexOf(SimpleFieldSet.MULTI_LEVEL_CHAR) != 
-1)

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-05-07 09:02:22 UTC (rev 
8633)
+++ trunk/freenet/src/freenet/node/Node.java    2006-05-07 09:38:32 UTC (rev 
8634)
@@ -113,7 +113,7 @@
                                node=n;
                        }
                        public String get() {
-                               if(myName.startsWith("Node created around")|| 
myName.startsWith("MyFirstFreenetNode")){
+                               if(myName.startsWith("Node created around")|| 
myName.equals("MyFirstFreenetNode")){
                                node.alerts.register(nodeNameUserAlert);
                        }else{
                                node.alerts.unregister(nodeNameUserAlert);
@@ -123,7 +123,7 @@

                        public void set(String val) throws 
InvalidConfigValueException {
                                myName = val;
-                               if(myName.startsWith("Node created around")|| 
myName.startsWith("MyFirstFreenetNode")){
+                               if(myName.startsWith("Node created around")|| 
myName.equals("MyFirstFreenetNode")){
                                node.alerts.register(nodeNameUserAlert);
                        }else{
                                node.alerts.unregister(nodeNameUserAlert);
@@ -134,11 +134,9 @@
        public class MyRequestThrottle implements BaseRequestThrottle {

                private final BootstrappingDecayingRunningAverage 
roundTripTime; 
-               private final String name;

                public MyRequestThrottle(ThrottleWindowManager throttleWindow, 
int rtt, String string) {
                        roundTripTime = new 
BootstrappingDecayingRunningAverage(rtt, 10, 5*60*1000, 10);
-                       this.name = string;
                }

                public synchronized long getDelay() {
@@ -553,6 +551,7 @@
     static class NodeInitException extends Exception {
        // One of the exit codes from above
        public final int exitCode;
+       static final long serialVersionUID=0;

        NodeInitException(int exitCode, String msg) {
                super(msg+" ("+exitCode+")");
@@ -1397,8 +1396,6 @@
     }

     public void realPutSSK(ClientSSKBlock block, boolean cache) throws 
LowLevelPutException {
-        byte[] data = block.getRawData();
-        byte[] headers = block.getRawHeaders();
         SSKInsertSender is;
         long uid = random.nextLong();
         if(!lockUID(uid)) {
@@ -2226,7 +2223,6 @@

        private ClientKeyBlock fetch(ClientSSK clientSSK) throws 
SSKVerifyException {
                DSAPublicKey key = clientSSK.getPubKey();
-               boolean hadKey = key != null;
                if(key == null) {
                        key = getKey(clientSSK.pubKeyHash);
                }

Modified: trunk/freenet/src/freenet/node/TextModeClientInterface.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-05-07 
09:02:22 UTC (rev 8633)
+++ trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-05-07 
09:38:32 UTC (rev 8634)
@@ -34,6 +34,7 @@
 import freenet.io.comm.PeerParseException;
 import freenet.keys.FreenetURI;
 import freenet.keys.InsertableClientSSK;
+import freenet.keys.Key;
 import freenet.support.ArrayBucket;
 import freenet.support.Bucket;
 import freenet.support.BucketTools;
@@ -124,8 +125,7 @@

         sb.append("Freenet 0.7 Trivial Node Test Interface\r\n");
         sb.append("---------------------------------------\r\n");
-        sb.append("Build "+Version.buildNumber()+"\r\n");
-        sb.append(Version.cvsRevision+"\r\n");
+        sb.append("Build "+Version.buildNumber()+" - "+ 
Version.cvsRevision+"\r\n");
         sb.append("Enter one of the following commands:\r\n");
         sb.append("GET:<Freenet key> - Fetch a key\r\n");
         sb.append("PUT:\r\n<text, until a . on a line by itself> - Insert the 
document and return the key.\r\n");
@@ -567,25 +567,12 @@
             while(key.length() > 0 && key.charAt(key.length()-1) == ' ')
                 key = key.substring(0, key.length()-2);
             outsb.append("New name: "+key);
-            SubConfig[] sc=n.config.getConfigs();

-            for(int i=0; i<sc.length ; i++){
-                       Option[] o = sc[i].getOptions();
-                       String prefix = new String(sc[i].getPrefix());
-                       String configName;
-                       
-                       for(int j=0; j<o.length; j++){
-                               configName=o[j].getName();
-                               // we look for node.name 
-                               if(prefix.equals("node") && 
configName.equals("name")){
-                                               Logger.minor(this, "Setting 
"+prefix+"."+configName+" to "+key);
-                                               try{
-                                                       o[j].setValue(key);
-                                               }catch(Exception e){
-                                                       Logger.error(this, 
"Error setting node's name");
-                                               }
-                               }
-                       }
+            try{
+               n.config.get("node").getOption("name").setValue(key);
+               Logger.minor(this, "Setting node.name to "+key);
+                       }catch(Exception e){
+                               Logger.error(this, "Error setting node's name");
                }
                n.config.store();
         } else if(uline.startsWith("DISCONNECT:")) {

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-05-07 09:02:22 UTC (rev 
8633)
+++ trunk/freenet/src/freenet/node/Version.java 2006-05-07 09:38:32 UTC (rev 
8634)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 685;
+       private static final int buildNumber = 686;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 591;


Reply via email to