diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index c1e1a5b7..9e91078f 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -225,6 +225,7 @@ public class Core { routerProps.setProperty("router.excludePeerCaps", i2pOptions["router.excludePeerCaps"]) routerProps.setProperty("i2np.inboundKBytesPerSecond", String.valueOf(props.inBw)) routerProps.setProperty("i2np.outboundKBytesPerSecond", String.valueOf(props.outBw)) + routerProps.setProperty("router.sharePercentage", String.valueOf(props.sharePercentage)) routerProps.setProperty("i2cp.disableInterface", "true") routerProps.setProperty("i2np.ntcp.nodelay", "true") routerProps.setProperty("router.encType","4") diff --git a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy index fa7da47b..e3c8be86 100644 --- a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy +++ b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy @@ -72,7 +72,10 @@ class MuWireSettings { boolean embeddedRouter boolean plugin boolean disableUpdates + int inBw, outBw + int sharePercentage + Set watchedKeywords Set watchedRegexes Set negativeFileTree @@ -117,6 +120,7 @@ class MuWireSettings { disableUpdates = Boolean.valueOf(props.getProperty("disableUpdates","false")) inBw = Integer.valueOf(props.getProperty("inBw","256")) outBw = Integer.valueOf(props.getProperty("outBw","128")) + sharePercentage = Integer.valueOf(props.getProperty("sharePercentage","80")) searchComments = Boolean.valueOf(props.getProperty("searchComments","true")) searchCollections = Boolean.valueOf(props.getProperty("searchCollections","true")) browseFiles = Boolean.valueOf(props.getProperty("browseFiles","true")) @@ -213,6 +217,7 @@ class MuWireSettings { props.setProperty("disableUpdates", String.valueOf(disableUpdates)) props.setProperty("inBw", String.valueOf(inBw)) props.setProperty("outBw", String.valueOf(outBw)) + props.setProperty("sharePercentage", String.valueOf(sharePercentage)) props.setProperty("searchComments", String.valueOf(searchComments)) props.setProperty("searchCollections", String.valueOf(searchCollections)) props.setProperty("browseFiles", String.valueOf(browseFiles)) diff --git a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy index 2f386450..e0eeccf1 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy @@ -149,6 +149,9 @@ class OptionsController { text = view.outBwField.text model.outBw = text settings.outBw = Integer.valueOf(text) + int sharePercentage = view.sharePercentageSlider.value + model.sharePercentage = sharePercentage + settings.sharePercentage = sharePercentage } // feed saving diff --git a/gui/griffon-app/i18n/messages.properties b/gui/griffon-app/i18n/messages.properties index e631aeec..e977cab5 100644 --- a/gui/griffon-app/i18n/messages.properties +++ b/gui/griffon-app/i18n/messages.properties @@ -43,6 +43,7 @@ UDP_PORT=UDP port BANDWIDTH_SETTINGS=Bandwidth Settings INBOUND_BANDWIDTH=Inbound Bandwidth (KB) OUTBOUND_BANDWIDTH=Outbound Bandwidth (KB) +SHARE_PERCENTAGE=Percent of bandwidth to share INVALID_UDP_PORT=Invalid UDP Port INVALID_TCP_PORT=Invalid TCP Port INVALID_PORT=Invalid Port diff --git a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy index 2cbd4f8f..454d3f97 100644 --- a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy @@ -61,6 +61,7 @@ class OptionsModel { // bw options @Observable String inBw @Observable String outBw + @Observable int sharePercentage // feed options @Observable boolean fileFeed @@ -148,6 +149,7 @@ class OptionsModel { if (core.router != null) { inBw = String.valueOf(settings.inBw) outBw = String.valueOf(settings.outBw) + sharePercentage = settings.sharePercentage } fileFeed = settings.fileFeed diff --git a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy index 39351f46..f5db63d2 100644 --- a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy @@ -81,6 +81,7 @@ class OptionsView { def inBwField def outBwField + def sharePercentageSlider def fileFeedCheckbox def advertiseFeedCheckbox @@ -336,6 +337,14 @@ class OptionsView { inBwField = textField(text : bind {model.inBw}, columns : 3, constraints : gbc(gridx : 1, gridy : 0, anchor : GridBagConstraints.LINE_END)) label(text : trans("OUTBOUND_BANDWIDTH"), constraints : gbc(gridx: 0, gridy : 1, anchor : GridBagConstraints.LINE_START, weightx : 100)) outBwField = textField(text : bind {model.outBw}, columns : 3, constraints : gbc(gridx : 1, gridy : 1, anchor : GridBagConstraints.LINE_END)) + label(text : trans("SHARE_PERCENTAGE"), constraints: gbc(gridx: 0, gridy: 2, anchor: GridBagConstraints.LINE_START, weightx: 50)) + def quantityTable = new Hashtable() + quantityTable.put(0, new JLabel("0")) + quantityTable.put(50, new JLabel("50")) + quantityTable.put(100, new JLabel("100")) + sharePercentageSlider = slider(minimum : 0, maximum : 100, value : bind {model.sharePercentage}, + majorTickSpacing : 5, snapToTicks : true, paintTicks: true, labelTable : quantityTable, + paintLabels : true, constraints: gbc(gridx: 1, gridy: 2, anchor: GridBagConstraints.LINE_END, weightx: 50)) } panel(constraints : gbc(gridx: 0, gridy: 1, weighty: 100)) }