1 package net.pterodactylus.sone.main
3 import com.google.inject.*
4 import freenet.client.*
5 import freenet.clients.http.*
7 import freenet.pluginmanager.*
8 import net.pterodactylus.sone.freenet.plugin.*
9 import javax.inject.Provider
10 import javax.inject.Singleton
13 * Guice [Module] that supplies some objects that are in fact supplied by the Freenet node.
15 class FreenetModule(private val pluginRespirator: PluginRespirator) : Module {
17 override fun configure(binder: Binder): Unit = binder.run {
18 bind(PluginRespiratorFacade::class.java).toProvider(Provider { FredPluginRespiratorFacade(pluginRespirator) }).`in`(Singleton::class.java)
19 bind(PluginConnector::class.java).to(FredPluginConnector::class.java).`in`(Singleton::class.java)
20 bind(Node::class.java).toProvider(Provider { pluginRespirator.node })
21 bind(HighLevelSimpleClient::class.java).toProvider(Provider<HighLevelSimpleClient> { pluginRespirator.hlSimpleClient!! })
22 bind(ToadletContainer::class.java).toProvider(Provider<ToadletContainer> { pluginRespirator.toadletContainer })
23 bind(PageMaker::class.java).toProvider(Provider<PageMaker> { pluginRespirator.pageMaker })
28 fun getSessionManager() = pluginRespirator.getSessionManager("Sone")!!