Author: saces
Date: 2007-11-17 22:59:26 +0000 (Sat, 17 Nov 2007)
New Revision: 15806

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:
pass the full access flag in and let the plugin decide what is admin and what 
isn't

Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java   
2007-11-17 22:37:47 UTC (rev 15805)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java   
2007-11-17 22:59:26 UTC (rev 15806)
@@ -82,11 +82,7 @@
                        try {
                                if(Logger.shouldLog(Logger.DEBUG, this))
                                        Logger.debug(this, "Incoming FCP 
message:\n"+messageType+'\n'+fs.toString());
-                               // fcp commands from plugins are only visible 
if full access
-                               if (handler.hasFullAccess())
-                                       msg = FCPMessage.create(messageType, 
fs, handler.bf, handler.server.core.persistentTempBucketFactory, 
handler.server.node.pluginManager);
-                               else
-                                       msg = FCPMessage.create(messageType, 
fs, handler.bf, handler.server.core.persistentTempBucketFactory, null);
+                               msg = FCPMessage.create(messageType, fs, 
handler.bf, handler.server.core.persistentTempBucketFactory, 
handler.server.node.pluginManager, handler.hasFullAccess());
                                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-17 22:37:47 UTC 
(rev 15805)
+++ trunk/freenet/src/freenet/node/fcp/FCPMessage.java  2007-11-17 22:59:26 UTC 
(rev 15806)
@@ -36,7 +36,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 
pluginmanager) throws MessageInvalidException {
+       public static FCPMessage create(String name, SimpleFieldSet fs, 
BucketFactory bfTemp, PersistentTempBucketFactory bfPersistent, PluginManager 
manager, boolean fullaccess) throws MessageInvalidException {
                if(name.equals(AddPeer.NAME))
                        return new AddPeer(fs);
                if(name.equals(ClientGetMessage.NAME))
@@ -93,10 +93,8 @@
                        return null;

                // We reached here? Must be a plugin. find it
-               // if pluginmanager == null it is *not* full access or a bug ;)
-               // plugins.HelloFCP.HelloFCP.Ping

-               if (pluginmanager != null) {                    
+               if (manager != null) {                  
                        // split at last point
                        int lp = name.lastIndexOf('.'); 
                        if (lp > 2) {
@@ -106,10 +104,10 @@
                                System.err.println("plugname: " + plugname);
                                System.err.println("plugcmd: " + plugcmd);

-                               FredPluginFCP plug = 
pluginmanager.getFCPPlugin(plugname);
+                               FredPluginFCP plug = 
manager.getFCPPlugin(plugname);
                                if (plug != null) {
                                        System.err.println("plug found: " + 
plugname);
-                                       FCPMessage msg = plug.create(plugcmd, 
fs);
+                                       FCPMessage msg = plug.create(plugcmd, 
fs, fullaccess);
                                        if (msg != null) {
                                                System.err.println("plug cmd 
seems valid: " + plugcmd);
                                                return msg;
@@ -125,7 +123,7 @@
         * Usefull for FCPClients
         */
        public static FCPMessage create(String name, SimpleFieldSet fs) throws 
MessageInvalidException {
-               return FCPMessage.create(name, fs, null, null, null);
+               return FCPMessage.create(name, fs, null, null, null, false);
        }

        /** 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-17 
22:37:47 UTC (rev 15805)
+++ trunk/freenet/src/freenet/pluginmanager/FredPluginFCP.java  2007-11-17 
22:59:26 UTC (rev 15806)
@@ -21,6 +21,6 @@
  */
 public interface FredPluginFCP {

-       FCPMessage create(String name, SimpleFieldSet fs);
+       FCPMessage create(String name, SimpleFieldSet fs, boolean fullacess);

 }


Reply via email to