Author: saces
Date: 2007-11-19 21:48:08 +0000 (Mon, 19 Nov 2007)
New Revision: 15858

Modified:
   trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
   trunk/freenet/src/freenet/node/fcp/FCPMessage.java
   trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java
Log:
rewritten plugin fcp api
it is now "A FCP Command to talk with a plugin that's implement FredPluginFCP"

Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java   
2007-11-19 21:46:50 UTC (rev 15857)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java   
2007-11-19 21:48:08 UTC (rev 15858)
@@ -82,7 +82,7 @@
                        try {
                                if(Logger.shouldLog(Logger.DEBUG, this))
                                        Logger.debug(this, "Incoming FCP 
message:\n"+messageType+'\n'+fs.toString());
-                               msg = FCPMessage.create(messageType, fs, 
handler.bf, handler.server.core.persistentTempBucketFactory, 
handler.server.node.pluginManager, handler.hasFullAccess());
+                               msg = FCPMessage.create(messageType, fs, 
handler.bf, handler.server.core.persistentTempBucketFactory);
                                if(msg == null) continue;
                        } catch (MessageInvalidException e) {
                                if(firstMessage) {

Modified: trunk/freenet/src/freenet/node/fcp/FCPMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPMessage.java  2007-11-19 21:46:50 UTC 
(rev 15857)
+++ trunk/freenet/src/freenet/node/fcp/FCPMessage.java  2007-11-19 21:48:08 UTC 
(rev 15858)
@@ -4,8 +4,6 @@
 import java.io.OutputStream;

 import freenet.node.Node;
-import freenet.pluginmanager.FredPluginFCP;
-import freenet.pluginmanager.PluginManager;
 import freenet.support.Logger;
 import freenet.support.SimpleFieldSet;
 import freenet.support.api.BucketFactory;
@@ -36,7 +34,7 @@
        /**
         * Create a message from a SimpleFieldSet, and the message's name, if 
possible. 
         */
-       public static FCPMessage create(String name, SimpleFieldSet fs, 
BucketFactory bfTemp, PersistentTempBucketFactory bfPersistent, PluginManager 
manager, boolean fullaccess) throws MessageInvalidException {
+       public static FCPMessage create(String name, SimpleFieldSet fs, 
BucketFactory bfTemp, PersistentTempBucketFactory bfPersistent) throws 
MessageInvalidException {
                if(name.equals(AddPeer.NAME))
                        return new AddPeer(fs);
                if(name.equals(ClientGetMessage.NAME))
@@ -49,6 +47,8 @@
                        return new ClientPutDiskDirMessage(fs);
                if(name.equals(ClientPutMessage.NAME))
                        return new ClientPutMessage(fs);
+               if(name.equals(FCPPluginMessage.NAME))
+                       return new FCPPluginMessage(fs);
                if(name.equals(GenerateSSKMessage.NAME))
                        return new GenerateSSKMessage(fs);
                if(name.equals(GetConfig.NAME))
@@ -92,29 +92,6 @@
                if(name.equals("Void"))
                        return null;

-               // We reached here? Must be a plugin. find it
-               
-               if (manager != null) {                  
-                       // split at last point
-                       int lp = name.lastIndexOf('.'); 
-                       if (lp > 2) {
-                               String plugname = name.substring(0, lp);
-                               String plugcmd = name.substring(lp+1);
-                       
-                               System.err.println("plugname: " + plugname);
-                               System.err.println("plugcmd: " + plugcmd);
-               
-                               FredPluginFCP plug = 
manager.getFCPPlugin(plugname);
-                               if (plug != null) {
-                                       System.err.println("plug found: " + 
plugname);
-                                       FCPMessage msg = plug.create(plugcmd, 
fs, fullaccess);
-                                       if (msg != null) {
-                                               System.err.println("plug cmd 
seems valid: " + plugcmd);
-                                               return msg;
-                                       }
-                               }
-                       }
-               }
                throw new 
MessageInvalidException(ProtocolErrorMessage.INVALID_MESSAGE, "Unknown message 
name "+name, null, false);
        }

@@ -123,7 +100,7 @@
         * Usefull for FCPClients
         */
        public static FCPMessage create(String name, SimpleFieldSet fs) throws 
MessageInvalidException {
-               return FCPMessage.create(name, fs, null, null, null, false);
+               return FCPMessage.create(name, fs, null, null);
        }

        /** Do whatever it is that we do with this type of message. 

Modified: trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java  2007-11-19 
21:46:50 UTC (rev 15857)
+++ trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java  2007-11-19 
21:48:08 UTC (rev 15858)
@@ -3,16 +3,12 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.pluginmanager;

-import freenet.node.fcp.FCPMessage;
 import freenet.support.SimpleFieldSet;
+import freenet.support.api.Bucket;

 /**
  * Interface that has to be implemented for plugins that want to add fcp 
commands
  * 
- * the namesheme is plugin.class.commandname
- * the node looks for the plugin "plugin.class" (the implementor of this 
interface)
- * and ask him for the FCPCommand corresponding to "commandname".
- * If the plugin don't know what to do with "commandname" it returns null.
  * 
  * see plugins.FCPHello for a simple sample.
  * 
@@ -21,6 +17,6 @@
  */
 public interface FredPluginFCP {

-       FCPMessage create(String name, SimpleFieldSet fs, boolean fullacess);
+       void handle(FCPPluginOutputWrapper replysender, SimpleFieldSet params, 
Bucket data, boolean fullacess);

 }


Reply via email to