mirror of https://github.com/zlatinb/muwire
associate persona with a search event, add skeleton for shared file panel
parent
cad5301827
commit
c7b0ae34af
|
@ -255,7 +255,8 @@ abstract class Connection implements Closeable {
|
|||
uuid : uuid,
|
||||
oobInfohash : oob,
|
||||
searchComments : searchComments,
|
||||
compressedResults : compressedResults)
|
||||
compressedResults : compressedResults,
|
||||
persona : originator)
|
||||
QueryEvent event = new QueryEvent ( searchEvent : searchEvent,
|
||||
replyTo : replyTo,
|
||||
originator : originator,
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muwire.core.search
|
|||
|
||||
import com.muwire.core.Event
|
||||
import com.muwire.core.InfoHash
|
||||
import com.muwire.core.Persona
|
||||
|
||||
class SearchEvent extends Event {
|
||||
|
||||
|
@ -11,6 +12,7 @@ class SearchEvent extends Event {
|
|||
boolean oobInfohash
|
||||
boolean searchComments
|
||||
boolean compressedResults
|
||||
Persona persona
|
||||
|
||||
String toString() {
|
||||
def infoHash = null
|
||||
|
|
|
@ -176,7 +176,7 @@ class UpdateClient {
|
|||
signer = payload.signer
|
||||
log.info("starting search for new version hash $payload.infoHash")
|
||||
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,
|
||||
receivedOn : me.destination, originator : me, sig : sig.data)
|
||||
eventBus.publish(queryEvent)
|
||||
|
|
|
@ -101,4 +101,9 @@ mvcGroups {
|
|||
view = 'com.muwire.gui.CertificateControlView'
|
||||
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
|
||||
byte [] payload
|
||||
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
|
||||
} else {
|
||||
def nonEmpty = SplitPattern.termify(search)
|
||||
payload = String.join(" ",nonEmpty).getBytes(StandardCharsets.UTF_8)
|
||||
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
|
||||
|
||||
|
@ -140,7 +140,7 @@ class MainFrameController {
|
|||
Signature sig = DSAEngine.getInstance().sign(infoHashBytes, core.spk)
|
||||
|
||||
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,
|
||||
replyTo: core.me.destination, receivedOn: core.me.destination,
|
||||
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++
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue