🔀 Merge “release/v81” into “master”
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / freenet / wot / WebOfTrustConnector.kt
1 package net.pterodactylus.sone.freenet.wot
2
3 import net.pterodactylus.sone.freenet.plugin.*
4
5 /**
6  * Connector for the web of trust plugin.
7  */
8 interface WebOfTrustConnector {
9
10         /**
11          * Loads all own identities from the Web of Trust plugin.
12          *
13          * @return All own identity
14          * @throws WebOfTrustException if the own identities can not be loaded
15          */
16         @Throws(WebOfTrustException::class)
17         fun loadAllOwnIdentities(): Set<OwnIdentity>
18
19         /**
20          * Loads all identities that the given identities trusts with a score of
21          * more than 0 and the (optional) given context.
22          *
23          * @param ownIdentity The own identity
24          * @param context The context to filter, or `null`
25          * @return All trusted identities
26          * @throws PluginException if an error occured talking to the Web of Trust plugin
27          */
28         @Throws(PluginException::class)
29         fun loadTrustedIdentities(ownIdentity: OwnIdentity, context: String? = null): Set<Identity>
30
31         /**
32          * Adds the given context to the given identity.
33          *
34          * @param ownIdentity The identity to add the context to
35          * @param context The context to add
36          * @throws PluginException if an error occured talking to the Web of Trust plugin
37          */
38         @Throws(PluginException::class)
39         fun addContext(ownIdentity: OwnIdentity, context: String)
40
41         /**
42          * Removes the given context from the given identity.
43          *
44          * @param ownIdentity The identity to remove the context from
45          * @param context The context to remove
46          * @throws PluginException if an error occured talking to the Web of Trust plugin
47          */
48         @Throws(PluginException::class)
49         fun removeContext(ownIdentity: OwnIdentity, context: String)
50
51         /**
52          * Sets the property with the given name to the given value.
53          *
54          * @param ownIdentity The identity to set the property on
55          * @param name The name of the property to set
56          * @param value The value to set
57          * @throws PluginException if an error occured talking to the Web of Trust plugin
58          */
59         @Throws(PluginException::class)
60         fun setProperty(ownIdentity: OwnIdentity, name: String, value: String)
61
62         /**
63          * Removes the property with the given name.
64          *
65          * @param ownIdentity The identity to remove the property from
66          * @param name The name of the property to remove
67          * @throws PluginException if an error occured talking to the Web of Trust plugin
68          */
69         @Throws(PluginException::class)
70         fun removeProperty(ownIdentity: OwnIdentity, name: String)
71
72         /**
73          * Pings the Web of Trust plugin. If the plugin can not be reached, a
74          * [PluginException] is thrown.
75          *
76          * @throws PluginException if the plugin is not loaded
77          */
78         @Throws(PluginException::class)
79         fun ping()
80
81         /**
82          * Stops the web of trust connector.
83          */
84         fun stop() = Unit
85
86 }