mirror of https://github.com/zlatinb/muwire
re-add the trust options in the senders table context menu
parent
baf783015a
commit
222988bab4
|
@ -3,6 +3,7 @@ package com.muwire.gui
|
|||
import com.muwire.core.InfoHash
|
||||
import com.muwire.core.SplitPattern
|
||||
import com.muwire.core.download.DownloadStartedEvent
|
||||
import com.muwire.core.profile.MWProfileHeader
|
||||
import com.muwire.gui.profile.PersonaOrProfile
|
||||
import com.muwire.gui.profile.ViewProfileHelper
|
||||
import griffon.core.GriffonApplication
|
||||
|
@ -11,6 +12,7 @@ import griffon.core.controller.ControllerAction
|
|||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import net.i2p.data.Base64
|
||||
import net.i2p.data.Destination
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
import javax.inject.Inject
|
||||
|
@ -210,4 +212,12 @@ class SearchTabController {
|
|||
params.uuid = model.uuid
|
||||
mvcGroup.createMVCGroup("result-details-frame", mvcId, params)
|
||||
}
|
||||
|
||||
void markTrust(PersonaOrProfile pop, TrustLevel level) {
|
||||
String reason = null
|
||||
if (level != TrustLevel.NEUTRAL)
|
||||
reason = view.promptTrustReason()
|
||||
model.core.getEventBus().publish(new TrustEvent(persona: pop.getPersona(), profileHeader: pop.getHeader(),
|
||||
reason: reason, level: level))
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.muwire.gui
|
|||
|
||||
import com.muwire.core.InfoHash
|
||||
import com.muwire.core.profile.MWProfileHeader
|
||||
import com.muwire.core.trust.TrustEvent
|
||||
import com.muwire.gui.profile.ImageScaler
|
||||
import com.muwire.gui.profile.PersonaOrProfile
|
||||
import com.muwire.gui.profile.ResultPOP
|
||||
|
@ -76,15 +77,25 @@ class SearchTabModel {
|
|||
treeModel = new ResultTreeModel(root)
|
||||
core = mvcGroup.parentGroup.model.core
|
||||
uiSettings = application.context.get("ui-settings")
|
||||
|
||||
core.getEventBus().register(TrustEvent.class, this)
|
||||
|
||||
timer.start()
|
||||
mvcGroup.parentGroup.model.results[UUID.fromString(uuid)] = mvcGroup
|
||||
}
|
||||
|
||||
void mvcGroupDestroy() {
|
||||
timer.stop()
|
||||
core.getEventBus().unregister(TrustEvent.class, this)
|
||||
mvcGroup.parentGroup.model.results.remove(uuid)
|
||||
}
|
||||
|
||||
void onTrustEvent(TrustEvent event) {
|
||||
runInsideUIAsync {
|
||||
view.onTrustChanged(event.persona)
|
||||
}
|
||||
}
|
||||
|
||||
private boolean filter(InfoHash infoHash) {
|
||||
if (filter == null)
|
||||
return true
|
||||
|
|
|
@ -16,6 +16,7 @@ import griffon.core.mvc.MVCGroup
|
|||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import net.i2p.data.Base64
|
||||
import net.i2p.data.Destination
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
import javax.inject.Inject
|
||||
|
@ -505,9 +506,43 @@ class SearchTabView {
|
|||
popupMenu.add(chatItem)
|
||||
}
|
||||
}
|
||||
|
||||
PersonaOrProfile selected = selectedSender()
|
||||
if (selected != null) {
|
||||
popupMenu.addSeparator()
|
||||
TrustLevel level = model.core.getTrustService().getLevel(selected.getPersona().getDestination())
|
||||
if (level != TrustLevel.TRUSTED) {
|
||||
JMenuItem addContactItem = new JMenuItem(trans("ADD_CONTACT"))
|
||||
addContactItem.setToolTipText(trans("TOOLTIP_ADD_CONTACT_SENDER"))
|
||||
addContactItem.addActionListener({controller.markTrust(
|
||||
selected, TrustLevel.TRUSTED
|
||||
)})
|
||||
popupMenu.add(addContactItem)
|
||||
}
|
||||
if (level != TrustLevel.NEUTRAL) {
|
||||
JMenuItem removeContact = new JMenuItem(trans("REMOVE_CONTACT"))
|
||||
removeContact.setToolTipText(trans("TOOLTIP_CONTACTS_REMOVE_CONTACT"))
|
||||
removeContact.addActionListener({controller.markTrust(
|
||||
selected, TrustLevel.NEUTRAL
|
||||
)})
|
||||
popupMenu.add(removeContact)
|
||||
}
|
||||
if (level != TrustLevel.DISTRUSTED) {
|
||||
JMenuItem block = new JMenuItem(trans("BLOCK"))
|
||||
block.setToolTipText(trans("TOOLTIP_PROFILE_VIEWER_BLOCK"))
|
||||
block.addActionListener({controller.markTrust(
|
||||
selected, TrustLevel.DISTRUSTED
|
||||
)})
|
||||
popupMenu.add(block)
|
||||
}
|
||||
}
|
||||
popupMenu.show(event.getComponent(), event.getX(), event.getY())
|
||||
}
|
||||
|
||||
String promptTrustReason() {
|
||||
JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
||||
}
|
||||
|
||||
private void showResultDetailsByFile(UIResultEvent event) {
|
||||
detailsPanelByFile.removeAll()
|
||||
InfoHash infoHash = event.infohash
|
||||
|
|
Loading…
Reference in New Issue