diff --git a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy index 9b100f16..f1c55980 100644 --- a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy @@ -369,7 +369,12 @@ class ConnectionAcceptor { def sharedFiles = fileManager.getSharedFiles().values() - os.write("Count: ${sharedFiles.size()}\r\n\r\n".getBytes(StandardCharsets.US_ASCII)) + os.write("Count: ${sharedFiles.size()}\r\n".getBytes(StandardCharsets.US_ASCII)) + + boolean chat = chatServer.running.get() && settings.advertiseChat + os.write("Chat: ${chat}\r\n".getBytes(StandardCharsets.US_ASCII)) + + os.write("\r\n".getBytes(StandardCharsets.US_ASCII)) DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os)) JsonOutput jsonOutput = new JsonOutput() diff --git a/core/src/main/groovy/com/muwire/core/search/BrowseManager.groovy b/core/src/main/groovy/com/muwire/core/search/BrowseManager.groovy index 0c5cc24d..63c560e7 100644 --- a/core/src/main/groovy/com/muwire/core/search/BrowseManager.groovy +++ b/core/src/main/groovy/com/muwire/core/search/BrowseManager.groovy @@ -55,6 +55,8 @@ class BrowseManager { int results = Integer.parseInt(headers['Count']) + boolean chat = headers.containsKey("Chat") && Boolean.parseBoolean(headers['Chat']) + // at this stage, start pulling the results eventBus.publish(new BrowseStatusEvent(status : BrowseStatus.FETCHING, totalResults : results)) @@ -67,6 +69,7 @@ class BrowseManager { dis.readFully(tmp) def json = slurper.parse(tmp) UIResultEvent result = ResultsParser.parse(e.host, uuid, json) + result.chat = chat eventBus.publish(result) } diff --git a/gui/griffon-app/controllers/com/muwire/gui/BrowseController.groovy b/gui/griffon-app/controllers/com/muwire/gui/BrowseController.groovy index 750bead8..fff00f5c 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/BrowseController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/BrowseController.groovy @@ -47,6 +47,7 @@ class BrowseController { void onUIResultEvent(UIResultEvent e) { runInsideUIAsync { + model.chatActionEnabled = e.chat model.results << e model.resultCount = model.results.size() view.resultsTable.model.fireTableDataChanged() @@ -116,4 +117,13 @@ class BrowseController { params['core'] = core mvcGroup.createMVCGroup("fetch-certificates", params) } + + @ControllerAction + void chat() { + dismiss() + def mainFrameGroup = application.mvcGroupManager.getGroups()['MainFrame'] + + mainFrameGroup.controller.startChat(model.host) + mainFrameGroup.view.showChatWindow.call() + } } \ No newline at end of file diff --git a/gui/griffon-app/models/com/muwire/gui/BrowseModel.groovy b/gui/griffon-app/models/com/muwire/gui/BrowseModel.groovy index 2c9502f9..c902e554 100644 --- a/gui/griffon-app/models/com/muwire/gui/BrowseModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/BrowseModel.groovy @@ -15,6 +15,7 @@ class BrowseModel { @Observable boolean downloadActionEnabled @Observable boolean viewCommentActionEnabled @Observable boolean viewCertificatesActionEnabled + @Observable boolean chatActionEnabled @Observable int totalResults @Observable int resultCount diff --git a/gui/griffon-app/views/com/muwire/gui/BrowseView.groovy b/gui/griffon-app/views/com/muwire/gui/BrowseView.groovy index d5311ea0..c6a61b0f 100644 --- a/gui/griffon-app/views/com/muwire/gui/BrowseView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/BrowseView.groovy @@ -68,6 +68,7 @@ class BrowseView { button(text : "Download", enabled : bind {model.downloadActionEnabled}, downloadAction) button(text : "View Comment", enabled : bind{model.viewCommentActionEnabled}, viewCommentAction) button(text : "View Certificates", enabled : bind{model.viewCertificatesActionEnabled}, viewCertificatesAction) + button(text : "Chat", enabled : bind {model.chatActionEnabled}, chatAction) button(text : "Dismiss", dismissAction) label(text : "Download sequentially") sequentialDownloadCheckbox = checkBox()