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.OwnIdentity;
25 import net.pterodactylus.wotns.freenet.wot.WebOfTrustConnector;
26 import net.pterodactylus.wotns.ui.web.WebInterface;
27 import freenet.client.HighLevelSimpleClient;
28 import freenet.clients.http.ToadletContainer;
29 import freenet.l10n.PluginL10n;
30 import freenet.l10n.BaseL10n.LANGUAGE;
31 import freenet.pluginmanager.FredPlugin;
32 import freenet.pluginmanager.FredPluginBaseL10n;
33 import freenet.pluginmanager.FredPluginL10n;
34 import freenet.pluginmanager.FredPluginThreadless;
35 import freenet.pluginmanager.FredPluginVersioned;
36 import freenet.pluginmanager.PluginRespirator;
41 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
43 public class WoTNSPlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10n, FredPluginVersioned, FredPluginThreadless {
46 Logging.setup("WoTNS");
47 Logging.setupConsoleLogging();
50 private static final Version VERSION = new Version(0, 1);
52 private PluginRespirator pluginRespirator;
54 private PluginL10n l10n;
56 private WebInterface webInterface;
58 private Resolver resolver;
60 private WebOfTrustConnector webOfTrustConnector;
62 private IdentityManager identityManager;
68 public HighLevelSimpleClient getHighLevelSimpleClient() {
69 return pluginRespirator.getHLSimpleClient();
72 public ToadletContainer getToadletContainer() {
73 return pluginRespirator.getToadletContainer();
76 public IdentityManager getIdentityManager() {
77 return identityManager;
80 public Resolver getResolver() {
92 public void runPlugin(PluginRespirator pluginRespirator) {
93 this.pluginRespirator = pluginRespirator;
95 PluginConnector pluginConnector = new PluginConnector(pluginRespirator);
96 webOfTrustConnector = new WebOfTrustConnector(pluginConnector);
97 identityManager = new IdentityManager(webOfTrustConnector);
98 // identityManager.setContext("WoTNS");
99 identityManager.start();
101 resolver = new Resolver(identityManager);
102 OwnIdentity bombeIdentity = identityManager.getOwnIdentity("e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U");
103 resolver.setOwnIdentity(bombeIdentity);
105 webInterface = new WebInterface(this);
107 webInterface.start();
114 public void terminate() {
115 identityManager.stop();
116 webOfTrustConnector.stop();
122 // FREDPLUGINL10N METHODS
129 public String getString(String key) {
130 return l10n.getBase().getString(key);
137 public void setLanguage(LANGUAGE newLanguage) {
138 l10n = new PluginL10n(this, newLanguage);
142 // FREDPLUGINBASEL10N METHODS
149 public String getL10nFilesBasePath() {
157 public String getL10nFilesMask() {
158 return "WoTNS.${lang}.properties";
165 public String getL10nOverrideFilesMask() {
166 return "WoTNS.${lang}.override.properties";
173 public ClassLoader getPluginClassLoader() {
174 return WoTNSPlugin.class.getClassLoader();
178 // FREDPLUGINVERSIONED METHODS
185 public String getVersion() {
186 return VERSION.toString();