mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move USB device reporting to non-static class and its UI to CLI.
This commit is contained in:
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -225,6 +225,7 @@
|
||||
<e p="Report" t="Include">
|
||||
<e p="ATA.cs" t="Include" />
|
||||
<e p="ATAPI.cs" t="Include" />
|
||||
<e p="DeviceReport.cs" t="Include" />
|
||||
<e p="FireWire.cs" t="Include" />
|
||||
<e p="NVMe.cs" t="Include" />
|
||||
<e p="PCMCIA.cs" t="Include" />
|
||||
|
||||
@@ -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);
|
||||
|
||||
16
DiscImageChef.Core/Devices/Report/DeviceReport.cs
Normal file
16
DiscImageChef.Core/Devices/Report/DeviceReport.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements creating a report for a USB device
|
||||
/// </summary>
|
||||
static class Usb
|
||||
public partial class DeviceReport
|
||||
{
|
||||
/// <summary>
|
||||
/// Fills a device report with parameters specific to a USB device
|
||||
@@ -49,21 +46,9 @@ namespace DiscImageChef.Core.Devices.Report
|
||||
/// <param name="report">Device report</param>
|
||||
/// <param name="removable">If device is removable</param>
|
||||
/// <param name="debug">If debug is enabled</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@
|
||||
<Compile Include="Devices\Info\DeviceInfo.cs" />
|
||||
<Compile Include="Devices\Info\Plextor.cs" />
|
||||
<Compile Include="Devices\Info\Properties.cs" />
|
||||
<Compile Include="Devices\Report\DeviceReport.cs" />
|
||||
<Compile Include="Entropy.cs" />
|
||||
<Compile Include="GetPluginBase.cs" />
|
||||
<Compile Include="ImageInfo.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:
|
||||
|
||||
Reference in New Issue
Block a user