After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688956 - Print dialog needs to support Bonjour broadcasting of remote printers
Print dialog needs to support Bonjour broadcasting of remote printers
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Printing
3.7.x
Other Linux
: Normal major
: ---
Assigned To: Marek Kašík
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-11-23 21:03 UTC by Till Kamppeter
Modified: 2013-03-04 13:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add avahi support to gtk printing (37.13 KB, patch)
2012-12-11 12:23 UTC, Marek Kašík
needs-work Details | Review
add avahi support to gtk printing (41.85 KB, patch)
2013-01-08 17:42 UTC, Marek Kašík
needs-work Details | Review
add avahi support to gtk printing - modified (57.51 KB, patch)
2013-02-27 17:03 UTC, Marek Kašík
committed Details | Review
add setting for listing of Avahi printers (3.02 KB, patch)
2013-02-27 17:06 UTC, Marek Kašík
reviewed Details | Review
remove unnecessary break (54.31 KB, patch)
2013-03-04 11:02 UTC, Marek Kašík
committed Details | Review
correctly mark texts for translation (1.98 KB, patch)
2013-03-04 11:03 UTC, Marek Kašík
committed Details | Review

Description Till Kamppeter 2012-11-23 21:03:56 UTC
CUPS upstream dropped the CUPS broadcasting/browsing mechanism to automatically discover shared remote printers beginning from 1.6.x. Replacement is Bonjour-based broadcasting odf the shared printers by CUPS and on the client side the application's print dialogs are responsible for browsing these broadcasts and listing the remote printers appropriately. CUPS even provides a library function for that now.

See

https://blueprints.launchpad.net/ubuntu/+spec/desktop-r-cups-bonjour-browsing

I wrote there:

----------
The CUPS Browsing/Broadcasting mechanism which made print queues shared on remote CUPS servers automatically visible for the local CUPS daemon and so for local applications got dropped upstream from CUPS 1.6.x on. Ubpstream has replaced this functionality by Bonjour-based broadcasting (under Linux implemented via Avahi), an OS-indpendent PWG (Printing Working Group) standard, but this lacks the implementation of browsing on the client side making the printers on remote CUPS servers not automatically appearing any more.

Ubuntu Quantal's CUPS has a mega patch to forward-port this functionality from the old CUPS for one cycle, to avoid regressions. We cannot carry such a patch eternally, and we should follow upstream and the PWG standards.

So in Ubuntu Raring we need the real solution which means that the print dialogs (upstream-recommended solution) or the CUPS daemon (how I like to have it) takes the new Bonjour (Avahi) broadcasts to display the shared remote CUPS queues automatically. The browsing functionality is implemented in the CUPS library (libcups) from CUPS 1.6.x on, but there is currently no production code using these functions.

Upstream expects the print dialogs to use the new library functions for displaying the new queues. This would require modifications and upstream submissions for GTK, Qt, and LibreOffice at least and this does not safely cover all existing applications which have CUPS-aware print dialogs and therefore listed the remote queues before. Especially printing from the command line would not be covered.

The better approach would be modifying the CUPS daemon so that it uses the new library function to find the remote queues and advertize them like its own local queues. Where the CUPS daemon needs to be patched for that we could probably derive from Quantal's CUPS Broadcasting/Browsing forward port patch. The new Bonjour browsing patch being based on the new standard way of Bonjour broadcasting has probably good chances to be accepted upstream.

This feature does not only prevent a regression, but it also helps to more easily access printers connected to Mac OS X machines (they broadcasted Bonjour-only all the time) and also for mobile Ubuntu devices. Usually you do not have connected printers to tablets or phones and you carry them around between different local networks, so here it is especially important that they automatically pick up the print queues in the local network.
----------

Such a patch to the CUPS daemon or an extra daemon to do the browsing and add/remove queues appropriately in the local CUPS environment is also not the best solution but a way to avoid regressions with legacy apps.

The real intention from upstream is that all print dialogs browse the print queues available on the local network via Bonjour (under Linux implemented by Avahi), where print queues on the local network are CUPS queues from Linux and Mac OS X but also IPP printers which broadcast themselves via Bonjour (IPP Everywhere printers). Printing on iOS devices (iPhone, iPad, iPod Touch) already works this way. These devices do not allow the setup of local queues at all and they discovcer available print queues via Bonjour.

For this the CUPS library has even special functions, see as sample code the program

cups/testcups.c

to be called as follows:

cups/testcups enum 1

"enum" makes it enumerating printers and the number is the number of seconds to Bonjour-browse for network printers.

The library function is the function cupsEnumDests() in cups/dest.c. For Bonjour browsing it must be called with a non-zero value for the msec parameter.

