]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
implicitclass: Get printer info via IPP request and not via PPD
authorTill Kamppeter <till.kamppeter@gmail.com>
Thu, 30 Dec 2021 01:52:36 +0000 (22:52 -0300)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 30 Dec 2021 01:52:36 +0000 (22:52 -0300)
If we create a printer cluster with cups-browsed a PPD file covering
the capabilities of all member printers is genererated, which
especially does not represent the capabilities of a single member
printer which gets selected to print a particular job. It also does
not contain the infor about color spaces and color depths which can
vary from printer top printer.

For the implicitclass backend to have the exact information about the
destination printer so that it can call the filters correctly we now
poll this information directly from the printer, using a
get-printer-attributes IPP request. With this we get exact paper sizes
and margins and also the color spaces and color depth which are
especially needed if the printer gets the job as raster data
(Apple/PWG Raster, PCLm).

We completely ignore the print queue's PPD file here and so the
filters get used PPD-less only based on the printer's IPP attributes.

backend/implicitclass.c

index 43e1283241ed705f5c0aaa266ae1a36fd205d8a3..a7ff3a7b4722f9fc49124e1ff8a4e71c6d3d4b88 100644 (file)
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <cupsfilters/filter.h>
+#include <cupsfilters/ipp.h>
 
 /*
  * Local globals...
@@ -276,7 +277,7 @@ main(int  argc,                             /* I - Number of command-line args */
        ptr3++;
       }
 
-      /* Finding the resolution requested for the job*/
+      /* Finding the resolution requested for the job */
       if ((ptr4 = strchr(ptr3, ' ')) != NULL) {
        *ptr4='\0';
        ptr4++;
@@ -299,24 +300,26 @@ main(int  argc,                           /* I - Number of command-line args */
 
       /* Set up filter data record to be used by the filter functions to
         process the job */
-      filter_data.printer = calloc(strlen(printer_uri) + 8, sizeof(char));
-      strcpy(filter_data.printer, printer_uri);
+      filter_data.printer = printer_uri;
       filter_data.job_id = atoi(argv[1]);
       filter_data.job_user = argv[2];
       filter_data.job_title = title;
       filter_data.copies = atoi(argv[4]);
       filter_data.job_attrs = NULL;        /* We use command line options */
-      filter_data.printer_attrs = NULL;    /* We use the queue's PPD file */
+      filter_data.printer_attrs =
+       get_printer_attributes4(printer_uri, NULL, 0, NULL, 0, 1, 0);
+                                           /* Poll the printer attributes from
+                                             the printer */
       filter_data.num_options = num_options;
-      filter_data.options = options;       /* Command line options from 5th arg */
-      filter_data.ppdfile = getenv("PPD"); /* PPD file name in the "PPD"
-                                             environment variable. */
-      filter_data.ppd = filter_data.ppdfile ?
-       ppdOpenFile(filter_data.ppdfile) : NULL;
-      /* Load PPD file */
-      filter_data.back_pipe[0] = -1;       /* CUPS back channel not supported */
+      filter_data.options = options;       /* Command line options from 5th
+                                             arg */
+      filter_data.ppdfile = NULL;          /* We poll the IPP attributes from
+                                             printer as the queue's PPD is
+                                             for the cluster */
+      filter_data.ppd = NULL;
+      filter_data.back_pipe[0] = -1;
       filter_data.back_pipe[1] = -1;
-      filter_data.side_pipe[0] = -1;       /* CUPS side channel not supported */
+      filter_data.side_pipe[0] = -1;
       filter_data.side_pipe[1] = -1;
       filter_data.logfunc = cups_logfunc;  /* Logging scheme of CUPS */
       filter_data.logdata = NULL;