Author: toad
Date: 2006-12-15 22:23:16 +0000 (Fri, 15 Dec 2006)
New Revision: 11428

Added:
   trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceGeneric.java
   trunk/freenet/src/freenet/support/api/HTTPReply.java
Modified:
   trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceHTMLString.java
Log:
New plugins: web interface

Added: trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceGeneric.java
===================================================================
--- trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceGeneric.java          
                (rev 0)
+++ trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceGeneric.java  
2006-12-15 22:23:16 UTC (rev 11428)
@@ -0,0 +1,28 @@
+package freenet.plugin.api;
+
+import java.net.URI;
+
+import freenet.support.api.HTTPReply;
+import freenet.support.api.HTTPRequest;
+
+/**
+ * Flexible interface for plugins to return data to the browser, of any type 
and of any amount.
+ */
+public interface NeedsWebInterfaceGeneric {
+
+       /** 
+        * Called when the plugin is registered.
+        * @param prefix The absolute path to the plugin's location on the web 
interface.
+        */
+       public void onRegister(URI prefix);
+       
+       /**
+        * Called to ask the plugin to handle an HTTP GET request.
+        * @param request The request to be handled.
+        * @return An HTTPReply containing the data and MIME type to be 
returned to the browser.
+        */
+       public HTTPReply handleGet(HTTPRequest request);
+       
+       public HTTPReply handlePost(HTTPRequest request);
+       
+}

Modified: trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceHTMLString.java
===================================================================
--- trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceHTMLString.java       
2006-12-15 22:07:25 UTC (rev 11427)
+++ trunk/freenet/src/freenet/plugin/api/NeedsWebInterfaceHTMLString.java       
2006-12-15 22:23:16 UTC (rev 11428)
@@ -1,11 +1,32 @@
 package freenet.plugin.api;

+import java.net.URI;
+
 import freenet.support.api.HTTPRequest;

+/**
+ * Simple interface for plugins that only need to return a small amount of 
HTML to the web interface.
+ */
 public interface NeedsWebInterfaceHTMLString {

+       /** 
+        * Called when the plugin is registered.
+        * @param prefix The absolute path to the plugin's location on the web 
interface.
+        */
+       public void onRegister(URI prefix);
+       
+       /**
+        * Handle an HTTP GET request.
+        * @param req The request to be handled.
+        * @return A String containing HTML to be returned to the browser.
+        */
        public String handleGet(HTTPRequest req);

+       /**
+        * Handle an HTTP POST request.
+        * @param req The request to be handled.
+        * @return A String containing HTML to be returned to the browser.
+        */
        public String handlePost(HTTPRequest req);

 }

Added: trunk/freenet/src/freenet/support/api/HTTPReply.java
===================================================================
--- trunk/freenet/src/freenet/support/api/HTTPReply.java                        
        (rev 0)
+++ trunk/freenet/src/freenet/support/api/HTTPReply.java        2006-12-15 
22:23:16 UTC (rev 11428)
@@ -0,0 +1,24 @@
+package freenet.support.api;
+
+/**
+ * An HTTP response.
+ */
+public final class HTTPReply {
+
+       private final String mimeType;
+       private final Bucket data;
+       
+       public HTTPReply(String mimeType, Bucket data) {
+               this.mimeType = mimeType;
+               this.data = data;
+       }
+       
+       public final String getMIMEType() {
+               return mimeType;
+       }
+       
+       public final Bucket getData() {
+               return data;
+       }
+
+}


Reply via email to