This feature in the print dialogs is VERY urgent because:

- This is how CUPS upstream and also the PWG (Printing Working Group,
  http://www.pwg.org/) expects how network printing with automatic
  queue discovery works.

- This is less resource-consuming on mobile devices which do not have
  local print queues. avahi-daemon is running anyway and the CUPS
  daemon does not need to be running when there are no local queues.

- CUPS upstream would not most probably not accept patches on the CUPS
  daemon to browse for Bonjour-advertized queues and let them appear
  like local queues.

Therefore I want to ask you to add this feature with priority.

This is urgently needed so that Linux distributions accept CUPS 1.6.x. See also

https://bugzilla.novell.com/show_bug.cgi?id=735404

Could you manage to implement this before the Feature Freeze of Ubuntu 13.04 (Raring) on March 7, 2013? I (and probably also the CUPS maintainers of all the other distros) would appreciate this very much.
Comment 1 Marek Kašík 2012-12-11 12:23:20 UTC
Created attachment 231250 [details] [review]
add avahi support to gtk printing

Hi,

this is first version of patch for addition of avahi support to gtk printing subsystem. It requests printer list from avahi client in cups_get_printer_list(). It requests information about found printers after getting their list (_ipps._tcp and _ipps._tcp services).
This is performed by IPP_GET_PRINTER_ATTRIBUTES posted to host of the printer. I need to test this part with a dnssd-enabled network printer yet.
Actual printing is done by IPP_PRINT_JOB on host of the printer in gtk_print_backend_cups_print_stream().
The patch is not finished yet but I assume that it will not change much.

I have also a question:
Where do we enable this avahi browsing ability?
I don't want to enable this by default for every user. It can be annoying to go through 50 printers each time I want to print. This should be configured somewhere and since CUPS removed required directives for this, we have to have this somewhere else. Is it possible in avahi itself?

Regards

Marek
Comment 2 Matthias Clasen 2012-12-11 15:14:50 UTC
(In reply to comment #1)
> Created an attachment (id=231250) [details] [review]
> add avahi support to gtk printing
> 
> Hi,
> 
> this is first version of patch for addition of avahi support to gtk printing
> subsystem. It requests printer list from avahi client in
> cups_get_printer_list(). It requests information about found printers after
> getting their list (_ipps._tcp and _ipps._tcp services).
> This is performed by IPP_GET_PRINTER_ATTRIBUTES posted to host of the printer.
> I need to test this part with a dnssd-enabled network printer yet.
> Actual printing is done by IPP_PRINT_JOB on host of the printer in
> gtk_print_backend_cups_print_stream().
> The patch is not finished yet but I assume that it will not change much.
> 
> I have also a question:
> Where do we enable this avahi browsing ability?
> I don't want to enable this by default for every user. It can be annoying to go
> through 50 printers each time I want to print. This should be configured
> somewhere and since CUPS removed required directives for this, we have to have
> this somewhere else. Is it possible in avahi itself?
> 

I think avahi probably needs to grow some dbus api for configuring this at runtime, then we can properly integrate it in the control-center.
Comment 3 Matthias Clasen 2012-12-11 16:13:32 UTC
Review of attachment 231250 [details] [review]:

::: modules/printbackends/cups/gtkprintbackendcups.c
@@ +1926,3 @@
+    cups_printer = gtk_printer_cups_new (info->printer_name,
+					 backend,
+					 cups_backend->colord_client);

Thats sad. We loose color management support in this change ?
Comment 4 Marek Kašík 2012-12-11 16:23:25 UTC
(In reply to comment #3)
> Review of attachment 231250 [details] [review]:
> 
> ::: modules/printbackends/cups/gtkprintbackendcups.c
> @@ +1926,3 @@
> +    cups_printer = gtk_printer_cups_new (info->printer_name,
> +                     backend,
> +                     cups_backend->colord_client);
> 
> Thats sad. We loose color management support in this change ?

There were some warnings that colord can not find the device. I'll try harder to make it work :).
Comment 5 Till Kamppeter 2012-12-11 21:21:56 UTC
Marek, first, I want to know why you did not use the cupsEnumDests() function of the CUPS library. What functionality is missing there? What extra functionality did you gain by directly using the Avahi API to implement the Bonjour printer browsing?

About the problem that the user will get his important printers hidden between lost of unwished entries, I suggest to always list "Print to file" at first, then all local printers and after that the Bonjour-discovered remote printers. So the important printers are first in the list and so easy to find.

In addition, a tree view can be used so that one can hide and show the individual groups (Print to file, local printers, remote printers). Also a search line like at the top of the message list in Thunderbird could be helpful.

Perhaps by default Print to file and local printers could be shown and remote printers hidden, where a simple click on the remote printer branch shows the list.

Configurability of the printer list display in the Control Center would be a plus in addition, to my list design suggestions above.
Comment 6 Marek Kašík 2012-12-12 14:11:02 UTC
(In reply to comment #5)
> Marek, first, I want to know why you did not use the cupsEnumDests() function
> of the CUPS library. What functionality is missing there? What extra
> functionality did you gain by directly using the Avahi API to implement the
> Bonjour printer browsing?

For the same reason for which we don't use cupsGetDests(), because it is a blocking call. Avahi has async api.


> About the problem that the user will get his important printers hidden between
> lost of unwished entries, I suggest to always list "Print to file" at first,
> then all local printers and after that the Bonjour-discovered remote printers.
> So the important printers are first in the list and so easy to find.

The problem is that the browsing ability could be disabled before and it can not be now (at least it seems so).
I hoped that there is a "deny-browsing-services=_ipp._tcp, _ipps._tcp" directive in avahi-daemon.conf.


> In addition, a tree view can be used so that one can hide and show the
> individual groups (Print to file, local printers, remote printers). Also a
> search line like at the top of the message list in Thunderbird could be
> helpful.
> 
> Perhaps by default Print to file and local printers could be shown and remote
> printers hidden, where a simple click on the remote printer branch shows the
> list.

I don't want to do such big change now because of addition of support for DNS-SD printers.


> Configurability of the printer list display in the Control Center would be a
> plus in addition, to my list design suggestions above.

Yes, this would be cool to have.

Btw, it seems that I'll have a network printer for testing next week.

Regards

Marek
Comment 7 Till Kamppeter 2012-12-12 16:29:17 UTC
(In reply to comment #6)
> The problem is that the browsing ability could be disabled before and it can
> not be now (at least it seems so).
> I hoped that there is a "deny-browsing-services=_ipp._tcp, _ipps._tcp"
> directive in avahi-daemon.conf.

The browsing is now done by avahi-daemon, and it does it all the time with all kinds of services broadcasting in the local network, independent of clients requesting the info or not. The client (in our case the print dialog) simply filters the "interesting" entries out of avahi-daemon's list. So the easiest is to hide/show the clutter by a button in the print dialog.
Comment 8 Matthias Clasen 2012-12-13 00:20:29 UTC
no 'fix the ui' buttons, please
Comment 9 Marek Kašík 2012-12-19 14:28:19 UTC
Unfortunately, the printer which I have for testing doesn't publish itself using _ipp._tcp ot _ipps._tcp services but only by _printer._tcp.

I'm currently investigating how to not break color management.
Comment 10 Till Kamppeter 2012-12-19 14:50:09 UTC
To get a test printer, set up a printer (CUPS queue) on a remote CUPS server with CUPS 1.6.x or 1.5.x + Avahi patch. Share the queue and turn printer sharing on on the server. Now your patched GTK dialog should see this printer and it should be able to print on it.
Comment 11 Marek Kašík 2012-12-19 15:06:00 UTC
(In reply to comment #10)
> To get a test printer, set up a printer (CUPS queue) on a remote CUPS server
> with CUPS 1.6.x or 1.5.x + Avahi patch. Share the queue and turn printer
> sharing on on the server. Now your patched GTK dialog should see this printer
> and it should be able to print on it.

Thanks, I already have such printer :). I wanted to test a real network printer which share itself over _ipp._tcp or _ipps._tcp and doesn't have a CUPS server behind itself.
Comment 12 Marek Kašík 2012-12-19 16:08:39 UTC
Btw, it is not possible to blacklist a service in avahi configuration. Basically you'll see all services if you have avahi enabled.
Comment 13 Marek Kašík 2013-01-08 17:42:11 UTC
Created attachment 232999 [details] [review]
add avahi support to gtk printing

Hi,

this patch adds the support for avahi browsed printers. It doesn't preserve color-management attributes. I'm working on it but it requires quite a lot of code and it won't probably work in all cases so I'll attach it later or will file separate bug for it.
The patch is ready for review :).

Regards

Marek
Comment 14 Marek Kašík 2013-02-22 14:53:06 UTC
Comment on attachment 232999 [details] [review]
add avahi support to gtk printing

I have almost finished the support for IPP printers which don't have CUPS server. I'll post it soon.
Comment 15 Marek Kašík 2013-02-27 17:03:36 UTC
Created attachment 237539 [details] [review]
add avahi support to gtk printing - modified

Hi,

this patch adds the support for avahi-advertised printers. It supports not just printers advertised by CUPS over Avahi but also standalone printers advertised over Avahi. Standalone printers don't offer a suitable PPD so these are treated as raw printers. The patch correctly prints multiple copies, reversed order, collatted copies and multiple pages per sheet on such printers.

I had to add negotiation about supported IPP version because of standalone printers support. The one I've tested this on supports IPP 1.1 but CUPS communicate using IPP 2.1.

The patch doesn't search for applicable color-management configuration.

The search for avahi-advertised printers is compiled in only when CUPS 1.6 or newer and Avahi are available.

Regards

Marek
Comment 16 Marek Kašík 2013-02-27 17:06:14 UTC
Created attachment 237540 [details] [review]
add setting for listing of Avahi printers

This patch adds setting for listing of printers advertised by Avahi to GtkSettings. Name of the settings is "gtk-list-avahi-printers". Its default value is TRUE.
Comment 17 Matthias Clasen 2013-03-01 04:53:22 UTC
Review of attachment 237539 [details] [review]:

::: modules/printbackends/cups/gtkprintbackendcups.c
@@ +2227,3 @@
+      if (info->is_paused && !info->is_accepting_jobs)
+        /* Translators: this is a printer status. */
+        tmp_msg2 = g_strdup ( N_("Paused ; Rejecting Jobs"));

Why N_() ? We do want to use the translation here, I think
Also, why the space in front of ; ?

@@ +2282,3 @@
+
+      if (reason_msg_desc != NULL)
+        g_free (reason_msg_desc);

g_free handles NULL just fine
Comment 18 Matthias Clasen 2013-03-01 04:54:16 UTC
Review of attachment 237540 [details] [review]:

Is such a setting really useful ? Who would set it, and why ?
Comment 19 Marek Kašík 2013-03-01 10:15:23 UTC
These parts of the patch just move the code which is already there to dedicated functions so we can use them for avahi printers.

(In reply to comment #17)
> Review of attachment 237539 [details] [review]:
> 
> ::: modules/printbackends/cups/gtkprintbackendcups.c
> @@ +2227,3 @@
> +      if (info->is_paused && !info->is_accepting_jobs)
> +        /* Translators: this is a printer status. */
> +        tmp_msg2 = g_strdup ( N_("Paused ; Rejecting Jobs"));
> 
> Why N_() ? We do want to use the translation here, I think
> Also, why the space in front of ; ?

I'll prepare a separate patch for this (string change).

> @@ +2282,3 @@
> +
> +      if (reason_msg_desc != NULL)
> +        g_free (reason_msg_desc);
> 
> g_free handles NULL just fine

I'll change this directly in the patch before committing it if accepted.
Comment 20 Marek Kašík 2013-03-01 10:20:49 UTC
(In reply to comment #18)
> Review of attachment 237540 [details] [review]:
> 
> Is such a setting really useful ? Who would set it, and why ?

I think that at least David would like to have it :) (see https://bugzilla.gnome.org/show_bug.cgi?id=679701).

It was possible to turn off appearing of browsed printers in CUPS but it is not possible now. You have only one option to not show Avahi printers without this patch, you have to disable Avahi.

It is for users which don't want to see all those Avahi printers available on their network.
Comment 21 Marek Kašík 2013-03-04 11:02:11 UTC
Created attachment 237946 [details] [review]
remove unnecessary break

This patch removes the first break.
Comment 22 Marek Kašík 2013-03-04 11:03:01 UTC
Created attachment 237947 [details] [review]
correctly mark texts for translation
Comment 23 Matthias Clasen 2013-03-04 13:31:58 UTC
(In reply to comment #20)
> (In reply to comment #18)
> > Review of attachment 237540 [details] [review] [details]:
> > 
> > Is such a setting really useful ? Who would set it, and why ?
> 
> I think that at least David would like to have it :) (see
> https://bugzilla.gnome.org/show_bug.cgi?id=679701).
> 
> It was possible to turn off appearing of browsed printers in CUPS but it is not
> possible now. You have only one option to not show Avahi printers without this
> patch, you have to disable Avahi.
> 
> It is for users which don't want to see all those Avahi printers available on
> their network.

The thing is, David complained about 'automagically' added printers. But with this setting, they will still be automagically added if you turn it on... We really need a way to control the list of shown printers from the control-center panel.
Comment 24 Marek Kašík 2013-03-04 13:38:09 UTC
Comment on attachment 237539 [details] [review]
add avahi support to gtk printing - modified

Thank you for the review. I've committed this to the master.
Comment 25 Marek Kašík 2013-03-04 13:39:41 UTC
Thank you all for your help. I'm closing this bug.