From bba98c2abf3f275b37e4c9eecb202482fbe4fd29 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 25 Nov 2018 19:17:21 +0000 Subject: [PATCH] Move ATAPI device reporting to non-static class and its UI to CLI. --- .../.idea/contentModel.xml | 1 - DiscImageChef.Core/Devices/Report/ATAPI.cs | 69 ------------------- .../Devices/Report/SCSI/General.cs | 2 - DiscImageChef.Core/DiscImageChef.Core.csproj | 1 - DiscImageChef/Commands/DeviceReport.cs | 16 ++++- 5 files changed, 15 insertions(+), 74 deletions(-) delete mode 100644 DiscImageChef.Core/Devices/Report/ATAPI.cs diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml index 42c2b0e16..7b3c95a36 100644 --- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml +++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml @@ -224,7 +224,6 @@ - diff --git a/DiscImageChef.Core/Devices/Report/ATAPI.cs b/DiscImageChef.Core/Devices/Report/ATAPI.cs deleted file mode 100644 index 9c0fa3f34..000000000 --- a/DiscImageChef.Core/Devices/Report/ATAPI.cs +++ /dev/null @@ -1,69 +0,0 @@ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : ATAPI.cs -// Author(s) : Natalia Portillo -// -// Component : Core algorithms. -// -// --[ Description ] ---------------------------------------------------------- -// -// Creates reports from ATAPI devices. -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2011-2018 Natalia Portillo -// ****************************************************************************/ - -using DiscImageChef.CommonTypes.Metadata; -using DiscImageChef.Console; -using DiscImageChef.Decoders.ATA; -using DiscImageChef.Devices; - -namespace DiscImageChef.Core.Devices.Report -{ - /// - /// Implements creating a report for an ATAPI device - /// - static class Atapi - { - /// - /// Fills a SCSI device report with parameters specific to an ATAPI device - /// - /// Device - /// Device report - /// If debug is enabled - internal static void Report(Device dev, ref DeviceReportV2 report, bool debug) - { - if(report == null) return; - - const uint TIMEOUT = 5; - - DicConsole.WriteLine("Querying ATAPI IDENTIFY..."); - - dev.AtapiIdentify(out byte[] buffer, out _, TIMEOUT, out _); - - if(!Identify.Decode(buffer).HasValue) return; - - Identify.IdentifyDevice? atapiIdNullable = Identify.Decode(buffer); - if(atapiIdNullable != null) report.ATAPI = new CommonTypes.Metadata.Ata {IdentifyDevice = atapiIdNullable}; - - if(debug) report.ATAPI.Identify = buffer; - } - } -} \ No newline at end of file diff --git a/DiscImageChef.Core/Devices/Report/SCSI/General.cs b/DiscImageChef.Core/Devices/Report/SCSI/General.cs index fe236939c..386273906 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/General.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/General.cs @@ -76,8 +76,6 @@ namespace DiscImageChef.Core.Devices.Report.SCSI removable = pressedKey.Key == ConsoleKey.Y; } - if(dev.Type == DeviceType.ATAPI) Atapi.Report(dev, ref report, debug); - DicConsole.WriteLine("Querying SCSI INQUIRY..."); sense = dev.ScsiInquiry(out byte[] buffer, out byte[] senseBuffer); diff --git a/DiscImageChef.Core/DiscImageChef.Core.csproj b/DiscImageChef.Core/DiscImageChef.Core.csproj index f6ca7cbe6..f27cd4684 100644 --- a/DiscImageChef.Core/DiscImageChef.Core.csproj +++ b/DiscImageChef.Core/DiscImageChef.Core.csproj @@ -77,7 +77,6 @@ - diff --git a/DiscImageChef/Commands/DeviceReport.cs b/DiscImageChef/Commands/DeviceReport.cs index a59f66034..8ba0c7adf 100644 --- a/DiscImageChef/Commands/DeviceReport.cs +++ b/DiscImageChef/Commands/DeviceReport.cs @@ -137,13 +137,15 @@ namespace DiscImageChef.Commands if(dev.IsPcmcia) report.PCMCIA = reporter.PcmciaReport(); + byte[] buffer; + switch(dev.Type) { case DeviceType.ATA: { DicConsole.WriteLine("Querying ATA IDENTIFY..."); - dev.AtaIdentify(out byte[] buffer, out _, dev.Timeout, out _); + dev.AtaIdentify(out buffer, out _, dev.Timeout, out _); if(!Identify.Decode(buffer).HasValue) break; @@ -225,6 +227,18 @@ namespace DiscImageChef.Commands case DeviceType.NVMe: throw new NotImplementedException("NVMe devices not yet supported."); case DeviceType.ATAPI: + DicConsole.WriteLine("Querying ATAPI IDENTIFY..."); + + dev.AtapiIdentify(out buffer, out _, dev.Timeout, out _); + + if(!Identify.Decode(buffer).HasValue) return; + + Identify.IdentifyDevice? atapiIdNullable = Identify.Decode(buffer); + if(atapiIdNullable != null) report.ATAPI = new CommonTypes.Metadata.Ata {IdentifyDevice = atapiIdNullable}; + + if(options.Debug) report.ATAPI.Identify = buffer; + + goto case DeviceType.SCSI; case DeviceType.SCSI: General.Report(dev, ref report, options.Debug, ref removable); break;