X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FWebOfTrustConnector.java;h=100241e8a5367cf4a2798b1a548fdc37d511e76f;hb=da6c0a57ac23f13e25a2347237ef3d9ac52ac332;hp=65b7ce877425379fd8938f3928d8dd30191549f2;hpb=45758dd574219c139923b1a9c50d174129a0b740;p=Sone.git 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 65b7ce8..100241e 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -87,12 +87,36 @@ public class WebOfTrustConnector implements ConnectorListener { String requestUri = fields.get("RequestURI" + ownIdentityCounter); String insertUri = fields.get("InsertURI" + ownIdentityCounter); String nickname = fields.get("Nickname" + ownIdentityCounter); - OwnIdentity ownIdentity = new OwnIdentity(id, nickname, requestUri, insertUri); + OwnIdentity ownIdentity = new OwnIdentity(this, id, nickname, requestUri, insertUri); ownIdentities.add(ownIdentity); } return ownIdentities; } + /** + * Loads the contexts of the given identity. + * + * @param identity + * The identity to load the contexts for + * @return The contexts of the identity + * @throws PluginException + * if an error occured talking to the Web of Trust plugin + */ + public Set loadIdentityContexts(Identity identity) throws PluginException { + Reply reply = performRequest("Identity", SimpleFieldSetConstructor.create().put("Message", "GetIdentity").put("TreeOwner", identity.getId()).put("Identity", identity.getId()).get()); + SimpleFieldSet fields = reply.getFields(); + int contextCounter = -1; + Set contexts = new HashSet(); + while (true) { + String context = fields.get("Context" + ++contextCounter); + if (context == null) { + break; + } + contexts.add(context); + } + return contexts; + } + // // PRIVATE ACTIONS //