Author: saces
Date: 2007-11-20 18:22:32 +0000 (Tue, 20 Nov 2007)
New Revision: 15877
Modified:
trunk/freenet/src/freenet/node/fcp/FCPPluginReply.java
trunk/freenet/src/freenet/pluginmanager/FCPPluginOutputWrapper.java
Log:
fix data carrying for FCPPlugin* messages
Modified: trunk/freenet/src/freenet/node/fcp/FCPPluginReply.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPPluginReply.java 2007-11-20
17:10:38 UTC (rev 15876)
+++ trunk/freenet/src/freenet/node/fcp/FCPPluginReply.java 2007-11-20
18:22:32 UTC (rev 15877)
@@ -5,6 +5,7 @@
import freenet.node.Node;
import freenet.support.SimpleFieldSet;
+import freenet.support.api.Bucket;
/**
* @author saces
@@ -16,11 +17,19 @@
public static final String PARAM_PREFIX = "Param";
+ private final long dataLength;
private final String plugname;
private final String identifier;
private final SimpleFieldSet plugparams;
-
- public FCPPluginReply(String pluginname, String identifier2,
SimpleFieldSet fs) {
+
+ public FCPPluginReply(String pluginname, String identifier2,
SimpleFieldSet fs, Bucket bucket2) {
+ bucket = bucket2;
+ if (bucket == null)
+ dataLength = -1;
+ else {
+ bucket.setReadOnly();
+ dataLength = bucket.size();
+ }
plugname = pluginname;
identifier = identifier2;
plugparams = fs;
@@ -35,7 +44,7 @@
}
long dataLength() {
- return -1;
+ return dataLength;
}
String getEndString() {
@@ -49,6 +58,8 @@
SimpleFieldSet sfs = new SimpleFieldSet(true);
sfs.putSingle("PluginName", plugname);
sfs.putSingle("Identifier", identifier);
+ if (dataLength() > 0)
+ sfs.put("DataLength", dataLength());
sfs.put("Replies", plugparams);
return sfs;
}
Modified: trunk/freenet/src/freenet/pluginmanager/FCPPluginOutputWrapper.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/FCPPluginOutputWrapper.java
2007-11-20 17:10:38 UTC (rev 15876)
+++ trunk/freenet/src/freenet/pluginmanager/FCPPluginOutputWrapper.java
2007-11-20 18:22:32 UTC (rev 15877)
@@ -7,6 +7,7 @@
import freenet.node.fcp.FCPPluginReply;
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
+import freenet.support.io.ArrayBucket;
/**
* @author saces
@@ -26,17 +27,17 @@
}
public void send(SimpleFieldSet params) {
- FCPPluginReply reply = new FCPPluginReply(plugname, identifier,
params);
+ FCPPluginReply reply = new FCPPluginReply(plugname, identifier,
params, null);
handler.outputHandler.queue(reply);
}
public void send(SimpleFieldSet params, byte[] data) {
- FCPPluginReply reply = new FCPPluginReply(plugname, identifier,
params);
+ FCPPluginReply reply = new FCPPluginReply(plugname, identifier,
params, new ArrayBucket(data));
handler.outputHandler.queue(reply);
}
- public void send(SimpleFieldSet params, Bucket data) {
- FCPPluginReply reply = new FCPPluginReply(plugname, identifier,
params);
+ public void send(SimpleFieldSet params, Bucket bucket) {
+ FCPPluginReply reply = new FCPPluginReply(plugname, identifier,
params, bucket);
handler.outputHandler.queue(reply);
}