Skip to content

Commit 7446b2c

Browse files
committed
Save printer strings when available
1 parent d60ea1b commit 7446b2c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/main/kotlin/de/gmuth/ipp/client/IppInspector.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ class IppInspector {
2828
}
2929
}
3030

31-
fun inspect(
32-
printerUri: URI,
33-
cancelJob: Boolean = true,
34-
savePrinterIcons: Boolean = true
35-
) =
36-
IppPrinter(printerUri, getPrinterAttributesOnInit = false)
37-
.inspect(cancelJob, savePrinterIcons)
31+
fun inspect(printerUri: URI, cancelJob: Boolean = true) =
32+
IppPrinter(printerUri, getPrinterAttributesOnInit = false).inspect(cancelJob)
3833

3934
/**
4035
* Exchange a few IPP requests and save the IPP responses returned by the printer.
@@ -43,7 +38,7 @@ class IppInspector {
4338
* - Print-Job, Get-Jobs, Get-Job-Attributes
4439
* - Hold-Job, Release-Job, Cancel-Job
4540
*/
46-
private fun IppPrinter.inspect(cancelJob: Boolean, savePrinterIcons: Boolean) {
41+
private fun IppPrinter.inspect(cancelJob: Boolean) {
4742
logger.info { "Inspect printer $printerUri" }
4843

4944
val printerModel = getModel(printerUri)
@@ -68,11 +63,21 @@ class IppInspector {
6863
logger.info { "Document formats: $documentFormatSupported" }
6964
}
7065

71-
if (savePrinterIcons && attributes.containsKey("printer-icons")) {
72-
logger.info { "> Save Printer icons" }
66+
if (attributes.containsKey("printer-icons")) {
67+
logger.info { "> Save printer icons" }
7368
savePrinterIcons()
7469
}
7570

71+
if(attributes.containsKey("printer-strings-languages-supported")) {
72+
logger.info { "> Save all printer strings" }
73+
saveAllPrinterStrings()
74+
} else if(attributes.containsKey("printer-strings-uri")) {
75+
attributes.getValueOrNull<String>("natural-language-configured")?.also {
76+
logger.info { "> Save printer strings for configured language $it"}
77+
savePrinterStrings(it)
78+
}
79+
}
80+
7681
if (supportsOperations(CupsGetPPD)) {
7782
logger.info { "> CUPS Get PPD" }
7883
savePPD(filename = "$printerModel.ppd")

0 commit comments

Comments
 (0)