Skip to content

Commit 4bef773

Browse files
committed
getJobs(): Only request specific attributes for CUPS printers. Let the printer decide otherwise (Issue #30)
1 parent 797582b commit 4bef773

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ open class IppPrinter(
6161
"media-source-supported",
6262
"ipp-versions-supported"
6363
)
64+
val cupsGetJobsRequestedAttributes = listOf(
65+
"job-id",
66+
"job-uri",
67+
"job-printer-uri",
68+
"job-state",
69+
"job-state-reasons",
70+
"job-name",
71+
"job-originating-user-name"
72+
)
6473
}
6574

6675
init {
@@ -122,10 +131,9 @@ open class IppPrinter(
122131
fun basicAuth(user: String, password: String) =
123132
ippClient.basicAuth(user, password)
124133

125-
var getJobsRequestedAttributes = mutableListOf(
126-
"job-id", "job-uri", "job-printer-uri", "job-state", "job-name",
127-
"job-state-reasons", "job-originating-user-name"
128-
)
134+
var getJobsRequestedAttributes: List<String>? =
135+
if (isCups()) cupsGetJobsRequestedAttributes
136+
else null // Printer or server decides which attributes to return.
129137

130138
//---------------
131139
// IPP attributes
@@ -511,7 +519,7 @@ open class IppPrinter(
511519
whichJobs: WhichJobs? = null,
512520
myJobs: Boolean? = null,
513521
limit: Int? = null,
514-
requestedAttributes: List<String>? = getJobsRequestedAttributes
522+
requestedAttributes: List<String>? = getJobsRequestedAttributes // see also RFC 8011 Section 5.3
515523
): Collection<IppJob> {
516524
logger.fine { "getJobs(whichJobs=$whichJobs, requestedAttributes=$requestedAttributes)" }
517525
val request = ippRequest(GetJobs, requestedAttributes = requestedAttributes).apply {

0 commit comments

Comments
 (0)