From: Michael R Sweet Date: Wed, 14 Aug 2024 00:11:43 +0000 (-0400) Subject: Fix printer-state-reasons/message in notifications (Issue #1013) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d1aaa79e9edd24b79562e1ab765634220796122;p=thirdparty%2Fcups.git Fix printer-state-reasons/message in notifications (Issue #1013) --- diff --git a/scheduler/printers.c b/scheduler/printers.c index 9e00b39f39..89b85bb961 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -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... */