diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml index 25a755c4f..72b0105b1 100644 --- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml +++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml @@ -225,6 +225,7 @@ + diff --git a/DiscImageChef.Core/Devices/Report/ATA.cs b/DiscImageChef.Core/Devices/Report/ATA.cs index 435baba91..0e724818b 100644 --- a/DiscImageChef.Core/Devices/Report/ATA.cs +++ b/DiscImageChef.Core/Devices/Report/ATA.cs @@ -58,8 +58,6 @@ namespace DiscImageChef.Core.Devices.Report const uint TIMEOUT = 5; - if(dev.IsUsb) Usb.Report(dev, ref report, debug, ref removable); - if(dev.IsFireWire) FireWire.Report(dev, ref report, ref removable); if(dev.IsPcmcia) Pcmcia.Report(dev, ref report); diff --git a/DiscImageChef.Core/Devices/Report/DeviceReport.cs b/DiscImageChef.Core/Devices/Report/DeviceReport.cs new file mode 100644 index 000000000..166059460 --- /dev/null +++ b/DiscImageChef.Core/Devices/Report/DeviceReport.cs @@ -0,0 +1,16 @@ +using DiscImageChef.Devices; + +namespace DiscImageChef.Core.Devices.Report +{ + public partial class DeviceReport + { + Device dev; + bool debug; + + public DeviceReport(Device device, bool debug) + { + this.dev = device; + this.debug = debug; + } + } +} \ 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 f412355b1..68b36016f 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/General.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/General.cs @@ -63,8 +63,6 @@ namespace DiscImageChef.Core.Devices.Report.SCSI const uint TIMEOUT = 5; ConsoleKeyInfo pressedKey; - if(dev.IsUsb) Usb.Report(dev, ref report, debug, ref removable); - if(dev.IsFireWire) FireWire.Report(dev, ref report, ref removable); if(dev.IsPcmcia) Pcmcia.Report(dev, ref report); diff --git a/DiscImageChef.Core/Devices/Report/USB.cs b/DiscImageChef.Core/Devices/Report/USB.cs index b42b1ec78..744f48fe2 100644 --- a/DiscImageChef.Core/Devices/Report/USB.cs +++ b/DiscImageChef.Core/Devices/Report/USB.cs @@ -30,17 +30,14 @@ // Copyright © 2011-2018 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.CommonTypes.Metadata; -using DiscImageChef.Console; -using DiscImageChef.Devices; namespace DiscImageChef.Core.Devices.Report { /// /// Implements creating a report for a USB device /// - static class Usb + public partial class DeviceReport { /// /// Fills a device report with parameters specific to a USB device @@ -49,21 +46,9 @@ namespace DiscImageChef.Core.Devices.Report /// Device report /// If device is removable /// If debug is enabled - internal static void Report(Device dev, ref DeviceReportV2 report, bool debug, ref bool removable) + public Usb UsbReport() { - if(report == null) return; - - ConsoleKeyInfo pressedKey = new ConsoleKeyInfo(); - while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) - { - DicConsole.Write("Is the device natively USB (in case of doubt, press Y)? (Y/N): "); - pressedKey = System.Console.ReadKey(); - DicConsole.WriteLine(); - } - - if(pressedKey.Key != ConsoleKey.Y) return; - - report.USB = new CommonTypes.Metadata.Usb + Usb usbReport = new Usb { Manufacturer = dev.UsbManufacturerString, Product = dev.UsbProductString, @@ -71,17 +56,9 @@ namespace DiscImageChef.Core.Devices.Report VendorID = dev.UsbVendorId }; - pressedKey = new ConsoleKeyInfo(); - while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) - { - DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): "); - pressedKey = System.Console.ReadKey(); - DicConsole.WriteLine(); - } + if(debug) usbReport.Descriptors = dev.UsbDescriptors; - report.USB.RemovableMedia = pressedKey.Key == ConsoleKey.Y; - removable = report.USB.RemovableMedia; - if(debug) report.USB.Descriptors = dev.UsbDescriptors; + return usbReport; } } } \ No newline at end of file diff --git a/DiscImageChef.Core/DiscImageChef.Core.csproj b/DiscImageChef.Core/DiscImageChef.Core.csproj index 8208068c5..04fb6c742 100644 --- a/DiscImageChef.Core/DiscImageChef.Core.csproj +++ b/DiscImageChef.Core/DiscImageChef.Core.csproj @@ -49,6 +49,7 @@ + diff --git a/DiscImageChef/Commands/DeviceReport.cs b/DiscImageChef/Commands/DeviceReport.cs index fac999d59..256cfd5b5 100644 --- a/DiscImageChef/Commands/DeviceReport.cs +++ b/DiscImageChef/Commands/DeviceReport.cs @@ -77,6 +77,35 @@ namespace DiscImageChef.Commands jsonFile = jsonFile.Replace('\\', '_').Replace('/', '_').Replace('?', '_'); + Core.Devices.Report.DeviceReport reporter = new Core.Devices.Report.DeviceReport(dev, options.Debug); + + if(dev.IsUsb) + { + ConsoleKeyInfo pressedKey = new ConsoleKeyInfo(); + while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) + { + DicConsole.Write("Is the device natively USB (in case of doubt, press Y)? (Y/N): "); + pressedKey = System.Console.ReadKey(); + DicConsole.WriteLine(); + } + + if(pressedKey.Key == ConsoleKey.Y) + { + report.USB = reporter.UsbReport(); + + pressedKey = new ConsoleKeyInfo(); + while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) + { + DicConsole.Write("Is the media removable from the reading/writing elements? (Y/N): "); + pressedKey = System.Console.ReadKey(); + DicConsole.WriteLine(); + } + + report.USB.RemovableMedia = pressedKey.Key == ConsoleKey.Y; + removable = report.USB.RemovableMedia; + } + } + switch(dev.Type) { case DeviceType.ATA: