2 * WoTNS - WoTNSPlugin.java - Copyright © 2011 David 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 package net.pterodactylus.wotns.main;
20 import net.pterodactylus.util.logging.Logging;
21 import net.pterodactylus.util.version.Version;
22 import net.pterodactylus.wotns.freenet.plugin.PluginConnector;
23 import net.pterodactylus.wotns.freenet.wot.IdentityManager;
24 import net.pterodactylus.wotns.freenet.wot.WebOfTrustConnector;
25 import net.pterodactylus.wotns.ui.web.WebInterface;
26 import freenet.client.HighLevelSimpleClient;
27 import freenet.clients.http.ToadletContainer;
28 import freenet.l10n.PluginL10n;
29 import freenet.l10n.BaseL10n.LANGUAGE;
30 import freenet.pluginmanager.FredPlugin;
31 import freenet.pluginmanager.FredPluginBaseL10n;
32 import freenet.pluginmanager.FredPluginL10n;
33 import freenet.pluginmanager.FredPluginThreadless;
34 import freenet.pluginmanager.FredPluginVersioned;
35 import freenet.pluginmanager.PluginRespirator;
40 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
42 public class WoTNSPlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10n, FredPluginVersioned, FredPluginThreadless {
45 Logging.setup("WoTNS");
46 Logging.setupConsoleLogging();
49 private static final Version VERSION = new Version(0, 0, 5);
51 private PluginRespirator pluginRespirator;
53 private PluginL10n l10n;
55 private WebInterface webInterface;
57 private Resolver resolver;
59 private WebOfTrustConnector webOfTrustConnector;
61 private IdentityManager identityManager;
67 public HighLevelSimpleClient getHighLevelSimpleClient() {
68 return pluginRespirator.getHLSimpleClient();
71 public ToadletContainer getToadletContainer() {
72 return pluginRespirator.getToadletContainer();
75 public IdentityManager getIdentityManager() {
76 return identityManager;
79 public Resolver getResolver() {
91 public void runPlugin(PluginRespirator pluginRespirator) {
92 this.pluginRespirator = pluginRespirator;
94 PluginConnector pluginConnector = new PluginConnector(pluginRespirator);
95 webOfTrustConnector = new WebOfTrustConnector(pluginConnector);
96 identityManager = new IdentityManager(webOfTrustConnector);
97 identityManager.setContext("WoTNS");
98 identityManager.start();
100 resolver = new Resolver(identityManager);
102 webInterface = new WebInterface(this);
104 webInterface.start();
111 public void terminate() {
112 identityManager.stop();
113 webOfTrustConnector.stop();
119 // FREDPLUGINL10N METHODS
126 public String getString(String key) {
127 return l10n.getBase().getString(key);
134 public void setLanguage(LANGUAGE newLanguage) {
135 l10n = new PluginL10n(this, newLanguage);
139 // FREDPLUGINBASEL10N METHODS
146 public String getL10nFilesBasePath() {
154 public String getL10nFilesMask() {
155 return "WoTNS.${lang}.properties";
162 public String getL10nOverrideFilesMask() {
163 return "WoTNS.${lang}.override.properties";
170 public ClassLoader getPluginClassLoader() {
171 return WoTNSPlugin.class.getClassLoader();
175 // FREDPLUGINVERSIONED METHODS
182 public String getVersion() {
183 return VERSION.toString();