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

Auto discovered network printers shows up twice (with cupsEnumDest()) #5017

Closed
NilanjanaLodh opened this issue Jun 5, 2017 · 8 comments
Closed
Assignees

Comments

@NilanjanaLodh
Copy link

I set up a pdf printer on a remote machine in the subnet(Simpulated through a virtual machine in bridged adapter mode) and shared it.
When I start my cups scheduler on the remote machine, the discovered printer shows up twice on the list.

I use cupsEnumDests(CUPS_DEST_FLAGS_NONE, -1, NULL, CUPS_PRINTER_LOCAL, CUPS_PRINTER_REMOTE, printDestName, NULL) to enumerate the printers.
Here printDestName is a callback function which prints the printer name to stdout.

All the other printers show up once; just each of the network printers show up twice.

@NilanjanaLodh NilanjanaLodh changed the title Auto discovered network printer shows up twice (with cupsEnumDest()) Auto discovered network printers shows up twice (with cupsEnumDest()) Jun 5, 2017
@michaelrsweet
Copy link
Collaborator

What version of CUPS are you using? We recently fixed some bugs in this area in Github master...

@michaelrsweet michaelrsweet self-assigned this Jun 5, 2017
@NilanjanaLodh
Copy link
Author

I am using the lastest snapshot from this repo.
I did a git pull just before testing(today)

@michaelrsweet
Copy link
Collaborator

Hmm, can you attach the output of "lpstat -ev"?

@NilanjanaLodh
Copy link
Author

Here is the output of lpstat -ev

Generic-CUPS-PDF-Printer
HP_LaserJet_M1120_MFP
Generic-CUPS-PDF-Printer
HP_LaserJet_M1120_MFP

@michaelrsweet
Copy link
Collaborator

OK, there was a bug in the lpstat program - it didn't parse the command-line arguments correctly so you are getting the -e output twice...

Please try again.

@NilanjanaLodh
Copy link
Author

NilanjanaLodh commented Jun 6, 2017

Here is the output of lpstat -ev

Generic-CUPS-PDF-Printer
HP_LaserJet_M1120_MFP
device for Generic-CUPS-PDF-Printer: cups-pdf:/
device for HP_LaserJet_M1120_MFP: usb://HP/LaserJet%20M1120%20MFP


These are manually configured printers.

The output of the program using cupsEnumDests() is:

Generic-CUPS-PDF-Printer
HP_LaserJet_M1120_MFP
PDFPrint @ nilanjana-lubuntuVM
PDFPrint @ nilanjana-lubuntuVM
Generic CUPS-PDF Printer @ nilanjana-lubuntuVM
Generic CUPS-PDF Printer @ nilanjana-lubuntuVM

@michaelrsweet
Copy link
Collaborator

OK, so you need to suppress duplicate destinations yourself in your application - I will make sure this is documented clearly.

Basically, cupsEnumDests is providing you with updates to existing queues as we get responses from Avahi (on Linux) or mDNSResponder (on macOS). See the sample code in the new CUPS Programming Manual (available on the CUPS web site under the "help" tab) for an example that uses cupsEnumDests to assemble an array of CUPS destinations (like cupsGetDests does, just under your code's control...)

michaelrsweet pushed a commit that referenced this issue Jun 7, 2017
@JonathanKang
Copy link

Sorry to bump this thread.

I'm using cupsGetDests to get a list of destinations. Do I need to manually suppress duplicate destinations as well?

Thanks in advance.

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

No branches or pull requests

3 participants