]> 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:11:43 +0000 (20:11 -0400)
committerMichael R Sweet <msweet@msweet.org>
Wed, 14 Aug 2024 00:11:43 +0000 (20:11 -0400)
scheduler/printers.c

index 9e00b39f39c250ad0013894098429f48e6c35375..89b85bb961cd060cad93ff292087e9354058af63 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.
  *
@@ -2712,12 +2712,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_PSTATE_STOPPED ? CUPSD_EVENT_PRINTER_STOPPED :
@@ -2733,33 +2741,21 @@ cupsdSetPrinterState(
     p->state_time = time(NULL);
   }
 
- /*
-  * Set/clear the paused reason as needed...
-  */
-
-  if (s == IPP_PSTATE_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_JSTATE_PENDING &&
          !_cups_strcasecmp(job->dest, p->name))
        ippSetString(job->attrs, &job->reasons, 0,
                     s == IPP_PSTATE_STOPPED ? "printer-stopped" : "none");
+    }
   }
 
- /*
-  * Clear the message for the queue when going to processing...
-  */
-
-  if (s == IPP_PSTATE_PROCESSING)
-    p->state_message[0] = '\0';
-
  /*
   * Let the browse protocols reflect the change...
   */