import com.google.inject.*
import freenet.support.*
+import kotlinx.coroutines.*
import net.pterodactylus.sone.freenet.*
import net.pterodactylus.sone.freenet.plugin.*
import java.lang.String.*
performRequest(SimpleFieldSetBuilder().put("Message", "RemoveProperty").put("Identity", ownIdentity.id).put("Property", name).get())
}
- override fun getTrust(ownIdentity: OwnIdentity, identity: Identity) =
- performRequest(SimpleFieldSetBuilder().put("Message", "GetIdentity").put("Truster", ownIdentity.id).put("Identity", identity.id).get())
- .fields
- .parseTrust()
-
- override fun setTrust(ownIdentity: OwnIdentity, identity: Identity, trust: Int, comment: String) {
- performRequest(SimpleFieldSetBuilder().put("Message", "SetTrust").put("Truster", ownIdentity.id).put("Trustee", identity.id).put("Value", trust.toString()).put("Comment", comment).get())
- }
-
- override fun removeTrust(ownIdentity: OwnIdentity, identity: Identity) {
- performRequest(SimpleFieldSetBuilder().put("Message", "RemoveTrust").put("Truster", ownIdentity.id).put("Trustee", identity.id).get())
- }
-
override fun ping() {
performRequest(SimpleFieldSetBuilder().put("Message", "Ping").get())
}
private fun performRequest(fields: SimpleFieldSet): PluginReply {
logger.log(Level.FINE, format("Sending FCP Request: %s", fields.get("Message")))
- return pluginConnector.sendRequest(WOT_PLUGIN_NAME, fields).also {
- logger.log(Level.FINEST, format("Received FCP Response for %s: %s", fields.get("Message"), it.fields.get("Message")))
- if ("Error" == it.fields.get("Message")) {
- throw PluginException("Could not perform request for " + fields.get("Message"))
+ return runBlocking {
+ pluginConnector.sendRequest(WOT_PLUGIN_NAME, fields).also {
+ logger.log(Level.FINEST, format("Received FCP Response for %s: %s", fields.get("Message"), it.fields.get("Message")))
+ if ("Error" == it.fields.get("Message")) {
+ throw PluginException("Could not perform request for " + fields.get("Message"))
+ }
}
}
}