Advertise real device capabilities in the ESCL server - #888
Open
zomars wants to merge 1 commit into
Open
Conversation
Closes the TODO in ScanServer.MakeEsclDeviceConfig by querying the shared device's actual capabilities via ScanController.GetCaps and using them to generate the ScannerCapabilities XML, so only the paper sources the device actually has are advertised (with its real resolutions, color modes and scan area). Capabilities are queried lazily on the first ScannerCapabilities request and cached; if the query fails or the driver doesn't provide capabilities, the previous hardcoded capabilities are served unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This closes the TODO in
ScanServer.MakeEsclDeviceConfig("Ideally we want to get the actual device capabilities (flatbed/feeder, resolution etc.)").What changes
EsclDeviceConfiggets an optionalCapabilitiesProvidercallback that can asynchronously supply fullEsclCapabilities.ScanServerimplements the provider by callingScanController.GetCaps()(the same API the profile dialog uses viaDeviceCapsCache) and mappingScanCaps/PerSourceCapsto the existingEsclCapabilities.PlatenCaps/AdfSimplexCaps/AdfDuplexCapsfields, which so far were only used by the ESCL client.EsclApiController.GetScannerCapabilitiesgenerates the Platen/Adf sections from those fields when they are populated, advertising only the paper sources the device actually has, with its real resolutions, color modes and max scan area.Design notes
ScannerCapabilitiesrequest rather than at registration, so sharing devices doesn't open device sessions at startup and server startup is never blocked. A successful query is cached for the lifetime of the registration; a failed query falls back to the defaults and is retried on the next request (same policy asDeviceCapsCache).DpiCaps.CommonValuesrather thanValues, since some drivers (e.g. Apple/ICA) report a continuous range with thousands of values that would be unreasonable to enumerate in the XML.Testing
ScanServerTests.GetCapsround-trip test (server announces caps from a mock backend, ESCL client parses them back) andScanServerTests.GetCapsWhenUnavailablefallback test; ran theRemotingtest suite plusNAPS2.Escl.Testson macOS (arm64). One pre-existing failure (ScanWithCorrectOptions,DeviceBusyExceptionwhen running the whole suite in parallel) reproduces identically on clean master on this machine and is unrelated.Note: for correct results with the Apple driver this depends on #887 (flatbed/feeder swap in
DeviceOperator.GetCaps); without it a flatbed-only Mac device is reported as feeder-only. The two PRs are independent code-wise.