]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/ipp.c
Merge changes from CUPS 1.4svn-r7696.
[thirdparty/cups.git] / scheduler / ipp.c
index ac80acb7ff0208f1c1a4adf3958f1afc5b7fca4d..7562cd9e2888739b85d93328f60ac73fceaf697a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c 7014 2007-10-10 21:57:43Z mike $"
+ * "$Id: ipp.c 7682 2008-06-21 00:06:02Z mike $"
  *
  *   IPP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -796,8 +796,8 @@ cupsdTimeoutJob(cupsd_job_t *job)   /* I - Job to timeout */
     * Yes...
     */
 
-    cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Adding end banner page \"%s\".",
-                    job->id, attr->values[1].string.text);
+    cupsdLogJob(job, CUPSD_LOG_INFO, "Adding end banner page \"%s\".",
+                attr->values[1].string.text);
 
     if ((kbytes = copy_banner(NULL, job, attr->values[1].string.text)) < 0)
       return (-1);
@@ -1754,10 +1754,10 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
 
           cupsdSetString(&attr->values[0].string.text, Classification);
 
-         cupsdLogMessage(CUPSD_LOG_NOTICE, "[Job %d] CLASSIFICATION FORCED "
-                                           "job-sheets=\"%s,none\", "
-                                           "job-originating-user-name=\"%s\"",
-                        job->id, Classification, job->username);
+         cupsdLogJob(job, CUPSD_LOG_NOTICE, "CLASSIFICATION FORCED "
+                                            "job-sheets=\"%s,none\", "
+                                            "job-originating-user-name=\"%s\"",
+                     Classification, job->username);
        }
        else if (attr->num_values == 2 &&
                 strcmp(attr->values[0].string.text,
@@ -1771,11 +1771,11 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
 
           cupsdSetString(&attr->values[1].string.text, attr->values[0].string.text);
 
-         cupsdLogMessage(CUPSD_LOG_NOTICE, "[Job %d] CLASSIFICATION FORCED "
-                                           "job-sheets=\"%s,%s\", "
-                                           "job-originating-user-name=\"%s\"",
-                        job->id, attr->values[0].string.text,
-                        attr->values[1].string.text, job->username);
+         cupsdLogJob(job, CUPSD_LOG_NOTICE, "CLASSIFICATION FORCED "
+                                            "job-sheets=\"%s,%s\", "
+                                            "job-originating-user-name=\"%s\"",
+                     attr->values[0].string.text,
+                     attr->values[1].string.text, job->username);
        }
        else if (strcmp(attr->values[0].string.text, Classification) &&
                 strcmp(attr->values[0].string.text, "none") &&
@@ -1784,18 +1784,18 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
                   strcmp(attr->values[1].string.text, "none"))))
         {
          if (attr->num_values == 1)
-            cupsdLogMessage(CUPSD_LOG_NOTICE,
-                           "[Job %d] CLASSIFICATION OVERRIDDEN "
-                           "job-sheets=\"%s\", "
-                           "job-originating-user-name=\"%s\"",
-                      job->id, attr->values[0].string.text, job->username);
+            cupsdLogJob(job, CUPSD_LOG_NOTICE,
+                       "CLASSIFICATION OVERRIDDEN "
+                       "job-sheets=\"%s\", "
+                       "job-originating-user-name=\"%s\"",
+                       attr->values[0].string.text, job->username);
           else
-            cupsdLogMessage(CUPSD_LOG_NOTICE,
-                           "[Job %d] CLASSIFICATION OVERRIDDEN "
-                           "job-sheets=\"%s,%s\",fffff "
-                           "job-originating-user-name=\"%s\"",
-                           job->id, attr->values[0].string.text,
-                           attr->values[1].string.text, job->username);
+            cupsdLogJob(job, CUPSD_LOG_NOTICE,
+                       "CLASSIFICATION OVERRIDDEN "
+                       "job-sheets=\"%s,%s\",fffff "
+                       "job-originating-user-name=\"%s\"",
+                       attr->values[0].string.text,
+                       attr->values[1].string.text, job->username);
         }
       }
       else if (strcmp(attr->values[0].string.text, Classification) &&
@@ -1824,18 +1824,18 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
         }
 
         if (attr->num_values > 1)
