From: Michael Sweet Date: Tue, 29 Aug 2017 13:33:48 +0000 (-0400) Subject: Fix the interactions between the "print-quality" and "cupsPrintQuality" X-Git-Tag: v2.2.5~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40cc612af4c0acedde5eb552032ce2a6edd3782d;p=thirdparty%2Fcups.git Fix the interactions between the "print-quality" and "cupsPrintQuality" options (Issue #5090) - Make sure print-quality-default does not override cupsPrintQuality - Make sure print-quality overrides cupsPrintQuality --- diff --git a/CHANGES.md b/CHANGES.md index 84afe8a318..d2bbe5b278 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -CHANGES - 2.2.5 - 2017-08-28 +CHANGES - 2.2.5 - 2017-08-29 ============================ CHANGES IN CUPS V2.2.5 @@ -31,6 +31,8 @@ CHANGES IN CUPS V2.2.5 - Updated the cups-files.conf and cupsd.conf file documentation for missing directives (Issue #5084) - Fixed an Avahi-related crash bug in the scheduler (Issue #5085, Issue #5086) +- Fixed the interactions between the "print-quality" and "cupsPrintQuality" + options (Issue #5090) - The IPP Everywhere PPD generator now sorts the supported resolutions before choosing them for draft, normal, and best quality modes (Issue #5091) - Fixed the localization unit test on Linux (Issue #5097) diff --git a/cups/ppd-mark.c b/cups/ppd-mark.c index 9fdaf0bd8e..464c09a987 100644 --- a/cups/ppd-mark.c +++ b/cups/ppd-mark.c @@ -1,7 +1,7 @@ /* * Option marking routines for CUPS. * - * Copyright 2007-2015 by Apple Inc. + * Copyright 2007-2017 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -253,6 +253,7 @@ cupsMarkOptions( */ for (i = num_options, optptr = options; i > 0; i --, optptr ++) + { if (!_cups_strcasecmp(optptr->name, "media") || !_cups_strcasecmp(optptr->name, "output-bin") || !_cups_strcasecmp(optptr->name, "output-mode") || @@ -341,6 +342,19 @@ cupsMarkOptions( ppd_mark_option(ppd, "MirrorPrint", optptr->value); else ppd_mark_option(ppd, optptr->name, optptr->value); + } + + if (print_quality) + { + int pq = atoi(print_quality); /* print-quaity value */ + + if (pq == IPP_QUALITY_DRAFT) + ppd_mark_option(ppd, "cupsPrintQuality", "Draft"); + else if (pq == IPP_QUALITY_HIGH) + ppd_mark_option(ppd, "cupsPrintQuality", "High"); + else + ppd_mark_option(ppd, "cupsPrintQuality", "Normal"); + } ppd_debug_marked(ppd, "After..."); diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 49a05a4079..d6ed50ba63 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -2924,8 +2924,10 @@ apply_printer_defaults( i --, option ++) if (!ippFindAttribute(job->attrs, option->name, IPP_TAG_ZERO)) { - num_options = cupsAddOption(option->name, option->value, num_options, - &options); + if (!strcmp(option->name, "print-quality") && ippFindAttribute(job->attrs, "cupsPrintQuality", IPP_TAG_NAME)) + continue; /* Don't override cupsPrintQuality */ + + num_options = cupsAddOption(option->name, option->value, num_options, &options); } /* diff --git a/scheduler/job.c b/scheduler/job.c index a8ba54c33c..f1c8110b78 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1,7 +1,7 @@ /* * Job management routines for the CUPS scheduler. * - * Copyright 2007-2016 by Apple Inc. + * Copyright 2007-2017 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -3624,12 +3624,9 @@ get_options(cupsd_job_t *job, /* I - Job */ pwgppds = NULL; if (pc && - !ippFindAttribute(job->attrs, - "com.apple.print.DocumentTicket.PMSpoolFormat", - IPP_TAG_ZERO) && + !ippFindAttribute(job->attrs, "com.apple.print.DocumentTicket.PMSpoolFormat", IPP_TAG_ZERO) && !ippFindAttribute(job->attrs, "APPrinterPreset", IPP_TAG_ZERO) && - (ippFindAttribute(job->attrs, "print-color-mode", IPP_TAG_ZERO) || - ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ZERO))) + (ippFindAttribute(job->attrs, "print-color-mode", IPP_TAG_ZERO) || ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ZERO) || ippFindAttribute(job->attrs, "cupsPrintQuality", IPP_TAG_ZERO))) { /* * Map print-color-mode and print-quality to a preset... @@ -3642,13 +3639,30 @@ get_options(cupsd_job_t *job, /* I - Job */ else print_color_mode = _PWG_PRINT_COLOR_MODE_COLOR; - if ((attr = ippFindAttribute(job->attrs, "print-quality", - IPP_TAG_ENUM)) != NULL && - attr->values[0].integer >= IPP_QUALITY_DRAFT && - attr->values[0].integer <= IPP_QUALITY_HIGH) - print_quality = attr->values[0].integer - IPP_QUALITY_DRAFT; + if ((attr = ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ENUM)) != NULL) + { + ipp_quality_t pq = (ipp_quality_t)ippGetInteger(attr, 0); + + if (pq >= IPP_QUALITY_DRAFT && pq <= IPP_QUALITY_HIGH) + print_quality = attr->values[0].integer - IPP_QUALITY_DRAFT; + else + print_quality = _PWG_PRINT_QUALITY_NORMAL; + } + else if ((attr = ippFindAttribute(job->attrs, "cupsPrintQuality", IPP_TAG_NAME)) != NULL) + { + const char *pq = ippGetString(attr, 0, NULL); + + if (!_cups_strcasecmp(pq, "draft")) + print_quality = _PWG_PRINT_QUALITY_DRAFT; + else if (!_cups_strcasecmp(pq, "high")) + print_quality = _PWG_PRINT_QUALITY_HIGH; + else + print_quality = _PWG_PRINT_QUALITY_NORMAL; + } else + { print_quality = _PWG_PRINT_QUALITY_NORMAL; + } if (pc->num_presets[print_color_mode][print_quality] == 0) { @@ -3689,6 +3703,15 @@ get_options(cupsd_job_t *job, /* I - Job */ if (pc) { + if ((attr = ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ENUM)) != NULL) + { + int pq = ippGetInteger(attr, 0); + static const char * const pqs[] = { "Draft", "Normal", "High" }; + + if (pq >= IPP_QUALITY_DRAFT && pq <= IPP_QUALITY_HIGH) + num_pwgppds = cupsAddOption("cupsPrintQuality", pqs[pq - IPP_QUALITY_DRAFT], num_pwgppds, &pwgppds); + } + if (!ippFindAttribute(job->attrs, "InputSlot", IPP_TAG_ZERO) && !ippFindAttribute(job->attrs, "HPPaperSource", IPP_TAG_ZERO)) { diff --git a/scheduler/printers.c b/scheduler/printers.c index dca09626a0..bb99907ad3 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -3317,16 +3317,17 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */ cupsArrayAdd(CommonDefaults, _cupsStrAlloc("document-format-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("finishings-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-account-id-default")); - cupsArrayAdd(CommonDefaults, - _cupsStrAlloc("job-accounting-user-id-default")); + cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-accounting-user-id-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-cancel-after-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-hold-until-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-priority-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-sheets-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("media-col-default")); + cupsArrayAdd(CommonDefaults, _cupsStrAlloc("notify-lease-duration-default")); + cupsArrayAdd(CommonDefaults, _cupsStrAlloc("notify-events-default")); cupsArrayAdd(CommonDefaults, _cupsStrAlloc("number-up-default")); - cupsArrayAdd(CommonDefaults, - _cupsStrAlloc("orientation-requested-default")); + cupsArrayAdd(CommonDefaults, _cupsStrAlloc("orientation-requested-default")); + cupsArrayAdd(CommonDefaults, _cupsStrAlloc("print-quality-default")); } /*