From eacee24d457b1168688c66c9ebdaa5a4ea75684d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 22 May 2024 20:46:17 -0400 Subject: [PATCH] Remove automatic eject and reset options --- CHANGELIST.md | 1 + MPF.Core/Data/Options.cs | 18 ---- MPF.Core/DumpEnvironment.cs | 109 ------------------------ MPF.Core/UI/ViewModels/MainViewModel.cs | 14 +-- 4 files changed, 2 insertions(+), 140 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index aa7a7fa4..1dfa4e95 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -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) diff --git a/MPF.Core/Data/Options.cs b/MPF.Core/Data/Options.cs index 0056e9bf..77f34dfd 100644 --- a/MPF.Core/Data/Options.cs +++ b/MPF.Core/Data/Options.cs @@ -284,15 +284,6 @@ namespace MPF.Core.Data set { Settings["DICDVDRereadCount"] = value.ToString(); } } - /// - /// Reset drive after dumping (useful for older drives) - /// - public bool DICResetDriveAfterDump - { - get { return GetBooleanSetting(Settings, "DICResetDriveAfterDump", false); } - set { Settings["DICResetDriveAfterDump"] = value.ToString(); } - } - /// /// Use the CMI flag for supported disc types /// @@ -477,15 +468,6 @@ namespace MPF.Core.Data set { Settings["ShowDiscEjectReminder"] = value.ToString(); } } - /// - /// Eject the disc after dumping - /// - public bool EjectAfterDump - { - get { return GetBooleanSetting(Settings, "EjectAfterDump", false); } - set { Settings["EjectAfterDump"] = value.ToString(); } - } - /// /// Ignore fixed drives when populating the list /// diff --git a/MPF.Core/DumpEnvironment.cs b/MPF.Core/DumpEnvironment.cs index 6541a077..45d66091 100644 --- a/MPF.Core/DumpEnvironment.cs +++ b/MPF.Core/DumpEnvironment.cs @@ -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 /// public void CancelDumping() => _executionContext?.KillInternalProgram(); - /// - /// Eject the disc using DiscImageCreator - /// - public async Task EjectDisc() => - await RunStandaloneDiscImageCreatorCommand(ExecutionContexts.DiscImageCreator.CommandStrings.Eject); - - /// - /// Reset the current drive using DiscImageCreator - /// - public async Task ResetDrive() => - await RunStandaloneDiscImageCreatorCommand(ExecutionContexts.DiscImageCreator.CommandStrings.Reset); - /// /// Execute the initial invocation of the dumping programs /// @@ -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; } - /// - /// Run internal program async with an input set of parameters - /// - /// ExecutionContext object representing how to invoke the internal program - /// Standard output from commandline window - private static async Task 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; - } - /// /// Validate the current environment is ready for a dump /// @@ -655,47 +587,6 @@ namespace MPF.Core return Tools.GetSupportStatus(_system, _type); } - /// - /// Validate that DIscImageCreator is able to be found - /// - /// True if DiscImageCreator is found properly, false otherwise - 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); - } - - /// - /// Run a standalone DiscImageCreator command - /// - /// Command string to run - /// The output of the command on success, null on error - private async Task 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 } } diff --git a/MPF.Core/UI/ViewModels/MainViewModel.cs b/MPF.Core/UI/ViewModels/MainViewModel.cs index e6b39cc9..771ade13 100644 --- a/MPF.Core/UI/ViewModels/MainViewModel.cs +++ b/MPF.Core/UI/ViewModels/MainViewModel.cs @@ -942,7 +942,7 @@ namespace MPF.Core.UI.ViewModels /// /// Toggle the Start/Stop button /// - 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(); - } } }