]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Resend jobs as raster if the original format fails, e.g., PDF (<rdar://problem/15583721>)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 21 Feb 2014 19:42:14 +0000 (19:42 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 21 Feb 2014 19:42:14 +0000 (19:42 +0000)
Add retry_as_raster flag to job object.

Add new JOBSTATE: cups-retry-as-raster message.

When starting a job, check whether the flag is set, and if so use image/urf
or image/pwg-raster as the alternate format.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11635 a1ca3aef-8c08-0410-bb20-df032aa958be

backend/ipp.c
doc/help/man-ipptool.html
doc/help/man-ipptoolfile.html
scheduler/job.c
scheduler/job.h

index c47f44225a6032b8048d86750bae15e1adaa1c6c..7c10819f3af2111c20909c517ae9a14d7e723dfa 100644 (file)
@@ -1769,6 +1769,20 @@ main(int  argc,                          /* I - Number of command-line args */
       fprintf(stderr, "PAGE: 1 %d\n", copies_sup ? atoi(argv[4]) : 1);
       copies_remaining --;
     }
+    else if ((ipp_status == IPP_STATUS_ERROR_DOCUMENT_FORMAT_ERROR || ipp_status == IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE) &&
+             argc == 6 &&
+             document_format && strcmp(document_format, "image/pwg-raster") && strcmp(document_format, "image/urf"))
+    {
+     /*
+      * Need to reprocess the job as raster...
+      */
+
+      fputs("JOBSTATE: cups-retry-as-raster\n", stderr);
+      if (job_id > 0)
+       cancel_job(http, uri, job_id, resource, argv[2], version);
+
+      goto cleanup;
+    }
     else if (ipp_status == IPP_SERVICE_UNAVAILABLE ||
              ipp_status == IPP_NOT_POSSIBLE ||
             ipp_status == IPP_PRINTER_BUSY)
index 486080c6ac909dd427842257879e19c086919d44..2812b9010e39453c4061430e96ec14ac2940f365 100644 (file)
@@ -38,10 +38,14 @@ The following options are recognized by <i>ipptool</i>:
 <dt>--help
 </dt>
 <dd>Shows program help.
---stop-after-include-error
-Tells <i>ipptool</i> to stop if an error occurs in an included file. Normally <i>ipptool</i> will continue with subsequent tests after the INCLUDE directive.
---version
-Shows the version of <i>ipptool</i> being used.
+</dd>
+<dt>--stop-after-include-error
+</dt>
+<dd>Tells <i>ipptool</i> to stop if an error occurs in an included file. Normally <i>ipptool</i> will continue with subsequent tests after the INCLUDE directive.
+</dd>
+<dt>--version
+</dt>
+<dd>Shows the version of <i>ipptool</i> being used.
 </dd>
 <dt>-4
 </dt>
@@ -123,16 +127,19 @@ The <i>ipptool</i> program is unique to CUPS.
 <h2 class="title"><a name="EXAMPLES">Examples</a></h2>
 Get a list of completed jobs for "myprinter":
 <pre>
+
     ipptool ipp://localhost/printers/myprinter get-completed-jobs.test
 </pre>
 <p>Send email notifications to "user@example.com" when "myprinter" changes:
 <pre>
-    ipptool -d recipient=mailto:user@example.com 
+
+    ipptool -d recipient=mailto:user@example.com \
         ipp://localhost/printers/myprinter create-printer-subscription.test
 </pre>
 <h2 class="title"><a name="STANDARD_FILES">Standard Files</a></h2>
 The following standard files are available:
 <pre>
+
     color.jpg
     create-printer-subscription.test
     document-a4.pdf
@@ -165,11 +172,15 @@ The following standard files are available:
     validate-job.test
 </pre>
 <h2 class="title"><a name="SEE_ALSO">See Also</a></h2>
-<a href='man-ipptoolfile.html?TOPIC=Man+Pages'>ipptoolfile(5)</a>,
+<a href='man-ipptoolfile.html?TOPIC=Man+Pages'>ipptoolfile(5)</a>, RFC 2911,
 <br>
 <a href='http://localhost:631/help'>http://localhost:631/help</a>
+<br>
+<a href='http://www.iana.org/assignments/ipp-registrations'>http://www.iana.org/assignments/ipp-registrations</a>
+<br>
+<a href='http://www.pwg.org/ipp'>http://www.pwg.org/ipp</a>
 <h2 class="title"><a name="COPYRIGHT">Copyright</a></h2>
-Copyright 2007-2013 by Apple Inc.
+Copyright 2007-2014 by Apple Inc.
 
 </body>
 </html>
index 1ce4f195dd6a78b95b4abebfe36619c4db807f18..e655bec978aa2f551265d90b485fe6ea38ecad6c 100644 (file)
@@ -174,7 +174,7 @@ The following directives are understood in a test:
 <dt>ATTR tag attribute-name value(s)
 </dt>
 <dd>Adds an attribute to the test request. Values are separated by the comma (",")
-character - escape commas using the "" character.
+character - escape commas using the "" character. Common attributes and values are listed in the IANA IPP registry - see references below.
 </dd>
 <dt>ATTR collection attribute-name { MEMBER tag member-name value(s) ... } [ ... { ... } ]
 </dt>
@@ -735,12 +735,15 @@ no notify-subscription-id has been seen.
 </dd>
 </dl>
 <h2 class="title"><a name="SEE_ALSO">See Also</a></h2>
-<a href='man-ipptool.html?TOPIC=Man+Pages'>ipptool(1)</a>,
+<a href='man-ipptool.html?TOPIC=Man+Pages'>ipptool(1)</a>, RFC 2911,
 <br>
 <a href='http://localhost:631/help'>http://localhost:631/help</a>
-
+<br>
+<a href='http://www.iana.org/assignments/ipp-registrations'>http://www.iana.org/assignments/ipp-registrations</a>
+<br>
+<a href='http://www.pwg.org/ipp'>http://www.pwg.org/ipp</a>
 <h2 class="title"><a name="COPYRIGHT">Copyright</a></h2>
-Copyright 2007-2013 by Apple Inc.
+Copyright 2007-2014 by Apple Inc.
 
 </body>
 </html>
index 2af8785ce1063e6e7f2bfbb1a0540e880a07fe5b..0c5d7da00a8d0e39837c1f8f57691d2a43594bb6 100644 (file)
@@ -563,12 +563,37 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
     * Local jobs get filtered...
     */
 
+    mime_type_t        *dst = job->printer->filetype;
+                                       /* Destination file type */
+
     snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot,
              job->id, job->current_file + 1);
     if (stat(filename, &fileinfo))
       fileinfo.st_size = 0;
 
