michaelrsweet / pappl

PAPPL - Printer Application Framework
https://www.msweet.org/pappl
Apache License 2.0
307 stars 49 forks source link

Fix listing devices via "devices" subcommand #260

Closed tillkamppeter closed 1 year ago

tillkamppeter commented 1 year ago

Fixes Issue #253

When running a Printer Application (ex. ps-printer-app) as server and doing the client call

ps-printer-app devices

the use of custom backends (schemes, like "cups:" for CUPS backends in pappl-retrofit) was not taken into account, as simply papplDeviceList() was called, with neither a system created nor the devices list polled from the running server.

One could create the system before to get the custom scheme definitions in place, but the server is usually running as root and the client doing the request as the calling user. As some backends, independent of being PAPPL's own backends or any custom backends, discover devices only as root, letting the client call producing a different usually incomplete result.

Therefore we do an IPP_OP_PAPPL_FIND_DEVICES IPP request to the server to let the server auto-discover the available devices and report back the results.

There is also a bug in the server's IPP_OP_PAPPL_FIND_DEVICES (and IPP_OP_PAPPL_CREATE_PRINTERS) operation. The device list callback function _papplDeviceInfoCallback() returns "true" and not "false" after outputting an item, making the device listing process stop on the first item. making only the first discovered device listed (or only the first discovered printer set up). This is also corrected in this commit.