From fc393619d8ac47e09f12f4588488cd89ec26bf32 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Tue, 10 Mar 2020 17:47:08 +0000 Subject: [PATCH] options for feeds --- .../com/muwire/core/MuWireSettings.groovy | 24 +++++++++++++ .../com/muwire/gui/OptionsController.groovy | 31 ++++++++++++++++ .../models/com/muwire/gui/OptionsModel.groovy | 17 +++++++++ .../views/com/muwire/gui/OptionsView.groovy | 36 +++++++++++++++++++ 4 files changed, 108 insertions(+) diff --git a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy index 073d79a5..03d2b154 100644 --- a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy +++ b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy @@ -31,8 +31,16 @@ class MuWireSettings { boolean shareHiddenFiles boolean searchComments boolean browseFiles + boolean fileFeed boolean advertiseFeed + boolean autoPublishSharedFiles + boolean defaultFeedAutoDownload + int defaultFeedUpdateInterval + int defaultFeedItemsToKeep + boolean defaultFeedSequential + + boolean startChatServer int maxChatConnections boolean advertiseChat @@ -84,8 +92,16 @@ class MuWireSettings { outBw = Integer.valueOf(props.getProperty("outBw","128")) searchComments = Boolean.valueOf(props.getProperty("searchComments","true")) browseFiles = Boolean.valueOf(props.getProperty("browseFiles","true")) + + // feed settings fileFeed = Boolean.valueOf(props.getProperty("fileFeed","true")) advertiseFeed = Boolean.valueOf(props.getProperty("advertiseFeed","true")) + autoPublishSharedFiles = Boolean.valueOf(props.getProperty("autoPublishSharedFiles", "false")) + defaultFeedAutoDownload = Boolean.valueOf(props.getProperty("defaultFeedAutoDownload", "false")) + defaultFeedItemsToKeep = Integer.valueOf(props.getProperty("defaultFeedItemsToKeep", "1000")) + defaultFeedSequential = Boolean.valueOf(props.getProperty("defaultFeedSequential", "false")) + defaultFeedUpdateInterval = Integer.valueOf(props.getProperty("defaultFeedUpdateInterval", "60")) + speedSmoothSeconds = Integer.valueOf(props.getProperty("speedSmoothSeconds","60")) totalUploadSlots = Integer.valueOf(props.getProperty("totalUploadSlots","-1")) uploadSlotsPerUser = Integer.valueOf(props.getProperty("uploadSlotsPerUser","-1")) @@ -141,8 +157,16 @@ class MuWireSettings { props.setProperty("outBw", String.valueOf(outBw)) props.setProperty("searchComments", String.valueOf(searchComments)) props.setProperty("browseFiles", String.valueOf(browseFiles)) + + // feed settings props.setProperty("fileFeed", String.valueOf(fileFeed)) props.setProperty("advertiseFeed", String.valueOf(advertiseFeed)) + props.setProperty("autoPublishSharedFiles", String.valueOf(autoPublishSharedFiles)) + props.setProperty("defaultFeedAutoDownload", String.valueOf(defaultFeedAutoDownload)) + props.setProperty("defaultFeedItemsToKeep", String.valueOf(defaultFeedItemsToKeep)) + props.setProperty("defaultFeedSequential", String.valueOf(defaultFeedSequential)) + props.setProperty("defaultFeedUpdateInterval", String.valueOf(defaultFeedUpdateInterval)) + props.setProperty("speedSmoothSeconds", String.valueOf(speedSmoothSeconds)) props.setProperty("totalUploadSlots", String.valueOf(totalUploadSlots)) props.setProperty("uploadSlotsPerUser", String.valueOf(uploadSlotsPerUser)) diff --git a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy index 17b854a9..2d5ce460 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy @@ -122,7 +122,38 @@ class OptionsController { model.outBw = text settings.outBw = Integer.valueOf(text) } + + // feed saving + + boolean fileFeed = view.fileFeedCheckbox.model.isSelected() + model.fileFeed = fileFeed + settings.fileFeed = fileFeed + + boolean advertiseFeed = view.advertiseFeedCheckbox.model.isSelected() + model.advertiseFeed = advertiseFeed + settings.advertiseFeed = advertiseFeed + + boolean autoPublishSharedFiles = view.autoPublishSharedFilesCheckbox.model.isSelected() + model.autoPublishSharedFiles = autoPublishSharedFiles + settings.autoPublishSharedFiles = autoPublishSharedFiles + + boolean defaultFeedAutoDownload = view.defaultFeedAutoDownloadCheckbox.model.isSelected() + model.defaultFeedAutoDownload = defaultFeedAutoDownload + settings.defaultFeedAutoDownload = defaultFeedAutoDownload + + boolean defaultFeedSequential = view.defaultFeedSequentialCheckbox.model.isSelected() + model.defaultFeedSequential = defaultFeedSequential + settings.defaultFeedSequential = defaultFeedSequential + + String defaultFeedItemsToKeep = view.defaultFeedItemsToKeepField.text + model.defaultFeedItemsToKeep = defaultFeedItemsToKeep + settings.defaultFeedItemsToKeep = Integer.parseInt(defaultFeedItemsToKeep) + + String defaultFeedUpdateInterval = view.defaultFeedUpdateIntervalField.text + model.defaultFeedUpdateInterval = defaultFeedUpdateInterval + settings.defaultFeedUpdateInterval = Integer.parseInt(defaultFeedUpdateInterval) + // trust saving boolean onlyTrusted = view.allowUntrustedCheckbox.model.isSelected() model.onlyTrusted = onlyTrusted diff --git a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy index 6e0c6eaf..b0f62bc6 100644 --- a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy @@ -50,6 +50,15 @@ class OptionsModel { @Observable String inBw @Observable String outBw + // feed options + @Observable boolean fileFeed + @Observable boolean advertiseFeed + @Observable boolean autoPublishSharedFiles + @Observable boolean defaultFeedAutoDownload + @Observable String defaultFeedItemsToKeep + @Observable boolean defaultFeedSequential + @Observable String defaultFeedUpdateInterval + // trust options @Observable boolean onlyTrusted @Observable boolean searchExtraHop @@ -105,6 +114,14 @@ class OptionsModel { inBw = String.valueOf(settings.inBw) outBw = String.valueOf(settings.outBw) } + + fileFeed = settings.fileFeed + advertiseFeed = settings.advertiseFeed + autoPublishSharedFiles = settings.autoPublishSharedFiles + defaultFeedAutoDownload = settings.defaultFeedAutoDownload + defaultFeedItemsToKeep = String.valueOf(settings.defaultFeedItemsToKeep) + defaultFeedSequential = settings.defaultFeedSequential + defaultFeedUpdateInterval = String.valueOf(settings.defaultFeedUpdateInterval) onlyTrusted = !settings.allowUntrusted() searchExtraHop = settings.searchExtraHop diff --git a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy index 3ab4464a..5054232a 100644 --- a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy @@ -32,6 +32,7 @@ class OptionsView { def i def u def bandwidth + def feed def trust def chat @@ -66,6 +67,14 @@ class OptionsView { def inBwField def outBwField + + def fileFeedCheckbox + def advertiseFeedCheckbox + def autoPublishSharedFilesCheckbox + def defaultFeedAutoDownloadCheckbox + def defaultFeedItemsToKeepField + def defaultFeedSequentialCheckbox + def defaultFeedUpdateIntervalField def allowUntrustedCheckbox def searchExtraHopCheckbox @@ -257,6 +266,32 @@ class OptionsView { } panel(constraints : gbc(gridx: 0, gridy: 1, weighty: 100)) } + feed = builder.panel { + gridBagLayout() + panel (border : titledBorder(title : "General Feed Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP), + constraints : gbc(gridx : 0, gridy : 0, fill : GridBagConstraints.HORIZONTAL, weightx: 100)) { + gridBagLayout() + label(text : "Enable file feed", constraints : gbc(gridx: 0, gridy : 0, anchor : GridBagConstraints.LINE_START, weightx: 100)) + fileFeedCheckbox = checkBox(selected : bind {model.fileFeed}, constraints : gbc(gridx: 1, gridy : 0, anchor : GridBagConstraints.LINE_END)) + label(text : "Advertise feed in search results", constraints : gbc(gridx: 0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx: 100)) + advertiseFeedCheckbox = checkBox(selected : bind {model.advertiseFeed}, constraints : gbc(gridx: 1, gridy : 1, anchor : GridBagConstraints.LINE_END)) + label(text : "Automatically publish shared files", constraints : gbc(gridx: 0, gridy : 2, anchor : GridBagConstraints.LINE_START, weightx: 100)) + autoPublishSharedFilesCheckbox = checkBox(selected : bind {model.autoPublishSharedFiles}, constraints : gbc(gridx: 1, gridy : 2, anchor : GridBagConstraints.LINE_END)) + } + panel (border : titledBorder(title : "Default Settings For New Feeds", border : etchedBorder(), titlePosition : TitledBorder.TOP), + constraints : gbc(gridx : 0, gridy : 1, fill : GridBagConstraints.HORIZONTAL, weightx: 100)) { + gridBagLayout() + label(text : "Automatically download files from feed", constraints : gbc(gridx: 0, gridy : 0, anchor : GridBagConstraints.LINE_START, weightx: 100)) + defaultFeedAutoDownloadCheckbox = checkBox(selected : bind {model.defaultFeedAutoDownload}, constraints : gbc(gridx: 1, gridy : 0, anchor : GridBagConstraints.LINE_END)) + label(text : "Download files from feed sequentially", constraints : gbc(gridx: 0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx: 100)) + defaultFeedSequentialCheckbox = checkBox(selected : bind {model.defaultFeedSequential}, constraints : gbc(gridx: 1, gridy : 1, anchor : GridBagConstraints.LINE_END)) + label(text : "Feed items to store on disk (-1 means unlimited)", constraints : gbc(gridx: 0, gridy : 2, anchor : GridBagConstraints.LINE_START, weightx: 100)) + defaultFeedItemsToKeepField = textField(text : bind {model.defaultFeedItemsToKeep}, constraints:gbc(gridx :1, gridy:2, anchor : GridBagConstraints.LINE_END)) + label(text : "Feed refresh frequency in minutes", constraints : gbc(gridx: 0, gridy : 3, anchor : GridBagConstraints.LINE_START, weightx: 100)) + defaultFeedUpdateIntervalField = textField(text : bind {model.defaultFeedUpdateInterval}, constraints:gbc(gridx :1, gridy:3, anchor : GridBagConstraints.LINE_END)) + } + panel(constraints : gbc(gridx: 0, gridy : 2, weighty: 100)) + } trust = builder.panel { gridBagLayout() panel (border : titledBorder(title : "Trust Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP), @@ -311,6 +346,7 @@ class OptionsView { if (core.router != null) { tabbedPane.addTab("Bandwidth", bandwidth) } + tabbedPane.addTab("Feed", feed) tabbedPane.addTab("Trust", trust) tabbedPane.addTab("Chat", chat)