diff --git a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy index 50805f7d..29c71af4 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy @@ -28,10 +28,14 @@ public class DownloadManager { public void onUIDownloadEvent(UIDownloadEvent e) { - def downloader = new Downloader(e.target, e.result.size, + def downloader = new Downloader(this, e.target, e.result.size, e.result.infohash, e.result.pieceSize, connector, e.result.sender.destination, incompletes) executor.execute({downloader.download()} as Runnable) eventBus.publish(new DownloadStartedEvent(downloader : downloader)) } + + void resume(Downloader downloader) { + executor.execute({downloader.download() as Runnable}) + } } diff --git a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy index 332cb2f2..6f4ec0f6 100644 --- a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy +++ b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy @@ -14,7 +14,8 @@ import net.i2p.data.Destination @Log public class Downloader { public enum DownloadState { CONNECTING, DOWNLOADING, FAILED, CANCELLED, FINISHED } - + + private final DownloadManager downloadManager private final File file private final Pieces pieces private final long length @@ -31,8 +32,10 @@ public class Downloader { private volatile boolean cancelled private volatile Thread downloadThread - public Downloader(File file, long length, InfoHash infoHash, int pieceSizePow2, I2PConnector connector, Destination destination, + public Downloader(DownloadManager downloadManager, File file, long length, InfoHash infoHash, + int pieceSizePow2, I2PConnector connector, Destination destination, File incompletes) { + this.downloadManager = downloadManager this.file = file this.infoHash = infoHash this.length = length @@ -112,4 +115,8 @@ public class Downloader { cancelled = true downloadThread?.interrupt() } + + public void resume() { + downloadManager.resume(this) + } } diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 38ce78da..c5d6e34a 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -90,6 +90,12 @@ class MainFrameController { downloader.cancel() } + @ControllerAction + void resume() { + def downloader = selectedDownload() + downloader.resume() + } + void mvcGroupInit(Map args) { application.addPropertyChangeListener("core", {e-> core = e.getNewValue() diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 0464c9a7..04dc1afa 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -99,7 +99,7 @@ class MainFrameView { } panel (constraints : BorderLayout.SOUTH) { button(text: "Cancel", enabled : bind {model.cancelButtonEnabled }, cancelAction ) - button("Retry", enabled : bind {model.retryButtonEnabled}) + button(text: "Retry", enabled : bind {model.retryButtonEnabled}, resumeAction) } } }