Compare commits

...

10 Commits

Author SHA1 Message Date
Robert McRackan
b479096fc2 Added logging. Bug fix in MFA login form 2021-07-25 16:49:07 -04:00
rmcrackan
ad09d36588 Merge pull request #69 from Mbucari/master
Added logging of download license.
2021-07-24 19:56:55 -04:00
Mbucari
1a9c0188a4 Update AaxcDownloadConverter.cs 2021-07-24 16:12:11 -06:00
Mbucari
ca75b55da4 Merge branch 'rmcrackan:master' into master 2021-07-24 15:12:12 -06:00
Michael Bucari-Tovo
285b1e7b45 Removed dll. 2021-07-24 15:11:50 -06:00
Michael Bucari-Tovo
6912a499d0 Moved download licnse from debug log to verbose log. 2021-07-24 15:11:05 -06:00
Robert McRackan
4e70365150 increm ver # 2021-07-24 16:27:17 -04:00
Robert McRackan
811a95aedf After LogLevel changed in settings: warn if Verbose logging level 2021-07-24 16:26:50 -04:00
Michael Bucari-Tovo
20971124ab Add DLL temporarily. 2021-07-24 11:29:49 -06:00
Michael Bucari-Tovo
fa66a361dc Add logging of download license in DebugInfo 2021-07-24 11:28:58 -06:00
8 changed files with 118 additions and 37 deletions

View File

