Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The printer(s) cannot be loaded from the state file again after restart pappl #298

Closed
tangyanli opened this issue Oct 13, 2023 · 1 comment
Assignees
Labels
bug Something isn't working priority-high
Milestone

Comments

@tangyanli
Copy link

Describe the bug
The printer(s) cannot be loaded from the state file again after restart pappl

To Reproduce
Steps to reproduce the behavior:

  1. Build and run legacy-printer-app
  2. And several printers on the web page
  3. Shutdown the legacy-printer-app
  4. Run the legacy-printer-app again, the pappl cannot load the printers from the state file again.

Expected behavior
The pappl can load the printers from the state file again.

System Information:

  • OS: Ubuntu22.10
  • Browser: Firefox
  • Version: pappl-1.4-x branch

Additional context
In the papplSystemSaveState() file, 6 options are saved for a printer.

num_options = cupsAddIntegerOption("id", printer->printer_id, num_options, &options);
num_options = cupsAddOption("name", printer->name, num_options, &options);
num_options = cupsAddOption("did", printer->device_id ? printer->device_id : "", num_options, &options);
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);

But in the papplSystemLoadState(), the printer is skipped when it's option number is not equal to 5.

if ((num_options = cupsParseOptions(value, 0, &options)) != 5 ||
    (printer_id = cupsGetOption("id", num_options, options)) == NULL ||  strtol(printer_id, NULL, 10) <= 0 || 
    (printer_name = cupsGetOption("name", num_options, options)) == NULL || 
    (device_id = cupsGetOption("did", num_options, options)) == NULL || 
    (device_uri = cupsGetOption("uri", num_options, options)) == NULL || 
    (driver_name = cupsGetOption("driver", num_options, options)) == NULL)
    {
	 papplLog(system, PAPPL_LOGLEVEL_ERROR, "Bad printer definition on line %d of '%s'.", linenum, filename);
	break;
    }
@michaelrsweet michaelrsweet self-assigned this Oct 13, 2023
@michaelrsweet michaelrsweet added bug Something isn't working priority-high labels Oct 13, 2023
@michaelrsweet michaelrsweet added this to the Stable milestone Oct 13, 2023
@michaelrsweet
Copy link
Owner

[master dc8e97b] Fix loading of previous state (Issue #298)

[v1.4.x 3a3c1e9] Fix loading of previous state (Issue #298)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-high
Projects
None yet
Development

No branches or pull requests

2 participants