associate persona with a search event, add skeleton for shared file panel
This commit is contained in:
@@ -255,7 +255,8 @@ abstract class Connection implements Closeable {
|
|||||||
uuid : uuid,
|
uuid : uuid,
|
||||||
oobInfohash : oob,
|
oobInfohash : oob,
|
||||||
searchComments : searchComments,
|
searchComments : searchComments,
|
||||||
compressedResults : compressedResults)
|
compressedResults : compressedResults,
|
||||||
|
persona : originator)
|
||||||
QueryEvent event = new QueryEvent ( searchEvent : searchEvent,
|
QueryEvent event = new QueryEvent ( searchEvent : searchEvent,
|
||||||
replyTo : replyTo,
|
replyTo : replyTo,
|
||||||
originator : originator,
|
originator : originator,
|
||||||
|
@@ -2,6 +2,7 @@ package com.muwire.core.search
|
|||||||
|
|
||||||
import com.muwire.core.Event
|
import com.muwire.core.Event
|
||||||
import com.muwire.core.InfoHash
|
import com.muwire.core.InfoHash
|
||||||
|
import com.muwire.core.Persona
|
||||||
|
|
||||||
class SearchEvent extends Event {
|
class SearchEvent extends Event {
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ class SearchEvent extends Event {
|
|||||||
boolean oobInfohash
|
boolean oobInfohash
|
||||||
boolean searchComments
|
boolean searchComments
|
||||||
boolean compressedResults
|
boolean compressedResults
|
||||||
|
Persona persona
|
||||||
|
|
||||||
String toString() {
|
String toString() {
|
||||||
def infoHash = null
|
def infoHash = null
|
||||||
|
@@ -176,7 +176,7 @@ class UpdateClient {
|
|||||||
signer = payload.signer
|
signer = payload.signer
|
||||||
log.info("starting search for new version hash $payload.infoHash")
|
log.info("starting search for new version hash $payload.infoHash")
|
||||||
Signature sig = DSAEngine.getInstance().sign(updateInfoHash.getRoot(), spk)
|
Signature sig = DSAEngine.getInstance().sign(updateInfoHash.getRoot(), spk)
|
||||||
def searchEvent = new SearchEvent(searchHash : updateInfoHash.getRoot(), uuid : UUID.randomUUID(), oobInfohash : true)
|
def searchEvent = new SearchEvent(searchHash : updateInfoHash.getRoot(), uuid : UUID.randomUUID(), oobInfohash : true, persona : me)
|
||||||
def queryEvent = new QueryEvent(searchEvent : searchEvent, firstHop : true, replyTo : me.destination,
|
def queryEvent = new QueryEvent(searchEvent : searchEvent, firstHop : true, replyTo : me.destination,
|
||||||
receivedOn : me.destination, originator : me, sig : sig.data)
|
receivedOn : me.destination, originator : me, sig : sig.data)
|
||||||
eventBus.publish(queryEvent)
|
eventBus.publish(queryEvent)
|
||||||
|
@@ -101,4 +101,9 @@ mvcGroups {
|
|||||||
view = 'com.muwire.gui.CertificateControlView'
|
view = 'com.muwire.gui.CertificateControlView'
|
||||||
controller = 'com.muwire.gui.CertificateControlController'
|
controller = 'com.muwire.gui.CertificateControlController'
|
||||||
}
|
}
|
||||||
|
'shared-file' {
|
||||||
|
model = 'com.muwire.gui.SharedFileModel'
|
||||||
|
view = 'com.muwire.gui.SharedFileView'
|
||||||
|
controller = 'com.muwire.gui.SharedFileController'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -107,13 +107,13 @@ class MainFrameController {
|
|||||||
def searchEvent
|
def searchEvent
|
||||||
byte [] payload
|
byte [] payload
|
||||||
if (hashSearch) {
|
if (hashSearch) {
|
||||||
searchEvent = new SearchEvent(searchHash : root, uuid : uuid, oobInfohash: true, compressedResults : true)
|
searchEvent = new SearchEvent(searchHash : root, uuid : uuid, oobInfohash: true, compressedResults : true, persona : core.me)
|
||||||
payload = root
|
payload = root
|
||||||
} else {
|
} else {
|
||||||
def nonEmpty = SplitPattern.termify(search)
|
def nonEmpty = SplitPattern.termify(search)
|
||||||
payload = String.join(" ",nonEmpty).getBytes(StandardCharsets.UTF_8)
|
payload = String.join(" ",nonEmpty).getBytes(StandardCharsets.UTF_8)
|
||||||
searchEvent = new SearchEvent(searchTerms : nonEmpty, uuid : uuid, oobInfohash: true,
|
searchEvent = new SearchEvent(searchTerms : nonEmpty, uuid : uuid, oobInfohash: true,
|
||||||
searchComments : core.muOptions.searchComments, compressedResults : true)
|
searchComments : core.muOptions.searchComments, compressedResults : true, persona : core.me)
|
||||||
}
|
}
|
||||||
boolean firstHop = core.muOptions.allowUntrusted || core.muOptions.searchExtraHop
|
boolean firstHop = core.muOptions.allowUntrusted || core.muOptions.searchExtraHop
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ class MainFrameController {
|
|||||||
Signature sig = DSAEngine.getInstance().sign(infoHashBytes, core.spk)
|
Signature sig = DSAEngine.getInstance().sign(infoHashBytes, core.spk)
|
||||||
|
|
||||||
def searchEvent = new SearchEvent(searchHash : Base64.decode(infoHash), uuid:uuid,
|
def searchEvent = new SearchEvent(searchHash : Base64.decode(infoHash), uuid:uuid,
|
||||||
oobInfohash: true)
|
oobInfohash: true, persona : core.me)
|
||||||
core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true,
|
core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true,
|
||||||
replyTo: core.me.destination, receivedOn: core.me.destination,
|
replyTo: core.me.destination, receivedOn: core.me.destination,
|
||||||
originator : core.me, sig : sig.data))
|
originator : core.me, sig : sig.data))
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonController
|
||||||
|
import griffon.core.controller.ControllerAction
|
||||||
|
import griffon.inject.MVCMember
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonController)
|
||||||
|
class SharedFileController {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
SharedFileModel model
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void click() {
|
||||||
|
model.clickCount++
|
||||||
|
}
|
||||||
|
}
|
10
gui/griffon-app/models/com/muwire/gui/SharedFileModel.groovy
Normal file
10
gui/griffon-app/models/com/muwire/gui/SharedFileModel.groovy
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonModel
|
||||||
|
import griffon.transform.Observable
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonModel)
|
||||||
|
class SharedFileModel {
|
||||||
|
@Observable int clickCount = 0
|
||||||
|
}
|
31
gui/griffon-app/views/com/muwire/gui/SharedFileView.groovy
Normal file
31
gui/griffon-app/views/com/muwire/gui/SharedFileView.groovy
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import griffon.core.artifact.GriffonView
|
||||||
|
import griffon.inject.MVCMember
|
||||||
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
import javax.swing.SwingConstants
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
@ArtifactProviderFor(GriffonView)
|
||||||
|
class SharedFileView {
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
FactoryBuilderSupport builder
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
SharedFileModel model
|
||||||
|
|
||||||
|
void initUI() {
|
||||||
|
builder.with {
|
||||||
|
application(size: [320, 160], id: 'shared-file',
|
||||||
|
title: application.configuration['application.title'],
|
||||||
|
iconImage: imageIcon('/griffon-icon-48x48.png').image,
|
||||||
|
iconImages: [imageIcon('/griffon-icon-48x48.png').image,
|
||||||
|
imageIcon('/griffon-icon-32x32.png').image,
|
||||||
|
imageIcon('/griffon-icon-16x16.png').image]) {
|
||||||
|
gridLayout(rows: 2, cols: 1)
|
||||||
|
label(id: 'clickLabel', text: bind { model.clickCount },
|
||||||
|
horizontalAlignment: SwingConstants.CENTER)
|
||||||
|
button(id: 'clickButton', clickAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user