From eb2005d35011fd20e044f99cc49be126f31c8373 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 25 Oct 2010 08:22:17 +0200 Subject: [PATCH] Add options to clear the configuration on next restart. --- src/main/java/net/pterodactylus/sone/core/Core.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 21d7a80..49cbc8a 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -615,6 +615,7 @@ public class Core extends AbstractService { /** * Loads the configuration. */ + @SuppressWarnings("unchecked") private void loadConfiguration() { logger.entering(Core.class.getName(), "loadConfiguration()"); @@ -627,6 +628,17 @@ public class Core extends AbstractService { })).set(configuration.getIntValue("Option/InsertionDelay").getValue(null)); + options.addBooleanOption("ClearOnNextRestart", new DefaultOption(false)).set(configuration.getBooleanValue("Option/ClearOnNextRestart").getValue(null)); + options.addBooleanOption("ReallyClearOnNextRestart", new DefaultOption(false)).set(configuration.getBooleanValue("Option/ReallyClearOnNextRestart").getValue(null)); + + boolean clearConfiguration = options.getBooleanOption("ClearOnNextRestart").get() && options.getBooleanOption("ReallyClearOnNextRestart").get(); + options.getBooleanOption("ClearOnNextRestart").set(null); + options.getBooleanOption("ReallyClearOnNextRestart").set(null); + if (clearConfiguration) { + /* stop loading the configuration. */ + return; + } + /* parse local Sones. */ logger.log(Level.INFO, "Loading Sones…"); int soneId = 0; @@ -772,6 +784,8 @@ public class Core extends AbstractService { try { /* store the options first. */ configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal()); + configuration.getBooleanValue("Option/ClearOnNextRestart").setValue(options.getBooleanOption("ClearOnNextRestart").getReal()); + configuration.getBooleanValue("Option/ReallyClearOnNextRestart").setValue(options.getBooleanOption("ReallyClearOnNextRestart").getReal()); /* store all Sones. */ int soneId = 0; -- 2.7.4