T-013: Download-Manager — Queue mit Bytes-Fortschritt-Events, Abbruch, Wiederaufnahme per Manifest nach Neustart, UI: Laden/Abbrechen auf Cards
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
mod audible;
|
||||
mod download;
|
||||
|
||||
use audible::{AudibleClient, AuthStatus, Book, CliAudibleClient};
|
||||
use download::{DownloadMgr, SharedDownloadMgr};
|
||||
|
||||
use tauri::Manager;
|
||||
|
||||
#[tauri::command]
|
||||
fn auth_status(client: tauri::State<CliAudibleClient>) -> Result<AuthStatus, String> {
|
||||
@ -17,6 +21,21 @@ fn start_decrypt(client: tauri::State<CliAudibleClient>) -> Result<bool, String>
|
||||
client.start_decrypt()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn download_list(dl: tauri::State<SharedDownloadMgr>) -> Vec<download::DlItem> {
|
||||
dl.list()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn download_enqueue(dl: tauri::State<SharedDownloadMgr>, asin: String) -> Result<download::DlItem, String> {
|
||||
dl.enqueue(&asin)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn download_cancel(dl: tauri::State<SharedDownloadMgr>, asin: String) -> Result<download::DlItem, String> {
|
||||
dl.cancel(&asin)
|
||||
}
|
||||
|
||||
/// Bibliothek laden: externer CLI-Export dauert (Netzwerk) — läuft deshalb
|
||||
/// auf einem Blocking-Thread, damit die UI nicht friert.
|
||||
#[tauri::command]
|
||||
@ -33,11 +52,20 @@ pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.manage(CliAudibleClient::new())
|
||||
.manage(DownloadMgr::new())
|
||||
.setup(|app| {
|
||||
app.state::<SharedDownloadMgr>()
|
||||
.attach(app.handle().clone());
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
auth_status,
|
||||
start_login,
|
||||
start_decrypt,
|
||||
get_library
|
||||
get_library,
|
||||
download_list,
|
||||
download_enqueue,
|
||||
download_cancel
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
Reference in New Issue
Block a user