X-Git-Url: https://git.pterodactylus.net/?p=WoTNS.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fwotns%2Fmain%2FWoTNSPlugin.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fwotns%2Fmain%2FWoTNSPlugin.java;h=f3ec6d45e4ead8f852e60a504f2d3d530f448608;hp=0000000000000000000000000000000000000000;hb=622c4a4d3ebed447d5708a41cf3e1e82e18fa29b;hpb=77869390c46e8e5eff63bf00c7ef44a37ba8f317 diff --git a/src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java b/src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java new file mode 100644 index 0000000..f3ec6d4 --- /dev/null +++ b/src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java @@ -0,0 +1,189 @@ +/* + * WoTNS - WoTNSPlugin.java - Copyright © 2011 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.wotns.main; + +import net.pterodactylus.util.logging.Logging; +import net.pterodactylus.util.version.Version; +import net.pterodactylus.wotns.freenet.plugin.PluginConnector; +import net.pterodactylus.wotns.freenet.wot.IdentityManager; +import net.pterodactylus.wotns.freenet.wot.OwnIdentity; +import net.pterodactylus.wotns.freenet.wot.WebOfTrustConnector; +import net.pterodactylus.wotns.ui.web.WebInterface; +import freenet.client.HighLevelSimpleClient; +import freenet.clients.http.ToadletContainer; +import freenet.l10n.PluginL10n; +import freenet.l10n.BaseL10n.LANGUAGE; +import freenet.pluginmanager.FredPlugin; +import freenet.pluginmanager.FredPluginBaseL10n; +import freenet.pluginmanager.FredPluginL10n; +import freenet.pluginmanager.FredPluginThreadless; +import freenet.pluginmanager.FredPluginVersioned; +import freenet.pluginmanager.PluginRespirator; + +/** + * TODO + * + * @author David ‘Bombe’ Roden + */ +public class WoTNSPlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10n, FredPluginVersioned, FredPluginThreadless { + + static { + Logging.setup("WoTNS"); + Logging.setupConsoleLogging(); + } + + private static final Version VERSION = new Version(0, 1); + + private PluginRespirator pluginRespirator; + + private PluginL10n l10n; + + private WebInterface webInterface; + + private Resolver resolver; + + private WebOfTrustConnector webOfTrustConnector; + + private IdentityManager identityManager; + + // + // ACCESSORS + // + + public HighLevelSimpleClient getHighLevelSimpleClient() { + return pluginRespirator.getHLSimpleClient(); + } + + public ToadletContainer getToadletContainer() { + return pluginRespirator.getToadletContainer(); + } + + public IdentityManager getIdentityManager() { + return identityManager; + } + + public Resolver getResolver() { + return resolver; + } + + // + // FREDPLUGIN METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public void runPlugin(PluginRespirator pluginRespirator) { + this.pluginRespirator = pluginRespirator; + + PluginConnector pluginConnector = new PluginConnector(pluginRespirator); + webOfTrustConnector = new WebOfTrustConnector(pluginConnector); + identityManager = new IdentityManager(webOfTrustConnector); +// identityManager.setContext("WoTNS"); + identityManager.start(); + + resolver = new Resolver(identityManager); + OwnIdentity bombeIdentity = identityManager.getOwnIdentity("e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U"); + resolver.setOwnIdentity(bombeIdentity); + + webInterface = new WebInterface(this); + + webInterface.start(); + } + + /** + * {@inheritDoc} + */ + @Override + public void terminate() { + identityManager.stop(); + webOfTrustConnector.stop(); + webInterface.stop(); + Logging.shutdown(); + } + + // + // FREDPLUGINL10N METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public String getString(String key) { + return l10n.getBase().getString(key); + } + + /** + * {@inheritDoc} + */ + @Override + public void setLanguage(LANGUAGE newLanguage) { + l10n = new PluginL10n(this, newLanguage); + } + + // + // FREDPLUGINBASEL10N METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public String getL10nFilesBasePath() { + return "i18n"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getL10nFilesMask() { + return "WoTNS.${lang}.properties"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getL10nOverrideFilesMask() { + return "WoTNS.${lang}.override.properties"; + } + + /** + * {@inheritDoc} + */ + @Override + public ClassLoader getPluginClassLoader() { + return WoTNSPlugin.class.getClassLoader(); + } + + // + // FREDPLUGINVERSIONED METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return VERSION.toString(); + } + +}