Skip to content

Commit

Permalink
backend/ipp: Fix print-scaling option support for IPP printers
Browse files Browse the repository at this point in the history
Fixes #862
  • Loading branch information
zdohnal committed Jan 12, 2024
1 parent e0c31f4 commit bccda96
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
18 changes: 10 additions & 8 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ CHANGES - OpenPrinting CUPS 2.4.8 - TBA
Changes in CUPS v2.4.8 (TBA)
----------------------------

- Added additional check on socket if `revents` from `poll()` returns POLLHUP
together with POLLIN or POLLOUT in `httpAddrConnect2()` (Issue #839)
- Added new value for 'lpstat' option '-W' - successfull - for getting
successfully printed jobs (Issue #830)
- Really backport fix for Issue #742
- Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751)
- Fixed memory leak when unloading a job (Issue #813)
- Fixed memory leak when creating color profiles (Issue #815)
- Added warning if the device has to be asked for 'all,media-col-database' separately
(Issue #829)
- Added new value for 'lpstat' option '-W' - successfull - for getting
successfully printed jobs (Issue #830)
- Fixed crash in `scan_ps()` if incoming argument is NULL (Issue #831)
- Fixed memory leak when creating color profiles (Issue #815)
- Fixed memory leak when unloading a job (Issue #813)
- Fixed setting job state reasons for successful jobs (Issue #832)
- Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751)
- Really backport fix for Issue #742
- Added additional check on socket if `revents` from `poll()` returns POLLHUP
together with POLLIN or POLLOUT in `httpAddrConnect2()` (Issue #839)
- Fixed IPP backend to support the "print-scaling" option with IPP printers
(Issue #862)


Changes in CUPS v2.4.7 (2023-09-20)
Expand Down
29 changes: 23 additions & 6 deletions backend/ipp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* IPP backend for CUPS.
*
* Copyright © 2021-2023 by OpenPrinting
* Copyright © 2021-2024 by OpenPrinting
* Copyright © 2007-2021 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
Expand Down Expand Up @@ -111,6 +111,7 @@ static const char * const pattrs[] = /* Printer attributes we want */
"multiple-document-handling-supported",
"operations-supported",
"print-color-mode-supported",
"print-scaling-supported",
"printer-alert",
"printer-alert-description",
"printer-is-accepting-jobs",
Expand Down Expand Up @@ -163,7 +164,8 @@ static ipp_t *new_request(ipp_op_t op, int version, const char *uri,
ppd_file_t *ppd,
ipp_attribute_t *media_col_sup,
ipp_attribute_t *doc_handling_sup,
ipp_attribute_t *print_color_mode_sup);
ipp_attribute_t *print_color_mode_sup,
ipp_attribute_t *print_scaling_sup);
static const char *password_cb(const char *prompt, http_t *http,
const char *method, const char *resource,
int *user_data);
Expand Down Expand Up @@ -251,6 +253,7 @@ main(int argc, /* I - Number of command-line args */
ipp_attribute_t *printer_state; /* printer-state attribute */
ipp_attribute_t *printer_accepting; /* printer-is-accepting-jobs */
ipp_attribute_t *print_color_mode_sup;/* Does printer support print-color-mode? */
ipp_attribute_t *print_scaling_sup; /* print-scaling-supported */
int create_job = 0, /* Does printer support Create-Job? */
get_job_attrs = 0, /* Does printer support Get-Job-Attributes? */
send_document = 0, /* Does printer support Send-Document? */
Expand Down Expand Up @@ -893,6 +896,7 @@ main(int argc, /* I - Number of command-line args */
operations_sup = NULL;
doc_handling_sup = NULL;
print_color_mode_sup = NULL;
print_scaling_sup = NULL;

do
{
Expand Down Expand Up @@ -1163,6 +1167,15 @@ main(int argc, /* I - Number of command-line args */

print_color_mode_sup = ippFindAttribute(supported, "print-color-mode-supported", IPP_TAG_KEYWORD);

if ((print_scaling_sup = ippFindAttribute(supported, "print-scaling-supported", IPP_TAG_KEYWORD)) != NULL)
{
int count = ippGetCount(print_scaling_sup);

fprintf(stderr, "DEBUG: print-scaling-supported (%d values)\n", count);
for (i = 0; i < count; i ++)
fprintf(stderr, "DEBUG: [%d] = %s\n", i, ippGetString(print_scaling_sup, i, NULL));
}

if ((operations_sup = ippFindAttribute(supported, "operations-supported",
IPP_TAG_ENUM)) != NULL)
{
Expand Down Expand Up @@ -1474,7 +1487,7 @@ main(int argc, /* I - Number of command-line args */
request = new_request(IPP_OP_VALIDATE_JOB, version, uri, argv[2],
monitor.job_name, num_options, options, compression,
copies_sup ? copies : 1, document_format, pc, ppd,
media_col_sup, doc_handling_sup, print_color_mode_sup);
media_col_sup, doc_handling_sup, print_color_mode_sup, print_scaling_sup);

response = cupsDoRequest(http, request, resource);

Expand Down Expand Up @@ -1597,7 +1610,7 @@ main(int argc, /* I - Number of command-line args */
version, uri, argv[2], monitor.job_name, num_options,
options, compression, copies_sup ? copies : 1,
document_format, pc, ppd, media_col_sup,
doc_handling_sup, print_color_mode_sup);
doc_handling_sup, print_color_mode_sup, print_scaling_sup);

/*
* Do the request...
Expand Down Expand Up @@ -2799,8 +2812,9 @@ new_request(
ppd_file_t *ppd, /* I - PPD file data */
ipp_attribute_t *media_col_sup, /* I - media-col-supported values */
ipp_attribute_t *doc_handling_sup, /* I - multiple-document-handling-supported values */
ipp_attribute_t *print_color_mode_sup)
/* I - Printer supports print-color-mode */
ipp_attribute_t *print_color_mode_sup,
/* I - Printer supports print-color-mode? */
ipp_attribute_t *print_scaling_sup) /* I - print-scaling-supported values */
{
ipp_t *request; /* Request data */
const char *keyword; /* PWG keyword */
Expand Down Expand Up @@ -2867,6 +2881,9 @@ new_request(

copies = _cupsConvertOptions(request, ppd, pc, media_col_sup, doc_handling_sup, print_color_mode_sup, user, format, copies, num_options, options);

if ((keyword = cupsGetOption("print-scaling", num_options, options)) != NULL && ippContainsString(print_scaling_sup, keyword))
ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "print-scaling", NULL, keyword);

/*
* Map FaxOut options...
*/
Expand Down

0 comments on commit bccda96

Please sign in to comment.