Skip to content

Commit

Permalink
Escl: Don't use references for setting profiles
Browse files Browse the repository at this point in the history
I'm not sure why - best as I can tell it's spec-compliant - but this fixes Mopria Scan compatibility.
  • Loading branch information
cyanfish committed Nov 27, 2023
1 parent c6d55ac commit 3c74817
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions NAPS2.Escl.Server/EsclApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal EsclApiController(EsclDeviceConfig deviceConfig, EsclServerState server
public async Task GetScannerCapabilities()
{
var caps = _deviceConfig.Capabilities;
var iconUri = caps.IconPng != null ? $"http://naps2-{caps.Uuid}.local.:{_deviceConfig.Port}/eSCL/icon.png" : "";
var doc =
EsclXmlHelper.CreateDocAsString(
new XElement(ScanNs + "ScannerCapabilities",
Expand All @@ -33,28 +34,8 @@ public async Task GetScannerCapabilities()
new XElement(PwgNs + "SerialNumber", caps.SerialNumber),
new XElement(ScanNs + "UUID", "0e468f6d-e5dc-4abe-8e9f-ad08d8546b0c"),
new XElement(ScanNs + "AdminURI", ""),
new XElement(ScanNs + "IconURI", caps.IconPng != null ? $"http://naps2-{caps.Uuid}.local.:{_deviceConfig.Port}/eSCL/icon.png" : ""),
new XElement(ScanNs + "IconURI", iconUri),
new XElement(ScanNs + "Naps2Extensions", "Progress"),
new XElement(ScanNs + "SettingProfiles",
new XElement(ScanNs + "SettingProfile",
new XAttribute("name", "p1"),
new XElement(ScanNs + "ColorModes",
new XElement(ScanNs + "ColorMode", "BlackAndWhite1"),
new XElement(ScanNs + "ColorMode", "Grayscale8"),
new XElement(ScanNs + "ColorMode", "RGB24")),
new XElement(ScanNs + "DocumentFormats",
new XElement(PwgNs + "DocumentFormat", "application/pdf"),
new XElement(PwgNs + "DocumentFormat", "image/jpeg"),
new XElement(PwgNs + "DocumentFormat", "image/png"),
new XElement(ScanNs + "DocumentFormatExt", "application/pdf"),
new XElement(ScanNs + "DocumentFormatExt", "image/jpeg"),
new XElement(ScanNs + "DocumentFormatExt", "image/png")
),
new XElement(ScanNs + "SupportedResolutions",
new XElement(ScanNs + "DiscreteResolutions",
new XElement(ScanNs + "DiscreteResolution",
new XElement(ScanNs + "XResolution", "100"),
new XElement(ScanNs + "YResolution", "100")))))),
new XElement(ScanNs + "Platen",
new XElement(ScanNs + "PlatenInputCaps",
new XElement(ScanNs + "MinWidth", "1"),
Expand All @@ -64,7 +45,23 @@ public async Task GetScannerCapabilities()
new XElement(ScanNs + "MaxScanRegions", "1"),
new XElement(ScanNs + "SettingProfiles",
new XElement(ScanNs + "SettingProfile",
new XAttribute("ref", "p1")))))));
new XElement(ScanNs + "ColorModes",
new XElement(ScanNs + "ColorMode", "BlackAndWhite1"),
new XElement(ScanNs + "ColorMode", "Grayscale8"),
new XElement(ScanNs + "ColorMode", "RGB24")),
new XElement(ScanNs + "DocumentFormats",
new XElement(PwgNs + "DocumentFormat", "application/pdf"),
new XElement(PwgNs + "DocumentFormat", "image/jpeg"),
new XElement(PwgNs + "DocumentFormat", "image/png"),
new XElement(ScanNs + "DocumentFormatExt", "application/pdf"),
new XElement(ScanNs + "DocumentFormatExt", "image/jpeg"),
new XElement(ScanNs + "DocumentFormatExt", "image/png")
),
new XElement(ScanNs + "SupportedResolutions",
new XElement(ScanNs + "DiscreteResolutions",
new XElement(ScanNs + "DiscreteResolution",
new XElement(ScanNs + "XResolution", "100"),
new XElement(ScanNs + "YResolution", "100"))))))))));
Response.ContentType = "text/xml";
using var writer = new StreamWriter(HttpContext.OpenResponseStream());
await writer.WriteAsync(doc);
Expand Down

0 comments on commit 3c74817

Please sign in to comment.