]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/util.c
Merge changes from CUPS 1.5svn-r8933.
[thirdparty/cups.git] / cups / util.c
index 87ba2c0ce508e03eaa0ba12d7e7e7ec7d96e978a..7bfbe29a2c76502dc3d5fcd5385a46d9b1c46faa 100644 (file)
@@ -570,17 +570,17 @@ cupsGetJobs2(http_t     *http,            /* I - Connection to server or @code CUPS_HTTP_D
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
   static const char * const attrs[] =  /* Requested attributes */
                {
+                 "document-format",
                  "job-id",
-                 "job-priority",
                  "job-k-octets",
+                 "job-name",
+                 "job-originating-user-name",
+                 "job-printer-uri",
+                 "job-priority",
                  "job-state",
                  "time-at-completed",
                  "time-at-creation",
-                 "time-at-processing",
-                 "job-printer-uri",
-                 "document-format",
-                 "job-name",
-                 "job-originating-user-name"
+                 "time-at-processing"
                };
 
 
@@ -1456,6 +1456,9 @@ cupsPrintFiles2(
   char         buffer[8192];           /* Copy buffer */
   ssize_t      bytes;                  /* Bytes in buffer */
   http_status_t        status;                 /* Status of write */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
+  ipp_status_t cancel_status;          /* Status code to preserve */
+  char         *cancel_message;        /* Error message to preserve */
 
 
   DEBUG_printf(("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, "
@@ -1507,8 +1510,8 @@ cupsPrintFiles2(
       * Unable to open print file, cancel the job and return...
       */
 
-      cupsCancelJob2(http, name, job_id, 0);
-      return (0);
+      _cupsSetError(IPP_DOCUMENT_ACCESS_ERROR, NULL, 0);
+      goto cancel_job;
     }
 
     do
@@ -1550,12 +1553,30 @@ cupsPrintFiles2(
       * Unable to queue, cancel the job and return...
       */
 
-      cupsCancelJob2(http, name, job_id, 0);
-      return (0);
+      goto cancel_job;
     }
   }
 
   return (job_id);
+
+ /*
+  * If we get here, something happened while sending the print job so we need
+  * to cancel the job without setting the last error (since we need to preserve
+  * the current error...
+  */
+
+  cancel_job:
+
+  cancel_status  = cg->last_error;
+  cancel_message = cg->last_status_message ?
+                       _cupsStrRetain(cg->last_status_message) : NULL;
+
+  cupsCancelJob2(http, name, job_id, 0);
+
+  cg->last_error          = cancel_status;
+  cg->last_status_message = cancel_message;
+
+  return (0);
 }