From: Michael R Sweet Date: Wed, 27 Mar 2024 16:42:53 +0000 (-0400) Subject: Update cupsd code to report all supported raster resolutions (Issue #901) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31ab57dd1267c47d7005195abad59a3fbbaae4ad;p=thirdparty%2Fcups.git Update cupsd code to report all supported raster resolutions (Issue #901) --- diff --git a/CHANGES.md b/CHANGES.md index bb99b129bd..0775df7c4e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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. diff --git a/cups/ppd-private.h b/cups/ppd-private.h index cc97f8b054..fc65d37334 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -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 */ /* diff --git a/scheduler/printers.c b/scheduler/printers.c index fc0bc36c28..2bb80455f1 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -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...