Skip to content

Commit cc63bdd

Browse files
committed
PPD for driverless IPP: Poll "media-col-database" separately if needed
In the create_local_bg_thread() function for auto-generating a PPD file for a CUPS queue for a driverless printer, either via the "everywhere" model selection or an auto-created temporary queue we need to query the full capabilities information from the printer. To get the full set of printer properties from a driverless IPP printer one does a "get-printer-attributes" IPP request with the attribute "requested-attributes" set to "all,media-col-database" (note that "all" does not include "media-col-database" because this attribute is often very long, it contains all valid combinations of media size, media type, media source, and margins). For some printers this fails and we fall back to just "all" and lose valuable information. But some of those printers which do not support "requested-attributes" set to "all,media-col-database" support "requested-attributes" set to "media-col-database" alone and this we now make use of, by polling "media-col-database" separately and adding it to the IPP response of "all" if needed. We discovered such a printer here: OpenPrinting/cups-filters#492
1 parent e70cfee commit cc63bdd

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

scheduler/ipp.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5385,6 +5385,43 @@ create_local_bg_thread(
53855385
cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: IPP/1.1 Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsLastError()), cupsLastErrorString());
53865386
}
53875387

5388+
/*
5389+
* If we did not succeed to obtain the "media-col-database" attribute
5390+
* try to get it separately
5391+
*/
5392+
if (ippFindAttribute(response, "media-col-database", IPP_TAG_ZERO) ==
5393+
NULL)
5394+
{
5395+
ipp_t *response2 = NULL;
5396+
5397+
cupsdLogMessage(CUPSD_LOG_DEBUG,
5398+
"Polling \"media-col-database\" attribute separately.");
5399+
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
5400+
ippSetVersion(request, 2, 0);
5401+
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
5402+
"printer-uri", NULL, uri);
5403+
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
5404+
"requested-attributes", NULL, "media-col-database");
5405+
response2 = cupsDoRequest(http, request, resource);
5406+
//ipp_status = cupsLastError();
5407+
if (response2)
5408+
{
5409+
if ((attr = ippFindAttribute(response2, "media-col-database",
5410+
IPP_TAG_ZERO)) != NULL)
5411+
{
5412+
/*
5413+
* Copy "media-col-database" attribute into the original
5414+
* IPP response
5415+
*/
5416+
5417+
cupsdLogMessage(CUPSD_LOG_DEBUG,
5418+
"\"media-col-database\" attribute found.");
5419+
ippCopyAttribute(response, attr, 0);
5420+
}
5421+
ippDelete(response2);
5422+
}
5423+
}
5424+
53885425
// TODO: Grab printer icon file...
53895426
httpClose(http);
53905427

0 commit comments

Comments
 (0)