]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/job.c
Merge changes from CUPS 1.5svn-r9400
[thirdparty/cups.git] / scheduler / job.c
index 2d930302bd4cbcb55f015341fc689c7fbc0e0f75..94fc08844a5cfeeb4b36b1aa7fd5fb80a26ab635 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * "$Id: job.c 7902 2008-09-03 14:20:17Z mike $"
  *
- *   Job management routines for the Common UNIX Printing System (CUPS).
+ *   Job management routines for the CUPS scheduler.
  *
  *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
@@ -294,6 +294,9 @@ cupsdCheckJobs(void)
 
     if (job->kill_time && job->kill_time <= curtime)
     {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "[Job %d] Stopping unresponsive job!", 
+                     job->id);
+
       stop_job(job, CUPSD_JOB_FORCE);
       continue;
     }
@@ -348,7 +351,7 @@ cupsdCheckJobs(void)
     */
 
     if (job->state_value == IPP_JOB_PENDING && !NeedReload && !Sleeping &&
-        !job->printer)
+        !DoingShutdown && !job->printer)
     {
       printer = cupsdFindDest(job->dest);
       pclass  = NULL;
@@ -2721,6 +2724,12 @@ finalize_job(cupsd_job_t *job,           /* I - Job */
   cupsdDestroyProfile(job->profile);
   job->profile = NULL;
 
+ /*
+  * Clear the unresponsive job watchdog timer...
+  */
+
+  job->kill_time = 0;
+
  /*
   * Close pipes and status buffer...
   */
@@ -2856,7 +2865,7 @@ finalize_job(cupsd_job_t *job,            /* I - Job */
 
              job->tries ++;
 
-             if (job->tries >= JobRetryLimit)
+             if (job->tries > JobRetryLimit && JobRetryLimit > 0)
              {
               /*
                * Too many tries...
@@ -3049,8 +3058,17 @@ get_options(cupsd_job_t *job,            /* I - Job */
   num_pwgppds = 0;
   pwgppds     = NULL;
 
-  if (pwg)
+  if (pwg &&
+      !ippFindAttribute(job->attrs,
+                        "com.apple.print.DocumentTicket.PMSpoolFormat",
+                       IPP_TAG_ZERO) &&
+      (ippFindAttribute(job->attrs, "output-mode", IPP_TAG_ZERO) ||
+       ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ZERO)))
   {
+   /*
+    * Map output-mode and print-quality to a preset...
+    */
+
     if ((attr = ippFindAttribute(job->attrs, "output-mode",
                                 IPP_TAG_KEYWORD)) != NULL &&
        !strcmp(attr->values[0].string.text, "monochrome"))
@@ -3059,12 +3077,12 @@ get_options(cupsd_job_t *job,           /* I - Job */
       output_mode = _PWG_OUTPUT_MODE_COLOR;
 
     if ((attr = ippFindAttribute(job->attrs, "print-quality",
-                                IPP_TAG_INTEGER)) != NULL &&
+                                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;
     else
-      print_quality = IPP_QUALITY_NORMAL;
+      print_quality = _PWG_PRINT_QUALITY_NORMAL;
 
     if (pwg->num_presets[output_mode][print_quality] == 0)
     {
@@ -3101,7 +3119,10 @@ get_options(cupsd_job_t *job,            /* I - Job */
                                      &pwgppds);
       }
     }
+  }
 
+  if (pwg)
+  {
     if (pwg->sides_option &&
         !ippFindAttribute(job->attrs, pwg->sides_option, IPP_TAG_ZERO) &&
        (attr = ippFindAttribute(job->attrs, "sides", IPP_TAG_KEYWORD)) != NULL)
@@ -3139,8 +3160,13 @@ get_options(cupsd_job_t *job,            /* I - Job */
     if (!ippFindAttribute(job->attrs, "PageRegion", IPP_TAG_ZERO) &&
        !ippFindAttribute(job->attrs, "PageSize", IPP_TAG_ZERO) &&
        (ppd = _pwgGetPageSize(pwg, job->attrs, NULL, &exact)) != NULL)
+    {
       num_pwgppds = cupsAddOption("PageSize", ppd, num_pwgppds, &pwgppds);
 
+      if (!ippFindAttribute(job->attrs, "media", IPP_TAG_ZERO))
+        num_pwgppds = cupsAddOption("media", ppd, num_pwgppds, &pwgppds);
+    }
+
     if (!ippFindAttribute(job->attrs, "OutputBin", IPP_TAG_ZERO) &&
        (attr = ippFindAttribute(job->attrs, "output-bin",
                                 IPP_TAG_ZERO)) != NULL &&
@@ -4401,7 +4427,7 @@ update_job(cupsd_job_t *job)              /* I - Job to check */
 
        event |= CUPSD_EVENT_PRINTER_STATE | CUPSD_EVENT_JOB_PROGRESS;
 
-       if (loglevel < job->status_level)
+       if (loglevel <= job->status_level && job->status_level > CUPSD_LOG_ERROR)
        {
         /*
          * Some messages show in the job-printer-state-message attribute...