mirror of https://github.com/zlatinb/muwire
show full persona in searches
parent
9e0d52d548
commit
4c21f2d5ae
|
@ -6,6 +6,7 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||
import java.util.logging.Level
|
||||
|
||||
import com.muwire.core.EventBus
|
||||
import com.muwire.core.Persona
|
||||
import com.muwire.core.hostcache.HostCache
|
||||
import com.muwire.core.hostcache.HostDiscoveredEvent
|
||||
import com.muwire.core.search.QueryEvent
|
||||
|
@ -14,6 +15,7 @@ import com.muwire.core.trust.TrustLevel
|
|||
import com.muwire.core.trust.TrustService
|
||||
|
||||
import groovy.util.logging.Log
|
||||
import net.i2p.data.Base64
|
||||
import net.i2p.data.Destination
|
||||
|
||||
@Log
|
||||
|
@ -122,6 +124,8 @@ abstract class Connection implements Closeable {
|
|||
query.firstHop = e.firstHop
|
||||
query.keywords = e.searchEvent.getSearchTerms()
|
||||
query.replyTo = e.replyTo.toBase64()
|
||||
if (e.originator != null)
|
||||
query.originator = e.originator.toBase64()
|
||||
messages.put(query)
|
||||
}
|
||||
|
||||
|
@ -157,11 +161,22 @@ abstract class Connection implements Closeable {
|
|||
}
|
||||
// TODO: add option to respond only to trusted peers
|
||||
|
||||
Persona originator = null
|
||||
if (search.originator != null) {
|
||||
originator = new Persona(new ByteArrayInputStream(Base64.decode(search.originator)))
|
||||
if (originator.destination != replyTo) {
|
||||
log.info("originator doesn't match destination")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SearchEvent searchEvent = new SearchEvent(searchTerms : search.keywords,
|
||||
searchHash : search.infohash,
|
||||
uuid : uuid)
|
||||
QueryEvent event = new QueryEvent ( searchEvent : searchEvent,
|
||||
replyTo : replyTo,
|
||||
originator : originator,
|
||||
receivedOn : endpoint.destination,
|
||||
firstHop : search.firstHop )
|
||||
eventBus.publish(event)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muwire.core.search
|
||||
|
||||
import com.muwire.core.Event
|
||||
import com.muwire.core.Persona
|
||||
|
||||
import net.i2p.data.Destination
|
||||
|
||||
|
@ -9,6 +10,7 @@ class QueryEvent extends Event {
|
|||
SearchEvent searchEvent
|
||||
boolean firstHop
|
||||
Destination replyTo
|
||||
Persona originator
|
||||
Destination receivedOn
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@ class MainFrameController {
|
|||
def terms = search.toLowerCase().trim().split(Constants.SPLIT_PATTERN)
|
||||
def searchEvent = new SearchEvent(searchTerms : terms, uuid : uuid)
|
||||
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))
|
||||
}
|
||||
|
||||
private def selectedResult() {
|
||||
|
|
|
@ -8,6 +8,7 @@ import javax.swing.JTable
|
|||
|
||||
import com.muwire.core.Core
|
||||
import com.muwire.core.InfoHash
|
||||
import com.muwire.core.Persona
|
||||
import com.muwire.core.connection.ConnectionAttemptStatus
|
||||
import com.muwire.core.connection.ConnectionEvent
|
||||
import com.muwire.core.connection.DisconnectionEvent
|
||||
|
@ -228,7 +229,7 @@ class MainFrameModel {
|
|||
if (search.trim().size() == 0)
|
||||
return
|
||||
runInsideUIAsync {
|
||||
searches.addFirst(new IncomingSearch(search : search, replyTo : e.replyTo))
|
||||
searches.addFirst(new IncomingSearch(search : search, replyTo : e.replyTo, originator : e.originator))
|
||||
while(searches.size() > 200)
|
||||
searches.removeLast()
|
||||
JTable table = builder.getVariable("searches-table")
|
||||
|
@ -239,5 +240,6 @@ class MainFrameModel {
|
|||
class IncomingSearch {
|
||||
String search
|
||||
Destination replyTo
|
||||
Persona originator
|
||||
}
|
||||
}
|
|
@ -178,7 +178,13 @@ class MainFrameView {
|
|||
table(id : "searches-table") {
|
||||
tableModel(list : model.searches) {
|
||||
closureColumn(header : "Keywords", type : String, read : { it.search })
|
||||
closureColumn(header : "From", type : String, read : {it.replyTo.toBase32()})
|
||||
closureColumn(header : "From", type : String, read : {
|
||||
if (it.originator != null) {
|
||||
return it.originator.getHumanReadableName()
|
||||
} else {
|
||||
return it.replyTo.toBase32()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue