From 5ed73aff2b108af09e27e7ff9645cb76f3ebe6a4 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 21 Apr 2020 14:39:39 -0700 Subject: [PATCH] Mock out the basics needed for DD --- DICUI.Library/DD/Converters.cs | 22 ++++ DICUI.Library/DD/Parameters.cs | 121 +++++++++++++++++++++ DICUI.Library/Data/Enumerations.cs | 4 +- DICUI.Library/Utilities/DumpEnvironment.cs | 36 ++---- DICUI/Options.cs | 5 +- DICUI/Windows/MainWindow.xaml.cs | 18 +-- 6 files changed, 168 insertions(+), 38 deletions(-) create mode 100644 DICUI.Library/DD/Converters.cs create mode 100644 DICUI.Library/DD/Parameters.cs diff --git a/DICUI.Library/DD/Converters.cs b/DICUI.Library/DD/Converters.cs new file mode 100644 index 00000000..6e8a1068 --- /dev/null +++ b/DICUI.Library/DD/Converters.cs @@ -0,0 +1,22 @@ +using DICUI.Data; + +namespace DICUI.DD +{ + public static class Converters + { + #region Cross-enumeration conversions + + /// + /// Get the default extension for a given disc type + /// + /// MediaType value to check + /// Valid extension (with leading '.'), null on error + public static string Extension(MediaType? type) + { + // DD has a single, unified output format by default + return ".bin"; + } + + #endregion + } +} \ No newline at end of file diff --git a/DICUI.Library/DD/Parameters.cs b/DICUI.Library/DD/Parameters.cs new file mode 100644 index 00000000..2d4a93bb --- /dev/null +++ b/DICUI.Library/DD/Parameters.cs @@ -0,0 +1,121 @@ +using DICUI.Data; + +namespace DICUI.DD +{ + /// + /// Represents a generic set of DD parameters + /// + public class Parameters : BaseParameters + { + /// + /// Populate a Parameters object from a param string + /// + /// String possibly representing a set of parameters + public Parameters(string parameters) + : base(parameters) + { + this.InternalProgram = InternalProgram.DD; + } + + /// + /// Generate parameters based on a set of known inputs + /// + /// KnownSystem value to use + /// MediaType value to use + /// Drive letter to use + /// Filename to use + /// Drive speed to use + /// Enable paranoid mode (safer dumping) + /// Enable quiet mode (no beeps) + /// User-defined reread count + public Parameters(KnownSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, bool paranoid, bool quietMode, int retryCount) + : base(system, type, driveLetter, filename, driveSpeed, paranoid, quietMode, retryCount) + { + } + + /// + /// Blindly generate a parameter string based on the inputs + /// + /// Correctly formatted parameter string, null on error + public override string GenerateParameters() + { + return string.Empty; + } + + /// + /// Get the input path from the implementation + /// + /// String representing the path, null on error + public override string InputPath() => string.Empty; + + /// + /// Get the output path from the implementation + /// + /// String representing the path, null on error + public override string OutputPath() => string.Empty; + + /// + /// Get the processing speed from the implementation + /// + /// int? representing the speed, null on error + public override int? GetSpeed() => null; + + /// + /// Set the processing speed int the implementation + /// + /// int? representing the speed + public override void SetSpeed(int? speed) + { + } + + /// + /// Get the MediaType from the current set of parameters + /// + /// MediaType value if successful, null on error + public override MediaType? GetMediaType() => null; + + /// + /// Gets if the current command is considered a dumping command or not + /// + /// True if it's a dumping command, false otherwise + public override bool IsDumpingCommand() => true; + + /// + /// Reset all special variables to have default values + /// + protected override void ResetValues() + { + } + + /// + /// Set default parameters for a given system and media type + /// + /// KnownSystem value to use + /// MediaType value to use + /// Drive letter to use + /// Filename to use + /// Drive speed to use + /// Enable paranoid mode (safer dumping) + /// User-defined reread count + protected override void SetDefaultParameters( + KnownSystem? system, + MediaType? type, + char driveLetter, + string filename, + int? driveSpeed, + bool paranoid, + int retryCount) + { + } + + /// + /// Scan a possible parameter string and populate whatever possible + /// + /// String possibly representing parameters + /// + protected override bool ValidateAndSetParameters(string parameters) + { + return true; + } + } +} diff --git a/DICUI.Library/Data/Enumerations.cs b/DICUI.Library/Data/Enumerations.cs index acc7a045..d35fb289 100644 --- a/DICUI.Library/Data/Enumerations.cs +++ b/DICUI.Library/Data/Enumerations.cs @@ -47,9 +47,9 @@ { NONE = 0, - DiscImageCreator, Aaru, - DD, // TODO: Currently unimplemented + DD, // TODO: Currently partially implemented + DiscImageCreator, } /// diff --git a/DICUI.Library/Utilities/DumpEnvironment.cs b/DICUI.Library/Utilities/DumpEnvironment.cs index 0ae607dc..1c979959 100644 --- a/DICUI.Library/Utilities/DumpEnvironment.cs +++ b/DICUI.Library/Utilities/DumpEnvironment.cs @@ -154,6 +154,11 @@ namespace DICUI.Utilities case InternalProgram.Aaru: Parameters = new Aaru.Parameters(parameters); break; + + case InternalProgram.DD: + Parameters = new DD.Parameters(parameters); + break; + case InternalProgram.DiscImageCreator: Parameters = new DiscImageCreator.Parameters(parameters); break; @@ -174,32 +179,6 @@ namespace DICUI.Utilities { } } - /// - /// Gets if the current drive has the latest firmware - /// - /// - public async Task DriveHasLatestFimrware() - { - // Validate that the required program exists - if (!File.Exists(Parameters.Path)) - return false; - - var parameters = new DiscImageCreator.Parameters(string.Empty) - { - BaseCommand = DiscImageCreator.Command.DriveSpeed, - DriveLetter = Drive.Letter.ToString(), - }; - - string output = await ExecuteDiscImageCreatorWithParameters(parameters); - - // If we get the firmware message - if (output.Contains("[ERROR] This drive isn't latest firmware. Please update.")) - return false; - - // Otherwise, we know the firmware's good - return true; - } - /// /// Eject the disc using DIC /// @@ -385,6 +364,11 @@ namespace DICUI.Utilities case InternalProgram.Aaru: Parameters = new Aaru.Parameters(System, Type, Drive.Letter, filename, driveSpeed, ParanoidMode, QuietMode, RereadAmountC2); break; + + case InternalProgram.DD: + Parameters = new DD.Parameters(System, Type, Drive.Letter, filename, driveSpeed, ParanoidMode, QuietMode, RereadAmountC2); + break; + case InternalProgram.DiscImageCreator: Parameters = new DiscImageCreator.Parameters(System, Type, Drive.Letter, filename, driveSpeed, ParanoidMode, QuietMode, RereadAmountC2); break; diff --git a/DICUI/Options.cs b/DICUI/Options.cs index 2a1e2c0e..2921d564 100644 --- a/DICUI/Options.cs +++ b/DICUI/Options.cs @@ -8,9 +8,11 @@ namespace DICUI { public class Options { - public string DefaultOutputPath { get; private set; } public string AaruPath { get; private set; } public string CreatorPath { get; private set; } + public string DDPath { get; private set; } + + public string DefaultOutputPath { get; private set; } public string SubDumpPath { get; private set; } public string InternalProgram { get; set; } @@ -61,6 +63,7 @@ namespace DICUI //TODO: hardcoded, we should find a better way this.AaruPath = GetStringSetting(configFile, "AaruPath", "Programs\\Aaru\\Aaru.exe"); this.CreatorPath = GetStringSetting(configFile, "CreatorPath", "Programs\\Creator\\DiscImageCreator.exe"); + this.DDPath = GetStringSetting(configFile, "DDPath", "Programs\\DD\\dd.exe"); this.SubDumpPath = GetStringSetting(configFile, "SubDumpPath", "Programs\\Subdump\\subdump.exe"); this.DefaultOutputPath = GetStringSetting(configFile, "DefaultOutputPath", "ISO"); this.InternalProgram = GetStringSetting(configFile, "InternalProgram", Data.InternalProgram.DiscImageCreator.ToString()); diff --git a/DICUI/Windows/MainWindow.xaml.cs b/DICUI/Windows/MainWindow.xaml.cs index 5f942471..1454e569 100644 --- a/DICUI/Windows/MainWindow.xaml.cs +++ b/DICUI/Windows/MainWindow.xaml.cs @@ -475,6 +475,10 @@ namespace DICUI.Windows env.Parameters.Path = _options.AaruPath; break; + case InternalProgram.DD: + env.Parameters.Path = _options.DDPath; + break; + case InternalProgram.DiscImageCreator: env.Parameters.Path = _options.CreatorPath; break; @@ -521,15 +525,6 @@ namespace DICUI.Windows try { - // Check for the firmware first for DiscImageCreator - // TODO: Remove this (and method) once DIC end-to-end logging becomes a thing - // TODO: Re-enable once whatever issues DIC is having with this are figured out - //if (_env.InternalProgram == InternalProgram.DiscImageCreator && !await _env.DriveHasLatestFimrware()) - //{ - // MessageBox.Show($"DiscImageCreator has reported that drive {_env.Drive.Letter} is not updated to the most recent firmware. Please update the firmware for your drive and try again.", "Outdated Firmware", MessageBoxButton.OK, MessageBoxImage.Error); - // return; - //} - // Validate that the user explicitly wants an inactive drive to be considered for dumping if (!_env.Drive.MarkedActive) { @@ -676,6 +671,11 @@ namespace DICUI.Windows case InternalProgram.Aaru: extension = Aaru.Converters.Extension(mediaType); break; + + case InternalProgram.DD: + extension = DD.Converters.Extension(mediaType); + break; + case InternalProgram.DiscImageCreator: extension = DiscImageCreator.Converters.Extension(mediaType); break;