-         cupsdLogMessage(CUPSD_LOG_NOTICE,
-                         "[Job %d] CLASSIFICATION FORCED "
-                         "job-sheets=\"%s,%s\", "
-                         "job-originating-user-name=\"%s\"",
-                         job->id, attr->values[0].string.text,
-                         attr->values[1].string.text, job->username);
+         cupsdLogJob(job, CUPSD_LOG_NOTICE,
+                     "CLASSIFICATION FORCED "
+                     "job-sheets=\"%s,%s\", "
+                     "job-originating-user-name=\"%s\"",
+                     attr->values[0].string.text,
+                     attr->values[1].string.text, job->username);
         else
-         cupsdLogMessage(CUPSD_LOG_NOTICE,
-                         "[Job %d] CLASSIFICATION FORCED "
-                         "job-sheets=\"%s\", "
-                         "job-originating-user-name=\"%s\"",
-                        job->id, Classification, job->username);
+         cupsdLogJob(job, CUPSD_LOG_NOTICE,
+                     "CLASSIFICATION FORCED "
+                     "job-sheets=\"%s\", "
+                     "job-originating-user-name=\"%s\"",
+                     Classification, job->username);
       }
     }
 
@@ -1845,9 +1845,8 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
     if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)))
     {
-      cupsdLogMessage(CUPSD_LOG_INFO,
-                      "[Job %d] Adding start banner page \"%s\".",
-                      job->id, attr->values[0].string.text);
+      cupsdLogJob(job, CUPSD_LOG_INFO, "Adding start banner page \"%s\".",
+                 attr->values[0].string.text);
 
       if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0)
       {
@@ -3669,8 +3668,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
 
   cupsdReleaseJob(job);
 
-  cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Authenticated by \"%s\".", jobid,
-                  con->username);
+  cupsdLogJob(job, CUPSD_LOG_INFO, "Authenticated by \"%s\".", con->username);
 }
 
 
@@ -4011,10 +4009,10 @@ cancel_job(cupsd_client_t  *con,        /* I - Client connection */
 
   if (purge)
     cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Purged by \"%s\".", jobid,
-                    username);
+                   username);
   else
     cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Canceled by \"%s\".", jobid,
-                    username);
+                   username);
 
   con->response->request.status.status_code = IPP_OK;
 }
@@ -5690,8 +5688,8 @@ create_job(cupsd_client_t  *con,  /* I - Client connection */
   * Save and log the job...
   */
 
-  cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Queued on \"%s\" by \"%s\".",
-                  job->id, job->dest, job->username);
+  cupsdLogJob(job, CUPSD_LOG_INFO, "Queued on \"%s\" by \"%s\".",
+             job->dest, job->username);
 }
 
 
@@ -7945,8 +7943,7 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
                   "Job job-hold-until value changed by user.");
   }
 
-  cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Held by \"%s\".", jobid,
-                  username);
+  cupsdLogJob(job, CUPSD_LOG_INFO, "Held by \"%s\".", username);
 
   con->response->request.status.status_code = IPP_OK;
 }
