mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-10 18:04:06 +02:00
refactor(backend): retire unused native bridge entry points
This commit is contained in:
1 parent
b8e3a4c166
commit
fe88048db2
45 files changed
+20
-1832
No files matched your search
@@ -59,18 +59,10 @@ impl CancellationRegistry {
|
||||
self.inner.cancel(&id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn cancel_active(&self) -> Result<Vec<String>, CancellationError> {
|
||||
self.inner.cancel_active().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn is_cancelled(&self, id: String) -> Result<bool, CancellationError> {
|
||||
self.inner.is_cancelled(&id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn reset_if_idle(&self, id: String) -> Result<(), CancellationError> {
|
||||
self.inner.reset_if_idle(&id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn shutdown(&self) {
|
||||
self.inner.shutdown();
|
||||
}
|
||||
@@ -87,14 +79,6 @@ impl RequestLease {
|
||||
self.inner.is_cancelled().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn check_active(&self) -> Result<(), CancellationError> {
|
||||
self.inner.check_active().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn wait_cancelled(&self, timeout_ms: i64) -> Result<bool, CancellationError> {
|
||||
self.inner.wait_cancelled(timeout_ms).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn release(&self) {
|
||||
self.inner.release();
|
||||
}
|
||||
|
||||
@@ -131,49 +131,6 @@ impl JsExtension {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn preflight_signed_session(
|
||||
&self,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
timeout_ms: u64,
|
||||
) -> Result<bool, JsExtensionError> {
|
||||
self.inner
|
||||
.preflight_signed_session(lease.map(|lease| Arc::clone(&lease.inner)), timeout_ms)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn call_download(
|
||||
&self,
|
||||
method: String,
|
||||
arguments_json: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
resolution_timeout_ms: u64,
|
||||
) -> Result<String, JsExtensionError> {
|
||||
self.inner
|
||||
.call_download(
|
||||
&method,
|
||||
&arguments_json,
|
||||
lease.map(|lease| Arc::clone(&lease.inner)),
|
||||
resolution_timeout_ms,
|
||||
)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn take_verification_url(&self) -> String {
|
||||
self.inner.take_verification_url()
|
||||
}
|
||||
|
||||
pub fn call_download_for_item(
|
||||
&self,
|
||||
method: String,
|
||||
arguments_json: String,
|
||||
item_id: String,
|
||||
resolution_timeout_ms: u64,
|
||||
) -> Result<String, JsExtensionError> {
|
||||
self.inner
|
||||
.call_download_for_item(&method, &arguments_json, &item_id, resolution_timeout_ms)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn shutdown(&self) {
|
||||
self.inner.shutdown();
|
||||
}
|
||||
@@ -220,48 +177,10 @@ impl ExtensionEnvironment {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn load(
|
||||
&self,
|
||||
manifest_json: String,
|
||||
source: String,
|
||||
timeout_ms: u64,
|
||||
) -> Result<Arc<JsExtension>, JsExtensionError> {
|
||||
let limits = RuntimeLimits {
|
||||
timeout_ms: if timeout_ms == 0 { 30_000 } else { timeout_ms },
|
||||
..RuntimeLimits::default()
|
||||
};
|
||||
Ok(Arc::new(JsExtension {
|
||||
inner: self.inner.load(&manifest_json, &source, limits)?,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn settings(&self, extension_id: String) -> Result<String, JsExtensionError> {
|
||||
Ok(serde_json::Value::Object(self.inner.settings(&extension_id)?).to_string())
|
||||
}
|
||||
|
||||
pub fn set_setting(
|
||||
&self,
|
||||
extension_id: String,
|
||||
key: String,
|
||||
value_json: String,
|
||||
) -> Result<(), JsExtensionError> {
|
||||
let value = serde_json::from_str(&value_json)
|
||||
.map_err(|error| JsExtensionError::InvalidInput(error.to_string()))?;
|
||||
self.inner
|
||||
.set_setting(&extension_id, &key, value)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn remove_setting(
|
||||
&self,
|
||||
extension_id: String,
|
||||
key: String,
|
||||
) -> Result<(), JsExtensionError> {
|
||||
self.inner
|
||||
.remove_setting(&extension_id, &key)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_allow_private_network(&self, allow: bool) -> Result<(), JsExtensionError> {
|
||||
self.inner
|
||||
.set_allow_private_network(allow)
|
||||
@@ -313,14 +232,6 @@ impl ExtensionEnvironment {
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn pending_auth(&self, extension_id: String) -> Result<String, JsExtensionError> {
|
||||
Ok(self
|
||||
.inner
|
||||
.pending_auth(&extension_id)?
|
||||
.map(|pending| serde_json::to_string(&pending).expect("pending auth JSON"))
|
||||
.unwrap_or_default())
|
||||
}
|
||||
|
||||
pub fn set_runtime_state(&self, raw: String) -> Result<(), JsExtensionError> {
|
||||
self.inner.set_runtime_state(&raw).map_err(Into::into)
|
||||
}
|
||||
@@ -336,16 +247,6 @@ impl ExtensionEnvironment {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn all_pending_auth(&self) -> Result<String, JsExtensionError> {
|
||||
Ok(serde_json::to_string(&self.inner.all_pending_auth()?).expect("pending auth JSON"))
|
||||
}
|
||||
|
||||
pub fn clear_pending_auth(&self, extension_id: String) -> Result<(), JsExtensionError> {
|
||||
self.inner
|
||||
.clear_pending_auth(&extension_id)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn resolve_callback_state(&self, state: String) -> Result<String, JsExtensionError> {
|
||||
self.inner
|
||||
.resolve_callback_state(&state, false)
|
||||
@@ -369,26 +270,6 @@ impl ExtensionEnvironment {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_auth_tokens(
|
||||
&self,
|
||||
extension_id: String,
|
||||
access_token: String,
|
||||
refresh_token: String,
|
||||
expires_in: i64,
|
||||
) -> Result<(), JsExtensionError> {
|
||||
let access_token = zeroize::Zeroizing::new(access_token);
|
||||
let refresh_token = zeroize::Zeroizing::new(refresh_token);
|
||||
self.inner
|
||||
.set_auth_tokens(&extension_id, &access_token, &refresh_token, expires_in)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn is_authenticated(&self, extension_id: String) -> Result<bool, JsExtensionError> {
|
||||
self.inner
|
||||
.is_authenticated(&extension_id)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn shutdown(&self) {
|
||||
self.inner.shutdown();
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@ pub struct FfmpegCommands {
|
||||
|
||||
#[uniffi::export]
|
||||
impl FfmpegCommands {
|
||||
pub fn pending(&self) -> Result<String, FfmpegError> {
|
||||
self.inner.pending_json().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn wait_pending(&self, timeout_ms: i64) -> Result<String, FfmpegError> {
|
||||
self.inner.wait_pending_json(timeout_ms).map_err(Into::into)
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
use crate::cancellation::RequestLease;
|
||||
use crate::extensions::{ExtensionEnvironment, JsExtensionError};
|
||||
use std::sync::Arc;
|
||||
|
||||
fn check(lease: &Option<Arc<RequestLease>>) -> Result<(), String> {
|
||||
lease.as_ref().map_or(Ok(()), |lease| {
|
||||
lease
|
||||
.inner
|
||||
.check_active()
|
||||
.map_err(|error| error.to_string())
|
||||
})
|
||||
}
|
||||
|
||||
#[uniffi::export]
|
||||
impl ExtensionEnvironment {
|
||||
pub fn prebuild_isrc_index(
|
||||
&self,
|
||||
directory: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<(), JsExtensionError> {
|
||||
self.inner
|
||||
.prebuild_isrc_index(&directory, &|| check(&lease))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn check_isrc_exists(
|
||||
&self,
|
||||
directory: String,
|
||||
isrc: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, JsExtensionError> {
|
||||
self.inner
|
||||
.check_isrc_exists(&directory, &isrc, &|| check(&lease))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn add_to_isrc_index(
|
||||
&self,
|
||||
directory: String,
|
||||
isrc: String,
|
||||
path: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<(), JsExtensionError> {
|
||||
self.inner
|
||||
.add_to_isrc_index(&directory, &isrc, &path, &|| check(&lease))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn check_files_exist_parallel(
|
||||
&self,
|
||||
directory: String,
|
||||
tracks_json: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, JsExtensionError> {
|
||||
self.inner
|
||||
.check_files_exist_parallel(&directory, &tracks_json, &|| check(&lease))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn invalidate_isrc_cache(&self, directory: String) -> Result<(), JsExtensionError> {
|
||||
self.inner
|
||||
.invalidate_isrc_cache(&directory)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn check_file_exists(&self, path: String) -> Result<bool, JsExtensionError> {
|
||||
self.inner.check_file_exists(&path).map_err(Into::into)
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ mod extensions;
|
||||
mod ffmpeg;
|
||||
mod filename;
|
||||
mod hires;
|
||||
mod index;
|
||||
mod library_metadata;
|
||||
mod logging;
|
||||
mod lyrics;
|
||||
|
||||
@@ -79,12 +79,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_lyrics_providers_json(&self) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_lyrics_providers_json()
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn set_lyrics_providers_json(
|
||||
&self,
|
||||
providers_json: String,
|
||||
@@ -100,12 +94,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_lyrics_fetch_options_json(&self) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_lyrics_fetch_options_json()
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn set_lyrics_fetch_options_json(
|
||||
&self,
|
||||
options_json: String,
|
||||
|
||||
@@ -81,18 +81,6 @@ impl ExtensionManager {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_app_version(&self) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_app_version()
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn set_app_version(&self, version: String) -> Result<(), ExtensionManagerError> {
|
||||
self.inner
|
||||
.set_app_version(&version)
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn install(&self, package_path: String) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.install(Path::new(&package_path))
|
||||
@@ -168,15 +156,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn download_with_extensions_json(
|
||||
&self,
|
||||
request_json: String,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.download_with_extensions_json(&request_json, &|| Ok(()))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn check_extension_health_json(
|
||||
&self,
|
||||
extension_id: String,
|
||||
@@ -200,12 +179,6 @@ impl ExtensionManager {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn release_idle_download_runtimes(&self) -> Result<u64, ExtensionManagerError> {
|
||||
self.inner
|
||||
.release_idle_download_runtimes()
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn release_memory(&self, under_pressure: bool) -> Result<(), ExtensionManagerError> {
|
||||
self.inner
|
||||
.release_memory(under_pressure)
|
||||
@@ -247,32 +220,6 @@ impl ExtensionManager {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn check_availability(
|
||||
&self,
|
||||
extension_id: String,
|
||||
request_json: String,
|
||||
timeout_ms: u64,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
let request = serde_json::from_str(&request_json).map_err(|error| {
|
||||
ExtensionManagerError::Operation(format!("invalid availability request: {error}"))
|
||||
})?;
|
||||
self.inner
|
||||
.check_availability(&extension_id, request, timeout_ms)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn enrich_track(
|
||||
&self,
|
||||
extension_id: String,
|
||||
track_json: String,
|
||||
item_id: String,
|
||||
timeout_ms: u64,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.enrich_track(&extension_id, &track_json, &item_id, timeout_ms)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn search_metadata_provider(
|
||||
&self,
|
||||
extension_id: String,
|
||||
@@ -333,10 +280,6 @@ impl ExtensionManager {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn provider_ids(&self, kind: String) -> Result<Vec<String>, ExtensionManagerError> {
|
||||
self.inner.provider_ids(&kind).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn provider_call(
|
||||
&self,
|
||||
extension_id: String,
|
||||
@@ -377,12 +320,6 @@ impl ExtensionManager {
|
||||
self.inner.provider_priorities().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn fallback_allowed(&self, extension_id: String) -> Result<bool, ExtensionManagerError> {
|
||||
self.inner
|
||||
.fallback_allowed(&extension_id)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn find_url_handler(&self, url: String) -> Result<Option<String>, ExtensionManagerError> {
|
||||
self.inner.find_url_handler(&url).map_err(Into::into)
|
||||
}
|
||||
@@ -396,14 +333,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn unload(&self, extension_id: String) -> Result<(), ExtensionManagerError> {
|
||||
self.inner.unload(&extension_id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn unload_all(&self) -> Result<(), ExtensionManagerError> {
|
||||
self.inner.unload_all().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn remove(&self, extension_id: String) -> Result<(), ExtensionManagerError> {
|
||||
self.inner.remove(&extension_id).map_err(Into::into)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,6 @@ use crate::cancellation::RequestLease;
|
||||
use crate::manager::{ExtensionManager, ExtensionManagerError};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(uniffi::Record)]
|
||||
pub struct DeezerResource {
|
||||
pub resource_type: String,
|
||||
pub resource_id: String,
|
||||
}
|
||||
|
||||
fn check(lease: &Option<Arc<RequestLease>>) -> Result<(), String> {
|
||||
lease.as_ref().map_or(Ok(()), |lease| {
|
||||
lease
|
||||
@@ -21,16 +15,6 @@ fn check(lease: &Option<Arc<RequestLease>>) -> Result<(), String> {
|
||||
/// Run network operations on a native background thread and retain any lease.
|
||||
#[uniffi::export]
|
||||
impl ExtensionManager {
|
||||
pub fn enrich_track_json(
|
||||
&self,
|
||||
extension_id: String,
|
||||
track_json: String,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.enrich_track_json(&extension_id, &track_json)
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn handle_url_json(&self, url: String) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.handle_url_json(&url)
|
||||
@@ -118,18 +102,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn set_song_link_region(&self, region: String) -> Result<(), ExtensionManagerError> {
|
||||
self.inner
|
||||
.set_song_link_region(®ion)
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_song_link_region(&self) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_song_link_region()
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_track_cache_size(&self) -> Result<u64, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_track_cache_size()
|
||||
@@ -142,47 +114,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn parse_deezer_url(&self, url: String) -> Result<DeezerResource, ExtensionManagerError> {
|
||||
let (resource_type, resource_id) = self
|
||||
.inner
|
||||
.parse_deezer_url(&url)
|
||||
.map_err(ExtensionManagerError::Operation)?;
|
||||
Ok(DeezerResource {
|
||||
resource_type,
|
||||
resource_id,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn search_deezer(
|
||||
&self,
|
||||
query: String,
|
||||
track_limit: i64,
|
||||
artist_limit: i64,
|
||||
filter: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.search_deezer(
|
||||
&query,
|
||||
track_limit as isize,
|
||||
artist_limit as isize,
|
||||
&filter,
|
||||
&|| check(&lease),
|
||||
)
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_deezer_metadata(
|
||||
&self,
|
||||
resource_type: String,
|
||||
resource_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_deezer_metadata(&resource_type, &resource_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_deezer_extended_metadata(
|
||||
&self,
|
||||
track_id: String,
|
||||
@@ -193,16 +124,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn search_deezer_by_isrc(
|
||||
&self,
|
||||
isrc: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.search_deezer_by_isrc(&isrc, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn search_deezer_by_isrc_for_item_id(
|
||||
&self,
|
||||
isrc: String,
|
||||
@@ -236,151 +157,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn check_track_availability_json(
|
||||
&self,
|
||||
spotify_id: String,
|
||||
isrc: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.check_track_availability_json(&spotify_id, &isrc, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn check_album_availability_json(
|
||||
&self,
|
||||
spotify_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.check_album_availability_json(&spotify_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn check_availability_from_deezer_json(
|
||||
&self,
|
||||
track_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.check_availability_from_deezer_json(&track_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn check_availability_by_platform_json(
|
||||
&self,
|
||||
platform: String,
|
||||
resource_type: String,
|
||||
resource_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.check_availability_by_platform_json(&platform, &resource_type, &resource_id, &|| {
|
||||
check(&lease)
|
||||
})
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn check_availability_from_url_json(
|
||||
&self,
|
||||
url: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.check_availability_from_url_json(&url, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_streaming_urls_json(
|
||||
&self,
|
||||
spotify_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_streaming_urls_json(&spotify_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_deezer_id_from_spotify(
|
||||
&self,
|
||||
spotify_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_deezer_id_from_spotify(&spotify_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_deezer_album_id_from_spotify(
|
||||
&self,
|
||||
spotify_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_deezer_album_id_from_spotify(&spotify_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_youtube_url_from_spotify(
|
||||
&self,
|
||||
spotify_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_youtube_url_from_spotify(&spotify_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_spotify_id_from_deezer_track(
|
||||
&self,
|
||||
track_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_spotify_id_from_deezer_track(&track_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_tidal_url_from_deezer_track(
|
||||
&self,
|
||||
track_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_tidal_url_from_deezer_track(&track_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_amazon_url_from_deezer_track(
|
||||
&self,
|
||||
track_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_amazon_url_from_deezer_track(&track_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn get_youtube_url_from_deezer_track(
|
||||
&self,
|
||||
track_id: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.get_youtube_url_from_deezer_track(&track_id, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn preview_reenrich_file(
|
||||
&self,
|
||||
request_json: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.preview_reenrich_file(&request_json, &|| check(&lease))
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn reenrich_file(
|
||||
&self,
|
||||
request_json: String,
|
||||
|
||||
@@ -72,58 +72,6 @@ impl DownloadState {
|
||||
self.inner.progress.remove(&item_id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn clear_all_progress(&self) -> Result<(), DownloadProgressError> {
|
||||
self.inner.progress.clear().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_preparing(
|
||||
&self,
|
||||
item_id: String,
|
||||
stage: String,
|
||||
) -> Result<(), DownloadProgressError> {
|
||||
self.inner
|
||||
.progress
|
||||
.preparing(&item_id, &stage)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_downloading(&self, item_id: String) -> Result<(), DownloadProgressError> {
|
||||
self.inner
|
||||
.progress
|
||||
.downloading(&item_id)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_total(&self, item_id: String, total: i64) -> Result<(), DownloadProgressError> {
|
||||
self.inner
|
||||
.progress
|
||||
.set_total(&item_id, total)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_received(
|
||||
&self,
|
||||
item_id: String,
|
||||
received: i64,
|
||||
) -> Result<(), DownloadProgressError> {
|
||||
self.inner
|
||||
.progress
|
||||
.set_received(&item_id, received)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_received_with_speed(
|
||||
&self,
|
||||
item_id: String,
|
||||
received: i64,
|
||||
speed: f64,
|
||||
) -> Result<(), DownloadProgressError> {
|
||||
self.inner
|
||||
.progress
|
||||
.set_received_with_speed(&item_id, received, speed)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_progress(
|
||||
&self,
|
||||
item_id: String,
|
||||
@@ -137,26 +85,10 @@ impl DownloadState {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_finalizing(&self, item_id: String) -> Result<(), DownloadProgressError> {
|
||||
self.inner.progress.finalizing(&item_id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn complete_item(&self, item_id: String) -> Result<(), DownloadProgressError> {
|
||||
self.inner.progress.complete(&item_id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn item_progress(&self, item_id: String) -> Result<String, DownloadProgressError> {
|
||||
self.inner.progress.item(&item_id).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn all_progress(&self) -> Result<String, DownloadProgressError> {
|
||||
self.inner.progress.snapshot().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn progress_delta(&self, since: i64) -> Result<String, DownloadProgressError> {
|
||||
self.inner.progress.delta(since).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn wait_progress_delta(
|
||||
&self,
|
||||
since: i64,
|
||||
|
||||
@@ -54,22 +54,6 @@ impl ExtensionRepository {
|
||||
self.search_inner(force_refresh, "", "")
|
||||
}
|
||||
|
||||
pub fn search(
|
||||
&self,
|
||||
query: String,
|
||||
category: String,
|
||||
) -> Result<String, ExtensionRepositoryError> {
|
||||
self.search_inner(false, &query, &category)
|
||||
}
|
||||
|
||||
pub fn categories(&self) -> Result<Vec<String>, ExtensionRepositoryError> {
|
||||
self.inner.categories().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn clear_cache(&self) -> Result<(), ExtensionRepositoryError> {
|
||||
self.inner.clear_cache().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn download(
|
||||
&self,
|
||||
extension_id: String,
|
||||
|
||||
@@ -93,17 +93,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn scan_library_folder(
|
||||
&self,
|
||||
folder: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.scan_library_folder(&folder, &|| check_lease(lease.as_deref()))
|
||||
.map(|value| value.to_string())
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn scan_library_folder_incremental(
|
||||
&self,
|
||||
folder: String,
|
||||
@@ -181,25 +170,6 @@ impl ExtensionManager {
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn save_cover_to_cache_with_hint_and_key(
|
||||
&self,
|
||||
audio_path: String,
|
||||
hint: String,
|
||||
cache_directory: String,
|
||||
cache_key: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, ExtensionManagerError> {
|
||||
self.inner
|
||||
.save_cover_to_cache_with_hint_and_key(
|
||||
&audio_path,
|
||||
&hint,
|
||||
&cache_directory,
|
||||
&cache_key,
|
||||
&|| check_lease(lease.as_deref()),
|
||||
)
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
|
||||
pub fn download_cover_to_file_sized(
|
||||
&self,
|
||||
url: String,
|
||||
@@ -280,22 +250,6 @@ impl ExtensionManager {
|
||||
})?;
|
||||
Ok(serde_json::json!({"success":true,"handled":handled}).to_string())
|
||||
}
|
||||
|
||||
/// Atomic audio tag editing on the root owner's granted file paths.
|
||||
pub fn edit_audio_tags(
|
||||
&self,
|
||||
path: String,
|
||||
format: String,
|
||||
fields_json: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<(), ExtensionManagerError> {
|
||||
let check = || check_lease(lease.as_deref());
|
||||
check().map_err(ExtensionManagerError::Operation)?;
|
||||
let fields = decode_fields(&fields_json).map_err(ExtensionManagerError::Operation)?;
|
||||
self.inner
|
||||
.edit_audio_tags(&path, &format, &fields, &check)
|
||||
.map_err(ExtensionManagerError::Operation)
|
||||
}
|
||||
}
|
||||
|
||||
fn decode_fields(json: &str) -> Result<BTreeMap<String, String>, String> {
|
||||
@@ -308,23 +262,9 @@ fn decode_fields(json: &str) -> Result<BTreeMap<String, String>, String> {
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// Read only the tag fields. Native callers retain ownership of any platform
|
||||
/// descriptor referenced by `path` until this synchronous operation returns.
|
||||
#[uniffi::export]
|
||||
pub fn read_audio_tags(
|
||||
path: String,
|
||||
format: String,
|
||||
lease: Option<Arc<RequestLease>>,
|
||||
) -> Result<String, AudioTagsError> {
|
||||
let check = || check_lease(lease.as_deref());
|
||||
check()?;
|
||||
let mut file = open_audio_file(&path)?;
|
||||
let metadata = tags::read_audio_tags(&mut file, &format, &check)?;
|
||||
serde_json::to_string(&metadata).map_err(|error| error.to_string().into())
|
||||
}
|
||||
|
||||
/// Complete application metadata. An empty hint is equivalent to the legacy
|
||||
/// ReadFileMetadata call. Native descriptor ownership matches read_audio_tags.
|
||||
/// ReadFileMetadata call. Native callers retain ownership of any platform
|
||||
/// descriptor referenced by `path` until this synchronous operation returns.
|
||||
#[uniffi::export]
|
||||
pub fn read_file_metadata(
|
||||
path: String,
|
||||
|
||||
Reference in new issue
Block a user