From 47277063e4e1a5d499482361111952be0efad728 Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 23 Mar 2017 13:54:02 +0000 Subject: [PATCH] Plugins: Add version number to console messages when downloading/starting, and linkify plugin name --- .../i2p/router/update/PluginUpdateRunner.java | 18 +++++++++--------- .../i2p/router/web/ConfigClientsHandler.java | 13 ++++++++++++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/update/PluginUpdateRunner.java b/apps/routerconsole/java/src/net/i2p/router/update/PluginUpdateRunner.java index 44847b1b9..b4a7493b7 100644 --- a/apps/routerconsole/java/src/net/i2p/router/update/PluginUpdateRunner.java +++ b/apps/routerconsole/java/src/net/i2p/router/update/PluginUpdateRunner.java @@ -480,7 +480,7 @@ class PluginUpdateRunner extends UpdateRunner { } // we don't need the original file anymore. to.delete(); - statusDone("" + _t("Plugin will be installed on next restart.") + ""); + statusDone("" + _t("Plugin will be installed on next restart.") + ' ' + appName + ' ' + version + ""); return; } if (PluginStarter.isPluginRunning(appName, _context)) { @@ -498,7 +498,7 @@ class PluginUpdateRunner extends UpdateRunner { } else { if (Boolean.valueOf(props.getProperty("update-only")).booleanValue()) { to.delete(); - statusDone("" + _t("Plugin is for upgrades only, but the plugin is not installed") + ""); + statusDone("" + _t("Plugin is for upgrades only, but the plugin is not installed") + ". " + appName + ' ' + version + ""); return; } if (!destDir.mkdir()) { @@ -518,7 +518,7 @@ class PluginUpdateRunner extends UpdateRunner { to.delete(); // install != update. Changing the user's settings like this is probabbly a bad idea. if (Boolean.valueOf( props.getProperty("dont-start-at-install")).booleanValue()) { - statusDone("" + _t("Plugin {0} installed", appName) + ""); + statusDone("" + _t("Plugin {0} installed", appName + ' ' + version) + ""); if(!update) { Properties pluginProps = PluginStarter.pluginProperties(); pluginProps.setProperty(PluginStarter.PREFIX + appName + PluginStarter.ENABLED, "false"); @@ -534,19 +534,19 @@ class PluginUpdateRunner extends UpdateRunner { String linkURL = ConfigClientsHelper.stripHTML(props, "consoleLinkURL"); String link; if (linkName != null && linkURL != null) - link = "" + linkName + ""; + link = "" + linkName + ' ' + version + ""; else - link = appName; + link = appName + ' ' + version; statusDone("" + _t("Plugin {0} installed and started", link) + ""); } else - statusDone("" + _t("Plugin {0} installed but failed to start, check logs", appName) + ""); + statusDone("" + _t("Plugin {0} installed but failed to start, check logs", appName + ' ' + version) + ""); } catch (Throwable e) { - statusDone("" + _t("Plugin {0} installed but failed to start", appName) + ": " + e + ""); - _log.error("Error starting plugin " + appName, e); + statusDone("" + _t("Plugin {0} installed but failed to start", appName + ' ' + version) + ": " + e + ""); + _log.error("Error starting plugin " + appName + ' ' + version, e); } } else { - statusDone("" + _t("Plugin {0} installed", appName) + ""); + statusDone("" + _t("Plugin {0} installed", appName + ' ' + version) + ""); } } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java index 4cdf13e35..a40c64531 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java @@ -573,7 +573,18 @@ public class ConfigClientsHandler extends FormHandler { private void startPlugin(String app) { try { PluginStarter.startPlugin(_context, app); - addFormNotice(_t("Started plugin {0}", app)); + // linkify the app name for the message if available + Properties props = PluginStarter.pluginProperties(_context, app); + String name = ConfigClientsHelper.stripHTML(props, "consoleLinkName_" + Messages.getLanguage(_context)); + if (name == null) + name = ConfigClientsHelper.stripHTML(props, "consoleLinkName"); + String url = ConfigClientsHelper.stripHTML(props, "consoleLinkURL"); + if (name != null && url != null && name.length() > 0 && url.length() > 0) { + app = "" + name + ""; + addFormNoticeNoEscape(_t("Started plugin {0}", app)); + } else { + addFormNotice(_t("Started plugin {0}", app)); + } } catch (Throwable e) { addFormError(_t("Error starting plugin {0}", app) + ": " + e); _log.error("Error starting plugin " + app, e);