]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix printer-state-reasons/message in notifications (Issue #1013)
authorMichael R Sweet <msweet@msweet.org>
Wed, 14 Aug 2024 00:16:14 +0000 (20:16 -0400)
committerMichael R Sweet <msweet@msweet.org>
Wed, 14 Aug 2024 00:16:14 +0000 (20:16 -0400)
CHANGES.md
scheduler/printers.c

index e0aa26cd21fe641571ca29f2d985d5697cf0db25..6b8f9d776a6ed2622147e8e9e7fc76557fc70b22 100644 (file)
@@ -5,9 +5,10 @@ CHANGES - OpenPrinting CUPS
 Changes in CUPS v2.4.11 (YYYY-MM-DD)
 ------------------------------------
 
-- Fix incorrect error message for HTTP/IPP errors (Issue #893)
 - Updated the maximum file descriptor limit for `cupsd` to 64k-1 (Issue #989)
-- Fix checkbox support (Issue #1008)
+- Fixed incorrect error message for HTTP/IPP errors (Issue #893)
+- Fixed checkbox support (Issue #1008)
+- Fixed printer state notifications (Issue #1013)
 
 
 Changes in CUPS v2.4.10 (2024-06-18)
index bf493a37cb63a7b9f7393cc219d980daa8f02f3a..34e95efbbb4ad2d33338567efd59fbf4b5575280 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Printer routines for the CUPS scheduler.
  *
- * Copyright © 2020-2023 by OpenPrinting
+ * Copyright © 2020-2024 by OpenPrinting
  * Copyright © 2007-2019 by Apple Inc.
  * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
  *
@@ -2695,12 +2695,20 @@ cupsdSetPrinterState(
 
 
  /*
-  * Set the new state...
+  * Set the new state and clear/set the reasons and message...
   */
 
   old_state = p->state;
   p->state  = s;
 
+  if (s == IPP_PSTATE_STOPPED)
+    cupsdSetPrinterReasons(p, "+paused");
+  else
+    cupsdSetPrinterReasons(p, "-paused");
+
+  if (s == IPP_PSTATE_PROCESSING)
+    p->state_message[0] = '\0';
+
   if (old_state != s)
   {
     cupsdAddEvent(s == IPP_PRINTER_STOPPED ? CUPSD_EVENT_PRINTER_STOPPED :
@@ -2716,33 +2724,21 @@ cupsdSetPrinterState(
     p->state_time = time(NULL);
   }
 
- /*
-  * Set/clear the paused reason as needed...
-  */
-
-  if (s == IPP_PRINTER_STOPPED)
-    cupsdSetPrinterReasons(p, "+paused");
-  else
-    cupsdSetPrinterReasons(p, "-paused");
-
   if (old_state != s)
   {
-    for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
-        job;
-        job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
+   /*
+    * Set/clear the printer-stopped reason as needed...
+    */
+
+    for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
+    {
       if (job->reasons && job->state_value == IPP_JOB_PENDING &&
          !_cups_strcasecmp(job->dest, p->name))
        ippSetString(job->attrs, &job->reasons, 0,
                     s == IPP_PRINTER_STOPPED ? "printer-stopped" : "none");
+    }
   }
 
- /*
-  * Clear the message for the queue when going to processing...
-  */
-
-  if (s == IPP_PRINTER_PROCESSING)
-    p->state_message[0] = '\0';
-
  /*
   * Let the browse protocols reflect the change...
   */