Compare commits
8 Commits
browse-hos
...
muwire-0.5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9c15208f3a | ||
![]() |
a9ce9d96b3 | ||
![]() |
4d2a5a8018 | ||
![]() |
8395047386 | ||
![]() |
cb23aa44f0 | ||
![]() |
dbcb8508b8 | ||
![]() |
47d406d93b | ||
![]() |
e06f1805c2 |
@@ -35,7 +35,7 @@ class Cli {
|
||||
|
||||
Core core
|
||||
try {
|
||||
core = new Core(props, home, "0.5.0")
|
||||
core = new Core(props, home, "0.5.1")
|
||||
} catch (Exception bad) {
|
||||
bad.printStackTrace(System.out)
|
||||
println "Failed to initialize core, exiting"
|
||||
|
@@ -53,7 +53,7 @@ class CliDownloader {
|
||||
|
||||
Core core
|
||||
try {
|
||||
core = new Core(props, home, "0.5.0")
|
||||
core = new Core(props, home, "0.5.1")
|
||||
} catch (Exception bad) {
|
||||
bad.printStackTrace(System.out)
|
||||
println "Failed to initialize core, exiting"
|
||||
|
@@ -375,7 +375,7 @@ public class Core {
|
||||
}
|
||||
}
|
||||
|
||||
Core core = new Core(props, home, "0.5.0")
|
||||
Core core = new Core(props, home, "0.5.1")
|
||||
core.startServices()
|
||||
|
||||
// ... at the end, sleep or execute script
|
||||
|
@@ -5,6 +5,7 @@ import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.logging.Level
|
||||
import java.util.zip.DeflaterOutputStream
|
||||
import java.util.zip.GZIPOutputStream
|
||||
import java.util.zip.InflaterInputStream
|
||||
|
||||
import com.muwire.core.EventBus
|
||||
@@ -279,7 +280,7 @@ class ConnectionAcceptor {
|
||||
|
||||
os.write("Count: ${sharedFiles.size()}\r\n\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||
|
||||
DataOutputStream dos = new DataOutputStream(os)
|
||||
DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os))
|
||||
JsonOutput jsonOutput = new JsonOutput()
|
||||
sharedFiles.each {
|
||||
def obj = ResultsSender.sharedFileToObj(it, false)
|
||||
@@ -288,6 +289,7 @@ class ConnectionAcceptor {
|
||||
dos.write(json.getBytes(StandardCharsets.US_ASCII))
|
||||
}
|
||||
dos.flush()
|
||||
dos.close()
|
||||
} finally {
|
||||
e.close()
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import java.nio.charset.StandardCharsets
|
||||
import java.util.concurrent.Executor
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.logging.Level
|
||||
import java.util.zip.GZIPInputStream
|
||||
|
||||
@Log
|
||||
class BrowseManager {
|
||||
@@ -62,7 +63,7 @@ class BrowseManager {
|
||||
eventBus.publish(new BrowseStatusEvent(status : BrowseStatus.FETCHING))
|
||||
|
||||
JsonSlurper slurper = new JsonSlurper()
|
||||
DataInputStream dis = new DataInputStream(is)
|
||||
DataInputStream dis = new DataInputStream(new GZIPInputStream(is))
|
||||
UUID uuid = UUID.randomUUID()
|
||||
for (int i = 0; i < results; i++) {
|
||||
int size = dis.readUnsignedShort()
|
||||
|
@@ -1,5 +1,5 @@
|
||||
group = com.muwire
|
||||
version = 0.5.0
|
||||
version = 0.5.1
|
||||
groovyVersion = 2.4.15
|
||||
slf4jVersion = 1.7.25
|
||||
spockVersion = 1.1-groovy-2.4
|
||||
|
@@ -58,7 +58,11 @@ dependencies {
|
||||
compile project(":core")
|
||||
compile "org.codehaus.griffon:griffon-guice:${griffon.version}"
|
||||
|
||||
runtime "org.slf4j:slf4j-simple:${slf4jVersion}"
|
||||
// runtime "org.slf4j:slf4j-simple:${slf4jVersion}"
|
||||
|
||||
runtime group: 'org.slf4j', name: 'slf4j-jdk14', version: "${slf4jVersion}"
|
||||
runtime group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jVersion}"
|
||||
runtime group: 'org.slf4j', name: 'jul-to-slf4j', version: "${slf4jVersion}"
|
||||
runtime "javax.annotation:javax.annotation-api:1.3.2"
|
||||
|
||||
testCompile "org.codehaus.griffon:griffon-fest-test:${griffon.version}"
|
||||
|
@@ -4,6 +4,8 @@ import griffon.core.artifact.GriffonController
|
||||
import griffon.core.controller.ControllerAction
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import net.i2p.data.Base64
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
|
||||
import com.muwire.core.Core
|
||||
@@ -101,4 +103,22 @@ class SearchTabController {
|
||||
|
||||
mvcGroup.createMVCGroup("browse", groupId, params)
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void showComment() {
|
||||
int[] selectedRows = view.resultsTable.getSelectedRows()
|
||||
if (selectedRows.length != 1)
|
||||
return
|
||||
if (view.lastSortEvent != null)
|
||||
selectedRows[0] = view.resultsTable.rowSorter.convertRowIndexToModel(selectedRows[0])
|
||||
UIResultEvent event = model.results[selectedRows[0]]
|
||||
if (event.comment == null)
|
||||
return
|
||||
|
||||
String groupId = Base64.encode(event.infohash.getRoot())
|
||||
Map<String,Object> params = new HashMap<>()
|
||||
params['result'] = event
|
||||
|
||||
mvcGroup.createMVCGroup("show-comment", groupId, params)
|
||||
}
|
||||
}
|
@@ -35,11 +35,11 @@ class Initialize extends AbstractLifecycleHandler {
|
||||
void execute() {
|
||||
|
||||
if (System.getProperty("java.util.logging.config.file") == null) {
|
||||
log.info("No config file specified, so turning off logging")
|
||||
log.info("No config file specified, so turning off most logging")
|
||||
def names = LogManager.getLogManager().getLoggerNames()
|
||||
while(names.hasMoreElements()) {
|
||||
def name = names.nextElement()
|
||||
LogManager.getLogManager().getLogger(name).setLevel(Level.OFF)
|
||||
LogManager.getLogManager().getLogger(name).setLevel(Level.SEVERE)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -181,7 +181,6 @@ class MainFrameModel {
|
||||
core = e.getNewValue()
|
||||
routerPresent = core.router != null
|
||||
me = core.me.getHumanReadableName()
|
||||
core.eventBus.register(UIResultEvent.class, this)
|
||||
core.eventBus.register(UIResultBatchEvent.class, this)
|
||||
core.eventBus.register(DownloadStartedEvent.class, this)
|
||||
core.eventBus.register(ConnectionEvent.class, this)
|
||||
|
@@ -22,6 +22,7 @@ class SearchTabModel {
|
||||
@Observable boolean downloadActionEnabled
|
||||
@Observable boolean trustButtonsEnabled
|
||||
@Observable boolean browseActionEnabled
|
||||
@Observable boolean viewCommentActionEnabled
|
||||
|
||||
Core core
|
||||
UISettings uiSettings
|
||||
|
@@ -3,9 +3,12 @@ package com.muwire.gui
|
||||
import griffon.core.artifact.GriffonView
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import net.i2p.data.Base64
|
||||
|
||||
import javax.swing.JDialog
|
||||
import javax.swing.JLabel
|
||||
import javax.swing.JMenuItem
|
||||
import javax.swing.JPopupMenu
|
||||
import javax.swing.ListSelectionModel
|
||||
import javax.swing.SwingConstants
|
||||
import javax.swing.table.DefaultTableCellRenderer
|
||||
@@ -13,6 +16,10 @@ import javax.swing.table.DefaultTableCellRenderer
|
||||
import com.muwire.core.search.UIResultEvent
|
||||
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Toolkit
|
||||
import java.awt.datatransfer.StringSelection
|
||||
import java.awt.event.MouseAdapter
|
||||
import java.awt.event.MouseEvent
|
||||
import java.awt.event.WindowAdapter
|
||||
import java.awt.event.WindowEvent
|
||||
|
||||
@@ -95,9 +102,70 @@ class BrowseView {
|
||||
downloadActionEnabled &= mvcGroup.parentGroup.parentGroup.model.canDownload(model.results[it].infohash)
|
||||
}
|
||||
model.downloadActionEnabled = downloadActionEnabled
|
||||
|
||||
resultsTable.addMouseListener(new MouseAdapter() {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger())
|
||||
showMenu(e)
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger())
|
||||
showMenu(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private void showMenu(MouseEvent e) {
|
||||
JPopupMenu menu = new JPopupMenu()
|
||||
if (model.downloadActionEnabled) {
|
||||
JMenuItem download = new JMenuItem("Download")
|
||||
download.addActionListener({controller.download()})
|
||||
menu.add(download)
|
||||
}
|
||||
if (model.viewCommentActionEnabled) {
|
||||
JMenuItem viewComment = new JMenuItem("View Comment")
|
||||
viewComment.addActionListener({controller.viewComment()})
|
||||
menu.add(viewComment)
|
||||
}
|
||||
|
||||
JMenuItem copyHash = new JMenuItem("Copy Hash To Clipboard")
|
||||
copyHash.addActionListener({
|
||||
List<UIResultEvent> results = selectedResults()
|
||||
def hash = ""
|
||||
for(Iterator<UIResultEvent> iter = results.iterator(); iter.hasNext();) {
|
||||
UIResultEvent result = iter.next()
|
||||
hash += Base64.encode(result.infohash.getRoot())
|
||||
if (iter.hasNext())
|
||||
hash += "\n"
|
||||
}
|
||||
copyString(hash)
|
||||
})
|
||||
menu.add(copyHash)
|
||||
|
||||
JMenuItem copyName = new JMenuItem("Copy Name To Clipboard")
|
||||
copyName.addActionListener({
|
||||
List<UIResultEvent> results = selectedResults()
|
||||
def name = ""
|
||||
for(Iterator<UIResultEvent> iter = results.iterator(); iter.hasNext();) {
|
||||
UIResultEvent result = iter.next()
|
||||
name += result.getName()
|
||||
if (iter.hasNext())
|
||||
name += "\n"
|
||||
}
|
||||
copyString(name)
|
||||
|
||||
})
|
||||
menu.add(copyName)
|
||||
|
||||
menu.show(e.getComponent(), e.getX(), e.getY())
|
||||
}
|
||||
|
||||
private static copyString(String s) {
|
||||
StringSelection selection = new StringSelection(s)
|
||||
def clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
|
||||
clipboard.setContents(selection, null)
|
||||
}
|
||||
void mvcGroupInit(Map<String,String> args) {
|
||||
controller.register()
|
||||
|
||||
|
@@ -72,10 +72,10 @@ class SearchTabView {
|
||||
}
|
||||
panel(constraints : BorderLayout.SOUTH) {
|
||||
gridLayout(rows: 1, cols : 2)
|
||||
panel {
|
||||
panel (border : etchedBorder()){
|
||||
button(text : "Browse Host", enabled : bind {model.browseActionEnabled}, browseAction)
|
||||
}
|
||||
panel {
|
||||
panel (border : etchedBorder()){
|
||||
button(text : "Trust", enabled: bind {model.trustButtonsEnabled }, trustAction)
|
||||
button(text : "Neutral", enabled: bind {model.trustButtonsEnabled}, neutralAction)
|
||||
button(text : "Distrust", enabled : bind {model.trustButtonsEnabled}, distrustAction)
|
||||
@@ -100,6 +100,7 @@ class SearchTabView {
|
||||
panel()
|
||||
panel {
|
||||
button(text : "Download", enabled : bind {model.downloadActionEnabled}, downloadAction)
|
||||
button(text : "View Comment", enabled : bind {model.viewCommentActionEnabled}, showCommentAction)
|
||||
}
|
||||
panel {
|
||||
gridBagLayout()
|
||||
@@ -190,6 +191,16 @@ class SearchTabView {
|
||||
}
|
||||
})
|
||||
|
||||
resultsTable.getSelectionModel().addListSelectionListener({
|
||||
def result = getSelectedResult()
|
||||
if (result == null) {
|
||||
model.viewCommentActionEnabled = false
|
||||
return
|
||||
} else {
|
||||
model.viewCommentActionEnabled = result.comment != null
|
||||
}
|
||||
})
|
||||
|
||||
// senders table
|
||||
sendersTable.setDefaultRenderer(Integer.class, centerRenderer)
|
||||
sendersTable.rowSorter.addRowSorterListener({evt -> lastSendersSortEvent = evt})
|
||||
@@ -241,12 +252,9 @@ class SearchTabView {
|
||||
showMenu = true
|
||||
|
||||
// show comment if any
|
||||
int selectedRow = resultsTable.getSelectedRow()
|
||||
if (lastSortEvent != null)
|
||||
selectedRow = resultsTable.rowSorter.convertRowIndexToModel(selectedRow)
|
||||
if (model.results[selectedRow].comment != null) {
|
||||
JMenuItem showComment = new JMenuItem("Show Comment")
|
||||
showComment.addActionListener({mvcGroup.view.showComment()})
|
||||
if (model.viewCommentActionEnabled) {
|
||||
JMenuItem showComment = new JMenuItem("View Comment")
|
||||
showComment.addActionListener({mvcGroup.controller.showComment()})
|
||||
menu.add(showComment)
|
||||
}
|
||||
}
|
||||
@@ -283,23 +291,6 @@ class SearchTabView {
|
||||
clipboard.setContents(selection, null)
|
||||
}
|
||||
|
||||
def showComment() {
|
||||
int selectedRow = resultsTable.getSelectedRow()
|
||||
if (selectedRow < 0)
|
||||
return
|
||||
if (lastSortEvent != null)
|
||||
selectedRow = resultsTable.rowSorter.convertRowIndexToModel(selectedRow)
|
||||
UIResultEvent event = model.results[selectedRow]
|
||||
if (event.comment == null)
|
||||
return
|
||||
|
||||
String groupId = Base64.encode(event.infohash.getRoot())
|
||||
Map<String,Object> params = new HashMap<>()
|
||||
params['result'] = event
|
||||
|
||||
mvcGroup.createMVCGroup("show-comment", groupId, params)
|
||||
}
|
||||
|
||||
int selectedSenderRow() {
|
||||
int row = sendersTable.getSelectedRow()
|
||||
if (row < 0)
|
||||
|
Reference in New Issue
Block a user