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

Fix listing devices via "devices" subcommand #262

Merged
merged 2 commits into from
Mar 7, 2023
Merged

Fix listing devices via "devices" subcommand #262

merged 2 commits into from
Mar 7, 2023

Conversation

tillkamppeter
Copy link
Contributor

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.

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.  # Please enter the commit message for your
changes. Lines starting # with '#' will be ignored, and an empty
message aborts the commit.  # # On branch master # Your branch is up
to date with 'origin/master'.  # # Changes to be committed: #
modified: pappl/device.c # modified: pappl/mainloop-subcommands.c #
Copy link
Owner

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I like this, just needs some cleanup.

pappl/mainloop-subcommands.c Outdated Show resolved Hide resolved
pappl/mainloop-subcommands.c Outdated Show resolved Hide resolved
pappl/mainloop-subcommands.c Outdated Show resolved Hide resolved
pappl/mainloop-subcommands.c Outdated Show resolved Hide resolved
pappl/mainloop-subcommands.c Outdated Show resolved Hide resolved
pappl/mainloop-subcommands.c Outdated Show resolved Hide resolved
pappl/mainloop-subcommands.c Outdated Show resolved Hide resolved
- Corrected coding style, especially description of all variables

- Use cups_len_t type

- Removed unnecessary NULL checks

- Free IPP response when erroring out

- Simplified error handling
@michaelrsweet michaelrsweet added bug Something isn't working priority-medium labels Mar 7, 2023
@michaelrsweet michaelrsweet modified the milestones: Stable, v1.4 Mar 7, 2023
@michaelrsweet michaelrsweet merged commit 9515f74 into michaelrsweet:master Mar 7, 2023
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-medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print queue setup fails. URI rejected.
2 participants