@@ -8519,11 +8516,10 @@ print_job(cupsd_client_t  *con,         /* I - Client connection */
   * Log and save the job...
   */
 
-  cupsdLogMessage(CUPSD_LOG_INFO,
-                  "[Job %d] File of type %s/%s queued by \"%s\".", job->id,
-                 filetype->super, filetype->type, job->username);
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] hold_until=%d", job->id,
-                  (int)job->hold_until);
+  cupsdLogJob(job, CUPSD_LOG_INFO,
+             "File of type %s/%s queued by \"%s\".",
+             filetype->super, filetype->type, job->username);
+  cupsdLogJob(job, CUPSD_LOG_DEBUG, "hold_until=%d", (int)job->hold_until);
 
  /*
   * Start the job if possible...
@@ -8930,8 +8926,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
   cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job,
                 "Job released by user.");
 
-  cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Released by \"%s\".", jobid,
-                  username);
+  cupsdLogJob(job, CUPSD_LOG_INFO, "Released by \"%s\".", username);
 
   con->response->request.status.status_code = IPP_OK;
 }
@@ -9150,8 +9145,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
 
   cupsdRestartJob(job);
 
-  cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Restarted by \"%s\".", jobid,
-                  username);
+  cupsdLogJob(job, CUPSD_LOG_INFO, "Restarted by \"%s\".", username);
 
   con->response->request.status.status_code = IPP_OK;
 }
@@ -9395,8 +9389,7 @@ save_krb5_creds(cupsd_client_t *con,      /* I - Client connection */
   cupsdSetStringf(&(job->ccname), "KRB5CCNAME=FILE:%s",
                   krb5_cc_get_name(KerberosContext, job->ccache));
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] save_krb5_creds: %s", job->id,
-                  job->ccname);
+  cupsdLogJob(job, CUPSD_LOG_DEBUG2, "save_krb5_creds: %s", job->ccname);
 #  endif /* HAVE_KRB5_CC_NEW_UNIQUE || HAVE_HEIMDAL */
 }
 #endif /* HAVE_GSSAPI && HAVE_KRB5_H */
@@ -9439,6 +9432,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
   struct stat          fileinfo;       /* File information */
   int                  kbytes;         /* Size of file */
   int                  compression;    /* Type of compression */
+  int                  start_job;      /* Start the job? */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_document(%p[%d], %s)", con,
@@ -9608,7 +9602,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     ipp_attribute_t    *doc_name;      /* document-name attribute */
 
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Auto-typing file...", job->id);
+    cupsdLogJob(job, CUPSD_LOG_DEBUG, "Auto-typing file...");
 
     doc_name = ippFindAttribute(con->request, "document-name", IPP_TAG_NAME);
     filetype = mimeFileType(MimeDatabase, con->filename,
@@ -9618,9 +9612,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     if (!filetype)
       filetype = mimeType(MimeDatabase, super, type);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG,
-                   "[Job %d] Request file type is %s/%s.", job->id,
-                   filetype->super, filetype->type);
+    cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.",
+               filetype->super, filetype->type);
   }
   else
     filetype = mimeType(MimeDatabase, super, type);
@@ -9703,9 +9696,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
 
   cupsdClearString(&con->filename);
 
-  cupsdLogMessage(CUPSD_LOG_INFO,
-                  "[Job %d] File of type %s/%s queued by \"%s\".", job->id,
-                  filetype->super, filetype->type, job->username);
+  cupsdLogJob(job, CUPSD_LOG_INFO, "File of type %s/%s queued by \"%s\".",
+             filetype->super, filetype->type, job->username);
 
  /*
   * Start the job if this is the last document...
@@ -9743,16 +9735,7 @@ send_document(cupsd_client_t  *con,      /* I - Client connection */
     job->dirty = 1;
     cupsdMarkDirty(CUPSD_DIRTY_JOBS);
 
-   /*
-    * Start the job if possible...  Since cupsdCheckJobs() can cancel a
-    * job if it doesn't print, we need to re-find the job afterwards...
-    */
-
-    jobid = job->id;
-
-    cupsdCheckJobs();
-
-    job = cupsdFindJob(jobid);
+    start_job = 1;
   }
   else
   {
@@ -9769,6 +9752,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
 
       cupsdMarkDirty(CUPSD_DIRTY_JOBS);
     }
+
+    start_job = 0;
   }
 
  /*
@@ -9784,10 +9769,17 @@ send_document(cupsd_client_t  *con,     /* I - Client connection */
   ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", jobid);
 
   ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state",
-                job ? job->state_value : IPP_JOB_CANCELED);
+                job->state_value);
   add_job_state_reasons(con, job);
 
   con->response->request.status.status_code = IPP_OK;
+
+ /*
+  * Start the job if necessary...
+  */
+
+  if (start_job)
+    cupsdCheckJobs();
 }
 
 
@@ -11035,5 +11027,5 @@ validate_user(cupsd_job_t    *job,      /* I - Job */
 
 
 /*
- * End of "$Id: ipp.c 7014 2007-10-10 21:57:43Z mike $".
+ * End of "$Id: ipp.c 7682 2008-06-21 00:06:02Z mike $".
  */