X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Ffcp%2FFcpInterface.java;h=8da41ed73b58c0a9bc3f7eebf5aadf15c913985c;hb=82ad9f2d7d1731ddcaef241ad94db3a38c92b718;hp=c6af12d047fc0d7dbf3fc378259a8aa86116055d;hpb=399bec7d1d8310a5d94770226ff8c3dcf5bffa75;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpInterface.java
index c6af12d..8da41ed 100644
--- a/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpInterface.java
+++ b/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpInterface.java
@@ -1,18 +1,18 @@
/*
* Sone - FcpInterface.java - Copyright © 2011 David Roden
*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package net.pterodactylus.sone.freenet.fcp;
@@ -24,6 +24,7 @@ import java.util.Map;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.freenet.fcp.Command.AccessType;
import net.pterodactylus.sone.freenet.fcp.Command.Reply;
+import freenet.pluginmanager.FredPluginFCP;
import freenet.pluginmanager.PluginNotFoundException;
import freenet.pluginmanager.PluginReplySender;
import freenet.support.SimpleFieldSet;
@@ -37,15 +38,34 @@ import freenet.support.api.Bucket;
*/
public class FcpInterface {
- private final Core core;
+ /** All available FCP commands. */
private final Map commands = Collections.synchronizedMap(new HashMap());
+ /**
+ * Creates a new FCP interface.
+ *
+ * @param core
+ * The core
+ */
public FcpInterface(Core core) {
- this.core = core;
commands.put("Version", new VersionCommand());
commands.put("GetPostFeed", new GetPostFeedCommand(core));
}
+ /**
+ * Handles a plugin FCP request.
+ *
+ * @param pluginReplySender
+ * The reply sender
+ * @param parameters
+ * The message parameters
+ * @param data
+ * The message data (may be {@code null})
+ * @param accessType
+ * One of {@link FredPluginFCP#ACCESS_DIRECT},
+ * {@link FredPluginFCP#ACCESS_FCP_FULL},
+ * {@link FredPluginFCP#ACCESS_FCP_RESTRICTED}
+ */
public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) {
Command command = commands.get(parameters.get("Message"));
if (command == null) {
@@ -57,8 +77,8 @@ public class FcpInterface {
/* TODO - return error? */
return;
}
- Reply reply = command.execute(parameters, data, AccessType.values()[accessType]);
try {
+ Reply reply = command.execute(parameters, data, AccessType.values()[accessType]);
SimpleFieldSet replyParameters = reply.getReplyParameters();
replyParameters.putOverwrite("Identifier", identifier);
if (reply.hasData()) {
@@ -68,6 +88,8 @@ public class FcpInterface {
} else {
pluginReplySender.send(replyParameters);
}
+ } catch (FcpException fe1) {
+ /* TODO - log, report */
} catch (PluginNotFoundException pnfe1) {
/* TODO - log */
}