]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Update cupsd code to report all supported raster resolutions (Issue #901)
authorMichael R Sweet <msweet@msweet.org>
Wed, 27 Mar 2024 16:42:53 +0000 (12:42 -0400)
committerMichael R Sweet <msweet@msweet.org>
Wed, 27 Mar 2024 16:42:53 +0000 (12:42 -0400)
CHANGES.md
cups/ppd-private.h
scheduler/printers.c

index bb99b129bd10f7f659cfe5fbe933b1165f86875c..0775df7c4e3097df5aeeb2bde6aec0a0862116ac 100644 (file)
@@ -58,6 +58,8 @@ Changes in CUPS v2.5b1 (TBA)
   (Issue #862)
 - Fixed Oki 407 freeze when printing larger jobs (Issue #877)
 - Fixed checking for required attributes during PPD generation (Issue #890)
+- Fixed pwg-raster-document-resolution-supported and urf-supported values
+  (Issue #901)
 - Fixed encoding of IPv6 addresses in HTTP requests (Issue #903)
 - Fixed encoding of `IPP_TAG_EXTENSION` values in IPP messages (Issue #913)
 - Removed hash support for SHA2-512-224 and SHA2-512-256.
index cc97f8b054e811e5cc03986c2b6062dddb651ac7..fc65d37334eceb19a2b47d89fbab254514d0257b 100644 (file)
@@ -36,7 +36,7 @@ extern "C" {
  * Constants...
  */
 
-#  define _PPD_CACHE_VERSION   11      /* Version number in cache file */
+#  define _PPD_CACHE_VERSION   12      /* Version number in cache file */
 
 
 /*
index fc0bc36c288f28b96f4a787f8c24b151866ad0c1..2bb80455f133e1bc526ef2ba89d268f4f4e16783 100644 (file)
@@ -4650,8 +4650,15 @@ load_ppd(cupsd_printer_t *p)             /* I - Printer */
       * Report all supported resolutions...
       */
 
+      ipp_attribute_t *pwg_supported;  /* pwg-raster-document-resolution-supported */
+      char *urf_rsptr = urf_rs;                /* Pointer into RS value */
+
       attr = ippAddResolutions(p->ppd_attrs, IPP_TAG_PRINTER, "printer-resolution-supported", resolution->num_choices, IPP_RES_PER_INCH, NULL, NULL);
 
+      pwg_supported = ippAddResolutions(p->ppd_attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", resolution->num_choices, IPP_RES_PER_INCH, NULL, NULL);
+
+      urf_rs[0] = '\0';
+
       for (i = 0, choice = resolution->choices;
            i < resolution->num_choices;
           i ++, choice ++)
@@ -4668,43 +4675,56 @@ load_ppd(cupsd_printer_t *p)            /* I - Printer */
          xdpi = ydpi = 300;
        }
 
-        attr->values[i].resolution.xres  = xdpi;
-        attr->values[i].resolution.yres  = ydpi;
-        attr->values[i].resolution.units = IPP_RES_PER_INCH;
+        ippSetResolution(p->ppd_attrs, &attr, i, IPP_RES_PER_INCH, xdpi, ydpi);
+        ippSetResolution(p->ppd_attrs, &pwg_supported, i, IPP_RES_PER_INCH, xdpi, ydpi);
 
         if (choice->marked)
          ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, "printer-resolution-default", IPP_RES_PER_INCH, xdpi, ydpi);
 
-        if (i == 0)
-        {
-         ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", IPP_RES_PER_INCH, xdpi, ydpi);
-          snprintf(urf_rs, sizeof(urf_rs), "RS%d", xdpi);
-          urf[num_urf ++] = urf_rs;
-       }
+        if (xdpi > ydpi)
+          xdpi = ydpi;
+
+        if (!urf_rs[0])
+          snprintf(urf_rsptr, sizeof(urf_rs) - (size_t)(urf_rsptr - urf_rs), "RS%d", xdpi);
+       else
+          snprintf(urf_rsptr, sizeof(urf_rs) - (size_t)(urf_rsptr - urf_rs), "-%d", xdpi);
+
+        urf_rsptr += strlen(urf_rsptr);
       }
     }
-    else if ((ppd_attr = ppdFindAttr(ppd, "DefaultResolution", NULL)) != NULL &&
-             ppd_attr->value)
+    else
     {
-     /*
-      * Just the DefaultResolution to report...
-      */
-
-      xdpi = ydpi = (int)strtol(ppd_attr->value, (char **)&resptr, 10);
-      if (resptr > ppd_attr->value && xdpi > 0)
+      if ((ppd_attr = ppdFindAttr(ppd, "DefaultResolution", NULL)) != NULL &&
+             ppd_attr->value)
       {
-       if (*resptr == 'x')
-         ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10);
-       else
-         ydpi = xdpi;
-      }
+       /*
+       * Just the DefaultResolution to report...
+       */
+
+       xdpi = ydpi = (int)strtol(ppd_attr->value, (char **)&resptr, 10);
+       if (resptr > ppd_attr->value && xdpi > 0)
+       {
+         if (*resptr == 'x')
+           ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10);
+         else
+           ydpi = xdpi;
+       }
 
-      if (xdpi <= 0 || ydpi <= 0)
+       if (xdpi <= 0 || ydpi <= 0)
+       {
+         cupsdLogMessage(CUPSD_LOG_WARN,
+                         "Bad default resolution \"%s\" for printer %s.",
+                         ppd_attr->value, p->name);
+         xdpi = ydpi = 300;
+       }
+      }
+      else
       {
-       cupsdLogMessage(CUPSD_LOG_WARN,
-                       "Bad default resolution \"%s\" for printer %s.",
-                       ppd_attr->value, p->name);
-       xdpi = ydpi = 300;
+       /*
+       * No resolutions in PPD - use 300dpi...
+       */
+
+        xdpi = ydpi = 300;
       }
 
       ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
@@ -4713,26 +4733,17 @@ load_ppd(cupsd_printer_t *p)            /* I - Printer */
       ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
                       "printer-resolution-supported", IPP_RES_PER_INCH,
                       xdpi, ydpi);
-      ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", IPP_RES_PER_INCH, xdpi, ydpi);
+      ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
+                      "pwg-raster-document-resolution-supported", IPP_RES_PER_INCH,
+                      xdpi, ydpi);
+
+      if (xdpi > ydpi)
+       xdpi = ydpi;
+
       snprintf(urf_rs, sizeof(urf_rs), "RS%d", xdpi);
-      urf[num_urf ++] = urf_rs;
     }
-    else
-    {
-     /*
-      * No resolutions in PPD - make one up...
-      */
 
-      ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
-                      "printer-resolution-default", IPP_RES_PER_INCH,
-                      300, 300);
-      ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER,
-                      "printer-resolution-supported", IPP_RES_PER_INCH,
-                      300, 300);
-      ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", IPP_RES_PER_INCH, 300, 300);
-      cupsCopyString(urf_rs, "RS300", sizeof(urf_rs));
-      urf[num_urf ++] = urf_rs;
-    }
+    urf[num_urf ++] = urf_rs;
 
    /*
     * Duplexing, etc...