-    filters = mimeFilter2(MimeDatabase, job->filetypes[job->current_file], (size_t)fileinfo.st_size, job->printer->filetype, &(job->cost));
+    if (job->retry_as_raster)
+    {
+     /*
+      * Need to figure out whether the printer supports image/pwg-raster or
+      * image/urf, and use the corresponding type...
+      */
+
+      char     type[MIME_MAX_TYPE];    /* MIME media type for printer */
+
+      snprintf(type, sizeof(type), "%s/image/urf", job->printer->name);
+      if ((dst = mimeType(MimeDatabase, "printer", type)) == NULL)
+      {
+       snprintf(type, sizeof(type), "%s/image/pwg-raster", job->printer->name);
+       dst = mimeType(MimeDatabase, "printer", type);
+      }
+
+      if (dst)
+        cupsdLogJob(job, CUPSD_LOG_DEBUG, "Retrying job as \"%s\".", strchr(dst->type, '/') + 1);
+      else
+        cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to retry job using a supported raster format.");
+    }
+
+    filters = mimeFilter2(MimeDatabase, job->filetypes[job->current_file], (size_t)fileinfo.st_size, dst, &(job->cost));
 
     if (!filters)
     {
@@ -4766,7 +4791,10 @@ update_job(cupsd_job_t *job)             /* I - Job to check */
 
       cupsdLogJob(job, CUPSD_LOG_DEBUG, "JOBSTATE: %s", message);
 
-      ippSetString(job->attrs, &job->reasons, 0, message);
+      if (!strcmp(message, "cups-retry-as-raster"))
+        job->retry_as_raster = 1;
+      else
+        ippSetString(job->attrs, &job->reasons, 0, message);
     }
     else if (loglevel == CUPSD_LOG_STATE)
     {
index d13bb97b37778ba009b6baec38c44ab128172dd9..c5d723e0ba7ba47b589ae7113334297a3b57fbce 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Print job definitions for the CUPS scheduler.
  *
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -75,6 +75,7 @@ struct cupsd_job_s                    /**** Job request ****/
   int                  status;         /* Status code from filters */
   int                  tries;          /* Number of tries for this job */
   int                  completed;      /* cups-waiting-for-job-completed seen */
+  int                  retry_as_raster;/* Need to retry the job as raster */
   char                 *auth_env[3],   /* AUTH_xxx environment variables,
                                          * if any */
                        *auth_uid;      /* AUTH_UID environment variable */