From f31570baa3b96a18d38f1351c55886a653fcdba8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 27 Feb 2016 15:10:29 +0100 Subject: [PATCH 1/1] send a message to wot and see what comes back --- .../sone/freenet/plugin/PluginConnector.java | 32 +++++++++++++++++++--- .../sone/freenet/wot/IdentityManagerImpl.java | 1 + .../sone/freenet/wot/WebOfTrustConnector.java | 8 ++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java b/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java index 46343a3..2e01f74 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java @@ -17,12 +17,19 @@ 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; @@ -37,7 +44,9 @@ import freenet.support.api.Bucket; * @author David ‘Bombe’ Roden */ @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; @@ -59,9 +68,24 @@ public class PluginConnector implements FredPluginTalker { 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. diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java index 33b1ef6..9efb270 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java @@ -127,6 +127,7 @@ public class IdentityManagerImpl extends AbstractService implements IdentityMana while (!shouldStop()) { try { Map> currentIdentities = identityLoader.loadIdentities(); + webOfTrustConnector.start(); IdentityChangeEventSender identityChangeEventSender = new IdentityChangeEventSender(eventBus, oldIdentities); identityChangeEventSender.detectChanges(currentIdentities); diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java index ca3a38c..8395e8b 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -80,6 +80,14 @@ public class WebOfTrustConnector { // ACTIONS // + public void start() { + try { + pluginConnector.start(); + } catch (PluginException e) { + e.printStackTrace(); + } + } + /** * Stops the web of trust connector. */ -- 2.7.4