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, 4);
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);
101 resolver.setOwnIdentityId("e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U");
103 webInterface = new WebInterface(this);
105 webInterface.start();
112 public void terminate() {
113 identityManager.stop();
114 webOfTrustConnector.stop();
120 // FREDPLUGINL10N METHODS
127 public String getString(String key) {
128 return l10n.getBase().getString(key);
135 public void setLanguage(LANGUAGE newLanguage) {
136 l10n = new PluginL10n(this, newLanguage);
140 // FREDPLUGINBASEL10N METHODS
147 public String getL10nFilesBasePath() {
155 public String getL10nFilesMask() {
156 return "WoTNS.${lang}.properties";
163 public String getL10nOverrideFilesMask() {
164 return "WoTNS.${lang}.override.properties";
171 public ClassLoader getPluginClassLoader() {
172 return WoTNSPlugin.class.getClassLoader();
176 // FREDPLUGINVERSIONED METHODS
183 public String getVersion() {
184 return VERSION.toString();