From ef67ae9d6a292fe5bd69a7df588888751d9bc162 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Fri, 9 May 2025 17:51:48 -0600 Subject: [PATCH] Ask users to clear the accounts when enabling widevine (#1249) --- .../Controls/Settings/Audio.axaml.cs | 25 ++++++++++++++++--- .../Configuration.PersistentSettings.cs | 2 +- .../Dialogs/SettingsDialog.AudioSettings.cs | 24 +++++++++++++++--- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Source/LibationAvalonia/Controls/Settings/Audio.axaml.cs b/Source/LibationAvalonia/Controls/Settings/Audio.axaml.cs index 6f247581..8cb6af48 100644 --- a/Source/LibationAvalonia/Controls/Settings/Audio.axaml.cs +++ b/Source/LibationAvalonia/Controls/Settings/Audio.axaml.cs @@ -31,10 +31,29 @@ namespace LibationAvalonia.Controls.Settings if (!accounts.AccountsSettings.Accounts.Any(a => a.IdentityTokens.DeviceType == AudibleApi.Resources.DeviceType)) { if (VisualRoot is Window parent) - await MessageBox.Show(parent, - "Your must remove account(s) from Libation and then re-add them to enable widwvine content.", + { + var choice = await MessageBox.Show(parent, + "In order to enable widevine content, Libation will need to log into your accounts again.\r\n\r\n" + + "Do you want Libation to clear your current account settings and prompt you to login before the next download?", "Widevine Content Unavailable", - MessageBoxButtons.OK); + MessageBoxButtons.YesNo, + MessageBoxIcon.Question, + MessageBoxDefaultButton.Button2); + + if (choice == DialogResult.Yes) + { + foreach (var account in accounts.AccountsSettings.Accounts.ToArray()) + { + if (account.IdentityTokens.DeviceType != AudibleApi.Resources.DeviceType) + { + accounts.AccountsSettings.Delete(account); + var acc = accounts.AccountsSettings.Upsert(account.AccountId, account.Locale.Name); + acc.AccountName = account.AccountName; + } + } + return; + } + } _viewModel.UseWidevine = false; } diff --git a/Source/LibationFileManager/Configuration.PersistentSettings.cs b/Source/LibationFileManager/Configuration.PersistentSettings.cs index 7da1c25c..71aeeb40 100644 --- a/Source/LibationFileManager/Configuration.PersistentSettings.cs +++ b/Source/LibationFileManager/Configuration.PersistentSettings.cs @@ -257,7 +257,7 @@ namespace LibationFileManager } [Description("Use widevine DRM")] - public bool UseWidevine { get => GetNonString(defaultValue: true); set => SetNonString(value); } + public bool UseWidevine { get => GetNonString(defaultValue: false); set => SetNonString(value); } [Description("Request Spatial Audio")] public bool RequestSpatial { get => GetNonString(defaultValue: true); set => SetNonString(value); } diff --git a/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs b/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs index c894e5ca..bb954ce1 100644 --- a/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs +++ b/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs @@ -206,10 +206,28 @@ namespace LibationWinForms.Dialogs if (!accounts.AccountsSettings.Accounts.Any(a => a.IdentityTokens.DeviceType == AudibleApi.Resources.DeviceType)) { - MessageBox.Show(this, - "Your must remove account(s) from Libation and then re-add them to enable widwvine content.", + var choice = MessageBox.Show(this, + "In order to enable widevine content, Libation will need to log into your accounts again.\r\n\r\n" + + "Do you want Libation to clear your current account settings and prompt you to login before the next download?", "Widevine Content Unavailable", - MessageBoxButtons.OK); + MessageBoxButtons.YesNo, + MessageBoxIcon.Question, + MessageBoxDefaultButton.Button2); + + if (choice == DialogResult.Yes) + { + foreach (var account in accounts.AccountsSettings.Accounts.ToArray()) + { + if (account.IdentityTokens.DeviceType != AudibleApi.Resources.DeviceType) + { + accounts.AccountsSettings.Delete(account); + var acc = accounts.AccountsSettings.Upsert(account.AccountId, account.Locale.Name); + acc.AccountName = account.AccountName; + } + } + + return; + } useWidevineCbox.Checked = false; return;