diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index bc5b72fa2..fa0da0069 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -3305,1632 +3305,3 @@ pub async fn v2_uncache_favorite_artist( store.remove_favorite_artist(artistId) .map_err(|e| RuntimeError::Internal(e)) } - -// ==================== Settings Commands (V2) ==================== - -// -- Tray Settings -- - -/// Get tray settings (V2) -#[tauri::command] -pub async fn v2_get_tray_settings( - state: State<'_, crate::config::tray_settings::TraySettingsState>, -) -> Result { - state.get_settings().map_err(|e| RuntimeError::Internal(e)) -} - -/// Set enable tray (V2) -#[tauri::command] -pub async fn v2_set_enable_tray( - value: bool, - state: State<'_, crate::config::tray_settings::TraySettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting enable_tray to {} (restart required)", value); - state.set_enable_tray(value).map_err(|e| RuntimeError::Internal(e)) -} - -/// Set minimize to tray (V2) -#[tauri::command] -pub async fn v2_set_minimize_to_tray( - value: bool, - state: State<'_, crate::config::tray_settings::TraySettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting minimize_to_tray to {}", value); - state.set_minimize_to_tray(value).map_err(|e| RuntimeError::Internal(e)) -} - -/// Set close to tray (V2) -#[tauri::command] -pub async fn v2_set_close_to_tray( - value: bool, - state: State<'_, crate::config::tray_settings::TraySettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting close_to_tray to {}", value); - state.set_close_to_tray(value).map_err(|e| RuntimeError::Internal(e)) -} - -// -- Graphics Settings -- - -/// Get graphics settings (V2) -#[tauri::command] -pub async fn v2_get_graphics_settings( - state: State<'_, crate::config::graphics_settings::GraphicsSettingsState>, -) -> Result { - crate::config::graphics_settings::get_graphics_settings(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set hardware acceleration (V2) -#[tauri::command] -pub async fn v2_set_hardware_acceleration( - enabled: bool, - state: State<'_, crate::config::graphics_settings::GraphicsSettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting hardware_acceleration to {}", enabled); - crate::config::graphics_settings::set_hardware_acceleration(state, enabled) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set GDK scale (V2) -#[tauri::command] -pub async fn v2_set_gdk_scale( - scale: Option, - state: State<'_, crate::config::graphics_settings::GraphicsSettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting gdk_scale to {:?}", scale); - crate::config::graphics_settings::set_gdk_scale(state, scale) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set GDK DPI scale (V2) -#[tauri::command] -pub async fn v2_set_gdk_dpi_scale( - scale: Option, - state: State<'_, crate::config::graphics_settings::GraphicsSettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting gdk_dpi_scale to {:?}", scale); - crate::config::graphics_settings::set_gdk_dpi_scale(state, scale) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get graphics startup status (V2) -#[tauri::command] -pub async fn v2_get_graphics_startup_status() -> Result { - Ok(crate::config::graphics_settings::get_graphics_startup_status()) -} - -// -- Window Settings -- - -/// Get window settings (V2) -#[tauri::command] -pub async fn v2_get_window_settings( - state: State<'_, crate::config::window_settings::WindowSettingsState>, -) -> Result { - crate::config::window_settings::get_window_settings(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set use system titlebar (V2) -#[tauri::command] -pub async fn v2_set_use_system_titlebar( - value: bool, - state: State<'_, crate::config::window_settings::WindowSettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting use_system_titlebar to {}", value); - crate::config::window_settings::set_use_system_titlebar(value, state) - .map_err(|e| RuntimeError::Internal(e)) -} - -// -- Developer Settings -- - -/// Get developer settings (V2) -#[tauri::command] -pub async fn v2_get_developer_settings( - state: State<'_, crate::config::developer_settings::DeveloperSettingsState>, -) -> Result { - crate::config::developer_settings::get_developer_settings(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set developer force DMABuf (V2) -#[tauri::command] -pub async fn v2_set_developer_force_dmabuf( - value: bool, - state: State<'_, crate::config::developer_settings::DeveloperSettingsState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting force_dmabuf to {}", value); - crate::config::developer_settings::set_developer_force_dmabuf(state, value) - .map_err(|e| RuntimeError::Internal(e)) -} - -// -- Playback Preferences -- - -/// Get playback preferences (V2) -#[tauri::command] -pub async fn v2_get_playback_preferences( - state: State<'_, crate::config::playback_preferences::PlaybackPreferencesState>, -) -> Result { - crate::config::playback_preferences::get_playback_preferences(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set autoplay mode (V2) -#[tauri::command] -pub async fn v2_set_autoplay_mode( - mode: String, - state: State<'_, crate::config::playback_preferences::PlaybackPreferencesState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting autoplay_mode to {}", mode); - crate::config::playback_preferences::set_autoplay_mode(mode, state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set show context icon (V2) -#[tauri::command] -pub async fn v2_set_show_context_icon( - value: bool, - state: State<'_, crate::config::playback_preferences::PlaybackPreferencesState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting show_context_icon to {}", value); - crate::config::playback_preferences::set_show_context_icon(value, state) - .map_err(|e| RuntimeError::Internal(e)) -} - -// -- Favorites Preferences -- - -/// Get favorites preferences (V2) -#[tauri::command] -pub async fn v2_get_favorites_preferences( - state: State<'_, crate::config::favorites_preferences::FavoritesPreferencesState>, -) -> Result { - crate::config::favorites_preferences::get_favorites_preferences(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Save favorites preferences (V2) -#[tauri::command] -pub async fn v2_save_favorites_preferences( - prefs: crate::config::favorites_preferences::FavoritesPreferences, - state: State<'_, crate::config::favorites_preferences::FavoritesPreferencesState>, -) -> Result { - log::info!("[V2] Saving favorites preferences"); - crate::config::favorites_preferences::save_favorites_preferences(prefs, state) - .map_err(|e| RuntimeError::Internal(e)) -} - -// -- Visualizer -- - -/// Set visualizer enabled (V2) -#[tauri::command] -pub async fn v2_set_visualizer_enabled( - enabled: bool, - app_state: State<'_, AppState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting visualizer_enabled to {}", enabled); - crate::commands::visualizer::set_visualizer_enabled(enabled, app_state) - .map_err(|e| RuntimeError::Internal(e)) -} - -// -- Blacklist -- - -/// Get artist blacklist (V2) -#[tauri::command] -pub async fn v2_get_artist_blacklist( - state: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result, RuntimeError> { - state.get_all().map_err(|e| RuntimeError::Internal(e)) -} - -/// Add to artist blacklist (V2) -#[tauri::command] -pub async fn v2_add_to_artist_blacklist( - artistId: u64, - artistName: String, - notes: Option, - state: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Adding artist {} to blacklist", artistId); - state.add(artistId, &artistName, notes.as_deref()) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Remove from artist blacklist (V2) -#[tauri::command] -pub async fn v2_remove_from_artist_blacklist( - artistId: u64, - state: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Removing artist {} from blacklist", artistId); - state.remove(artistId).map_err(|e| RuntimeError::Internal(e)) -} - -/// Clear artist blacklist (V2) -#[tauri::command] -pub async fn v2_clear_artist_blacklist( - state: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Clearing artist blacklist"); - state.clear_all().map_err(|e| RuntimeError::Internal(e)) -} - -/// Set blacklist enabled (V2) -#[tauri::command] -pub async fn v2_set_blacklist_enabled( - enabled: bool, - state: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting blacklist_enabled to {}", enabled); - state.set_enabled(enabled).map_err(|e| RuntimeError::Internal(e)) -} - -/// Get blacklist settings (V2) -#[tauri::command] -pub async fn v2_get_blacklist_settings( - state: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result { - state.get_settings().map_err(|e| RuntimeError::Internal(e)) -} - -/// Get blacklist count (V2) -#[tauri::command] -pub async fn v2_get_blacklist_count( - state: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result { - Ok(state.count()) -} - -// -- API Locale -- - -/// Set API locale (V2) -#[tauri::command] -pub async fn v2_set_api_locale( - locale: String, - app_state: State<'_, AppState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] Setting API locale to {}", locale); - crate::commands::auth::set_api_locale(locale, app_state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ==================== Cache Management Commands (V2) ==================== - -/// Get cache stats (V2) -#[tauri::command] -pub async fn v2_get_cache_stats( - app_state: State<'_, AppState>, -) -> Result { - log::info!("[V2] get_cache_stats"); - Ok(app_state.audio_cache.stats()) -} - -/// Clear audio cache (V2) -#[tauri::command] -pub async fn v2_clear_cache( - app_state: State<'_, AppState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] clear_cache"); - app_state.audio_cache.clear(); - Ok(()) -} - -/// Clear artist cache (V2) -#[tauri::command] -pub async fn v2_clear_artist_cache( - cache_state: State<'_, crate::api_cache::ApiCacheState>, -) -> Result { - log::info!("[V2] clear_artist_cache"); - let guard = cache_state.cache.lock().await; - let cache = guard.as_ref() - .ok_or_else(|| RuntimeError::Internal("No active session".to_string()))?; - cache.clear_all_artists() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Clear vector store (V2) -#[tauri::command] -pub async fn v2_clear_vector_store( - store_state: State<'_, crate::artist_vectors::ArtistVectorStoreState>, -) -> Result { - log::info!("[V2] clear_vector_store"); - let mut guard = store_state.store.lock().await; - let store = guard.as_mut() - .ok_or_else(|| RuntimeError::Internal("No active session".to_string()))?; - store.clear_all() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get vector store stats (V2) -#[tauri::command] -pub async fn v2_get_vector_store_stats( - store_state: State<'_, crate::artist_vectors::ArtistVectorStoreState>, -) -> Result { - log::info!("[V2] get_vector_store_stats"); - let guard = store_state.store.lock().await; - let store = guard.as_ref() - .ok_or_else(|| RuntimeError::Internal("No active session".to_string()))?; - store.get_stats() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Clear offline cache (V2) -#[tauri::command] -pub async fn v2_clear_offline_cache( - cache_state: State<'_, crate::offline_cache::OfflineCacheState>, - library_state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] clear_offline_cache"); - crate::offline_cache::commands::clear_offline_cache(cache_state, library_state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Clear saved credentials (V2) -#[tauri::command] -pub async fn v2_clear_saved_credentials() -> Result<(), RuntimeError> { - log::info!("[V2] clear_saved_credentials"); - crate::commands::auth::clear_saved_credentials() - .map_err(|e| RuntimeError::Internal(e)) -} - -// ==================== Playlist Custom Commands (V2) ==================== - -/// Set playlist sort (V2) -#[tauri::command] -pub async fn v2_playlist_set_sort( - playlistId: u64, - sortBy: String, - sortOrder: String, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_set_sort {} {} {}", playlistId, sortBy, sortOrder); - crate::library::commands::playlist_set_sort(playlistId, sortBy, sortOrder, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set playlist artwork (V2) -#[tauri::command] -pub async fn v2_playlist_set_artwork( - playlistId: u64, - artworkPath: Option, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_set_artwork {} {:?}", playlistId, artworkPath); - crate::library::commands::playlist_set_artwork(playlistId, artworkPath, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Add local track to playlist (V2) -#[tauri::command] -pub async fn v2_playlist_add_local_track( - playlistId: u64, - trackId: i64, - position: i32, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_add_local_track {} {} pos={}", playlistId, trackId, position); - crate::library::commands::playlist_add_local_track(playlistId, trackId, position, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Remove local track from playlist (V2) -#[tauri::command] -pub async fn v2_playlist_remove_local_track( - playlistId: u64, - trackId: i64, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_remove_local_track {} {}", playlistId, trackId); - crate::library::commands::playlist_remove_local_track(playlistId, trackId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set playlist hidden (V2) -#[tauri::command] -pub async fn v2_playlist_set_hidden( - playlistId: u64, - hidden: bool, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_set_hidden {} {}", playlistId, hidden); - crate::library::commands::playlist_set_hidden(playlistId, hidden, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set playlist favorite (V2) -#[tauri::command] -pub async fn v2_playlist_set_favorite( - playlistId: u64, - favorite: bool, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_set_favorite {} {}", playlistId, favorite); - crate::library::commands::playlist_set_favorite(playlistId, favorite, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Reorder playlists (V2) - reorder playlists in sidebar -#[tauri::command] -pub async fn v2_playlist_reorder( - playlistIds: Vec, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_reorder {} playlists", playlistIds.len()); - crate::library::commands::playlist_reorder(playlistIds, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Init playlist custom order (V2) - initialize custom track order -/// trackIds is Vec<(track_id, is_local)> -#[tauri::command] -pub async fn v2_playlist_init_custom_order( - playlistId: u64, - trackIds: Vec<(i64, bool)>, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_init_custom_order {} tracks={}", playlistId, trackIds.len()); - crate::library::commands::playlist_init_custom_order(playlistId, trackIds, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set playlist custom order (V2) - set track positions -/// orders is Vec<(track_id, is_local, position)> -#[tauri::command] -pub async fn v2_playlist_set_custom_order( - playlistId: u64, - orders: Vec<(i64, bool, i32)>, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_set_custom_order {} tracks={}", playlistId, orders.len()); - crate::library::commands::playlist_set_custom_order(playlistId, orders, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Move track in playlist (V2) -#[tauri::command] -pub async fn v2_playlist_move_track( - playlistId: u64, - trackId: i64, - isLocal: bool, - newPosition: i32, - state: State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] playlist_move_track {} {} local={} -> {}", playlistId, trackId, isLocal, newPosition); - crate::library::commands::playlist_move_track(playlistId, trackId, isLocal, newPosition, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Cast / DLNA / AirPlay V2 Commands -// ============================================================================ - -// === Chromecast V2 === - -/// Start Chromecast discovery (V2) -#[tauri::command] -pub async fn v2_cast_start_discovery( - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_start_discovery"); - crate::cast::commands::cast_start_discovery(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Stop Chromecast discovery (V2) -#[tauri::command] -pub async fn v2_cast_stop_discovery( - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_stop_discovery"); - crate::cast::commands::cast_stop_discovery(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get discovered Chromecast devices (V2) -#[tauri::command] -pub async fn v2_cast_get_devices( - state: State<'_, crate::cast::commands::CastState>, -) -> Result, RuntimeError> { - log::info!("[V2] cast_get_devices"); - crate::cast::commands::cast_get_devices(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Connect to Chromecast device (V2) -#[tauri::command] -pub async fn v2_cast_connect( - deviceId: String, - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_connect {}", deviceId); - crate::cast::commands::cast_connect(deviceId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Disconnect from Chromecast (V2) -#[tauri::command] -pub async fn v2_cast_disconnect( - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_disconnect"); - crate::cast::commands::cast_disconnect(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get Chromecast status (V2) -#[tauri::command] -pub async fn v2_cast_get_status( - state: State<'_, crate::cast::commands::CastState>, -) -> Result { - crate::cast::commands::cast_get_status(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get Chromecast position (V2) -#[tauri::command] -pub async fn v2_cast_get_position( - state: State<'_, crate::cast::commands::CastState>, -) -> Result { - crate::cast::commands::cast_get_position(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Play track on Chromecast (V2) -#[tauri::command] -pub async fn v2_cast_play_track( - trackId: u64, - metadata: crate::cast::MediaMetadata, - state: State<'_, crate::cast::commands::CastState>, - appState: State<'_, crate::AppState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_play_track {}", trackId); - crate::cast::commands::cast_play_track(trackId, metadata, state, appState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Play local track on Chromecast (V2) -#[tauri::command] -pub async fn v2_cast_play_local_track( - trackId: i64, - state: State<'_, crate::cast::commands::CastState>, - libraryState: State<'_, crate::library::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_play_local_track {}", trackId); - crate::cast::commands::cast_play_local_track(trackId, state, libraryState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Play on Chromecast (V2) -#[tauri::command] -pub async fn v2_cast_play( - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_play"); - crate::cast::commands::cast_play(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Pause Chromecast (V2) -#[tauri::command] -pub async fn v2_cast_pause( - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_pause"); - crate::cast::commands::cast_pause(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Stop Chromecast (V2) -#[tauri::command] -pub async fn v2_cast_stop( - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_stop"); - crate::cast::commands::cast_stop(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Seek on Chromecast (V2) -#[tauri::command] -pub async fn v2_cast_seek( - positionSecs: f64, - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_seek {}", positionSecs); - crate::cast::commands::cast_seek(positionSecs, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set Chromecast volume (V2) -#[tauri::command] -pub async fn v2_cast_set_volume( - volume: f32, - state: State<'_, crate::cast::commands::CastState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] cast_set_volume {}", volume); - crate::cast::commands::cast_set_volume(volume, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// === DLNA V2 === - -/// Start DLNA discovery (V2) -#[tauri::command] -pub async fn v2_dlna_start_discovery( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_start_discovery"); - crate::cast::dlna::commands::dlna_start_discovery(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Stop DLNA discovery (V2) -#[tauri::command] -pub async fn v2_dlna_stop_discovery( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_stop_discovery"); - crate::cast::dlna::commands::dlna_stop_discovery(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get discovered DLNA devices (V2) -#[tauri::command] -pub async fn v2_dlna_get_devices( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result, RuntimeError> { - log::info!("[V2] dlna_get_devices"); - crate::cast::dlna::commands::dlna_get_devices(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Connect to DLNA device (V2) -#[tauri::command] -pub async fn v2_dlna_connect( - deviceId: String, - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_connect {}", deviceId); - crate::cast::dlna::commands::dlna_connect(deviceId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Disconnect from DLNA device (V2) -#[tauri::command] -pub async fn v2_dlna_disconnect( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_disconnect"); - crate::cast::dlna::commands::dlna_disconnect(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get DLNA status (V2) -#[tauri::command] -pub async fn v2_dlna_get_status( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result { - crate::cast::dlna::commands::dlna_get_status(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get DLNA position (V2) -#[tauri::command] -pub async fn v2_dlna_get_position( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result { - crate::cast::dlna::commands::dlna_get_position(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Play track on DLNA device (V2) -#[tauri::command] -pub async fn v2_dlna_play_track( - trackId: u64, - metadata: crate::cast::dlna::DlnaMetadata, - dlnaState: State<'_, crate::cast::dlna::commands::DlnaState>, - appState: State<'_, crate::AppState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_play_track {}", trackId); - crate::cast::dlna::commands::dlna_play_track(trackId, metadata, dlnaState, appState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Load media on DLNA (stub) (V2) -#[tauri::command] -pub async fn v2_dlna_load_media( - metadata: crate::cast::dlna::DlnaMetadata, - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - crate::cast::dlna::commands::dlna_load_media(metadata, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Play on DLNA (V2) -#[tauri::command] -pub async fn v2_dlna_play( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_play"); - crate::cast::dlna::commands::dlna_play(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Pause DLNA (V2) -#[tauri::command] -pub async fn v2_dlna_pause( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_pause"); - crate::cast::dlna::commands::dlna_pause(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Stop DLNA (V2) -#[tauri::command] -pub async fn v2_dlna_stop( - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_stop"); - crate::cast::dlna::commands::dlna_stop(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Seek DLNA (V2) -#[tauri::command] -pub async fn v2_dlna_seek( - positionSecs: u64, - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_seek {}", positionSecs); - crate::cast::dlna::commands::dlna_seek(positionSecs, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set DLNA volume (V2) -#[tauri::command] -pub async fn v2_dlna_set_volume( - volume: f32, - state: State<'_, crate::cast::dlna::commands::DlnaState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] dlna_set_volume {}", volume); - crate::cast::dlna::commands::dlna_set_volume(volume, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// === AirPlay V2 === - -/// Start AirPlay discovery (V2) -#[tauri::command] -pub async fn v2_airplay_start_discovery( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_start_discovery"); - crate::cast::airplay::commands::airplay_start_discovery(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Stop AirPlay discovery (V2) -#[tauri::command] -pub async fn v2_airplay_stop_discovery( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_stop_discovery"); - crate::cast::airplay::commands::airplay_stop_discovery(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get discovered AirPlay devices (V2) -#[tauri::command] -pub async fn v2_airplay_get_devices( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result, RuntimeError> { - log::info!("[V2] airplay_get_devices"); - crate::cast::airplay::commands::airplay_get_devices(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Connect to AirPlay device (V2) -#[tauri::command] -pub async fn v2_airplay_connect( - deviceId: String, - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_connect {}", deviceId); - crate::cast::airplay::commands::airplay_connect(deviceId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Disconnect from AirPlay device (V2) -#[tauri::command] -pub async fn v2_airplay_disconnect( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_disconnect"); - crate::cast::airplay::commands::airplay_disconnect(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get AirPlay status (V2) -#[tauri::command] -pub async fn v2_airplay_get_status( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result { - crate::cast::airplay::commands::airplay_get_status(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Load media on AirPlay (V2) -#[tauri::command] -pub async fn v2_airplay_load_media( - metadata: crate::cast::airplay::AirPlayMetadata, - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_load_media"); - crate::cast::airplay::commands::airplay_load_media(metadata, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Play on AirPlay (V2) -#[tauri::command] -pub async fn v2_airplay_play( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_play"); - crate::cast::airplay::commands::airplay_play(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Pause AirPlay (V2) -#[tauri::command] -pub async fn v2_airplay_pause( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_pause"); - crate::cast::airplay::commands::airplay_pause(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Stop AirPlay (V2) -#[tauri::command] -pub async fn v2_airplay_stop( - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_stop"); - crate::cast::airplay::commands::airplay_stop(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Set AirPlay volume (V2) -#[tauri::command] -pub async fn v2_airplay_set_volume( - volume: f32, - state: State<'_, crate::cast::airplay::commands::AirPlayState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] airplay_set_volume {}", volume); - crate::cast::airplay::commands::airplay_set_volume(volume, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Audio Backends V2 Commands -// ============================================================================ - -/// Get available audio backends (V2) -#[tauri::command] -pub fn v2_get_available_backends() -> Result, RuntimeError> { - log::info!("[V2] get_available_backends"); - crate::commands::audio_backends::get_available_backends() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get devices for a specific backend (V2) -#[tauri::command] -pub fn v2_get_devices_for_backend( - backendType: crate::audio::AudioBackendType, -) -> Result, RuntimeError> { - log::info!("[V2] get_devices_for_backend {:?}", backendType); - crate::commands::audio_backends::get_devices_for_backend(backendType) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get ALSA plugins (V2) -#[tauri::command] -pub fn v2_get_alsa_plugins() -> Result, RuntimeError> { - log::info!("[V2] get_alsa_plugins"); - crate::commands::audio_backends::get_alsa_plugins() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Check if ALSA utils are installed (V2) -#[tauri::command] -pub fn v2_check_alsa_utils_installed() -> bool { - crate::commands::audio_backends::check_alsa_utils_installed() -} - -/// Get default device name for backend (V2) -#[tauri::command] -pub fn v2_get_default_device_name( - backendType: crate::audio::AudioBackendType, -) -> Option { - log::info!("[V2] get_default_device_name {:?}", backendType); - crate::commands::audio_backends::get_default_device_name(backendType) -} - -/// Get Linux distro info (V2) -#[tauri::command] -pub fn v2_get_linux_distro() -> crate::commands::audio_backends::LinuxDistroInfo { - log::info!("[V2] get_linux_distro"); - crate::commands::audio_backends::get_linux_distro() -} - -/// Query DAC capabilities (V2) -#[tauri::command] -pub fn v2_query_dac_capabilities( - nodeName: String, -) -> crate::commands::audio_backends::DacCapabilities { - log::info!("[V2] query_dac_capabilities {}", nodeName); - crate::commands::audio_backends::query_dac_capabilities(nodeName) -} - -// ============================================================================ -// Audio Diagnostics V2 Commands -// ============================================================================ - -/// Get hardware audio status (V2) -#[tauri::command] -pub fn v2_get_hardware_audio_status() -> Result { - log::info!("[V2] get_hardware_audio_status"); - crate::commands::audio_diagnostics::get_hardware_audio_status() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Start bit-depth capture (V2) -#[tauri::command] -pub fn v2_start_bitdepth_capture( - app: tauri::AppHandle, -) -> Result { - log::info!("[V2] start_bitdepth_capture"); - crate::commands::audio_diagnostics::start_bitdepth_capture(app) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Stop bit-depth capture and analyze (V2) -#[tauri::command] -pub fn v2_stop_bitdepth_capture( - app: tauri::AppHandle, -) -> Result { - log::info!("[V2] stop_bitdepth_capture"); - crate::commands::audio_diagnostics::stop_bitdepth_capture(app) - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Radio V2 Commands -// ============================================================================ - -/// Create artist radio (V2) -#[tauri::command] -pub async fn v2_create_artist_radio( - artistId: u64, - artistName: String, - state: State<'_, crate::AppState>, - blacklistState: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result { - log::info!("[V2] create_artist_radio {} {}", artistId, artistName); - crate::commands::radio::create_artist_radio(artistId, artistName, state, blacklistState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Create track radio (V2) -#[tauri::command] -pub async fn v2_create_track_radio( - trackId: u64, - trackName: String, - artistId: u64, - state: State<'_, crate::AppState>, - blacklistState: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result { - log::info!("[V2] create_track_radio {} {} {}", trackId, trackName, artistId); - crate::commands::radio::create_track_radio(trackId, trackName, artistId, state, blacklistState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Refill radio queue (V2) -#[tauri::command] -pub async fn v2_refill_radio_queue( - sessionId: String, - state: State<'_, crate::AppState>, - blacklistState: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result { - log::info!("[V2] refill_radio_queue {}", sessionId); - crate::commands::radio::refill_radio_queue(sessionId, state, blacklistState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get queue remaining count (V2) -#[tauri::command] -pub fn v2_get_queue_remaining( - state: State<'_, crate::AppState>, -) -> u32 { - crate::commands::radio::get_queue_remaining(state) -} - -/// Create infinite radio from recent tracks (V2) -#[tauri::command] -pub async fn v2_create_infinite_radio( - recentTrackIds: Vec, - state: State<'_, crate::AppState>, - blacklistState: State<'_, crate::artist_blacklist::BlacklistState>, -) -> Result { - log::info!("[V2] create_infinite_radio {:?}", recentTrackIds); - crate::commands::radio::create_infinite_radio(recentTrackIds, state, blacklistState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Share V2 Commands -// ============================================================================ - -/// Get Qobuz track URL (V2) -#[tauri::command] -pub fn v2_get_qobuz_track_url(trackId: u64) -> String { - crate::commands::share::get_qobuz_track_url(trackId) -} - -/// Get Qobuz album URL (V2) -#[tauri::command] -pub fn v2_get_qobuz_album_url(albumId: String) -> String { - crate::commands::share::get_qobuz_album_url(albumId) -} - -/// Get Qobuz artist URL (V2) -#[tauri::command] -pub fn v2_get_qobuz_artist_url(artistId: u64) -> String { - crate::commands::share::get_qobuz_artist_url(artistId) -} - -// ============================================================================ -// Visualizer V2 Commands -// ============================================================================ - -/// Check if visualizer is enabled (V2) -#[tauri::command] -pub fn v2_is_visualizer_enabled( - state: State<'_, crate::AppState>, -) -> bool { - crate::commands::visualizer::is_visualizer_enabled(state) -} - -// ============================================================================ -// Queue V2 Additional Commands -// ============================================================================ - -/// Get current queue track (V2) -#[tauri::command] -pub fn v2_get_current_queue_track( - state: State<'_, crate::AppState>, -) -> Result, RuntimeError> { - crate::commands::queue::get_current_queue_track(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Peek next track (V2) -#[tauri::command] -pub fn v2_peek_next_track( - state: State<'_, crate::AppState>, -) -> Result, RuntimeError> { - crate::commands::queue::peek_next_track(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get shuffle state (V2) -#[tauri::command] -pub fn v2_get_shuffle( - state: State<'_, crate::AppState>, -) -> Result { - crate::commands::queue::get_shuffle(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get repeat mode (V2) -#[tauri::command] -pub fn v2_get_repeat( - state: State<'_, crate::AppState>, -) -> Result { - crate::commands::queue::get_repeat(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Playlist Additional V2 Commands -// ============================================================================ - -/// Get current user ID (V2) -#[tauri::command] -pub async fn v2_get_current_user_id( - state: State<'_, crate::AppState>, -) -> Result, RuntimeError> { - crate::commands::playlist::get_current_user_id(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Auth V2 Additional Commands -// ============================================================================ - -/// Has saved credentials (V2) -#[tauri::command] -pub fn v2_has_saved_credentials() -> bool { - crate::commands::auth::has_saved_credentials() -} - -/// Save credentials (V2) -#[tauri::command] -pub fn v2_save_credentials( - email: String, - password: String, -) -> Result<(), RuntimeError> { - log::info!("[V2] save_credentials"); - crate::commands::auth::save_credentials(email, password) - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Plex V2 Commands -// ============================================================================ - -/// Plex ping (V2) -#[tauri::command] -pub async fn v2_plex_ping( - baseUrl: String, - token: String, -) -> Result { - log::info!("[V2] plex_ping"); - crate::plex::plex_ping(baseUrl, token).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex get music sections (V2) -#[tauri::command] -pub async fn v2_plex_get_music_sections( - baseUrl: String, - token: String, -) -> Result, RuntimeError> { - log::info!("[V2] plex_get_music_sections"); - crate::plex::plex_get_music_sections(baseUrl, token).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex get section tracks (V2) -#[tauri::command] -pub async fn v2_plex_get_section_tracks( - baseUrl: String, - token: String, - sectionKey: String, - limit: Option, -) -> Result, RuntimeError> { - log::info!("[V2] plex_get_section_tracks section={}", sectionKey); - crate::plex::plex_get_section_tracks(baseUrl, token, sectionKey, limit).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex get track metadata (V2) -#[tauri::command] -pub async fn v2_plex_get_track_metadata( - baseUrl: String, - token: String, - ratingKey: String, -) -> Result { - log::info!("[V2] plex_get_track_metadata rating_key={}", ratingKey); - crate::plex::plex_get_track_metadata(baseUrl, token, ratingKey).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex auth pin start (V2) -#[tauri::command] -pub async fn v2_plex_auth_pin_start( - clientIdentifier: String, -) -> Result { - log::info!("[V2] plex_auth_pin_start"); - crate::plex::plex_auth_pin_start(clientIdentifier).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex auth pin check (V2) -#[tauri::command] -pub async fn v2_plex_auth_pin_check( - clientIdentifier: String, - pinId: u64, - code: Option, -) -> Result { - log::info!("[V2] plex_auth_pin_check pin_id={}", pinId); - crate::plex::plex_auth_pin_check(clientIdentifier, pinId, code).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex open auth URL (V2) -#[tauri::command] -pub async fn v2_plex_open_auth_url( - url: String, -) -> Result<(), RuntimeError> { - log::info!("[V2] plex_open_auth_url"); - crate::plex::plex_open_auth_url(url).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache get sections (V2) -#[tauri::command] -pub fn v2_plex_cache_get_sections() -> Result, RuntimeError> { - log::info!("[V2] plex_cache_get_sections"); - crate::plex::plex_cache_get_sections() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache save sections (V2) -#[tauri::command] -pub fn v2_plex_cache_save_sections( - serverId: Option, - sections: Vec, -) -> Result { - log::info!("[V2] plex_cache_save_sections count={}", sections.len()); - crate::plex::plex_cache_save_sections(serverId, sections) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache get tracks (V2) -#[tauri::command] -pub fn v2_plex_cache_get_tracks( - sectionKey: Option, - limit: Option, -) -> Result, RuntimeError> { - log::info!("[V2] plex_cache_get_tracks section={:?}", sectionKey); - crate::plex::plex_cache_get_tracks(sectionKey, limit) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache get albums (V2) -#[tauri::command] -pub fn v2_plex_cache_get_albums() -> Result, RuntimeError> { - log::info!("[V2] plex_cache_get_albums"); - crate::plex::plex_cache_get_albums() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache get album tracks (V2) -#[tauri::command] -pub fn v2_plex_cache_get_album_tracks( - albumKey: String, -) -> Result, RuntimeError> { - log::info!("[V2] plex_cache_get_album_tracks album={}", albumKey); - crate::plex::plex_cache_get_album_tracks(albumKey) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache search tracks (V2) -#[tauri::command] -pub fn v2_plex_cache_search_tracks( - query: String, - limit: Option, -) -> Result, RuntimeError> { - log::info!("[V2] plex_cache_search_tracks query={}", query); - crate::plex::plex_cache_search_tracks(query, limit) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache save tracks (V2) -#[tauri::command] -pub fn v2_plex_cache_save_tracks( - serverId: Option, - sectionKey: String, - tracks: Vec, -) -> Result { - log::info!("[V2] plex_cache_save_tracks section={} count={}", sectionKey, tracks.len()); - crate::plex::plex_cache_save_tracks(serverId, sectionKey, tracks) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache update track quality (V2) -#[tauri::command] -pub fn v2_plex_cache_update_track_quality( - updates: Vec, -) -> Result { - log::info!("[V2] plex_cache_update_track_quality count={}", updates.len()); - crate::plex::plex_cache_update_track_quality(updates) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache get tracks needing hydration (V2) -#[tauri::command] -pub fn v2_plex_cache_get_tracks_needing_hydration( - limit: Option, -) -> Result, RuntimeError> { - log::info!("[V2] plex_cache_get_tracks_needing_hydration"); - crate::plex::plex_cache_get_tracks_needing_hydration(limit) - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex cache clear (V2) -#[tauri::command] -pub fn v2_plex_cache_clear() -> Result<(), RuntimeError> { - log::info!("[V2] plex_cache_clear"); - crate::plex::plex_cache_clear() - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Plex play track (V2) -#[tauri::command] -pub async fn v2_plex_play_track( - baseUrl: String, - token: String, - ratingKey: String, - appState: tauri::State<'_, crate::AppState>, -) -> Result { - log::info!("[V2] plex_play_track rating_key={}", ratingKey); - crate::plex::plex_play_track(baseUrl, token, ratingKey, appState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Playlist Additional V2 Commands -// ============================================================================ - -/// Get playlist settings (V2) -#[tauri::command] -pub async fn v2_playlist_get_settings( - playlistId: u64, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_settings {}", playlistId); - crate::library::commands::playlist_get_settings(playlistId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get all playlist settings (V2) -#[tauri::command] -pub async fn v2_playlist_get_all_settings( - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_all_settings"); - crate::library::commands::playlist_get_all_settings(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get playlist stats (V2) -#[tauri::command] -pub async fn v2_playlist_get_stats( - playlistId: u64, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_stats {}", playlistId); - crate::library::commands::playlist_get_stats(playlistId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get all playlist stats (V2) -#[tauri::command] -pub async fn v2_playlist_get_all_stats( - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_all_stats"); - crate::library::commands::playlist_get_all_stats(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Increment playlist play count (V2) -#[tauri::command] -pub async fn v2_playlist_increment_play_count( - playlistId: u64, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result { - log::info!("[V2] playlist_increment_play_count {}", playlistId); - crate::library::commands::playlist_increment_play_count(playlistId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get favorite playlist IDs (V2) -#[tauri::command] -pub async fn v2_playlist_get_favorites( - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_favorites"); - crate::library::commands::playlist_get_favorites(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get local tracks in playlist (V2) -#[tauri::command] -pub async fn v2_playlist_get_local_tracks( - playlistId: u64, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_local_tracks {}", playlistId); - crate::library::commands::playlist_get_local_tracks(playlistId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get local tracks in playlist with positions (V2) -#[tauri::command] -pub async fn v2_playlist_get_local_tracks_with_position( - playlistId: u64, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_local_tracks_with_position {}", playlistId); - crate::library::commands::playlist_get_local_tracks_with_position(playlistId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get playlist custom order (V2) -#[tauri::command] -pub async fn v2_playlist_get_custom_order( - playlistId: u64, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_custom_order {}", playlistId); - crate::library::commands::playlist_get_custom_order(playlistId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Check if playlist has custom order (V2) -#[tauri::command] -pub async fn v2_playlist_has_custom_order( - playlistId: u64, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result { - log::info!("[V2] playlist_has_custom_order {}", playlistId); - crate::library::commands::playlist_has_custom_order(playlistId, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Get tracks with local copies (V2) -#[tauri::command] -pub async fn v2_playlist_get_tracks_with_local_copies( - trackIds: Vec, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_tracks_with_local_copies count={}", trackIds.len()); - crate::library::commands::playlist_get_tracks_with_local_copies(trackIds, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Playlist import preview (V2) -#[tauri::command] -pub async fn v2_playlist_import_preview( - url: String, -) -> Result { - log::info!("[V2] playlist_import_preview {}", url); - crate::commands::playlist_import::playlist_import_preview(url).await - .map_err(|e| RuntimeError::Internal(e)) -} - -/// Playlist import execute (V2) -#[tauri::command] -pub async fn v2_playlist_import_execute( - app: tauri::AppHandle, - url: String, - nameOverride: Option, - isPublic: Option, - state: tauri::State<'_, crate::AppState>, -) -> Result { - log::info!("[V2] playlist_import_execute {}", url); - crate::commands::playlist_import::playlist_import_execute(app, url, nameOverride, isPublic, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Library V2 Commands -// ============================================================================ - -#[tauri::command] -pub async fn v2_library_play_track( - trackId: i64, - libraryState: tauri::State<'_, crate::library::commands::LibraryState>, - appState: tauri::State<'_, crate::AppState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] library_play_track {}", trackId); - crate::library::commands::library_play_track(trackId, libraryState, appState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_get_albums( - includeHidden: Option, - excludeNetworkFolders: Option, - state: tauri::State<'_, crate::library::commands::LibraryState>, - downloadSettingsState: tauri::State<'_, crate::config::DownloadSettingsState>, -) -> Result, RuntimeError> { - log::info!("[V2] library_get_albums"); - crate::library::commands::library_get_albums(includeHidden, excludeNetworkFolders, state, downloadSettingsState).await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_get_tracks_by_ids( - trackIds: Vec, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] library_get_tracks_by_ids count={}", trackIds.len()); - crate::library::commands::library_get_tracks_by_ids(trackIds, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_check_folder_accessible(path: String) -> Result { - log::info!("[V2] library_check_folder_accessible {}", path); - crate::library::commands::library_check_folder_accessible(path).await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_set_album_hidden( - albumId: String, - hidden: bool, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] library_set_album_hidden {} hidden={}", albumId, hidden); - crate::library::commands::library_set_album_hidden(albumId, hidden, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_get_scan_progress( - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result { - crate::library::commands::library_get_scan_progress(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_clear_artwork_cache() -> Result { - log::info!("[V2] library_clear_artwork_cache"); - crate::library::commands::library_clear_artwork_cache().await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_clear_thumbnails_cache() -> Result { - log::info!("[V2] library_clear_thumbnails_cache"); - crate::library::commands::library_clear_thumbnails_cache().await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_remove_folder( - path: String, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result<(), RuntimeError> { - log::info!("[V2] library_remove_folder {}", path); - crate::library::commands::library_remove_folder(path, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_library_set_album_artwork( - albumId: String, - artworkPath: String, - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result { - log::info!("[V2] library_set_album_artwork {}", albumId); - crate::library::commands::library_set_album_artwork(albumId, artworkPath, state).await - .map_err(|e| RuntimeError::Internal(e)) -} - -// ============================================================================ -// Offline V2 Commands -// ============================================================================ - -#[tauri::command] -pub fn v2_get_pending_playlists( - state: tauri::State<'_, crate::offline::OfflineState>, -) -> Result, RuntimeError> { - log::info!("[V2] get_pending_playlists"); - crate::offline::commands::get_pending_playlists(state) - .map_err(|e| RuntimeError::Internal(e)) -} - -#[tauri::command] -pub async fn v2_playlist_get_all_local_track_counts( - state: tauri::State<'_, crate::library::commands::LibraryState>, -) -> Result, RuntimeError> { - log::info!("[V2] playlist_get_all_local_track_counts"); - crate::library::commands::playlist_get_all_local_track_counts(state).await - .map_err(|e| RuntimeError::Internal(e)) -} - diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index f59657590..23a292225 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1253,174 +1253,6 @@ pub fn run() { commands_v2::v2_sync_cached_favorite_artists, commands_v2::v2_cache_favorite_artist, commands_v2::v2_uncache_favorite_artist, - // Settings V2 - commands_v2::v2_get_tray_settings, - commands_v2::v2_set_enable_tray, - commands_v2::v2_set_minimize_to_tray, - commands_v2::v2_set_close_to_tray, - commands_v2::v2_get_graphics_settings, - commands_v2::v2_set_hardware_acceleration, - commands_v2::v2_set_gdk_scale, - commands_v2::v2_set_gdk_dpi_scale, - commands_v2::v2_get_graphics_startup_status, - commands_v2::v2_get_window_settings, - commands_v2::v2_set_use_system_titlebar, - commands_v2::v2_get_developer_settings, - commands_v2::v2_set_developer_force_dmabuf, - commands_v2::v2_get_playback_preferences, - commands_v2::v2_set_autoplay_mode, - commands_v2::v2_set_show_context_icon, - commands_v2::v2_get_favorites_preferences, - commands_v2::v2_save_favorites_preferences, - commands_v2::v2_set_visualizer_enabled, - commands_v2::v2_get_artist_blacklist, - commands_v2::v2_add_to_artist_blacklist, - commands_v2::v2_remove_from_artist_blacklist, - commands_v2::v2_clear_artist_blacklist, - commands_v2::v2_set_blacklist_enabled, - commands_v2::v2_get_blacklist_settings, - commands_v2::v2_get_blacklist_count, - commands_v2::v2_set_api_locale, - // Playlist Custom V2 - commands_v2::v2_playlist_set_sort, - commands_v2::v2_playlist_set_artwork, - commands_v2::v2_playlist_add_local_track, - commands_v2::v2_playlist_remove_local_track, - commands_v2::v2_playlist_set_hidden, - commands_v2::v2_playlist_set_favorite, - commands_v2::v2_playlist_reorder, - commands_v2::v2_playlist_init_custom_order, - commands_v2::v2_playlist_set_custom_order, - commands_v2::v2_playlist_move_track, - // Cast / DLNA / AirPlay V2 - commands_v2::v2_cast_start_discovery, - commands_v2::v2_cast_stop_discovery, - commands_v2::v2_cast_get_devices, - commands_v2::v2_cast_connect, - commands_v2::v2_cast_disconnect, - commands_v2::v2_cast_get_status, - commands_v2::v2_cast_get_position, - commands_v2::v2_cast_play_track, - commands_v2::v2_cast_play_local_track, - commands_v2::v2_cast_play, - commands_v2::v2_cast_pause, - commands_v2::v2_cast_stop, - commands_v2::v2_cast_seek, - commands_v2::v2_cast_set_volume, - commands_v2::v2_dlna_start_discovery, - commands_v2::v2_dlna_stop_discovery, - commands_v2::v2_dlna_get_devices, - commands_v2::v2_dlna_connect, - commands_v2::v2_dlna_disconnect, - commands_v2::v2_dlna_get_status, - commands_v2::v2_dlna_get_position, - commands_v2::v2_dlna_play_track, - commands_v2::v2_dlna_load_media, - commands_v2::v2_dlna_play, - commands_v2::v2_dlna_pause, - commands_v2::v2_dlna_stop, - commands_v2::v2_dlna_seek, - commands_v2::v2_dlna_set_volume, - commands_v2::v2_airplay_start_discovery, - commands_v2::v2_airplay_stop_discovery, - commands_v2::v2_airplay_get_devices, - commands_v2::v2_airplay_connect, - commands_v2::v2_airplay_disconnect, - commands_v2::v2_airplay_get_status, - commands_v2::v2_airplay_load_media, - commands_v2::v2_airplay_play, - commands_v2::v2_airplay_pause, - commands_v2::v2_airplay_stop, - commands_v2::v2_airplay_set_volume, - // Audio Backends V2 - commands_v2::v2_get_available_backends, - commands_v2::v2_get_devices_for_backend, - commands_v2::v2_get_alsa_plugins, - commands_v2::v2_check_alsa_utils_installed, - commands_v2::v2_get_default_device_name, - commands_v2::v2_get_linux_distro, - commands_v2::v2_query_dac_capabilities, - // Audio Diagnostics V2 - commands_v2::v2_get_hardware_audio_status, - commands_v2::v2_start_bitdepth_capture, - commands_v2::v2_stop_bitdepth_capture, - // Radio V2 - commands_v2::v2_create_artist_radio, - commands_v2::v2_create_track_radio, - commands_v2::v2_refill_radio_queue, - commands_v2::v2_get_queue_remaining, - commands_v2::v2_create_infinite_radio, - // Share V2 - commands_v2::v2_get_qobuz_track_url, - commands_v2::v2_get_qobuz_album_url, - commands_v2::v2_get_qobuz_artist_url, - // Visualizer V2 - commands_v2::v2_is_visualizer_enabled, - // Queue Additional V2 - commands_v2::v2_get_current_queue_track, - commands_v2::v2_peek_next_track, - commands_v2::v2_get_shuffle, - commands_v2::v2_get_repeat, - // Playlist Additional V2 - commands_v2::v2_get_current_user_id, - // Auth Additional V2 - commands_v2::v2_has_saved_credentials, - commands_v2::v2_save_credentials, - // Cache Management V2 - commands_v2::v2_get_cache_stats, - commands_v2::v2_clear_cache, - commands_v2::v2_clear_artist_cache, - commands_v2::v2_clear_vector_store, - commands_v2::v2_get_vector_store_stats, - commands_v2::v2_clear_offline_cache, - commands_v2::v2_clear_saved_credentials, - // Plex V2 - commands_v2::v2_plex_ping, - commands_v2::v2_plex_get_music_sections, - commands_v2::v2_plex_get_section_tracks, - commands_v2::v2_plex_get_track_metadata, - commands_v2::v2_plex_auth_pin_start, - commands_v2::v2_plex_auth_pin_check, - commands_v2::v2_plex_open_auth_url, - commands_v2::v2_plex_cache_get_sections, - commands_v2::v2_plex_cache_save_sections, - commands_v2::v2_plex_cache_get_tracks, - commands_v2::v2_plex_cache_get_albums, - commands_v2::v2_plex_cache_get_album_tracks, - commands_v2::v2_plex_cache_search_tracks, - commands_v2::v2_plex_cache_save_tracks, - commands_v2::v2_plex_cache_update_track_quality, - commands_v2::v2_plex_cache_get_tracks_needing_hydration, - commands_v2::v2_plex_cache_clear, - commands_v2::v2_plex_play_track, - // Playlist Additional V2 - commands_v2::v2_playlist_get_settings, - commands_v2::v2_playlist_get_all_settings, - commands_v2::v2_playlist_get_stats, - commands_v2::v2_playlist_get_all_stats, - commands_v2::v2_playlist_increment_play_count, - commands_v2::v2_playlist_get_favorites, - commands_v2::v2_playlist_get_local_tracks, - commands_v2::v2_playlist_get_local_tracks_with_position, - commands_v2::v2_playlist_get_custom_order, - commands_v2::v2_playlist_has_custom_order, - commands_v2::v2_playlist_get_tracks_with_local_copies, - commands_v2::v2_playlist_import_preview, - commands_v2::v2_playlist_import_execute, - // Library V2 - commands_v2::v2_library_play_track, - commands_v2::v2_library_get_albums, - commands_v2::v2_library_get_tracks_by_ids, - commands_v2::v2_library_check_folder_accessible, - commands_v2::v2_library_set_album_hidden, - commands_v2::v2_library_get_scan_progress, - commands_v2::v2_library_clear_artwork_cache, - commands_v2::v2_library_clear_thumbnails_cache, - commands_v2::v2_library_remove_folder, - commands_v2::v2_library_set_album_artwork, - // Offline V2 - commands_v2::v2_get_pending_playlists, - commands_v2::v2_playlist_get_all_local_track_counts, ]) .run(tauri::generate_context!()) .expect("error while running tauri application");