Skip to content

Commit

Permalink
IppRequest extension printerGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Oct 11, 2023
1 parent 0941886 commit 24955e7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/kotlin/de/gmuth/ipp/client/CupsClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package de.gmuth.ipp.client

import de.gmuth.ipp.client.IppExchangeException.ClientErrorNotFoundException
import de.gmuth.ipp.client.WhichJobs.All
import de.gmuth.ipp.core.IppAttributesGroup
import de.gmuth.ipp.core.IppOperation
import de.gmuth.ipp.core.IppOperation.*
import de.gmuth.ipp.core.IppRequest
Expand Down Expand Up @@ -221,17 +222,14 @@ class CupsClient(
).apply {
updateAttributes("printer-name")
log.info(toString())
require(deviceUri.scheme.startsWith("ipp")) { "uri scheme unsupported: $deviceUri" }
log.info { "CUPS now generates IPP Everywhere PPD." }
do { // https://github.com/apple/cups/issues/5919
updateAttributes("printer-make-and-model")
} while (!makeAndModel.text.lowercase().contains("everywhere"))
log.info { "Make printer permanent." }
exchange(
cupsPrinterRequest(CupsAddModifyPrinter, printerName).apply {
getSingleAttributesGroup(Printer).run {
attribute("printer-is-temporary", IppTag.Boolean, false)
}
printerGroup.attribute("printer-is-temporary", IppTag.Boolean, false)
}
)
log.info { "Make printer operational." }
Expand All @@ -240,6 +238,9 @@ class CupsClient(
updateAttributes()
}

private val IppRequest.printerGroup: IppAttributesGroup
get() = getSingleAttributesGroup(Printer)

// ---------------------------
// Get jobs and save documents
// ---------------------------
Expand Down

0 comments on commit 24955e7

Please sign in to comment.