mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Mock out the basics needed for DD
This commit is contained in:
22
DICUI.Library/DD/Converters.cs
Normal file
22
DICUI.Library/DD/Converters.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using DICUI.Data;
|
||||
|
||||
namespace DICUI.DD
|
||||
{
|
||||
public static class Converters
|
||||
{
|
||||
#region Cross-enumeration conversions
|
||||
|
||||
/// <summary>
|
||||
/// Get the default extension for a given disc type
|
||||
/// </summary>
|
||||
/// <param name="type">MediaType value to check</param>
|
||||
/// <returns>Valid extension (with leading '.'), null on error</returns>
|
||||
public static string Extension(MediaType? type)
|
||||
{
|
||||
// DD has a single, unified output format by default
|
||||
return ".bin";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
121
DICUI.Library/DD/Parameters.cs
Normal file
121
DICUI.Library/DD/Parameters.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using DICUI.Data;
|
||||
|
||||
namespace DICUI.DD
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic set of DD parameters
|
||||
/// </summary>
|
||||
public class Parameters : BaseParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// Populate a Parameters object from a param string
|
||||
/// </summary>
|
||||
/// <param name="parameters">String possibly representing a set of parameters</param>
|
||||
public Parameters(string parameters)
|
||||
: base(parameters)
|
||||
{
|
||||
this.InternalProgram = InternalProgram.DD;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate parameters based on a set of known inputs
|
||||
/// </summary>
|
||||
/// <param name="system">KnownSystem value to use</param>
|
||||
/// <param name="type">MediaType value to use</param>
|
||||
/// <param name="driveLetter">Drive letter to use</param>
|
||||
/// <param name="filename">Filename to use</param>
|
||||
/// <param name="driveSpeed">Drive speed to use</param>
|
||||
/// <param name="paranoid">Enable paranoid mode (safer dumping)</param>
|
||||
/// <param name="quietMode">Enable quiet mode (no beeps)</param>
|
||||
/// <param name="retryCount">User-defined reread count</param>
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Blindly generate a parameter string based on the inputs
|
||||
/// </summary>
|
||||
/// <returns>Correctly formatted parameter string, null on error</returns>
|
||||
public override string GenerateParameters()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the input path from the implementation
|
||||
/// </summary>
|
||||
/// <returns>String representing the path, null on error</returns>
|
||||
public override string InputPath() => string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Get the output path from the implementation
|
||||
/// </summary>
|
||||
/// <returns>String representing the path, null on error</returns>
|
||||
public override string OutputPath() => string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Get the processing speed from the implementation
|
||||
/// </summary>
|
||||
/// <returns>int? representing the speed, null on error</returns>
|
||||
public override int? GetSpeed() => null;
|
||||
|
||||
/// <summary>
|
||||
/// Set the processing speed int the implementation
|
||||
/// </summary>
|
||||
/// <param name="speed">int? representing the speed</param>
|
||||
public override void SetSpeed(int? speed)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the MediaType from the current set of parameters
|
||||
/// </summary>
|
||||
/// <returns>MediaType value if successful, null on error</returns>
|
||||
public override MediaType? GetMediaType() => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets if the current command is considered a dumping command or not
|
||||
/// </summary>
|
||||
/// <returns>True if it's a dumping command, false otherwise</returns>
|
||||
public override bool IsDumpingCommand() => true;
|
||||
|
||||
/// <summary>
|
||||
/// Reset all special variables to have default values
|
||||
/// </summary>
|
||||
protected override void ResetValues()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set default parameters for a given system and media type
|
||||
/// </summary>
|
||||
/// <param name="system">KnownSystem value to use</param>
|
||||
/// <param name="type">MediaType value to use</param>
|
||||
/// <param name="driveLetter">Drive letter to use</param>
|
||||
/// <param name="filename">Filename to use</param>
|
||||
/// <param name="driveSpeed">Drive speed to use</param>
|
||||
/// <param name="paranoid">Enable paranoid mode (safer dumping)</param>
|
||||
/// <param name="retryCount">User-defined reread count</param>
|
||||
protected override void SetDefaultParameters(
|
||||
KnownSystem? system,
|
||||
MediaType? type,
|
||||
char driveLetter,
|
||||
string filename,
|
||||
int? driveSpeed,
|
||||
bool paranoid,
|
||||
int retryCount)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scan a possible parameter string and populate whatever possible
|
||||
/// </summary>
|
||||
/// <param name="parameters">String possibly representing parameters</param>
|
||||
/// <returns></returns>
|
||||
protected override bool ValidateAndSetParameters(string parameters)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,9 +47,9 @@
|
||||
{
|
||||
NONE = 0,
|
||||
|
||||
DiscImageCreator,
|
||||
Aaru,
|
||||
DD, // TODO: Currently unimplemented
|
||||
DD, // TODO: Currently partially implemented
|
||||
DiscImageCreator,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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
|
||||
{ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets if the current drive has the latest firmware
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Eject the disc using DIC
|
||||
/// </summary>
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user