Author: zothar
Date: 2007-04-08 21:03:17 +0000 (Sun, 08 Apr 2007)
New Revision: 12556
Modified:
trunk/freenet/src/freenet/config/FilePersistentConfig.java
trunk/freenet/src/freenet/config/PersistentConfig.java
trunk/freenet/src/freenet/node/fcp/ConfigData.java
trunk/freenet/src/freenet/node/fcp/GetConfig.java
trunk/freenet/src/freenet/node/fcp/ModifyConfig.java
Log:
Hopefully the last step for full config data via FCP. "WithCurrent" is now
required to get the current settings. Current settings will be returned in the
"current" tree and default settings will be returned in the "default" tree.
All of the other config data should now be available via FCP; read the patch
for how to access it. I'll let this stew at least a week before I document it
in the wiki, both to catch any API flaws before documenting and because I won't
have free time for at least a week. I don't anticipate any changes, so go
ahead and play with it if you're interested.
Modified: trunk/freenet/src/freenet/config/FilePersistentConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/FilePersistentConfig.java 2007-04-08
16:25:11 UTC (rev 12555)
+++ trunk/freenet/src/freenet/config/FilePersistentConfig.java 2007-04-08
21:03:17 UTC (rev 12556)
@@ -161,9 +161,4 @@
System.err.println("Written "+filename);
}
}
-
- private SimpleFieldSet exportFieldSet() {
- return exportFieldSet(false);
- }
-
}
Modified: trunk/freenet/src/freenet/config/PersistentConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/PersistentConfig.java 2007-04-08
16:25:11 UTC (rev 12555)
+++ trunk/freenet/src/freenet/config/PersistentConfig.java 2007-04-08
21:03:17 UTC (rev 12556)
@@ -30,14 +30,22 @@
}
origConfigFileContents = null;
}
+
+ public SimpleFieldSet exportFieldSet() {
+ return exportFieldSet(false);
+ }
- public synchronized SimpleFieldSet exportFieldSet(boolean withDefaults)
{
+ public SimpleFieldSet exportFieldSet(boolean withDefaults) {
+ return
exportFieldSet(Config.CONFIG_REQUEST_TYPE_CURRENT_SETTINGS, withDefaults);
+ }
+
+ public synchronized SimpleFieldSet exportFieldSet(int
configRequestType, boolean withDefaults) {
SimpleFieldSet fs = new SimpleFieldSet(true);
Iterator configsIterator = configsByPrefix.keySet().iterator();
SubConfig current;
while (configsIterator.hasNext()) {
current = (SubConfig)
configsByPrefix.get(configsIterator.next());
- SimpleFieldSet scfs =
current.exportFieldSet(withDefaults);
+ SimpleFieldSet scfs =
current.exportFieldSet(configRequestType, withDefaults);
fs.tput(current.prefix, scfs);
}
return fs;
Modified: trunk/freenet/src/freenet/node/fcp/ConfigData.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ConfigData.java 2007-04-08 16:25:11 UTC
(rev 12555)
+++ trunk/freenet/src/freenet/node/fcp/ConfigData.java 2007-04-08 21:03:17 UTC
(rev 12556)
@@ -3,6 +3,7 @@
* http://www.gnu.org/ for further details of the GPL. */
package freenet.node.fcp;
+import freenet.config.Config;
import freenet.node.Node;
import freenet.support.SimpleFieldSet;
@@ -10,15 +11,71 @@
static final String name = "ConfigData";
final Node node;
+ final boolean withCurrent;
final boolean withDefaults;
+ final boolean withSortOrder;
+ final boolean withExpertFlag;
+ final boolean withForceWriteFlag;
+ final boolean withShortDescription;
+ final boolean withLongDescription;
- public ConfigData(Node node, boolean withDefaults) {
+ public ConfigData(Node node, boolean withCurrent, boolean withDefaults,
boolean withSortOrder, boolean withExpertFlag, boolean withForceWriteFlag,
boolean withShortDescription, boolean withLongDescription) {
this.node = node;
+ this.withCurrent = withCurrent;
this.withDefaults = withDefaults;
+ this.withSortOrder = withSortOrder;
+ this.withExpertFlag = withExpertFlag;
+ this.withForceWriteFlag = withForceWriteFlag;
+ this.withShortDescription = withShortDescription;
+ this.withLongDescription = withLongDescription;
}
+
public SimpleFieldSet getFieldSet() {
- return node.config.exportFieldSet(withDefaults);
+ SimpleFieldSet fs = new SimpleFieldSet(true);
+ if(withCurrent) {
+ SimpleFieldSet current =
node.config.exportFieldSet(Config.CONFIG_REQUEST_TYPE_CURRENT_SETTINGS, true);
+ if(!current.isEmpty()) {
+ fs.put("current", current);
+ }
+ }
+ if(withDefaults) {
+ SimpleFieldSet defaultSettings =
node.config.exportFieldSet(Config.CONFIG_REQUEST_TYPE_DEFAULT_SETTINGS, false);
+ if(!defaultSettings.isEmpty()) {
+ fs.put("default", defaultSettings);
+ }
+ }
+ if(withSortOrder) {
+ SimpleFieldSet sortOrder =
node.config.exportFieldSet(Config.CONFIG_REQUEST_TYPE_SORT_ORDER, false);
+ if(!sortOrder.isEmpty()) {
+ fs.put("sortOrder", sortOrder);
+ }
+ }
+ if(withExpertFlag) {
+ SimpleFieldSet expertFlag =
node.config.exportFieldSet(Config.CONFIG_REQUEST_TYPE_EXPERT_FLAG, false);
+ if(!expertFlag.isEmpty()) {
+ fs.put("expertFlag", expertFlag);
+ }
+ }
+ if(withForceWriteFlag) {
+ SimpleFieldSet forceWriteFlag =
node.config.exportFieldSet(Config.CONFIG_REQUEST_TYPE_FORCE_WRITE_FLAG, false);
+ if(!forceWriteFlag.isEmpty()) {
+ fs.put("forceWriteFlag", forceWriteFlag);
+ }
+ }
+ if(withShortDescription) {
+ SimpleFieldSet shortDescription =
node.config.exportFieldSet(Config.CONFIG_REQUEST_TYPE_SHORT_DESCRIPTION, false);
+ if(!shortDescription.isEmpty()) {
+ fs.put("shortDescription", shortDescription);
+ }
+ }
+ if(withLongDescription) {
+ SimpleFieldSet longDescription =
node.config.exportFieldSet(Config.CONFIG_REQUEST_TYPE_LONG_DESCRIPTION, false);
+ if(!longDescription.isEmpty()) {
+ fs.put("longDescription", longDescription);
+ }
+ }
+ return fs;
}
public String getName() {
Modified: trunk/freenet/src/freenet/node/fcp/GetConfig.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/GetConfig.java 2007-04-08 16:25:11 UTC
(rev 12555)
+++ trunk/freenet/src/freenet/node/fcp/GetConfig.java 2007-04-08 21:03:17 UTC
(rev 12556)
@@ -9,11 +9,23 @@
public class GetConfig extends FCPMessage {
+ final boolean withCurrent;
final boolean withDefaults;
+ final boolean withSortOrder;
+ final boolean withExpertFlag;
+ final boolean withForceWriteFlag;
+ final boolean withShortDescription;
+ final boolean withLongDescription;
static final String name = "GetConfig";
public GetConfig(SimpleFieldSet fs) {
+ withCurrent = Fields.stringToBool(fs.get("WithCurrent"), false);
withDefaults = Fields.stringToBool(fs.get("WithDefaults"),
false);
+ withSortOrder = Fields.stringToBool(fs.get("WithSortOrder"),
false);
+ withExpertFlag = Fields.stringToBool(fs.get("WithExpertFlag"),
false);
+ withForceWriteFlag =
Fields.stringToBool(fs.get("WithForceWriteFlag"), false);
+ withShortDescription =
Fields.stringToBool(fs.get("WithShortDescription"), false);
+ withLongDescription =
Fields.stringToBool(fs.get("WithLongDescription"), false);
}
public SimpleFieldSet getFieldSet() {
@@ -29,7 +41,7 @@
if(!handler.hasFullAccess()) {
throw new
MessageInvalidException(ProtocolErrorMessage.ACCESS_DENIED, "GetConfig requires
full access", null, false);
}
- handler.outputHandler.queue(new ConfigData(node, true));
+ handler.outputHandler.queue(new ConfigData(node, withCurrent,
withDefaults, withSortOrder, withExpertFlag, withForceWriteFlag,
withShortDescription, withLongDescription));
}
}
Modified: trunk/freenet/src/freenet/node/fcp/ModifyConfig.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ModifyConfig.java 2007-04-08
16:25:11 UTC (rev 12555)
+++ trunk/freenet/src/freenet/node/fcp/ModifyConfig.java 2007-04-08
21:03:17 UTC (rev 12556)
@@ -61,7 +61,6 @@
}
}
node.clientCore.storeConfig();
- handler.outputHandler.queue(new ConfigData(node, true));
+ handler.outputHandler.queue(new ConfigData(node, true, false,
false, false, false, false, false));
}
-
}