From a7125963a7834c6571e4e002bcbfb648bc51a05e Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 9 Jun 2019 16:19:35 +0100 Subject: [PATCH] DownloadManager listens to events, not FileManager --- core/src/main/groovy/com/muwire/core/Core.groovy | 2 +- .../groovy/com/muwire/core/download/DownloadManager.groovy | 5 +++++ .../src/main/groovy/com/muwire/core/files/FileManager.groovy | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 312c0aae..fcbd51a5 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -154,7 +154,6 @@ public class Core { eventBus.register(FileDownloadedEvent.class, fileManager) eventBus.register(FileUnsharedEvent.class, fileManager) eventBus.register(SearchEvent.class, fileManager) - eventBus.register(UILoadedEvent.class, fileManager) log.info "initializing persistence service" persisterService = new PersisterService(new File(home, "files.json"), eventBus, 5000, fileManager) @@ -194,6 +193,7 @@ public class Core { log.info("initializing download manager") DownloadManager downloadManager = new DownloadManager(eventBus, i2pConnector, new File(home, "incompletes"), me) eventBus.register(UIDownloadEvent.class, downloadManager) + eventBus.register(UILoadedEvent.class, downloadManager) log.info("initializing upload manager") UploadManager uploadManager = new UploadManager(eventBus, fileManager) 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 7b4b5f59..89ee0cd2 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy @@ -7,6 +7,7 @@ import net.i2p.data.Destination import com.muwire.core.EventBus import com.muwire.core.Persona +import com.muwire.core.UILoadedEvent import java.util.concurrent.Executor import java.util.concurrent.Executors @@ -57,4 +58,8 @@ public class DownloadManager { void resume(Downloader downloader) { executor.execute({downloader.download() as Runnable}) } + + void onUILoadedEvent(UILoadedEvent e) { + // TODO: load downloads here + } } diff --git a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy index 083d5706..887e511e 100644 --- a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy +++ b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy @@ -135,8 +135,4 @@ class FileManager { } rv } - - void onUILoadedEvent(UILoadedEvent e) { - // TODO: resume downloads - } }