1 package net.pterodactylus.sone.main
3 import com.google.inject.Binder
4 import com.google.inject.Module
5 import com.google.inject.Provides
6 import freenet.client.HighLevelSimpleClient
7 import freenet.node.Node
8 import freenet.pluginmanager.PluginRespirator
9 import javax.inject.Singleton
12 * Guice [Module] that supplies some objects that are in fact supplied by the Freenet node.
14 class FreenetModule(private val pluginRespirator: PluginRespirator): Module {
16 override fun configure(binder: Binder): Unit = binder.run {
17 bind(PluginRespirator::class.java).toProvider { pluginRespirator }
18 pluginRespirator.node!!.let { node -> bind(Node::class.java).toProvider { node } }
19 bind(HighLevelSimpleClient::class.java).toProvider { pluginRespirator.hlSimpleClient!! }
23 fun getSessionManager() = pluginRespirator.getSessionManager("Sone")!!