Skip to content

Commit

Permalink
Fix print-scaling option support for IPP printers (Issue #862)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Jan 10, 2024
1 parent cbfa37b commit 3c2f086
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
6 changes: 4 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ Changes in CUPS v2.5b1 (TBA)
- Fixed printing to stderr if we can't open cups-files.conf (Issue #777)
- Fixed memory leak when unloading a job (Issue #813)
- Fixed memory leak when creating color profiles (Issue #814)
- Fixed crash in `ppdEmitString()` if there is no record for page size `Custom`
(Issue #849)
- Fixed crash in `scan_ps()` if incoming argument is NULL (Issue #831)
- Fixed setting job state reasons for successful jobs (Issue #832)
- Fixed crash in `ppdEmitString()` if there is no record for page size `Custom`
(Issue #849)
- Fixed IPP backend to support the "print-scaling" option with IPP printers
(Issue #862)
- Removed hash support for SHA2-512-224 and SHA2-512-256.
- Removed `mantohtml` script for generating html pages (use
`https://www.msweet.org/mantohtml/`)
Expand Down
31 changes: 23 additions & 8 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 @@ -108,6 +108,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 @@ -160,7 +161,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 @@ -246,6 +248,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 @@ -876,6 +879,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 @@ -1143,6 +1147,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 @@ -1454,7 +1467,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 @@ -1577,7 +1590,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 @@ -2781,15 +2794,14 @@ 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 */


(void)compression; // TODO: Add compression support???

/*
* Create the IPP request...
*/
Expand Down Expand Up @@ -2849,6 +2861,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 3c2f086

Please sign in to comment.