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;
38 * Main plugin class for Web of Trust Name Service.
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 /** The current version of the plugin. */
50 private static final Version VERSION = new Version(0, 0, 7);
52 /** The plugin respirator. */
53 private PluginRespirator pluginRespirator;
55 /** The l10n handler. */
56 private PluginL10n l10n;
58 /** The web interface. */
59 private WebInterface webInterface;
62 private Resolver resolver;
64 /** The web of trust connector. */
65 private WebOfTrustConnector webOfTrustConnector;
67 /** The identity manager. */
68 private IdentityManager identityManager;
75 * Returns the high-level simple client for the node.
77 * @return The high-level simple client
79 public HighLevelSimpleClient getHighLevelSimpleClient() {
80 return pluginRespirator.getHLSimpleClient();
84 * Returns the toadlet container of the node.
86 * @return The toadlet container of the node
88 public ToadletContainer getToadletContainer() {
89 return pluginRespirator.getToadletContainer();
93 * Returns the identity manager.
95 * @return The identity manager
97 public IdentityManager getIdentityManager() {
98 return identityManager;
102 * Returns the resolver.
104 * @return The resolver
106 public Resolver getResolver() {
111 // FREDPLUGIN METHODS
118 public void runPlugin(@SuppressWarnings("hiding") PluginRespirator pluginRespirator) {
119 this.pluginRespirator = pluginRespirator;
121 PluginConnector pluginConnector = new PluginConnector(pluginRespirator);
122 webOfTrustConnector = new WebOfTrustConnector(pluginConnector);
123 identityManager = new IdentityManager(webOfTrustConnector);
124 identityManager.setContext("WoTNS");
125 identityManager.start();
127 resolver = new Resolver(identityManager);
129 webInterface = new WebInterface(this);
131 webInterface.start();
138 public void terminate() {
139 identityManager.stop();
140 webOfTrustConnector.stop();
146 // FREDPLUGINL10N METHODS
153 public String getString(String key) {
154 return l10n.getBase().getString(key);
161 public void setLanguage(LANGUAGE newLanguage) {
162 l10n = new PluginL10n(this, newLanguage);
166 // FREDPLUGINBASEL10N METHODS
173 public String getL10nFilesBasePath() {
181 public String getL10nFilesMask() {
182 return "WoTNS.${lang}.properties";
189 public String getL10nOverrideFilesMask() {
190 return "WoTNS.${lang}.override.properties";
197 public ClassLoader getPluginClassLoader() {
198 return WoTNSPlugin.class.getClassLoader();
202 // FREDPLUGINVERSIONED METHODS
209 public String getVersion() {
210 return VERSION.toString();