From 4e0b3740e2fbb8c34db49a8d2c7a4dc9581988b1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 12 Sep 2012 07:47:22 +0200 Subject: [PATCH] Get trust values for trusted identities. --- .../net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 9cda2eb..531275d 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -29,6 +29,7 @@ import net.pterodactylus.sone.freenet.plugin.ConnectorListener; import net.pterodactylus.sone.freenet.plugin.PluginConnector; import net.pterodactylus.sone.freenet.plugin.PluginException; import net.pterodactylus.util.logging.Logging; +import net.pterodactylus.util.number.Numbers; import freenet.support.SimpleFieldSet; import freenet.support.api.Bucket; @@ -128,7 +129,7 @@ public class WebOfTrustConnector { * if an error occured talking to the Web of Trust plugin */ public Set loadTrustedIdentities(OwnIdentity ownIdentity, String context) throws PluginException { - Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetIdentitiesByScore").put("Truster", ownIdentity.getId()).put("Selection", "+").put("Context", (context == null) ? "" : context).get()); + Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetIdentitiesByScore").put("Truster", ownIdentity.getId()).put("Selection", "+").put("Context", (context == null) ? "" : context).put("WantTrustValues", "true").get()); SimpleFieldSet fields = reply.getFields(); Set identities = new HashSet(); int identityCounter = -1; @@ -142,6 +143,10 @@ public class WebOfTrustConnector { DefaultIdentity identity = new DefaultIdentity(id, nickname, requestUri); identity.setContexts(parseContexts("Contexts" + identityCounter + ".", fields)); identity.setProperties(parseProperties("Properties" + identityCounter + ".", fields)); + Integer trust = Numbers.safeParseInteger(fields.get("Trust" + identityCounter), null); + int score = Numbers.safeParseInteger(fields.get("Score" + identityCounter)); + int rank = Numbers.safeParseInteger(fields.get("Rank" + identityCounter)); + identity.setTrust(ownIdentity, new Trust(trust, score, rank)); identities.add(identity); } return identities; -- 2.7.4