summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2018-02-20 21:46:59 -0500
committerMichael R Sweet <michael.r.sweet@gmail.com>2018-02-20 21:46:59 -0500
commitfe1a4305450f8d2f563c247433ff8ad0d1e3e6e2 (patch)
tree64dd07186559f312b20cf0d436f0d46af59d4618 /backend
parent53f8d64f8451caa0737c635aa4eb126a1869d624 (diff)
The IPP backend did not properly detect failed PDF prints (rdar://34055474)
Look for document-format-error and document-unprintable job state reasons strings and log either that state or the CUPS "retry" state.
Diffstat (limited to 'backend')
-rw-r--r--backend/ipp.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/backend/ipp.c b/backend/ipp.c
index 2a2921db6..a61f8e9dd 100644
--- a/backend/ipp.c
+++ b/backend/ipp.c
@@ -42,6 +42,8 @@ extern void xpc_connection_set_target_uid(xpc_connection_t connection,
#define _CUPS_JSR_ACCOUNT_LIMIT_REACHED 0x08
#define _CUPS_JSR_JOB_PASSWORD_WAIT 0x10
#define _CUPS_JSR_JOB_RELEASE_WAIT 0x20
+#define _CUPS_JSR_DOCUMENT_FORMAT_ERROR 0x40
+#define _CUPS_JSR_DOCUMENT_UNPRINTABLE 0x80
/*
@@ -64,6 +66,7 @@ typedef struct _cups_monitor_s /**** Monitoring data ****/
http_encryption_t encryption; /* Use encryption? */
ipp_jstate_t job_state; /* Current job state */
ipp_pstate_t printer_state; /* Current printer state */
+ int retryable; /* Is this a job that should be retried? */
} _cups_monitor_t;
@@ -1443,6 +1446,7 @@ main(int argc, /* I - Number of command-line args */
monitor.encryption = cupsEncryption();
monitor.job_state = IPP_JOB_PENDING;
monitor.printer_state = IPP_PRINTER_IDLE;
+ monitor.retryable = argc == 6 && document_format && strcmp(document_format, "image/pwg-raster") && strcmp(document_format, "image/urf");
if (create_job)
{
@@ -2563,22 +2567,24 @@ monitor_printer(
for (i = 0; i < attr->num_values; i ++)
{
- if (!strcmp(attr->values[i].string.text,
- "account-authorization-failed"))
+ if (!strcmp(attr->values[i].string.text, "account-authorization-failed"))
new_reasons |= _CUPS_JSR_ACCOUNT_AUTHORIZATION_FAILED;
else if (!strcmp(attr->values[i].string.text, "account-closed"))
new_reasons |= _CUPS_JSR_ACCOUNT_CLOSED;
else if (!strcmp(attr->values[i].string.text, "account-info-needed"))
new_reasons |= _CUPS_JSR_ACCOUNT_INFO_NEEDED;
- else if (!strcmp(attr->values[i].string.text,
- "account-limit-reached"))
+ else if (!strcmp(attr->values[i].string.text, "account-limit-reached"))
new_reasons |= _CUPS_JSR_ACCOUNT_LIMIT_REACHED;
else if (!strcmp(attr->values[i].string.text, "job-password-wait"))
new_reasons |= _CUPS_JSR_JOB_PASSWORD_WAIT;
else if (!strcmp(attr->values[i].string.text, "job-release-wait"))
new_reasons |= _CUPS_JSR_JOB_RELEASE_WAIT;
- if (!job_canceled &&
- (!strncmp(attr->values[i].string.text, "job-canceled-", 13) || !strcmp(attr->values[i].string.text, "aborted-by-system")))
+ else if (!strcmp(attr->values[i].string.text, "document-format-error"))
+ new_reasons |= _CUPS_JSR_DOCUMENT_FORMAT_ERROR;
+ else if (!strcmp(attr->values[i].string.text, "document-unprintable"))
+ new_reasons |= _CUPS_JSR_DOCUMENT_UNPRINTABLE;
+
+ if (!job_canceled && (!strncmp(attr->values[i].string.text, "job-canceled-", 13) || !strcmp(attr->values[i].string.text, "aborted-by-system")))
job_canceled = 1;
}
@@ -2596,6 +2602,26 @@ monitor_printer(
fputs("JOBSTATE: job-password-wait\n", stderr);
else if (new_reasons & _CUPS_JSR_JOB_RELEASE_WAIT)
fputs("JOBSTATE: job-release-wait\n", stderr);
+ else if (new_reasons & (_CUPS_JSR_DOCUMENT_FORMAT_ERROR | _CUPS_JSR_DOCUMENT_UNPRINTABLE))
+ {
+ if (monitor->retryable)
+ {
+ /*
+ * Can't print this, so retry as raster...
+ */
+
+ job_canceled = 1;
+ fputs("JOBSTATE: cups-retry-as-raster\n", stderr);
+ }
+ else if (new_reasons & _CUPS_JSR_DOCUMENT_FORMAT_ERROR)
+ {
+ fputs("JOBSTATE: document-format-error\n", stderr);
+ }
+ else
+ {
+ fputs("JOBSTATE: document-unprintable\n", stderr);
+ }
+ }
else
fputs("JOBSTATE: job-printing\n", stderr);