]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Mirror 1.1.x changes.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 28 Apr 2003 19:33:42 +0000 (19:33 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 28 Apr 2003 19:33:42 +0000 (19:33 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3673 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES-1.1.txt
scheduler/job.c
systemv/cancel.c

index e82be2a38974c700518dcf5d690604e336a590b4..d83ea0ad6781e736b270127d001feff43f1fdda2 100644 (file)
@@ -3,6 +3,11 @@ CHANGES-1.1.txt
 
 CHANGES IN CUPS V1.1.19rc3
 
+       - The scheduler could get in an infinite loop cancelling
+         jobs using "cancel -u user dest" (STR #48)
+       - The "cancel -u user" command did nothing (it should
+         cancel all jobs on all printers owned by the named
+         user - STR #48)
        - The scheduler would write 0-length job control files
          (STR #46)
        - Updated the French man pages (translation provided by
index a1fff5cf9a5218834a9964015732e695f82c4e4d..f99d57d4c666fae93f65a9902ea68caf9ae16ab5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: job.c,v 1.124.2.68 2003/04/25 15:30:24 mike Exp $"
+ * "$Id: job.c,v 1.124.2.69 2003/04/28 19:33:40 mike Exp $"
  *
  *   Job management routines for the Common UNIX Printing System (CUPS).
  *
@@ -237,11 +237,12 @@ CancelJob(int id,         /* I - Job to cancel */
  */
 
 void
-CancelJobs(const char *dest,   /* I - Destination to cancel */
-           const char *username,/* I - Username or NULL */
-          int        purge)    /* I - Purge jobs? */
+CancelJobs(const char *dest,           /* I - Destination to cancel */
+           const char *username,       /* I - Username or NULL */
+          int        purge)            /* I - Purge jobs? */
 {
-  job_t        *current;               /* Current job */
+  job_t        *current,                       /* Current job */
+       *next;                          /* Next job */
 
 
   for (current = Jobs; current != NULL;)
@@ -252,9 +253,11 @@ CancelJobs(const char *dest,       /* I - Destination to cancel */
       * Cancel all jobs matching this destination/user...
       */
 
+      next = current->next;
+
       CancelJob(current->id, purge);
 
-      current = Jobs;
+      current = next;
     }
     else
       current = current->next;
@@ -2761,5 +2764,5 @@ start_process(const char *command,        /* I - Full path to command */
 
 
 /*
- * End of "$Id: job.c,v 1.124.2.68 2003/04/25 15:30:24 mike Exp $".
+ * End of "$Id: job.c,v 1.124.2.69 2003/04/28 19:33:40 mike Exp $".
  */
index 468ce38197fd8f72619647f2e1712b7f556e6a01..b3187891add17d4053760ec180c75b43b4a76915 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cancel.c,v 1.19.2.12 2003/03/12 21:27:39 mike Exp $"
+ * "$Id: cancel.c,v 1.19.2.13 2003/04/28 19:33:42 mike Exp $"
  *
  *   "cancel" command for the Common UNIX Printing System (CUPS).
  *
@@ -297,10 +297,85 @@ main(int  argc,                   /* I - Number of command-line arguments */
       ippDelete(response);
     }
 
+  if (num_dests == 0 && op == IPP_PURGE_JOBS)
+  {
+   /*
+    * Open a connection to the server...
+    */
+
+    if (http == NULL)
+      if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
+                                    cupsEncryption())) == NULL)
+      {
+       fputs("cancel: Unable to contact server!\n", stderr);
+       return (1);
+      }
+
+   /*
+    * Build an IPP request, which requires the following
+    * attributes:
+    *
+    *    attributes-charset
+    *    attributes-natural-language
+    *    printer-uri + job-id *or* job-uri
+    *    [requesting-user-name]
+    */
+
+    request = ippNew();
+
+    request->request.op.operation_id = op;
+    request->request.op.request_id   = 1;
+
+    language = cupsLangDefault();
+
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
+                "attributes-charset", NULL, cupsLangEncoding(language));
+
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
+                 "attributes-natural-language", NULL, language->language);
+
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+                "printer-uri", NULL, "ipp://localhost/printers/");
+
+    if (user)
+    {
+      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+                   "requesting-user-name", NULL, user);
+      ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1);
+    }
+    else
+      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+                   "requesting-user-name", NULL, cupsUser());
+
+    ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", purge);
+
+   /*
+    * Do the request and get back a response...
+    */
+
+    response = cupsDoRequest(http, request, "/admin/");
+
+    if (response == NULL ||
+        response->request.status.status_code > IPP_OK_CONFLICT)
+    {
+      fprintf(stderr, "cancel: %s failed: %s\n",
+             op == IPP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
+              response ? ippErrorString(response->request.status.status_code) :
+                        ippErrorString(cupsLastError()));
+
+      if (response)
+       ippDelete(response);
+
+      return (1);
+    }
+
+    ippDelete(response);
+  }
+
   return (0);
 }
 
 
 /*
- * End of "$Id: cancel.c,v 1.19.2.12 2003/03/12 21:27:39 mike Exp $".
+ * End of "$Id: cancel.c,v 1.19.2.13 2003/04/28 19:33:42 mike Exp $".
  */