]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
lpstat: Implemenet successful filter for jobs
authorZdenek Dohnal <zdohnal@redhat.com>
Fri, 24 Nov 2023 06:42:05 +0000 (07:42 +0100)
committerZdenek Dohnal <zdohnal@redhat.com>
Fri, 24 Nov 2023 06:42:05 +0000 (07:42 +0100)
CHANGES.md
doc/help/man-lpstat.html
man/lpstat.1
systemv/lpstat.c

index 50bc96cb288f8d2f696aba1de6879d2cac63bdd8..9ed7424630674c24a4e73a363ab917815097ab59 100644 (file)
@@ -4,6 +4,8 @@ CHANGES - OpenPrinting CUPS 2.4.8 - TBA
 Changes in CUPS v2.4.8 (TBA)
 ----------------------------
 
+- Added new value for 'lpstat' option '-W' - successfull - for getting
+  successfully printed jobs (Issue #830)
 - Fixed memory leak when creating color profiles (Issue #815)
 - Fixed memory leak when unloading a job (Issue #813)
 - Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751)
index ce7f48a49a8b2e0c46bcedb6c2dcb89b6244110a..aed35f3bda6c31c8719e21d74da775e861449dfe 100644 (file)
@@ -77,7 +77,7 @@ The <b>lpstat</b> command supports the following options:
 <dt><b>-U </b><i>username</i>
 <dd style="margin-left: 5.0em">Specifies an alternate username.
 <dt><b>-W </b><i>which-jobs</i>
-<dd style="margin-left: 5.0em">Specifies which jobs to show, "completed" or "not-completed" (the default).
+<dd style="margin-left: 5.0em">Specifies which jobs to show, "all", "successful", "completed" or "not-completed" (the default).
 This option <i>must</i> appear before the <i>-o</i> option and/or any printer names, otherwise the default ("not-completed") value will be used in the request to the scheduler.
 <dt><b>-a </b>[<i>printer(s)</i>]
 <dd style="margin-left: 5.0em">Shows the accepting state of printer queues.
index dec52e2bd2aa50a230bc5fbbc1e4dc719deab33e..9197ed282027629813749cd5d6fc1b9c0ea7f61f 100644 (file)
@@ -82,7 +82,7 @@ Shows the ranking of print jobs.
 Specifies an alternate username.
 .TP 5
 \fB\-W \fIwhich-jobs\fR
-Specifies which jobs to show, "completed" or "not-completed" (the default).
+Specifies which jobs to show, "all, "successful", "completed" or "not-completed" (the default).
 This option \fImust\fR appear before the \fI-o\fR option and/or any printer names, otherwise the default ("not-completed") value will be used in the request to the scheduler.
 .TP 5
 \fB\-a \fR[\fIprinter(s)\fR]
index eb1258ac95ff89c716b887ede2ce20f4c577a23d..b23f04d0df48c6f148256c4ffe9bc37c543106f5 100644 (file)
@@ -147,16 +147,16 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
                if (i >= argc)
                {
-                 _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv[0]);
+                 _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", \"successful\", or \"all\" after \"-W\" option."), argv[0]);
                  usage();
                }
 
                which = argv[i];
              }
 
-             if (strcmp(which, "completed") && strcmp(which, "not-completed") && strcmp(which, "all"))
+             if (strcmp(which, "completed") && strcmp(which, "not-completed") && strcmp(which, "all") && strcmp(which, "successful"))
              {
-               _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv[0]);
+               _cupsLangPrintf(stderr, _("%s: Error - need \"completed\", \"not-completed\", \"successful\", or \"all\" after \"-W\" option."), argv[0]);
                usage();
              }
              break;
@@ -1364,7 +1364,7 @@ show_jobs(const char *dests,              /* I - Destinations */
                NULL, cupsUser());
 
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
-               NULL, which);
+               NULL, !strcmp(which, "successful") ? "completed" : which);
 
  /*
   * Do the request and get back a response...
@@ -1402,6 +1402,7 @@ show_jobs(const char *dests,              /* I - Destinations */
 
     if (!strcmp(which, "aborted") ||
         !strcmp(which, "canceled") ||
+        !strcmp(which, "successful") ||
         !strcmp(which, "completed"))
       time_at = "time-at-completed";
     else
@@ -1482,7 +1483,11 @@ show_jobs(const char *dests,             /* I - Destinations */
 
       if (match_list(dests, dest) && match_list(users, username))
       {
-        snprintf(temp, sizeof(temp), "%s-%d", dest, jobid);
+       if (!strcmp(which, "successful") && (!reasons || (reasons &&
+           strcmp(reasons->values[0].string.text, "job-completed-successfully"))))
+         continue;
+
+       snprintf(temp, sizeof(temp), "%s-%d", dest, jobid);
 
        _cupsStrDate(date, sizeof(date), jobtime);
 
@@ -1563,7 +1568,7 @@ show_printers(const char  *printers,      /* I - Destinations */
   int          jobid;                  /* Job ID of current job */
   char         printer_uri[HTTP_MAX_URI],
                                        /* Printer URI */
-               printer_state_time[255];/* Printer state time */
+       printer_state_time[255];/* Printer state time */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
   static const char *pattrs[] =                /* Attributes we need for printers... */
                {