From b88988670634bc03741662799a36ce72ef832bcb Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Sun, 26 Nov 2023 21:23:21 -0800 Subject: [PATCH] Escl: Don't use references for setting profiles I'm not sure why - best as I can tell it's spec-compliant - but this fixes Mopria Scan compatibility. --- NAPS2.Escl.Server/EsclApiController.cs | 41 ++++++++++++-------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/NAPS2.Escl.Server/EsclApiController.cs b/NAPS2.Escl.Server/EsclApiController.cs index 613b8d7015..4dbf9afcee 100644 --- a/NAPS2.Escl.Server/EsclApiController.cs +++ b/NAPS2.Escl.Server/EsclApiController.cs @@ -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", @@ -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"), @@ -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);