From: Till Kamppeter Date: Sun, 22 Jan 2023 00:28:02 +0000 (-0300) Subject: PPD for driverless IPP: Poll "media-col-database" separately if needed X-Git-Tag: v2.4.3~58^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc63bdd8edff950191d8b1d20cb3a92f4982ea36;p=thirdparty%2Fcups.git 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: https://github.com/OpenPrinting/cups-filters/issues/492 --- diff --git a/scheduler/ipp.c b/scheduler/ipp.c index c6df281a92..f048a000ee 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -5385,6 +5385,43 @@ create_local_bg_thread( cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: IPP/1.1 Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsLastError()), cupsLastErrorString()); } + /* + * If we did not succeed to obtain the "media-col-database" attribute + * try to get it separately + */ + if (ippFindAttribute(response, "media-col-database", IPP_TAG_ZERO) == + NULL) + { + ipp_t *response2 = NULL; + + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Polling \"media-col-database\" attribute separately."); + request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); + ippSetVersion(request, 2, 0); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, + "printer-uri", NULL, uri); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, + "requested-attributes", NULL, "media-col-database"); + response2 = cupsDoRequest(http, request, resource); + //ipp_status = cupsLastError(); + if (response2) + { + if ((attr = ippFindAttribute(response2, "media-col-database", + IPP_TAG_ZERO)) != NULL) + { + /* + * Copy "media-col-database" attribute into the original + * IPP response + */ + + cupsdLogMessage(CUPSD_LOG_DEBUG, + "\"media-col-database\" attribute found."); + ippCopyAttribute(response, attr, 0); + } + ippDelete(response2); + } + } + // TODO: Grab printer icon file... httpClose(http);