From: David ‘Bombe’ Roden Date: Sun, 12 Dec 2010 13:33:13 +0000 (+0100) Subject: Add notification if the config file can not be read. X-Git-Tag: beta-freefall-0.6.2-1~197^2~7 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a7289fbfa428ebc9c1facb48be08587feb0ee489;p=Sone.git Add notification if the config file can not be read. --- diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index ca629fa..a24802b 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -148,10 +148,12 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 Configuration oldConfiguration; Configuration newConfiguration = null; boolean firstStart = !new File("sone.properties").exists(); + boolean newConfig = false; try { oldConfiguration = new Configuration(new MapConfigurationBackend(new File("sone.properties"), false)); newConfiguration = oldConfiguration; } catch (ConfigurationException ce1) { + newConfig = true; logger.log(Level.INFO, "Could not load configuration file, trying plugin store…", ce1); try { newConfiguration = new Configuration(new MapConfigurationBackend(new File("sone.properties"), true)); @@ -183,6 +185,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 /* create the web interface. */ webInterface = new WebInterface(this); webInterface.setFirstStart(firstStart); + webInterface.setNewConfig(newConfig); core.addCoreListener(webInterface); /* create the identity manager. */ diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 0e7905d..5865f1d 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -261,6 +261,21 @@ public class WebInterface implements CoreListener { } } + /** + * Sets whether Sone was started with a fresh configuration file. + * + * @param newConfig + * {@code true} if Sone was started with a fresh configuration, + * {@code false} if the existing configuration could be read + */ + public void setNewConfig(boolean newConfig) { + if (newConfig && (notificationManager.getNotification("first-start-notification") == null)) { + Template configNotReadNotificationTemplate = new Template(createReader("/templates/notify/configNotReadNotification.html")); + Notification configNotReadNotification = new TemplateNotification("config-not-read-notification", configNotReadNotificationTemplate); + notificationManager.addNotification(configNotReadNotification); + } + } + // // ACTIONS // diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 1a69477..89af2d1 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -178,6 +178,7 @@ WebInterface.ClickToShow.Replies=Click here to show hidden replies. Notification.FirstStart.Text=This seems to be the first time you start Sone. To start, create a new Sone from a web of trust identity and start following other Sones. Notification.Startup.Text=Sone is currently starting up. It may take a while to retrieve all identities and Sones from the web of trust. If you are missing some elements, please be patient, they will probably reappear very soon. +Notification.ConfigNotRead.Text=The configuration file “sone.properties” could not be read, probably because it was not saved correctly. This can happen on versions prior to Sone 0.3.3 and there is nothing you can do about it. Notification.Button.Dismiss=Dismiss Notification.NewSone.Text=New Sones have been discovered: Notification.NewPost.Text=New posts have been discovered by the following Sones: diff --git a/src/main/resources/templates/notify/configNotReadNotification.html b/src/main/resources/templates/notify/configNotReadNotification.html new file mode 100644 index 0000000..3de81a4 --- /dev/null +++ b/src/main/resources/templates/notify/configNotReadNotification.html @@ -0,0 +1 @@ +
<%= Notification.ConfigNotRead.Text|l10n|html>