diff --git a/src-tauri/src/commands/lastfm.rs b/src-tauri/src/commands/lastfm.rs index 946abb33c..b98b37cc3 100644 --- a/src-tauri/src/commands/lastfm.rs +++ b/src-tauri/src/commands/lastfm.rs @@ -1,4 +1,9 @@ //! Last.fm integration commands +//! +//! **DEPRECATED**: Use V2 commands in `commands_v2.rs` instead. +//! These legacy commands will be removed in a future version. + +#![allow(deprecated)] use tauri::State; @@ -38,6 +43,7 @@ pub async fn lastfm_set_credentials( } /// Check if Last.fm is authenticated +#[deprecated(since = "1.2.0", note = "Use v2_lastfm_is_authenticated instead")] #[tauri::command] pub async fn lastfm_is_authenticated(state: State<'_, AppState>) -> Result { let client = state.lastfm.lock().await; @@ -45,6 +51,7 @@ pub async fn lastfm_is_authenticated(state: State<'_, AppState>) -> Result) -> Result<(String, String), String> { log::info!("Command: lastfm_get_auth_url"); @@ -55,6 +62,7 @@ pub async fn lastfm_get_auth_url(state: State<'_, AppState>) -> Result<(String, } /// Complete Last.fm authentication with token +#[deprecated(since = "1.2.0", note = "Use v2_lastfm_complete_auth instead")] #[tauri::command] pub async fn lastfm_authenticate( token: String, @@ -66,6 +74,7 @@ pub async fn lastfm_authenticate( } /// Set Last.fm session key (for restoring saved session) +#[deprecated(since = "1.2.0", note = "Use v2_lastfm_set_session instead")] #[tauri::command] pub async fn lastfm_set_session( session_key: String, @@ -78,6 +87,7 @@ pub async fn lastfm_set_session( } /// Disconnect from Last.fm +#[deprecated(since = "1.2.0", note = "Use v2_lastfm_disconnect instead")] #[tauri::command] pub async fn lastfm_disconnect(state: State<'_, AppState>) -> Result<(), String> { log::info!("Command: lastfm_disconnect"); @@ -88,6 +98,7 @@ pub async fn lastfm_disconnect(state: State<'_, AppState>) -> Result<(), String> } /// Scrobble a track to Last.fm +#[deprecated(since = "1.2.0", note = "Use v2_lastfm_scrobble instead")] #[tauri::command] pub async fn lastfm_scrobble( artist: String, @@ -104,6 +115,7 @@ pub async fn lastfm_scrobble( } /// Update "now playing" on Last.fm +#[deprecated(since = "1.2.0", note = "Use v2_lastfm_now_playing instead")] #[tauri::command] pub async fn lastfm_now_playing( artist: String, diff --git a/src-tauri/src/commands/listenbrainz.rs b/src-tauri/src/commands/listenbrainz.rs index 26f2d8982..9b17f2ac5 100644 --- a/src-tauri/src/commands/listenbrainz.rs +++ b/src-tauri/src/commands/listenbrainz.rs @@ -1,6 +1,11 @@ //! ListenBrainz Tauri commands //! //! Exposes ListenBrainz scrobbling to the frontend +//! +//! **DEPRECATED**: Use V2 commands in `commands_v2.rs` instead. +//! These legacy commands will be removed in a future version. + +#![allow(deprecated)] use tauri::State; @@ -9,6 +14,7 @@ use crate::listenbrainz::{ }; /// Get ListenBrainz connection status +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_get_status instead")] #[tauri::command] pub async fn listenbrainz_get_status( state: State<'_, ListenBrainzSharedState>, @@ -18,6 +24,7 @@ pub async fn listenbrainz_get_status( } /// Check if ListenBrainz is enabled +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_is_enabled instead")] #[tauri::command] pub async fn listenbrainz_is_enabled( state: State<'_, ListenBrainzSharedState>, @@ -27,6 +34,7 @@ pub async fn listenbrainz_is_enabled( } /// Enable or disable ListenBrainz integration +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_set_enabled instead")] #[tauri::command] pub async fn listenbrainz_set_enabled( enabled: bool, @@ -53,6 +61,7 @@ pub async fn listenbrainz_set_enabled( } /// Connect to ListenBrainz with a user token +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_connect instead")] #[tauri::command] pub async fn listenbrainz_connect( token: String, @@ -77,6 +86,7 @@ pub async fn listenbrainz_connect( } /// Disconnect from ListenBrainz +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_disconnect instead")] #[tauri::command] pub async fn listenbrainz_disconnect( state: State<'_, ListenBrainzSharedState>, @@ -100,6 +110,7 @@ pub async fn listenbrainz_disconnect( } /// Submit "now playing" to ListenBrainz +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_now_playing instead")] #[tauri::command] pub async fn listenbrainz_now_playing( artist: String, @@ -130,6 +141,7 @@ pub async fn listenbrainz_now_playing( } /// Submit a scrobble to ListenBrainz +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_scrobble instead")] #[tauri::command] pub async fn listenbrainz_scrobble( artist: String, @@ -161,6 +173,7 @@ pub async fn listenbrainz_scrobble( } /// Queue a listen for offline submission +#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_queue_listen instead")] #[tauri::command] pub async fn listenbrainz_queue_listen( artist: String, diff --git a/src-tauri/src/commands/musicbrainz.rs b/src-tauri/src/commands/musicbrainz.rs index c0e0b62a5..d747b6a81 100644 --- a/src-tauri/src/commands/musicbrainz.rs +++ b/src-tauri/src/commands/musicbrainz.rs @@ -1,6 +1,11 @@ //! MusicBrainz Tauri commands //! //! Exposes MusicBrainz entity resolution to the frontend +//! +//! **DEPRECATED**: Use V2 commands in `commands_v2.rs` instead. +//! These legacy commands will be removed in a future version. + +#![allow(deprecated)] use tauri::State; @@ -270,6 +275,7 @@ pub async fn musicbrainz_get_artist_relationships( } /// Check if MusicBrainz integration is enabled +#[deprecated(since = "1.2.0", note = "Use v2_musicbrainz_is_enabled instead")] #[tauri::command] pub async fn musicbrainz_is_enabled( state: State<'_, MusicBrainzSharedState>, @@ -278,6 +284,7 @@ pub async fn musicbrainz_is_enabled( } /// Enable or disable MusicBrainz integration +#[deprecated(since = "1.2.0", note = "Use v2_musicbrainz_set_enabled instead")] #[tauri::command] pub async fn musicbrainz_set_enabled( enabled: bool, diff --git a/src-tauri/src/commands/playback.rs b/src-tauri/src/commands/playback.rs index 4e02e1bc0..8d6ff2a64 100644 --- a/src-tauri/src/commands/playback.rs +++ b/src-tauri/src/commands/playback.rs @@ -1208,6 +1208,7 @@ pub fn get_audio_output_status( /// Reinitialize audio device (releases and re-acquires) /// Call this when changing audio settings like exclusive mode or output device +#[deprecated(since = "1.2.0", note = "Use v2_reinit_audio_device instead")] #[tauri::command] pub fn reinit_audio_device( device: Option, diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index 83f2638b1..22695ad78 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -2750,3 +2750,52 @@ pub async fn v2_lastfm_scrobble( client.scrobble(&artist, &track, album.as_deref(), timestamp).await .map_err(|e| RuntimeError::Internal(e.to_string())) } + +/// Set Last.fm session key (V2) +/// +/// Used to restore a previously saved session key. +#[tauri::command] +pub async fn v2_lastfm_set_session( + session_key: String, + state: State<'_, LastFmV2State>, +) -> Result<(), RuntimeError> { + log::info!("[V2] lastfm_set_session"); + let mut client = state.client.lock().await; + client.set_session_key(session_key); + Ok(()) +} + +/// Queue a listen for offline submission (V2) +/// +/// Uses legacy cache for persistence until qbz-integrations has its own cache. +#[tauri::command] +pub async fn v2_listenbrainz_queue_listen( + artist: String, + track: String, + album: Option, + timestamp: i64, + recording_mbid: Option, + release_mbid: Option, + artist_mbids: Option>, + isrc: Option, + duration_ms: Option, + legacy_state: State<'_, crate::listenbrainz::ListenBrainzSharedState>, +) -> Result { + log::info!("[V2] listenbrainz_queue_listen: {} - {}", artist, track); + + let cache_guard = legacy_state.cache.lock().await; + let cache = cache_guard.as_ref() + .ok_or_else(|| RuntimeError::Internal("No active session - please log in".to_string()))?; + + cache.queue_listen( + timestamp, + &artist, + &track, + album.as_deref(), + recording_mbid.as_deref(), + release_mbid.as_deref(), + artist_mbids.as_deref(), + isrc.as_deref(), + duration_ms, + ).map_err(|e| RuntimeError::Internal(e)) +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 37b0a1984..2425033f4 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1225,6 +1225,8 @@ pub fn run() { commands_v2::v2_lastfm_disconnect, commands_v2::v2_lastfm_now_playing, commands_v2::v2_lastfm_scrobble, + commands_v2::v2_lastfm_set_session, + commands_v2::v2_listenbrainz_queue_listen, ]) .run(tauri::generate_context!()) .expect("error while running tauri application");