♻️ Extract interface for WOT connector
[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          * Returns the trust for the given identity assigned to it by the given own
74          * identity.
75          *
76          * @param ownIdentity The own identity
77          * @param identity The identity to get the trust for
78          * @return The trust for the given identity
79          * @throws PluginException if an error occured talking to the Web of Trust plugin
80          */
81         @Throws(PluginException::class)
82         fun getTrust(ownIdentity: OwnIdentity, identity: Identity): Trust
83
84         /**
85          * Sets the trust for the given identity.
86          *
87          * @param ownIdentity The trusting identity
88          * @param identity The trusted identity
89          * @param trust The amount of trust (-100 thru 100)
90          * @param comment The comment or explanation of the trust value
91          * @throws PluginException if an error occured talking to the Web of Trust plugin
92          */
93         @Throws(PluginException::class)
94         fun setTrust(ownIdentity: OwnIdentity, identity: Identity, trust: Int, comment: String)
95
96         /**
97          * Removes any trust assignment of the given own identity for the given
98          * identity.
99          *
100          * @param ownIdentity The own identity
101          * @param identity The identity to remove all trust for
102          * @throws WebOfTrustException if an error occurs
103          */
104         @Throws(WebOfTrustException::class)
105         fun removeTrust(ownIdentity: OwnIdentity, identity: Identity)
106
107         /**
108          * Pings the Web of Trust plugin. If the plugin can not be reached, a
109          * [PluginException] is thrown.
110          *
111          * @throws PluginException if the plugin is not loaded
112          */
113         @Throws(PluginException::class)
114         fun ping()
115
116         /**
117          * Stops the web of trust connector.
118          */
119         fun stop() = Unit
120
121 }