Add missing V2 commands and deprecate legacy integration commands
New V2 commands: - v2_lastfm_set_session: Set session key for restored sessions - v2_listenbrainz_queue_listen: Queue listen for offline (uses legacy cache) Deprecated legacy commands (with #[deprecated] markers): - ListenBrainz: get_status, is_enabled, set_enabled, connect, disconnect, now_playing, scrobble, queue_listen - Last.fm: is_authenticated, get_auth_url, authenticate, set_session, disconnect, scrobble, now_playing - MusicBrainz: is_enabled, set_enabled - Audio: reinit_audio_device All deprecated commands point to their V2 replacements in the note. Frontend migration to V2 commands is next.
This commit is contained in:
1 parent
943f886637
commit
53927b5c6f
6 files changed
+84
No files matched your search
@@ -1,4 +1,9 @@
|
|||||||
//! Last.fm integration commands
|
//! 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;
|
use tauri::State;
|
||||||
|
|
||||||
@@ -38,6 +43,7 @@ pub async fn lastfm_set_credentials(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if Last.fm is authenticated
|
/// Check if Last.fm is authenticated
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_lastfm_is_authenticated instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn lastfm_is_authenticated(state: State<'_, AppState>) -> Result<bool, String> {
|
pub async fn lastfm_is_authenticated(state: State<'_, AppState>) -> Result<bool, String> {
|
||||||
let client = state.lastfm.lock().await;
|
let client = state.lastfm.lock().await;
|
||||||
@@ -45,6 +51,7 @@ pub async fn lastfm_is_authenticated(state: State<'_, AppState>) -> Result<bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get Last.fm authentication token and URL
|
/// Get Last.fm authentication token and URL
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_lastfm_get_auth_url instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn lastfm_get_auth_url(state: State<'_, AppState>) -> Result<(String, String), String> {
|
pub async fn lastfm_get_auth_url(state: State<'_, AppState>) -> Result<(String, String), String> {
|
||||||
log::info!("Command: lastfm_get_auth_url");
|
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
|
/// Complete Last.fm authentication with token
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_lastfm_complete_auth instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn lastfm_authenticate(
|
pub async fn lastfm_authenticate(
|
||||||
token: String,
|
token: String,
|
||||||
@@ -66,6 +74,7 @@ pub async fn lastfm_authenticate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set Last.fm session key (for restoring saved session)
|
/// Set Last.fm session key (for restoring saved session)
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_lastfm_set_session instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn lastfm_set_session(
|
pub async fn lastfm_set_session(
|
||||||
session_key: String,
|
session_key: String,
|
||||||
@@ -78,6 +87,7 @@ pub async fn lastfm_set_session(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Disconnect from Last.fm
|
/// Disconnect from Last.fm
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_lastfm_disconnect instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn lastfm_disconnect(state: State<'_, AppState>) -> Result<(), String> {
|
pub async fn lastfm_disconnect(state: State<'_, AppState>) -> Result<(), String> {
|
||||||
log::info!("Command: lastfm_disconnect");
|
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
|
/// Scrobble a track to Last.fm
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_lastfm_scrobble instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn lastfm_scrobble(
|
pub async fn lastfm_scrobble(
|
||||||
artist: String,
|
artist: String,
|
||||||
@@ -104,6 +115,7 @@ pub async fn lastfm_scrobble(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update "now playing" on Last.fm
|
/// Update "now playing" on Last.fm
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_lastfm_now_playing instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn lastfm_now_playing(
|
pub async fn lastfm_now_playing(
|
||||||
artist: String,
|
artist: String,
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
//! ListenBrainz Tauri commands
|
//! ListenBrainz Tauri commands
|
||||||
//!
|
//!
|
||||||
//! Exposes ListenBrainz scrobbling to the frontend
|
//! 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;
|
use tauri::State;
|
||||||
|
|
||||||
@@ -9,6 +14,7 @@ use crate::listenbrainz::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Get ListenBrainz connection status
|
/// Get ListenBrainz connection status
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_get_status instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_get_status(
|
pub async fn listenbrainz_get_status(
|
||||||
state: State<'_, ListenBrainzSharedState>,
|
state: State<'_, ListenBrainzSharedState>,
|
||||||
@@ -18,6 +24,7 @@ pub async fn listenbrainz_get_status(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if ListenBrainz is enabled
|
/// Check if ListenBrainz is enabled
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_is_enabled instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_is_enabled(
|
pub async fn listenbrainz_is_enabled(
|
||||||
state: State<'_, ListenBrainzSharedState>,
|
state: State<'_, ListenBrainzSharedState>,
|
||||||
@@ -27,6 +34,7 @@ pub async fn listenbrainz_is_enabled(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Enable or disable ListenBrainz integration
|
/// Enable or disable ListenBrainz integration
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_set_enabled instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_set_enabled(
|
pub async fn listenbrainz_set_enabled(
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
@@ -53,6 +61,7 @@ pub async fn listenbrainz_set_enabled(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Connect to ListenBrainz with a user token
|
/// Connect to ListenBrainz with a user token
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_connect instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_connect(
|
pub async fn listenbrainz_connect(
|
||||||
token: String,
|
token: String,
|
||||||
@@ -77,6 +86,7 @@ pub async fn listenbrainz_connect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Disconnect from ListenBrainz
|
/// Disconnect from ListenBrainz
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_disconnect instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_disconnect(
|
pub async fn listenbrainz_disconnect(
|
||||||
state: State<'_, ListenBrainzSharedState>,
|
state: State<'_, ListenBrainzSharedState>,
|
||||||
@@ -100,6 +110,7 @@ pub async fn listenbrainz_disconnect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Submit "now playing" to ListenBrainz
|
/// Submit "now playing" to ListenBrainz
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_now_playing instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_now_playing(
|
pub async fn listenbrainz_now_playing(
|
||||||
artist: String,
|
artist: String,
|
||||||
@@ -130,6 +141,7 @@ pub async fn listenbrainz_now_playing(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Submit a scrobble to ListenBrainz
|
/// Submit a scrobble to ListenBrainz
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_scrobble instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_scrobble(
|
pub async fn listenbrainz_scrobble(
|
||||||
artist: String,
|
artist: String,
|
||||||
@@ -161,6 +173,7 @@ pub async fn listenbrainz_scrobble(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Queue a listen for offline submission
|
/// Queue a listen for offline submission
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_listenbrainz_queue_listen instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn listenbrainz_queue_listen(
|
pub async fn listenbrainz_queue_listen(
|
||||||
artist: String,
|
artist: String,
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
//! MusicBrainz Tauri commands
|
//! MusicBrainz Tauri commands
|
||||||
//!
|
//!
|
||||||
//! Exposes MusicBrainz entity resolution to the frontend
|
//! 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;
|
use tauri::State;
|
||||||
|
|
||||||
@@ -270,6 +275,7 @@ pub async fn musicbrainz_get_artist_relationships(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if MusicBrainz integration is enabled
|
/// Check if MusicBrainz integration is enabled
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_musicbrainz_is_enabled instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn musicbrainz_is_enabled(
|
pub async fn musicbrainz_is_enabled(
|
||||||
state: State<'_, MusicBrainzSharedState>,
|
state: State<'_, MusicBrainzSharedState>,
|
||||||
@@ -278,6 +284,7 @@ pub async fn musicbrainz_is_enabled(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Enable or disable MusicBrainz integration
|
/// Enable or disable MusicBrainz integration
|
||||||
|
#[deprecated(since = "1.2.0", note = "Use v2_musicbrainz_set_enabled instead")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn musicbrainz_set_enabled(
|
pub async fn musicbrainz_set_enabled(
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
|
|||||||
@@ -1208,6 +1208,7 @@ pub fn get_audio_output_status(
|
|||||||
|
|
||||||
/// Reinitialize audio device (releases and re-acquires)
|
/// Reinitialize audio device (releases and re-acquires)
|
||||||
/// Call this when changing audio settings like exclusive mode or output device
|
/// 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]
|
#[tauri::command]
|
||||||
pub fn reinit_audio_device(
|
pub fn reinit_audio_device(
|
||||||
device: Option<String>,
|
device: Option<String>,
|
||||||
|
|||||||
@@ -2750,3 +2750,52 @@ pub async fn v2_lastfm_scrobble(
|
|||||||
client.scrobble(&artist, &track, album.as_deref(), timestamp).await
|
client.scrobble(&artist, &track, album.as_deref(), timestamp).await
|
||||||
.map_err(|e| RuntimeError::Internal(e.to_string()))
|
.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<String>,
|
||||||
|
timestamp: i64,
|
||||||
|
recording_mbid: Option<String>,
|
||||||
|
release_mbid: Option<String>,
|
||||||
|
artist_mbids: Option<Vec<String>>,
|
||||||
|
isrc: Option<String>,
|
||||||
|
duration_ms: Option<u64>,
|
||||||
|
legacy_state: State<'_, crate::listenbrainz::ListenBrainzSharedState>,
|
||||||
|
) -> Result<i64, RuntimeError> {
|
||||||
|
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))
|
||||||
|
}
|
||||||
@@ -1225,6 +1225,8 @@ pub fn run() {
|
|||||||
commands_v2::v2_lastfm_disconnect,
|
commands_v2::v2_lastfm_disconnect,
|
||||||
commands_v2::v2_lastfm_now_playing,
|
commands_v2::v2_lastfm_now_playing,
|
||||||
commands_v2::v2_lastfm_scrobble,
|
commands_v2::v2_lastfm_scrobble,
|
||||||
|
commands_v2::v2_lastfm_set_session,
|
||||||
|
commands_v2::v2_listenbrainz_queue_listen,
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
Reference in new issue
Block a user