@@ -2,6 +2,7 @@
using Dinah.Core;
using Dinah.Core.Diagnostics;
using Dinah.Core.IO;
using Dinah.Core.Logging;
using Dinah.Core.StepRunner;
using System;
using System.IO;
@@ -39,6 +40,7 @@ namespace AaxDecrypter
ArgumentValidator.EnsureNotNullOrWhiteSpace(outFileName, nameof(outFileName));
OutputFileName = outFileName;
var outDir = Path.GetDirectoryName(OutputFileName);
if (!Directory.Exists(outDir))
throw new ArgumentNullException(nameof(outDir), "Directory does not exist");
if (File.Exists(OutputFileName))
@@ -51,6 +53,8 @@ namespace AaxDecrypter
downloadLicense = ArgumentValidator.EnsureNotNull(dlLic, nameof(dlLic));
OutputFormat = outputFormat;
Serilog.Log.Logger.Verbose("Download License. {@DebugInfo}", downloadLicense);
steps = new StepSequence
{
Name = "Download and Convert Aaxc To " + (outputFormat == OutputFormat.Mp4a ? "M4b" : "Mp3"),

View File

@@ -67,9 +67,29 @@ namespace FileLiberator
{
validate(libraryBook);
Serilog.Log.Logger.Debug("Trying to debug mysterious null ref exception {@DebugInfo}", new {
libraryBookIsNull = libraryBook is null,
BookIsNull = libraryBook?.Book is null,
libraryBook?.Book?.Locale,
libraryBook?.Book?.AudibleProductId,
AccountLength = libraryBook?.Account?.Length
});
var api = await InternalUtilities.AudibleApiActions.GetApiAsync(libraryBook.Account, libraryBook.Book.Locale);
Serilog.Log.Logger.Debug("Trying to debug mysterious null ref exception {@DebugInfo}", new { apiIsNull = api is null });
var contentLic = await api.GetDownloadLicenseAsync(libraryBook.Book.AudibleProductId);
Serilog.Log.Logger.Debug("Trying to debug mysterious null ref exception {@DebugInfo}", new {
contentLicIsNull = contentLic is null,
contentMetadataIsNull = contentLic?.ContentMetadata is null,
voucherIsNull = contentLic?.Voucher is null,
keyIsNull = contentLic?.Voucher?.Key is null,
keyLength = contentLic?.Voucher?.Key?.Length,
ivIsNull = contentLic?.Voucher?.Iv is null,
ivLength = contentLic?.Voucher?.Iv?.Length,
});
var aaxcDecryptDlLic = new DownloadLicense
(

View File

@@ -13,7 +13,7 @@
<!-- <PublishSingleFile>true</PublishSingleFile> -->
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Version>5.3.6.1</Version>
<Version>5.3.8.1</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -328,19 +328,7 @@ namespace LibationLauncher
DecryptInProgressFiles = Directory.EnumerateFiles(AudibleFileStorage.DecryptInProgress).Count(),
});
// when turning on debug (and especially Verbose) to share logs, some privacy settings may not be obscured
if (Log.Logger.IsVerboseEnabled())
MessageBox.Show(@"
Warning: verbose logging is enabled.
This should be used for debugging only. It creates many
more logs and debug files, neither of which are as
strictly anonomous.
When you are finished debugging, it's highly recommended
to set your debug MinimumLevel to Information and restart
Libation.
".Trim(), "Verbose logging enabled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBoxVerboseLoggingWarning.ShowIfTrue();
}
private static void checkForUpdate(Configuration config)

View File

@@ -14,49 +14,74 @@ namespace LibationWinForms.Dialogs.Login
{
private RadioButton[] radioButtons { get; }
AudibleApi.MfaConfig _mfaConfig { get; }
public MfaDialog(AudibleApi.MfaConfig mfaConfig)
{
InitializeComponent();
_mfaConfig = mfaConfig;
radioButtons = new[] { this.radioButton1, this.radioButton2, this.radioButton3 };
// optional string settings
if (!string.IsNullOrWhiteSpace(mfaConfig.Title))
this.Text = mfaConfig.Title;
setOptional(this.radioButton1, mfaConfig.Button1Text);
setOptional(this.radioButton2, mfaConfig.Button2Text);
setOptional(this.radioButton3, mfaConfig.Button3Text);
// mandatory values
radioButton1.Name = mfaConfig.Button1Name;
radioButton1.Tag = mfaConfig.Button1Value;
setRadioButton(0, this.radioButton1);
setRadioButton(1, this.radioButton2);
setRadioButton(2, this.radioButton3);
radioButton2.Name = mfaConfig.Button2Name;
radioButton2.Tag = mfaConfig.Button2Value;
radioButton3.Name = mfaConfig.Button3Name;
radioButton3.Tag = mfaConfig.Button3Value;
Serilog.Log.Logger.Information("{@DebugInfo}", new {
paramButtonCount = mfaConfig.Buttons.Count,
visibleRadioButtonCount = radioButtons.Count(rb => rb.Visible)
});
}
private static void setOptional(RadioButton radioButton, string text)
private void setRadioButton(int pos, RadioButton rb)
{
if (!string.IsNullOrWhiteSpace(text))
radioButton.Text = text;
if (_mfaConfig.Buttons.Count <= pos)
{
rb.Checked = false;
rb.Enabled = false;
rb.Visible = false;
return;
}
var btn = _mfaConfig.Buttons[pos];
// optional
if (!string.IsNullOrWhiteSpace(btn.Text))
rb.Text = btn.Text;
// mandatory values
rb.Name = btn.Name;
rb.Tag = btn.Value;
}
public string SelectedName { get; private set; }
public string SelectedValue { get; private set; }
private void submitBtn_Click(object sender, EventArgs e)
{
Serilog.Log.Logger.Debug("RadioButton states: {@DebugInfo}", new {
Serilog.Log.Logger.Information("RadioButton states: {@DebugInfo}", new {
rb1_visible = radioButton1.Visible,
rb1_checked = radioButton1.Checked,
r21_visible = radioButton2.Visible,
r21_checked = radioButton2.Checked,
rb3_visible = radioButton3.Visible,
rb3_checked = radioButton3.Checked
});
var selected = radioButtons.Single(rb => rb.Checked);
var selected = radioButtons.FirstOrDefault(rb => rb.Checked);
if (selected is null)
{
MessageBox.Show("No MFA option selected", "None selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Serilog.Log.Logger.Debug("Selected: {@DebugInfo}", new { isSelected = selected is not null, name = selected?.Name, value = selected?.Tag });
Serilog.Log.Logger.Information("Selected: {@DebugInfo}", new { isSelected = selected is not null, name = selected?.Name, value = selected?.Tag });
SelectedName = selected.Name;
SelectedValue = (string)selected.Tag;

View File

@@ -17,7 +17,7 @@ namespace LibationWinForms.Login
public string Get2faCode()
{
using var dialog = new _2faCodeDialog();
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (showDialog(dialog))
return dialog.Code;
return null;
}
@@ -25,7 +25,7 @@ namespace LibationWinForms.Login
public string GetCaptchaAnswer(byte[] captchaImage)
{
using var dialog = new CaptchaDialog(captchaImage);
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (showDialog(dialog))
return dialog.Answer;
return null;
}
@@ -33,7 +33,7 @@ namespace LibationWinForms.Login
public (string name, string value) GetMfaChoice(MfaConfig mfaConfig)
{
using var dialog = new MfaDialog(mfaConfig);
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (showDialog(dialog))
return (dialog.SelectedName, dialog.SelectedValue);
return (null, null);
}
@@ -41,7 +41,7 @@ namespace LibationWinForms.Login
public (string email, string password) GetLogin()
{
using var dialog = new AudibleLoginDialog(_account);
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (showDialog(dialog))
return (dialog.Email, dialog.Password);
return (null, null);
}
@@ -49,7 +49,15 @@ namespace LibationWinForms.Login
public void ShowApprovalNeeded()
{
using var dialog = new ApprovalNeededDialog();
dialog.ShowDialog();
showDialog(dialog);
}
/// <returns>True if ShowDialog's DialogResult == OK</returns>
private static bool showDialog(System.Windows.Forms.Form dialog)
{
var result = dialog.ShowDialog();
Serilog.Log.Logger.Debug("{@DebugInfo}", new { DialogResult = result });
return result == System.Windows.Forms.DialogResult.OK;
}
}
}

View File

@@ -94,7 +94,16 @@ namespace LibationWinForms.Dialogs
config.Books = newBooks;
config.LogLevel = (Serilog.Events.LogEventLevel)loggingLevelCb.SelectedItem;
{
var logLevelOld = config.LogLevel;
var logLevelNew = (Serilog.Events.LogEventLevel)loggingLevelCb.SelectedItem;
config.LogLevel = logLevelNew;
// only warn if changed during this time. don't want to warn every time user happens to change settings while level is verbose
if (logLevelOld != logLevelNew)
MessageBoxVerboseLoggingWarning.ShowIfTrue();
}
config.AllowLibationFixup = allowLibationFixupCbox.Checked;
config.DecryptToLossy = convertLossyRb.Checked;

View File

@@ -0,0 +1,27 @@
using System;
using System.Windows.Forms;
using Dinah.Core.Logging;
using Serilog;
namespace LibationWinForms
{
public static class MessageBoxVerboseLoggingWarning
{
public static void ShowIfTrue()
{
// when turning on debug (and especially Verbose) to share logs, some privacy settings may not be obscured
if (Log.Logger.IsVerboseEnabled())
MessageBox.Show(@"
Warning: verbose logging is enabled.
This should be used for debugging only. It creates many
more logs and debug files, neither of which are as
strictly anonomous.
When you are finished debugging, it's highly recommended
to set your debug MinimumLevel to Information and restart
Libation.
".Trim(), "Verbose logging enabled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}