Skip to content

Commit

Permalink
When multiple queues are supported, preserve the paused state of each…
Browse files Browse the repository at this point in the history
… printer (Issue #286)
  • Loading branch information
michaelrsweet committed Sep 2, 2023
1 parent b02062d commit caca78c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Changes in v1.4.0
disable unwanted device types (Issue #259)
- Added support for suspending and resuming jobs at copy boundaries (Issue #266)
- Added support for server configuration files (Issue #279)
- Now preserve the paused state of printers (Issue #286)
- Fixed reporting of "xxx-k-octet-supported" attributes.
- Fixed printing of 1/2/4-bit grayscale PNG images (Issue #267)
- Fixed USB serial number for DYMO printers (Issue #271)
Expand Down
9 changes: 8 additions & 1 deletion pappl/system-loadsave.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// System load/save functions for the Printer Application Framework
//
// Copyright © 2020-2022 by Michael R Sweet.
// Copyright © 2020-2023 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
Expand Down Expand Up @@ -134,6 +134,7 @@ papplSystemLoadState(
cups_option_t *options = NULL;// Options
const char *printer_id, // Printer ID
*printer_name, // Printer name
*printer_state, // Printer state
*device_id, // Device ID
*device_uri, // Device URI
*driver_name; // Driver name
Expand All @@ -156,6 +157,9 @@ papplSystemLoadState(
papplLog(system, PAPPL_LOGLEVEL_ERROR, "Dropping printer '%s' and its job history because an error occurred: %s", printer_name, strerror(errno));
}

if ((system->options & PAPPL_SOPTIONS_MULTI_QUEUE) && (printer_state = cupsGetOption("state", num_options, options)) != NULL && (ipp_pstate_t)atoi(printer_state) == IPP_PSTATE_STOPPED)
papplPrinterPause(printer);

while (read_line(fp, line, sizeof(line), &value, &linenum))
{
if (!strcasecmp(line, "</Printer>"))
Expand Down Expand Up @@ -462,6 +466,9 @@ papplSystemSaveState(
num_options = cupsAddOption("uri", printer->device_uri, num_options, &options);
num_options = cupsAddOption("driver", printer->driver_name, num_options, &options);

if (system->options & PAPPL_SOPTIONS_MULTI_QUEUE)
num_options = cupsAddIntegerOption("state", (int)printer->state, num_options, &options);

write_options(fp, "<Printer", num_options, options);
cupsFreeOptions(num_options, options);

Expand Down

0 comments on commit caca78c

Please sign in to comment.