Skip to content

Commit a919bd4

Browse files
committed
implicitclass: If IPP poll of printer fails, use PPD file for capabilities
Member printers of a cups-browsed printer cluster are always IPP printers, in most cases driverless IPP (IPP 2.x) printers and here a get-printer-attributes IPP request gets all needed capability info from the destination printer in order to run the filters to turn the PDF input into the printer's data format. If the destination printer is a legacy IPP (IPP 1.x) printer, our get-printer-attributes IPP request fails (we accept only IPP 2.x here) and then we fall back to using the PPD file. The PPD file is the cluster's PPD, not the printer's, but all settings are supported by our destination printer (otherwise it would not have gotten selected). This way we recover support for legacy IPP printers which got dropped with the recent commits to switch over to use filter functions instead of external filter executables.
1 parent e541dc6 commit a919bd4

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

backend/implicitclass.c

+39-9
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,44 @@ main(int argc, /* I - Number of command-line args */
306306
filter_data.job_title = title;
307307
filter_data.copies = atoi(argv[4]);
308308
filter_data.job_attrs = NULL; /* We use command line options */
309-
filter_data.printer_attrs =
310-
get_printer_attributes4(printer_uri, NULL, 0, NULL, 0, 1, 0);
309+
if ((filter_data.printer_attrs =
310+
get_printer_attributes4(printer_uri, NULL, 0, NULL, 0, 1, 0)) !=
311+
NULL)
311312
/* Poll the printer attributes from
312313
the printer */
314+
filter_data.ppdfile = NULL; /* We have successfully polled
315+
the IPP attributes from the
316+
printer. This is the most
317+
precise printer capability info.
318+
As the queue's PPD is only
319+
for the cluster we prefer the
320+
IPP attributes */
321+
else
322+
filter_data.ppdfile = getenv("PPD");/*The polling of the printer's
323+
IPP attribute failed, meaning
324+
that it is most probably not a
325+
driverless IPP printers (IPP 2.x)
326+
but a legacy IPP printer (IPP
327+
1.x) which usually has
328+
unsufficient capability info.
329+
Therefore we fall back to the
330+
PPD file here which contains
331+
some info from the printer's
332+
DNS-SD record. */
333+
if (filter_data.ppdfile)
334+
filter_data.ppd = ppdOpenFile(filter_data.ppdfile);
335+
else
336+
filter_data.ppd = NULL;
337+
if (filter_data.printer_attrs == NULL && filter_data.ppd == NULL)
338+
{
339+
ippDelete(response);
340+
fprintf(stderr, "ERROR: Unable to get sufficient capability info of the destination printer.\n");
341+
return (CUPS_BACKEND_FAILED);
342+
}
343+
313344
filter_data.num_options = num_options;
314345
filter_data.options = options; /* Command line options from 5th
315346
arg */
316-
filter_data.ppdfile = NULL; /* We poll the IPP attributes from
317-
printer as the queue's PPD is
318-
for the cluster */
319-
filter_data.ppd = NULL;
320347
filter_data.back_pipe[0] = -1;
321348
filter_data.back_pipe[1] = -1;
322349
filter_data.side_pipe[0] = -1;
@@ -355,14 +382,17 @@ main(int argc, /* I - Number of command-line args */
355382
cupsArrayAdd(filter_chain, &ipp_in_chain);
356383

357384
/* DEVICE_URI environment variable */
358-
setenv("DEVICE_URI",printer_uri, 1);
385+
setenv("DEVICE_URI", printer_uri, 1);
359386

360387
/* FINAL_CONTENT_TYPE environment variable */
361388
setenv("FINAL_CONTENT_TYPE", document_format, 1);
362389

363390
/* Mark the defaults and option settings in the PPD file */
364-
ppdMarkDefaults(filter_data.ppd);
365-
ppdMarkOptions(filter_data.ppd, num_options, options);
391+
if (filter_data.ppd)
392+
{
393+
ppdMarkDefaults(filter_data.ppd);
394+
ppdMarkOptions(filter_data.ppd, num_options, options);
395+
}
366396

367397
/* We call the IPP CUPS backend at the end of the chain, so we have
368398
no output */

0 commit comments

Comments
 (0)