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