Skip to content

Fix hiding of configured multi-protocol printers when adding printers - #485

Merged
alexpevzner merged 4 commits into
masterfrom
fix/filter-configured-printer-connections
Oct 26, 2026
Merged

alexpevzner merged 4 commits into
masterfrom
fix/filter-configured-printer-connections

Conversation

@SinghCod3r

@SinghCod3r SinghCod3r commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR addresses two related multi-protocol printer issues in NewPrinterGUI:

  1. Suppress already-configured multi-protocol printers from discovery:
    Previously (from PR Suppress already configured printers in New Printer window #465), _filter_configured_devices() only filtered devices by exact URI match. If a multi-protocol printer was already configured via IPP, its other discovered endpoints (e.g., LPD, AppSocket) still appeared in the New Printer search results.
    Discovered devices are now grouped into PhysicalDevice instances (matching by DNS-SD service instance name or serial number). If any queue for that physical printer is already configured in CUPS, all of its discovered connections are suppressed to avoid duplicate queue creation.

  2. Prevent driverless PPD reuse when switching connections:
    When setting up a new printer with multiple connection options, switching between connections (e.g., from an IPP/driverless connection to LPD) could leave the previously cached driverless PPD associated with the printer, leading to an incorrect driver selection for non-driverless connections.
    Connection-specific driverless PPD caches are now validated against the current device URI and cleared when switching connections.

Changes

  • Physical device-aware filtering:

    • Extended _filter_configured_devices() to map configured queues and discovered devices to PhysicalDevice objects.
    • Matches across DNS-SD instance names and serial numbers to suppress all endpoints of an already-configured printer.
    • Keeps distinct physical devices on the same IP or different hostnames separate.
  • Driverless PPD cache invalidation:

    • Invalidate _cached_driverless_ppd and _cached_driverless_ppd_name when switching to a different device or non-matching URI.
    • Ensure driverless PPDs are only assigned to connections that explicitly support them.

Testing

  • Unit tests added in test_newprinter.py:
    • test_filter_configured_devices_multiprotocol_hidden: Verifies IPP + LPD endpoints are both hidden if one is configured.
    • test_filter_configured_devices_unrelated_printer_visible: Ensures unrelated printers remain visible.
    • test_filter_configured_devices_identical_models_different_hosts_separate: Ensures separate physical units are not grouped incorrectly.
    • test_filter_configured_devices_same_ip_different_queues_stay_separate: Ensures distinct non-DNS-SD socket queues stay separate.
    • test_device_from_object_explicit_kwargs: Verifies proper device attributes construction.
    • test_switching_connection_does_not_reuse_stale_driverless_ppd: Verifies switching from IPPS to LPD does not reuse the driverless PPD.
  • Ran full test suite:
    • pytest -q test_newprinter.py — all tests pass.

@SinghCod3r SinghCod3r changed the title newprinter: do not reuse driverless PPD from another connection newprinter: suppress configured multi-protocol printers and prevent driverless PPD reuse across connections Oct 26, 2026
@alexpevzner alexpevzner changed the title newprinter: suppress configured multi-protocol printers and prevent driverless PPD reuse across connections Fix hiding of configured multi-protocol printers when adding printers Oct 26, 2026
@alexpevzner
alexpevzner merged commit 38f70d1 into master Oct 26, 2026
5 checks passed
@alexpevzner
alexpevzner deleted the fix/filter-configured-printer-connections branch October 26, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants