From 7446b2c96710539558147ff7ffdc34522e4ce614 Mon Sep 17 00:00:00 2001 From: Gerhard Muth Date: Wed, 6 Nov 2024 18:26:58 +0100 Subject: [PATCH] Save printer strings when available --- .../de/gmuth/ipp/client/IppInspector.kt | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/de/gmuth/ipp/client/IppInspector.kt b/src/main/kotlin/de/gmuth/ipp/client/IppInspector.kt index 644cfc83..9c42c987 100644 --- a/src/main/kotlin/de/gmuth/ipp/client/IppInspector.kt +++ b/src/main/kotlin/de/gmuth/ipp/client/IppInspector.kt @@ -28,13 +28,8 @@ class IppInspector { } } - fun inspect( - printerUri: URI, - cancelJob: Boolean = true, - savePrinterIcons: Boolean = true - ) = - IppPrinter(printerUri, getPrinterAttributesOnInit = false) - .inspect(cancelJob, savePrinterIcons) + fun inspect(printerUri: URI, cancelJob: Boolean = true) = + IppPrinter(printerUri, getPrinterAttributesOnInit = false).inspect(cancelJob) /** * Exchange a few IPP requests and save the IPP responses returned by the printer. @@ -43,7 +38,7 @@ class IppInspector { * - Print-Job, Get-Jobs, Get-Job-Attributes * - Hold-Job, Release-Job, Cancel-Job */ - private fun IppPrinter.inspect(cancelJob: Boolean, savePrinterIcons: Boolean) { + private fun IppPrinter.inspect(cancelJob: Boolean) { logger.info { "Inspect printer $printerUri" } val printerModel = getModel(printerUri) @@ -68,11 +63,21 @@ class IppInspector { logger.info { "Document formats: $documentFormatSupported" } } - if (savePrinterIcons && attributes.containsKey("printer-icons")) { - logger.info { "> Save Printer icons" } + if (attributes.containsKey("printer-icons")) { + logger.info { "> Save printer icons" } savePrinterIcons() } + if(attributes.containsKey("printer-strings-languages-supported")) { + logger.info { "> Save all printer strings" } + saveAllPrinterStrings() + } else if(attributes.containsKey("printer-strings-uri")) { + attributes.getValueOrNull("natural-language-configured")?.also { + logger.info { "> Save printer strings for configured language $it"} + savePrinterStrings(it) + } + } + if (supportsOperations(CupsGetPPD)) { logger.info { "> CUPS Get PPD" } savePPD(filename = "$printerModel.ppd")