ability to chat from browse window

pull/34/head
Zlatin Balevsky 2019-11-29 03:41:59 +00:00
parent 631963f43c
commit cf396b739e
5 changed files with 21 additions and 1 deletions

View File

@ -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()

View File

@ -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)
}

View File

@ -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()
}
}

View File

@ -15,6 +15,7 @@ class BrowseModel {
@Observable boolean downloadActionEnabled
@Observable boolean viewCommentActionEnabled
@Observable boolean viewCertificatesActionEnabled
@Observable boolean chatActionEnabled
@Observable int totalResults
@Observable int resultCount

View File

@ -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()