From 72985bacb62c381cd64e4ebc12c5bd0e8a34224f Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 26 Sep 2020 17:53:29 +0100 Subject: [PATCH] add ability to disable updates completely, intended for 3rd party packaging --- core/src/main/groovy/com/muwire/core/Core.groovy | 4 ++-- .../groovy/com/muwire/core/MuWireSettings.groovy | 3 +++ gui/griffon-app/lifecycle/Ready.groovy | 4 ++++ .../models/com/muwire/gui/OptionsModel.groovy | 4 ++++ .../views/com/muwire/gui/OptionsView.groovy | 14 ++++++++------ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 7f8874a1..54f72415 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -329,13 +329,13 @@ public class Core { log.info("initializing cache client") cacheClient = new CacheClient(eventBus,hostCache, connectionManager, i2pSession, props, 10000) - if (!props.plugin) { + if (!(props.plugin || props.disableUpdates)) { log.info("initializing update client") updateClient = new UpdateClient(eventBus, i2pSession, myVersion, props, fileManager, me, spk) eventBus.register(FileDownloadedEvent.class, updateClient) eventBus.register(UIResultBatchEvent.class, updateClient) } else - log.info("running as plugin, not initializing update client") + log.info("running as plugin or updates disabled, not initializing update client") log.info("initializing connector") I2PConnector i2pConnector = new I2PConnector(i2pSocketManager) diff --git a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy index 9c184bc6..41da7435 100644 --- a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy +++ b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy @@ -57,6 +57,7 @@ class MuWireSettings { int speedSmoothSeconds boolean embeddedRouter boolean plugin + boolean disableUpdates int inBw, outBw Set watchedKeywords Set watchedRegexes @@ -95,6 +96,7 @@ class MuWireSettings { meshExpiration = Integer.valueOf(props.getProperty("meshExpiration","60")) embeddedRouter = Boolean.valueOf(props.getProperty("embeddedRouter","false")) plugin = Boolean.valueOf(props.getProperty("plugin","false")) + disableUpdates = Boolean.valueOf(props.getProperty("disableUpdates","false")) inBw = Integer.valueOf(props.getProperty("inBw","256")) outBw = Integer.valueOf(props.getProperty("outBw","128")) searchComments = Boolean.valueOf(props.getProperty("searchComments","true")) @@ -170,6 +172,7 @@ class MuWireSettings { props.setProperty("meshExpiration", String.valueOf(meshExpiration)) props.setProperty("embeddedRouter", String.valueOf(embeddedRouter)) props.setProperty("plugin", String.valueOf(plugin)) + props.setProperty("disableUpdates", String.valueOf(disableUpdates)) props.setProperty("inBw", String.valueOf(inBw)) props.setProperty("outBw", String.valueOf(outBw)) props.setProperty("searchComments", String.valueOf(searchComments)) diff --git a/gui/griffon-app/lifecycle/Ready.groovy b/gui/griffon-app/lifecycle/Ready.groovy index 577afd9e..03808d93 100644 --- a/gui/griffon-app/lifecycle/Ready.groovy +++ b/gui/griffon-app/lifecycle/Ready.groovy @@ -50,6 +50,9 @@ class Ready extends AbstractLifecycleHandler { props = new MuWireSettings(props) if (props.incompleteLocation == null) props.incompleteLocation = new File(home, "incompletes") + + if (System.getProperties().containsKey("disableUpdates")) + props.disableUpdates = Boolean.valueOf(System.getProperty("disableUpdates")) } else { log.info("creating new properties") props = new MuWireSettings() @@ -88,6 +91,7 @@ class Ready extends AbstractLifecycleHandler { props.embeddedRouter = embeddedRouterAvailable props.updateType = System.getProperty("updateType","jar") + props.disableUpdates = Boolean.parseBoolean(System.getProperty("disableUpdates", "false")) propsFile.withPrintWriter("UTF-8", { diff --git a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy index 16048007..2b4aebb7 100644 --- a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy @@ -75,6 +75,8 @@ class OptionsModel { @Observable boolean advertiseChat @Observable int maxChatLines @Observable String chatWelcomeFile + + boolean disableUpdates void mvcGroupInit(Map args) { MuWireSettings settings = application.context.get("muwire-settings") @@ -139,5 +141,7 @@ class OptionsModel { advertiseChat = settings.advertiseChat maxChatLines = uiSettings.maxChatLines chatWelcomeFile = settings.chatWelcomeFile?.getAbsolutePath() + + disableUpdates = settings.disableUpdates } } \ No newline at end of file diff --git a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy index ad9414d1..1e35fb10 100644 --- a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy @@ -158,16 +158,18 @@ class OptionsView { shareHiddenCheckbox = checkBox(selected : bind {model.shareHiddenFiles}, constraints : gbc(gridx :1, gridy:1, weightx : 0)) } - panel (border : titledBorder(title : "Update Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP, + if (!model.disableUpdates) { + panel (border : titledBorder(title : "Update Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP, constraints : gbc(gridx : 0, gridy : 4, fill : GridBagConstraints.HORIZONTAL))) { - gridBagLayout() - label(text : "Check for updates every (hours)", constraints : gbc(gridx : 0, gridy: 0, anchor : GridBagConstraints.LINE_START, weightx : 100)) - updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 0, weightx: 0)) + gridBagLayout() + label(text : "Check for updates every (hours)", constraints : gbc(gridx : 0, gridy: 0, anchor : GridBagConstraints.LINE_START, weightx : 100)) + updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 0, weightx: 0)) - label(text : "Download updates automatically", constraints: gbc(gridx :0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx: 100)) - autoDownloadUpdateCheckbox = checkBox(selected : bind {model.autoDownloadUpdate}, + label(text : "Download updates automatically", constraints: gbc(gridx :0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx: 100)) + autoDownloadUpdateCheckbox = checkBox(selected : bind {model.autoDownloadUpdate}, constraints : gbc(gridx:1, gridy : 1, anchor : GridBagConstraints.LINE_END)) + } } } i = builder.panel {