package net.pterodactylus.sone.freenet.plugin;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder;
import net.pterodactylus.sone.freenet.plugin.event.ReceivedReplyEvent;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import freenet.clients.fcp.FCPPluginConnection;
+import freenet.clients.fcp.FCPPluginMessage;
+import freenet.pluginmanager.FredPluginFCPMessageHandler.ClientSideFCPMessageHandler;
import freenet.pluginmanager.FredPluginTalker;
import freenet.pluginmanager.PluginNotFoundException;
import freenet.pluginmanager.PluginRespirator;
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
@Singleton
-public class PluginConnector implements FredPluginTalker {
+public class PluginConnector implements FredPluginTalker, ClientSideFCPMessageHandler {
+
+ private static final Logger logger = Logger.getLogger(PluginConnector.class.getName());
/** The event bus. */
private final EventBus eventBus;
this.pluginRespirator = pluginRespirator;
}
- //
- // ACTIONS
- //
+ public void start() throws PluginException {
+ try {
+ FCPPluginConnection pluginConnection = pluginRespirator.connectToOtherPlugin("plugins.WebOfTrust.WebOfTrust", this);
+ logger.fine("Got PluginConnection: " + pluginConnection);
+ SimpleFieldSet simpleFieldSet = new SimpleFieldSetBuilder().put("Message", "Subscribe").put("To", "Identities").get();
+ pluginConnection.send(FCPPluginMessage.construct(simpleFieldSet, null));
+ } catch (PluginNotFoundException pnfe1) {
+ throw new PluginException(pnfe1);
+ } catch (IOException ioe1) {
+ throw new PluginException(ioe1);
+ }
+ }
+
+ @Override
+ public FCPPluginMessage handlePluginFCPMessage(FCPPluginConnection connection, FCPPluginMessage message) {
+ logger.fine("Got Reply: " + message);
+ return null;
+ }
/**
* Sends a request to the given plugin.