diff --git a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy index 6dc90f6a..9c7dbc8e 100644 --- a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy +++ b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy @@ -24,6 +24,7 @@ class MuWireSettings { File downloadLocation CrawlerResponse crawlerResponse boolean shareDownloadedFiles + boolean searchComments Set watchedDirectories float downloadSequentialRatio int hostClearInterval, hostHopelessInterval, hostRejectInterval @@ -60,6 +61,7 @@ class MuWireSettings { embeddedRouter = Boolean.valueOf(props.getProperty("embeddedRouter","false")) inBw = Integer.valueOf(props.getProperty("inBw","256")) outBw = Integer.valueOf(props.getProperty("outBw","128")) + searchComments = Boolean.valueOf(props.getProperty("searchComments","true")) watchedDirectories = readEncodedSet(props, "watchedDirectories") watchedKeywords = readEncodedSet(props, "watchedKeywords") @@ -98,6 +100,7 @@ class MuWireSettings { props.setProperty("embeddedRouter", String.valueOf(embeddedRouter)) props.setProperty("inBw", String.valueOf(inBw)) props.setProperty("outBw", String.valueOf(outBw)) + props.setProperty("searchComments", String.valueOf(searchComments)) writeEncodedSet(watchedDirectories, "watchedDirectories", props) writeEncodedSet(watchedKeywords, "watchedKeywords", props) diff --git a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy index eaff57b8..9f470f8c 100644 --- a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy @@ -132,6 +132,7 @@ abstract class Connection implements Closeable { query.firstHop = e.firstHop query.keywords = e.searchEvent.getSearchTerms() query.oobInfohash = e.searchEvent.oobInfohash + query.searchComments = e.searchEvent.searchComments if (e.searchEvent.searchHash != null) query.infohash = Base64.encode(e.searchEvent.searchHash) query.replyTo = e.replyTo.toBase64() @@ -209,11 +210,15 @@ abstract class Connection implements Closeable { boolean oob = false if (search.oobInfohash != null) oob = search.oobInfohash + boolean searchComments = false + if (search.searchComments != null) + searchComments = search.searchComments SearchEvent searchEvent = new SearchEvent(searchTerms : search.keywords, searchHash : infohash, uuid : uuid, - oobInfohash : oob) + oobInfohash : oob, + searchComments : searchComments) QueryEvent event = new QueryEvent ( searchEvent : searchEvent, replyTo : replyTo, originator : originator, diff --git a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy index 74f75d74..7df2ffb3 100644 --- a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy +++ b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy @@ -165,7 +165,8 @@ class FileManager { Set files = new HashSet<>() names.each { files.addAll nameToFiles.getOrDefault(it, []) - files.addAll commentToFile.getOrDefault(it, []) + if (e.searchComments) + files.addAll commentToFile.getOrDefault(it, []) } Set sharedFiles = new HashSet<>() files.each { sharedFiles.add fileToSharedFile[it] } diff --git a/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy b/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy index b8b65cf9..0d1fea56 100644 --- a/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy @@ -9,11 +9,12 @@ class SearchEvent extends Event { byte [] searchHash UUID uuid boolean oobInfohash + boolean searchComments String toString() { def infoHash = null if (searchHash != null) infoHash = new InfoHash(searchHash) - "searchTerms: $searchTerms searchHash:$infoHash, uuid:$uuid oobInfohash:$oobInfohash" + "searchTerms: $searchTerms searchHash:$infoHash, uuid:$uuid oobInfohash:$oobInfohash searchComments:$searchComments" } } diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index dbbb7dd4..c4e9b087 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -85,7 +85,8 @@ class MainFrameController { def terms = replaced.split(" ") def nonEmpty = [] terms.each { if (it.length() > 0) nonEmpty << it } - searchEvent = new SearchEvent(searchTerms : nonEmpty, uuid : uuid, oobInfohash: true) + searchEvent = new SearchEvent(searchTerms : nonEmpty, uuid : uuid, oobInfohash: true, + searchComments : core.muOptions.searchComments) } boolean firstHop = core.muOptions.allowUntrusted || core.muOptions.searchExtraHop core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : firstHop, diff --git a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy index 81f886d6..af0fb93e 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy @@ -70,6 +70,10 @@ class OptionsController { model.updateCheckInterval = text settings.updateCheckInterval = Integer.valueOf(text) + boolean searchComments = view.searchCommentsCheckbox.model.isSelected() + model.searchComments = searchComments + settings.searchComments = searchComments + boolean autoDownloadUpdate = view.autoDownloadUpdateCheckbox.model.isSelected() model.autoDownloadUpdate = autoDownloadUpdate settings.autoDownloadUpdate = autoDownloadUpdate diff --git a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy index 634b2511..8dfc15f6 100644 --- a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy @@ -14,6 +14,7 @@ class OptionsModel { @Observable boolean autoDownloadUpdate @Observable boolean shareDownloadedFiles @Observable String downloadLocation + @Observable boolean searchComments // i2p options @Observable String inboundLength @@ -50,6 +51,7 @@ class OptionsModel { autoDownloadUpdate = settings.autoDownloadUpdate shareDownloadedFiles = settings.shareDownloadedFiles downloadLocation = settings.downloadLocation.getAbsolutePath() + searchComments = settings.searchComments Core core = application.context.get("core") inboundLength = core.i2pOptions["inbound.length"] diff --git a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy index 8c882b63..f99ecf63 100644 --- a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy @@ -35,6 +35,7 @@ class OptionsView { def updateField def autoDownloadUpdateCheckbox def shareDownloadedCheckbox + def searchCommentsCheckbox def inboundLengthField def inboundQuantityField @@ -69,23 +70,26 @@ class OptionsView { d.setResizable(false) p = builder.panel { gridBagLayout() - label(text : "Retry failed downloads every", constraints : gbc(gridx: 0, gridy: 0)) - retryField = textField(text : bind { model.downloadRetryInterval }, columns : 2, constraints : gbc(gridx: 1, gridy: 0)) - label(text : "seconds", constraints : gbc(gridx : 2, gridy: 0)) + label(text : "Search in comments", constraints:gbc(gridx: 0, gridy:0)) + searchCommentsCheckbox = checkBox(selected : bind {model.searchComments}, constraints : gbc(gridx:1, gridy:0)) + + label(text : "Retry failed downloads every", constraints : gbc(gridx: 0, gridy: 1)) + retryField = textField(text : bind { model.downloadRetryInterval }, columns : 2, constraints : gbc(gridx: 1, gridy: 1)) + label(text : "seconds", constraints : gbc(gridx : 2, gridy: 1)) - label(text : "Check for updates every", constraints : gbc(gridx : 0, gridy: 1)) - updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 1)) - label(text : "hours", constraints : gbc(gridx: 2, gridy : 1)) + label(text : "Check for updates every", constraints : gbc(gridx : 0, gridy: 2)) + updateField = textField(text : bind {model.updateCheckInterval }, columns : 2, constraints : gbc(gridx : 1, gridy: 2)) + label(text : "hours", constraints : gbc(gridx: 2, gridy : 2)) - label(text : "Download updates automatically", constraints: gbc(gridx :0, gridy : 2)) - autoDownloadUpdateCheckbox = checkBox(selected : bind {model.autoDownloadUpdate}, constraints : gbc(gridx:1, gridy : 2)) + label(text : "Download updates automatically", constraints: gbc(gridx :0, gridy : 3)) + autoDownloadUpdateCheckbox = checkBox(selected : bind {model.autoDownloadUpdate}, constraints : gbc(gridx:1, gridy : 3)) - label(text : "Share downloaded files", constraints : gbc(gridx : 0, gridy:3)) - shareDownloadedCheckbox = checkBox(selected : bind {model.shareDownloadedFiles}, constraints : gbc(gridx :1, gridy:3)) + label(text : "Share downloaded files", constraints : gbc(gridx : 0, gridy:4)) + shareDownloadedCheckbox = checkBox(selected : bind {model.shareDownloadedFiles}, constraints : gbc(gridx :1, gridy:4)) - label(text : "Save downloaded files to:", constraints: gbc(gridx:0, gridy:4)) - button(text : "Choose", constraints : gbc(gridx : 1, gridy:4), downloadLocationAction) - label(text : bind {model.downloadLocation}, constraints: gbc(gridx:0, gridy:5, gridwidth:2)) + label(text : "Save downloaded files to:", constraints: gbc(gridx:0, gridy:5)) + button(text : "Choose", constraints : gbc(gridx : 1, gridy:5), downloadLocationAction) + label(text : bind {model.downloadLocation}, constraints: gbc(gridx:0, gridy:6, gridwidth:2)) } i = builder.panel {