show trust status in certificates view

This commit is contained in:
Zlatin Balevsky
2019-11-06 18:13:07 +00:00
parent 739dbc7a24
commit b3f775f59a
4 changed files with 18 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ import net.i2p.data.Base64
import javax.annotation.Nonnull import javax.annotation.Nonnull
import com.muwire.core.Core
import com.muwire.core.EventBus import com.muwire.core.EventBus
import com.muwire.core.download.UIDownloadEvent import com.muwire.core.download.UIDownloadEvent
import com.muwire.core.search.BrowseStatus import com.muwire.core.search.BrowseStatus
@@ -22,18 +23,18 @@ class BrowseController {
@MVCMember @Nonnull @MVCMember @Nonnull
BrowseView view BrowseView view
EventBus eventBus Core core
void register() { void register() {
eventBus.register(BrowseStatusEvent.class, this) core.eventBus.register(BrowseStatusEvent.class, this)
eventBus.register(UIResultEvent.class, this) core.eventBus.register(UIResultEvent.class, this)
eventBus.publish(new UIBrowseEvent(host : model.host)) core.eventBus.publish(new UIBrowseEvent(host : model.host))
} }
void mvcGroupDestroy() { void mvcGroupDestroy() {
eventBus.unregister(BrowseStatusEvent.class, this) core.eventBus.unregister(BrowseStatusEvent.class, this)
eventBus.unregister(UIResultEvent.class, this) core.eventBus.unregister(UIResultEvent.class, this)
} }
void onBrowseStatusEvent(BrowseStatusEvent e) { void onBrowseStatusEvent(BrowseStatusEvent e) {
@@ -69,7 +70,7 @@ class BrowseController {
selectedResults.each { result -> selectedResults.each { result ->
def file = new File(application.context.get("muwire-settings").downloadLocation, result.name) def file = new File(application.context.get("muwire-settings").downloadLocation, result.name)
eventBus.publish(new UIDownloadEvent( core.eventBus.publish(new UIDownloadEvent(
result : [result], result : [result],
sources : [model.host.destination], sources : [model.host.destination],
target : file, target : file,
@@ -109,7 +110,7 @@ class BrowseController {
def params = [:] def params = [:]
params['result'] = result params['result'] = result
params['eventBus'] = eventBus params['core'] = core
mvcGroup.createMVCGroup("fetch-certificates", params) mvcGroup.createMVCGroup("fetch-certificates", params)
} }
} }

View File

@@ -7,6 +7,7 @@ import griffon.metadata.ArtifactProviderFor
import javax.annotation.Nonnull import javax.annotation.Nonnull
import javax.swing.JOptionPane import javax.swing.JOptionPane
import com.muwire.core.Core
import com.muwire.core.EventBus import com.muwire.core.EventBus
import com.muwire.core.filecert.CertificateFetchEvent import com.muwire.core.filecert.CertificateFetchEvent
import com.muwire.core.filecert.CertificateFetchStatus import com.muwire.core.filecert.CertificateFetchStatus
@@ -21,10 +22,10 @@ class FetchCertificatesController {
@MVCMember @Nonnull @MVCMember @Nonnull
FetchCertificatesView view FetchCertificatesView view
EventBus eventBus Core core
void register() { void register() {
eventBus.with { core.eventBus.with {
register(CertificateFetchEvent.class, this) register(CertificateFetchEvent.class, this)
register(CertificateFetchedEvent.class, this) register(CertificateFetchedEvent.class, this)
publish(new UIFetchCertificatesEvent(host : model.result.sender, infoHash : model.result.infohash)) publish(new UIFetchCertificatesEvent(host : model.result.sender, infoHash : model.result.infohash))
@@ -32,8 +33,8 @@ class FetchCertificatesController {
} }
void mvcGroupDestroy() { void mvcGroupDestroy() {
eventBus.unregister(CertificateFetchEvent.class, this) core.eventBus.unregister(CertificateFetchEvent.class, this)
eventBus.unregister(CertificateFetchedEvent.class, this) core.eventBus.unregister(CertificateFetchedEvent.class, this)
} }
void onCertificateFetchEvent(CertificateFetchEvent e) { void onCertificateFetchEvent(CertificateFetchEvent e) {
@@ -58,7 +59,7 @@ class FetchCertificatesController {
if (selectedCerts == null) if (selectedCerts == null)
return return
selectedCerts.each { selectedCerts.each {
eventBus.publish(new UIImportCertificateEvent(certificate : it)) core.eventBus.publish(new UIImportCertificateEvent(certificate : it))
} }
JOptionPane.showMessageDialog(null, "Certificates imported.") JOptionPane.showMessageDialog(null, "Certificates imported.")
} }

View File

@@ -99,7 +99,7 @@ class SearchTabController {
String groupId = sender.getHumanReadableName() String groupId = sender.getHumanReadableName()
Map<String,Object> params = new HashMap<>() Map<String,Object> params = new HashMap<>()
params['host'] = sender params['host'] = sender
params['eventBus'] = core.eventBus params['core'] = core
mvcGroup.createMVCGroup("browse", groupId, params) mvcGroup.createMVCGroup("browse", groupId, params)
} }
@@ -136,7 +136,7 @@ class SearchTabController {
def params = [:] def params = [:]
params['result'] = event params['result'] = event
params['eventBus'] = core.eventBus params['core'] = core
mvcGroup.createMVCGroup("fetch-certificates", params) mvcGroup.createMVCGroup("fetch-certificates", params)
} }
} }

View File

@@ -52,6 +52,7 @@ class FetchCertificatesView {
certsTable = table(autoCreateRowSorter : true, rowHeight : rowHeight) { certsTable = table(autoCreateRowSorter : true, rowHeight : rowHeight) {
tableModel(list : model.certificates) { tableModel(list : model.certificates) {
closureColumn(header : "Issuer", preferredWidth : 200, type : String, read : {it.issuer.getHumanReadableName()}) closureColumn(header : "Issuer", preferredWidth : 200, type : String, read : {it.issuer.getHumanReadableName()})
closureColumn(header : "Trust Status", preferredWidth: 50, type : String, read : {controller.core.trustService.getLevel(it.issuer.destination)})
closureColumn(header : "Name", preferredWidth : 200, type: String, read : {it.name.name.toString()}) closureColumn(header : "Name", preferredWidth : 200, type: String, read : {it.name.name.toString()})
closureColumn(header : "Issued", preferredWidth : 100, type : String, read : { closureColumn(header : "Issued", preferredWidth : 100, type : String, read : {
def date = new Date(it.timestamp) def date = new Date(it.timestamp)