version 0.4.4: if default node is created, use it as selected node 0.4.4
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Sat, 22 Apr 2006 22:09:56 +0000 (22:09 +0000)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Sat, 22 Apr 2006 22:09:56 +0000 (22:09 +0000)
src/de/todesbaum/jsite/main/Configuration.java
src/de/todesbaum/jsite/main/Version.java

index 3931dcb..1a06f37 100644 (file)
@@ -171,18 +171,38 @@ public class Configuration {
                return Boolean.parseBoolean(nodeValue);
        }
 
+       /**
+        * Returns the hostname of the node.
+        * @return The hostname of the node
+        * @deprecated Use {@link #getSelectedNode()} instead
+        */
        public String getNodeAddress() {
                return getNodeValue(new String[] { "node-address" }, "localhost");
        }
 
+       /**
+        * Sets the hostname of the node.
+        * @param nodeAddress The hostname of the node
+        * @deprecated Use {@link #setSelectedNode(Node)} instead
+        */
        public void setNodeAddress(String nodeAddress) {
                rootNode.replace("node-address", nodeAddress);
        }
 
+       /**
+        * The port number of the node
+        * @return The port number of the node
+        * @deprecated Use {@link #getSelectedNode()} instead. 
+        */
        public int getNodePort() {
                return getNodeIntValue(new String[] { "node-port" }, 9481);
        }
 
+       /**
+        * Sets the port number of the node.
+        * @param nodePort The port number of the node
+        * @deprecated Use {@link #setSelectedNode(Node)} instead
+        */
        public void setNodePort(int nodePort) {
                rootNode.replace("node-port", String.valueOf(nodePort));
        }
@@ -305,6 +325,10 @@ public class Configuration {
                if (nodesNode == null) {
                        String hostname = getNodeAddress();
                        int port = getNodePort();
+                       if (hostname == null) {
+                               hostname = "127.0.0.1";
+                               port = 9481;
+                       }
                        return new Node[] { new Node(hostname, port, "Node") };
                }
                SimpleXML[] nodeNodes = nodesNode.getNodes("node");
@@ -344,7 +368,13 @@ public class Configuration {
        public Node getSelectedNode() {
                SimpleXML selectedNodeNode = rootNode.getNode("selected-node");
                if (selectedNodeNode == null) {
-                       return null;
+                       String hostname = getNodeAddress();
+                       int port = getNodePort();
+                       if (hostname == null) {
+                               hostname = "127.0.0.1";
+                               port = 9481;
+                       }
+                       return new Node(hostname, port, "Node");
                }
                String name = selectedNodeNode.getNode("name").getValue();
                String hostname = selectedNodeNode.getNode("hostname").getValue();
index 1eb492e..2c635c8 100644 (file)
@@ -25,7 +25,7 @@ package de.todesbaum.jsite.main;
  */
 public class Version {
 
-       private static final String VERSION = "0.4.3";
+       private static final String VERSION = "0.4.4";
 
        public static final String getVersion() {
                return VERSION;