mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Remove automatic eject and reset options
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
- Move GetLibCryptDetected back to DIC processor
|
||||
- Make RunProtectionScanOnPath signature easier to read
|
||||
- Clean up usings
|
||||
- Remove automatic eject and reset options
|
||||
|
||||
### 3.1.9a (2024-05-21)
|
||||
|
||||
|
||||
@@ -284,15 +284,6 @@ namespace MPF.Core.Data
|
||||
set { Settings["DICDVDRereadCount"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset drive after dumping (useful for older drives)
|
||||
/// </summary>
|
||||
public bool DICResetDriveAfterDump
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "DICResetDriveAfterDump", false); }
|
||||
set { Settings["DICResetDriveAfterDump"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use the CMI flag for supported disc types
|
||||
/// </summary>
|
||||
@@ -477,15 +468,6 @@ namespace MPF.Core.Data
|
||||
set { Settings["ShowDiscEjectReminder"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Eject the disc after dumping
|
||||
/// </summary>
|
||||
public bool EjectAfterDump
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "EjectAfterDump", false); }
|
||||
set { Settings["EjectAfterDump"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ignore fixed drives when populating the list
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -334,18 +333,6 @@ namespace MPF.Core
|
||||
/// </summary>
|
||||
public void CancelDumping() => _executionContext?.KillInternalProgram();
|
||||
|
||||
/// <summary>
|
||||
/// Eject the disc using DiscImageCreator
|
||||
/// </summary>
|
||||
public async Task<string?> EjectDisc() =>
|
||||
await RunStandaloneDiscImageCreatorCommand(ExecutionContexts.DiscImageCreator.CommandStrings.Eject);
|
||||
|
||||
/// <summary>
|
||||
/// Reset the current drive using DiscImageCreator
|
||||
/// </summary>
|
||||
public async Task<string?> ResetDrive() =>
|
||||
await RunStandaloneDiscImageCreatorCommand(ExecutionContexts.DiscImageCreator.CommandStrings.Reset);
|
||||
|
||||
/// <summary>
|
||||
/// Execute the initial invocation of the dumping programs
|
||||
/// </summary>
|
||||
@@ -450,20 +437,6 @@ namespace MPF.Core
|
||||
resultProgress?.Report(ResultEventArgs.Success("Information injection complete!"));
|
||||
}
|
||||
|
||||
// Eject the disc automatically if configured to
|
||||
if (_options.EjectAfterDump == true)
|
||||
{
|
||||
resultProgress?.Report(ResultEventArgs.Success($"Ejecting disc in drive {_drive?.Name}"));
|
||||
await EjectDisc();
|
||||
}
|
||||
|
||||
// Reset the drive automatically if configured to
|
||||
if (_internalProgram == InternalProgram.DiscImageCreator && _options.DICResetDriveAfterDump)
|
||||
{
|
||||
resultProgress?.Report(ResultEventArgs.Success($"Resetting drive {_drive?.Name}"));
|
||||
await ResetDrive();
|
||||
}
|
||||
|
||||
// Get user-modifiable information if confugured to
|
||||
if (_options.PromptForDiscInformation && processUserInfo != null)
|
||||
{
|
||||
@@ -584,47 +557,6 @@ namespace MPF.Core
|
||||
return parametersValid && floppyValid && removableDiskValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run internal program async with an input set of parameters
|
||||
/// </summary>
|
||||
/// <param name="executionContext">ExecutionContext object representing how to invoke the internal program</param>
|
||||
/// <returns>Standard output from commandline window</returns>
|
||||
private static async Task<string> ExecuteInternalProgram(BaseExecutionContext parameters)
|
||||
{
|
||||
Process childProcess;
|
||||
#if NET40
|
||||
string output = await Task.Factory.StartNew(() =>
|
||||
#else
|
||||
string output = await Task.Run(() =>
|
||||
#endif
|
||||
{
|
||||
childProcess = new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = parameters.ExecutablePath!,
|
||||
Arguments = parameters.GenerateParameters()!,
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true,
|
||||
},
|
||||
};
|
||||
childProcess.Start();
|
||||
childProcess.WaitForExit(1000);
|
||||
|
||||
// Just in case, we want to push a button 5 times to clear any errors
|
||||
for (int i = 0; i < 5; i++)
|
||||
childProcess.StandardInput.WriteLine("Y");
|
||||
|
||||
string stdout = childProcess.StandardOutput.ReadToEnd();
|
||||
childProcess.Dispose();
|
||||
return stdout;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate the current environment is ready for a dump
|
||||
/// </summary>
|
||||
@@ -655,47 +587,6 @@ namespace MPF.Core
|
||||
return Tools.GetSupportStatus(_system, _type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate that DIscImageCreator is able to be found
|
||||
/// </summary>
|
||||
/// <returns>True if DiscImageCreator is found properly, false otherwise</returns>
|
||||
private bool RequiredProgramsExist()
|
||||
{
|
||||
// Validate that the path is configured
|
||||
if (string.IsNullOrEmpty(_options.DiscImageCreatorPath))
|
||||
return false;
|
||||
|
||||
// Validate that the required program exists
|
||||
return File.Exists(_options.DiscImageCreatorPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run a standalone DiscImageCreator command
|
||||
/// </summary>
|
||||
/// <param name="command">Command string to run</param>
|
||||
/// <returns>The output of the command on success, null on error</returns>
|
||||
private async Task<string?> RunStandaloneDiscImageCreatorCommand(string command)
|
||||
{
|
||||
// Validate that DiscImageCreator is all set
|
||||
if (!RequiredProgramsExist())
|
||||
return null;
|
||||
|
||||
// Validate we're not trying to eject a non-optical
|
||||
if (_drive == null || _drive.InternalDriveType != InternalDriveType.Optical)
|
||||
return null;
|
||||
|
||||
CancelDumping();
|
||||
|
||||
var parameters = new ExecutionContexts.DiscImageCreator.ExecutionContext(string.Empty)
|
||||
{
|
||||
BaseCommand = command,
|
||||
DrivePath = _drive.Name,
|
||||
ExecutablePath = _options.DiscImageCreatorPath,
|
||||
};
|
||||
|
||||
return await ExecuteInternalProgram(parameters);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Toggle the Start/Stop button
|
||||
/// </summary>
|
||||
public async void ToggleStartStop()
|
||||
public void ToggleStartStop()
|
||||
{
|
||||
// Dump or stop the dump
|
||||
if (this.StartStopButtonText as string == StartDumpingValue)
|
||||
@@ -954,18 +954,6 @@ namespace MPF.Core.UI.ViewModels
|
||||
VerboseLogLn("Canceling dumping process...");
|
||||
_environment?.CancelDumping();
|
||||
this.CopyProtectScanButtonEnabled = true;
|
||||
|
||||
if (_environment != null && this.Options.EjectAfterDump)
|
||||
{
|
||||
VerboseLogLn($"Ejecting disc in drive {_environment.DriveName}");
|
||||
await _environment.EjectDisc();
|
||||
}
|
||||
|
||||
if (_environment != null && this.Options.DICResetDriveAfterDump)
|
||||
{
|
||||
VerboseLogLn($"Resetting drive {_environment.DriveName}");
|
||||
await _environment.ResetDrive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user