2 * Sone - PluginRespiratorFacade.kt - Copyright © 2019 David ‘Bombe’ Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /* Yes, this handle Fred-based stuff that’s mostly deprecated. */
19 @file:Suppress("DEPRECATION")
21 package net.pterodactylus.sone.freenet.plugin
23 import freenet.pluginmanager.*
24 import freenet.support.*
25 import freenet.support.api.*
29 * Facade for the only method of a [plugin respirator][PluginRespirator] that Sone actually uses,
32 interface PluginRespiratorFacade {
34 @Throws(PluginNotFoundException::class)
35 fun getPluginTalker(pluginTalker: FredPluginTalker, pluginName: String, identifier: String): PluginTalkerFacade
40 * Facade for a [plugin talker][PluginTalker], for easier testing.
42 interface PluginTalkerFacade {
44 fun send(pluginParameters: SimpleFieldSet, data: Bucket?)
49 * Fred-based [PluginRespiratorFacade] implementation that proxies the given real [PluginRespirator].
51 class FredPluginRespiratorFacade @Inject constructor(private val pluginRespirator: PluginRespirator) : PluginRespiratorFacade {
53 override fun getPluginTalker(pluginTalker: FredPluginTalker, pluginName: String, identifier: String) =
54 FredPluginTalkerFacade(pluginRespirator.getPluginTalker(pluginTalker, pluginName, identifier))
59 * Fred-based [PluginTalkerFacade] implementation that proxies the given real [PluginTalker].
61 class FredPluginTalkerFacade(private val pluginTalker: PluginTalker) : PluginTalkerFacade {
63 override fun send(pluginParameters: SimpleFieldSet, data: Bucket?) =
64 pluginTalker.send(pluginParameters, data)