Skip to content

Commit

Permalink
Save printer strings when available
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Nov 6, 2024
1 parent d60ea1b commit 7446b2c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/main/kotlin/de/gmuth/ipp/client/IppInspector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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<String>("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")
Expand Down

0 comments on commit 7446b2c

Please sign in to comment.