Merge feature/guest-local-mode into pre-release

cc

# Conflicts:
#	crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po
#	crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po
#	crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po
#	crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po
#	crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po
#	crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po
#	crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po
This commit is contained in:
vicrodh committed 2026-07-07 09:14:23 -06:00
commit 7bf79378d2
11 files changed
+97 -7

No files matched your search

+40
View File
@@ -193,6 +193,7 @@ impl<A: FrontendAdapter + Send + Sync + 'static> AppRuntime<A> {
/// activates against them, and persists the last-user marker so the /// activates against them, and persists the last-user marker so the
/// session can be restored on the next launch. /// session can be restored on the next launch.
pub async fn activate(&self, user_id: u64) -> Result<(), String> { pub async fn activate(&self, user_id: u64) -> Result<(), String> {
Self::adopt_guest_profile(user_id);
self.user_paths.set_user(user_id); self.user_paths.set_user(user_id);
let data_dir = self.user_paths.user_data_dir()?; let data_dir = self.user_paths.user_data_dir()?;
let cache_dir = self.user_paths.user_cache_dir()?; let cache_dir = self.user_paths.user_cache_dir()?;
@@ -201,6 +202,45 @@ impl<A: FrontendAdapter + Send + Sync + 'static> AppRuntime<A> {
Ok(()) Ok(())
} }
/// First real login takes possession of the guest profile (#553): data
/// built while logged off (local library, mixtapes, per-user prefs —
/// `users/0/`) is renamed to this account IF the account has no profile
/// on this machine yet. An existing profile always wins — the guest
/// dirs then stay parked at user 0, no merge is attempted. Best-effort:
/// a failed rename logs and falls through to a fresh profile; login
/// must never break here.
fn adopt_guest_profile(user_id: u64) {
if user_id == 0 {
return;
}
for (kind, guest, target) in [
(
"data",
UserDataPaths::data_dir_for(0),
UserDataPaths::data_dir_for(user_id),
),
(
"cache",
UserDataPaths::cache_dir_for(0),
UserDataPaths::cache_dir_for(user_id),
),
] {
let (Ok(guest), Ok(target)) = (guest, target) else {
continue;
};
if guest.is_dir() && !target.exists() {
match std::fs::rename(&guest, &target) {
Ok(()) => {
log::info!("[AppRuntime] guest profile {kind} adopted by the new session")
}
Err(e) => log::warn!(
"[AppRuntime] guest profile {kind} adoption failed ({e}); starting fresh"
),
}
}
}
}
/// Activate an offline-only session using the last known user. /// Activate an offline-only session using the last known user.
/// ///
/// Falls back to user id `0` (an empty profile) when no previous session /// Falls back to user id `0` (an empty profile) when no previous session
+17
View File
@@ -82,6 +82,23 @@ impl UserDataPaths {
Ok(base) Ok(base)
} }
/// Data directory for an ARBITRARY user id (no active-user requirement):
/// ~/.local/share/qbz/users/{uid}/ — the same layout `user_data_dir`
/// resolves for the active user. Used by the guest-profile adoption
/// (#553), which must compare two users' paths before either is active.
pub fn data_dir_for(user_id: u64) -> Result<PathBuf, String> {
Ok(Self::global_data_dir()?
.join("users")
.join(user_id.to_string()))
}
/// Cache twin of [`Self::data_dir_for`]: ~/.cache/qbz/users/{uid}/.
pub fn cache_dir_for(user_id: u64) -> Result<PathBuf, String> {
Ok(Self::global_cache_dir()?
.join("users")
.join(user_id.to_string()))
}
/// Get the global (non-user-scoped) data directory: ~/.local/share/qbz/ /// Get the global (non-user-scoped) data directory: ~/.local/share/qbz/
pub fn global_data_dir() -> Result<PathBuf, String> { pub fn global_data_dir() -> Result<PathBuf, String> {
dirs::data_dir() dirs::data_dir()
@@ -4458,3 +4458,6 @@ msgstr "Keine verfügbaren Titel zum Abspielen"
# Always-visible log uploader entry (settings sub-nav footer) # Always-visible log uploader entry (settings sub-nav footer)
msgid "Share logs" msgid "Share logs"
msgstr "Protokolle teilen" msgstr "Protokolle teilen"
# Guest local-only mode disclaimer line (login screen, #553)
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
msgstr "QBZ kann ohne Qobuz™-Konto als Offline-Player genutzt werden (kein Zugriff auf die Qobuz™-Bibliothek)."
@@ -227,3 +227,6 @@ msgstr "Favorite"
# Always-visible log uploader entry (settings sub-nav footer) # Always-visible log uploader entry (settings sub-nav footer)
msgid "Share logs" msgid "Share logs"
msgstr "Share logs" msgstr "Share logs"
# Guest local-only mode disclaimer line (login screen, #553)
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
msgstr "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
@@ -4488,3 +4488,6 @@ msgstr "No hay pistas disponibles para reproducir"
# Always-visible log uploader entry (settings sub-nav footer) # Always-visible log uploader entry (settings sub-nav footer)
msgid "Share logs" msgid "Share logs"
msgstr "Compartir registros" msgstr "Compartir registros"
# Guest local-only mode disclaimer line (login screen, #553)
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
msgstr "QBZ puede usarse como reproductor sin conexión sin una cuenta de Qobuz™ (sin acceso a la biblioteca de Qobuz™)."
@@ -4458,3 +4458,6 @@ msgstr "Aucune piste disponible à lire"
# Always-visible log uploader entry (settings sub-nav footer) # Always-visible log uploader entry (settings sub-nav footer)
msgid "Share logs" msgid "Share logs"
msgstr "Partager les journaux" msgstr "Partager les journaux"
# Guest local-only mode disclaimer line (login screen, #553)
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
msgstr "QBZ peut être utilisé comme lecteur hors ligne sans compte Qobuz™ (pas d'accès à la bibliothèque Qobuz™)."
@@ -4447,3 +4447,6 @@ msgstr "再生できるトラックがありません"
# Always-visible log uploader entry (settings sub-nav footer) # Always-visible log uploader entry (settings sub-nav footer)
msgid "Share logs" msgid "Share logs"
msgstr "ログを共有" msgstr "ログを共有"
# Guest local-only mode disclaimer line (login screen, #553)
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
msgstr "QBZはQobuz™アカウントなしでオフラインプレーヤーとして使用できます(Qobuz™ライブラリにはアクセスできません)。"
@@ -4458,3 +4458,6 @@ msgstr "Nenhuma faixa disponível para reprodução"
# Always-visible log uploader entry (settings sub-nav footer) # Always-visible log uploader entry (settings sub-nav footer)
msgid "Share logs" msgid "Share logs"
msgstr "Compartilhar registros" msgstr "Compartilhar registros"
# Guest local-only mode disclaimer line (login screen, #553)
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
msgstr "O QBZ pode ser usado como reprodutor offline sem conta Qobuz™ (sem acesso à biblioteca Qobuz™)."
@@ -4471,3 +4471,6 @@ msgstr "Нет доступных треков для воспроизведен
# Always-visible log uploader entry (settings sub-nav footer) # Always-visible log uploader entry (settings sub-nav footer)
msgid "Share logs" msgid "Share logs"
msgstr "Поделиться журналами" msgstr "Поделиться журналами"
# Guest local-only mode disclaimer line (login screen, #553)
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
msgstr "QBZ можно использовать как офлайн-плеер без учётной записи Qobuz™ (без доступа к библиотеке Qobuz™)."
+6 -1
View File
@@ -258,7 +258,10 @@ export component LoginScreen inherits Rectangle {
Rectangle { height: Spacing.sm; } Rectangle { height: Spacing.sm; }
} }
if OfflineState.has-previous-session: HorizontalLayout { // Always visible (#553): without a previous session this
// opens the GUEST profile (user 0) — Local Library only,
// adopted by the account on the first real login.
HorizontalLayout {
alignment: center; alignment: center;
QbzTextLink { QbzTextLink {
label: @tr("Start offline (no access to Qobuz™ services)"); label: @tr("Start offline (no access to Qobuz™ services)");
@@ -273,6 +276,8 @@ export component LoginScreen inherits Rectangle {
// --- Legal disclaimer ------------------------------------ // --- Legal disclaimer ------------------------------------
Text { Text {
text: @tr("QBZ requires an active Qobuz™ subscription. Your credentials are sent directly to Qobuz™.") text: @tr("QBZ requires an active Qobuz™ subscription. Your credentials are sent directly to Qobuz™.")
+ "\n"
+ @tr("QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library).")
+ "\n" + "\n"
+ @tr("This application uses the Qobuz API but is not certified by Qobuz.") + @tr("This application uses the Qobuz API but is not certified by Qobuz.")
+ " " + " "
+13 -6
View File
@@ -539,12 +539,19 @@ async fn enter_shell_offline(
image_cache: artwork::ImageCache, image_cache: artwork::ImageCache,
settings_ctx: Arc<settings::SettingsCtx>, settings_ctx: Arc<settings::SettingsCtx>,
) -> Result<(), String> { ) -> Result<(), String> {
// Never open the empty user-0 profile: offline mode needs a previous // No previous session → the GUEST profile, user 0 (#553; restores the
// session's data (Tauri falls back to user 0; the port refuses — the // Tauri fallback this port used to refuse). The guest builds a real
// login UI hides the link in that case, this is the backstop). // per-user store set (local library, mixtapes, prefs) under users/0;
let Some(user_id) = qbz_app::user_data::UserDataPaths::load_last_user_id() else { // the first successful login ADOPTS it (AppRuntime::activate renames
return Err("no previous session — offline mode requires a prior login".to_string()); // users/0 to the real id when that account has no profile here yet).
}; // `activate_offline` below resolves the same id — 0 is never persisted
// as the last-user marker, so it never masquerades as a real session.
let user_id = qbz_app::user_data::UserDataPaths::load_last_user_id().unwrap_or(0);
if user_id == 0 {
log::info!(
"[qbz-slint] offline shell: no previous session — entering the guest profile (user 0)"
);
}
// Session scaffolding at the last user (session store, runtime state). // Session scaffolding at the last user (session store, runtime state).
runtime.activate_offline().await?; runtime.activate_offline().await?;