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 725441 - Print Dialog: Add support for PPD-less printing on IPP printers reported by cups-browsed
Print Dialog: Add support for PPD-less printing on IPP printers reported by c...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Printing
3.11.x
Other Linux
: Normal enhancement
: ---
Assigned To: Marek Kašík
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-03-01 13:52 UTC by Till Kamppeter
Modified: 2018-04-15 00:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Update paper size names [1/4] (24.21 KB, patch)
2014-10-02 13:51 UTC, Marek Kašík
committed Details | Review
Create paper size from IPP media name [2/4] (5.62 KB, patch)
2014-10-02 13:53 UTC, Marek Kašík
none Details | Review
Remove dead code from CUPS backend [3/4] (5.41 KB, patch)
2014-10-02 13:54 UTC, Marek Kašík
committed Details | Review
Get paper sizes from IPP query [4/4] (22.95 KB, patch)
2014-10-02 13:57 UTC, Marek Kašík
committed Details | Review
Create paper size from IPP media name (modified) (5.93 KB, patch)
2014-10-06 11:20 UTC, Marek Kašík
committed Details | Review
Get duplex option via IPP (18.17 KB, patch)
2014-10-06 11:48 UTC, Marek Kašík
reviewed Details | Review
Get duplex option via IPP (modified) (18.34 KB, patch)
2014-10-10 11:50 UTC, Marek Kašík
committed Details | Review
Get output bin via IPP (10.58 KB, patch)
2014-10-13 14:14 UTC, Marek Kašík
none Details | Review
Get output bin via IPP (11.53 KB, patch)
2014-10-15 13:48 UTC, Marek Kašík
committed Details | Review

Description Till Kamppeter 2014-03-01 13:52:26 UTC
cups-browsed of cups-filters 1.0.43 and newer is capable of auto-discovering IPP network printers (native printers, not remote CUPS queues) with known page description languages (PostScript, PDF, PWG Raster, PCL) and auto-create PPD-less print queues for them. These queues use a System-V interface script to turn incoming PDF into the printer's native language so that PDF files get printed without needing a printer-model-specific driver.

To be able to get better control over these printers on the client side, the print dialog would need to IPP-query the capabilities of the printer and based on the query result display options like page size, resolution, duplex, print quality, ... Sending the settings as key/value pairs with the option and choice names presented in the answer to the IPP query will the pdftoippprinter filter (called by the queue's System V script) and the printer executing the settings. Also static (not user-settable) parameters (like non-printable margins) can be set to the print queue as key/value pairs like options.

Note that "CreateIPPPrinterQueues Yes" must be set in /etc/cups/cups-browsed.conf to let cups-browsed create such print queues.
Comment 1 Till Kamppeter 2014-03-01 14:02:20 UTC
Code snippets for IPP polling of printer capabilities:

Input:  "uri" is the URI of the IPP printer to poll.

debug_printf() is a wrapper around printf(), printing only if the
program is called with the "--debug" option, you can simply replace it
by the normal printf() for testing.

The code needs libcups.

  #include <cups/cups.h>

  int i, uri_status, port, status;
  http_t *http;
  char scheme[10], userpass[1024], host_name[1024], resource[1024];
  ipp_t *request, *response;
  ipp_attribute_t *attr;
  static const char * const requested_attrs[] =
    {	/* Requested attributes for getting IPP network printer capabilities */
	/* Explicit attribute listings for the case that "all" does not cover
	   everything */
      "job-template",
      "printer-description",
      /*"document-format-supported",
      "color-supported",
      "pages-per-minute",
      "pages-per-minute-color",
      "media-supported",
      "media-ready",
      "media-default",
      "media-type-supported",
      "media-source-supported",*/
      "media-col-database",
      /*"sides-supported",
      "sides-default",
      "output-bin-supported",
      "output-bin-default",
      "finishings-supported",
      "finishings-default",
      "print-color-mode-supported",
      "print-color-mode-default",
      "output-mode-supported",
      "output-mode-default",
      "print-quality-supported",
      "print-quality-default",
      "printer-resolution-supported",
      "printer-resolution-default",
      "copies-supported",
      "copies-default",*/
      /* Catch things which were forgotten above or newly introduced */
      "all"
    };
  static int versions_to_try[] =
    {
      20,
      11
    };

    uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, uri,
				 scheme, sizeof(scheme),
				 userpass, sizeof(userpass),
				 host_name, sizeof(host_name),
				 &(port),
				 resource, sizeof(resource));
    if (uri_status != HTTP_URI_OK)
      goto fail;
    if ((http = httpConnect(host_name, port)) ==
	NULL) {
      debug_printf("cups-browsed: Cannot connect to remote printer %s (%s:%d), ignoring this printer.\n",
		   p->uri, host_name, port);
      goto fail;
    }
    for (i = 0;
	 i < sizeof(versions_to_try) / sizeof(versions_to_try[0]);
	 i ++) {
      /* Create IPP request */
      request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
      /* Set IPP version */
      ippSetVersion(request, versions_to_try[i] / 10, versions_to_try[i] % 10);
      /* Printer URI */
      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
		   "printer-uri", NULL, p->uri);
      /* Requested IPP attributes */
      ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
		    "requested-attributes",
		    sizeof(requested_attrs) / sizeof(requested_attrs[0]),
		    NULL, requested_attrs);
      /* Do it */
      response = cupsDoRequest(http, request, resource);
      if (response == NULL) {
	debug_printf("cups-browsed: No answer to Get-Printer-Attributes IPP request from remote printer %s, ignoring this printer (IPP Error: %s %s).\n",
		     p->uri, ippErrorString(cupsLastError()),
		     cupsLastErrorString());
	httpClose(http);
	goto fail;
      }
      status = cupsLastError();
      debug_printf("cups-browsed: Remote printer %s, IPP %3.1f: %s (%s)\n",
		   p->uri, versions_to_try[i] / 10.0,
		   ippErrorString(cupsLastError()),
		   cupsLastErrorString());
      /* If succeeded, go on, on error try a lower IPP version */
      if (status < 0x0400)
	break;
    }
    if (i >= sizeof(versions_to_try) / sizeof(versions_to_try[0])) {
      /* All IPP versions failed */
      debug_printf("cups-browsed: Remote printer %s: All IPP versions failed\n",
		   p->uri);
      goto fail;
    }
    /* Read out the printer's capabilities */
    attr = ippFirstAttribute(response);
    while (attr) {
      debug_printf("Attr: %s\n",
		   ippGetName(attr));
      for (i = 0; i < ippGetCount(attr); i ++)
	debug_printf("Keyword: %s\n",
		     ippGetString(attr, i, NULL));
      attr = ippNextAttribute(response);
    }
    attr = ippFindAttribute(response,
			    "document-format-supported",
			    IPP_TAG_ZERO);
    if (attr)
      for (i = 0; i < ippGetCount(attr); i ++)
	debug_printf("Format: %s\n",
		     ippGetString(attr, i, NULL));
    else
      debug_printf("No formats\n");

    /* Clean up */
    ippDelete(response);
    httpClose(http);

----------
Comment 2 Marek Kašík 2014-09-22 12:49:15 UTC
I'm working on this bug currently but I'm not sure how much time it will take.

The biggest problem for me is probably that I don't see a way how to get custom options over IPP as I was used via PPD and that there is no support for creating UIs via IPP as in PPD.

I'll try to add support for all known "*-supported" options for printers for which we don't have PPD.
Comment 3 Marek Kašík 2014-10-02 13:51:50 UTC
Created attachment 287588 [details] [review]
Update paper size names [1/4]

This is first set of patches for this bug. This patch updates paper size names in gtk/paper_names.c according to PWG 5101.1-2013 and CUPS' cups/pwg-media.c.
Comment 4 Marek Kašík 2014-10-02 13:53:32 UTC
Created attachment 287589 [details] [review]
Create paper size from IPP media name [2/4]

Add function gtk_paper_size_new_from_ipp() which looks for given name in standard paper size names list and create appropriate GtkPaperSize. It also adds function gtk_paper_size_is_ipp() which returns whether given paper size is an IPP standard paper size.
Comment 5 Marek Kašík 2014-10-02 13:54:24 UTC
Created attachment 287590 [details] [review]
Remove dead code from CUPS backend [3/4]

This patch just removes unused code (which contains function of the same name as we will define in the next patch).
Comment 6 Marek Kašík 2014-10-02 13:57:30 UTC
Created attachment 287591 [details] [review]
Get paper sizes from IPP query [4/4]

This patch queries printer via IPP for paper sizes if there is no or empty PPD file.
It parses "media-supported" and "media-size-supported" attributes for list of paper sizes. It also parses "media-default" and "media-col-default" attributes for default paper size and margins. Unfortunately, the default margins are global so they don't change across with paper sizes (which is a regression from the PPD way).
Comment 7 Marek Kašík 2014-10-02 13:59:10 UTC
I'm working on the other options as well but it is not finished yet.
Comment 8 Matthias Clasen 2014-10-03 16:38:36 UTC
Review of attachment 287588 [details] [review]:

I think this will need to be redone to replace the x by U+00D7 MULTIPLICATION SIGN as I've done in bug 735192.
Sadly, it seems I lost the gen-paper-names.c changes for this, so you may have to wait for me to reconstruct them, or do the change manually.
Comment 9 Marek Kašík 2014-10-06 11:20:29 UTC
Created attachment 287836 [details] [review]
Create paper size from IPP media name (modified)

I forgot to handle translations of the paper names and brackets in a condition.
Comment 10 Marek Kašík 2014-10-06 11:36:29 UTC
(In reply to comment #8)
> Review of attachment 287588 [details] [review]:
> 
> I think this will need to be redone to replace the x by U+00D7 MULTIPLICATION
> SIGN as I've done in bug 735192.
> Sadly, it seems I lost the gen-paper-names.c changes for this, so you may have
> to wait for me to reconstruct them, or do the change manually.

I'm not quite sure what you mean here. I tried to use MULTIPLICATION SIGN at the same places as you did (in translatable strings in "display_name" of PaperInfo struct). I haven't used them for "ppd_name" member of PaperInfo struct.
Comment 11 Marek Kašík 2014-10-06 11:48:14 UTC
Created attachment 287840 [details] [review]
Get duplex option via IPP

This patch creates the gtk-duplex option using IPP's "sides-supported" and "sides-default" attributes if there is no PPD for selected printer.
It passes "sides" option with other options in printer_get_options().
It adds function setup_ipp_option() for creating of IPP option of given name with passed choices and default value and marks such an option as "is-ipp-option" so we can distinguish it later.
Comment 12 Matthias Clasen 2014-10-07 03:18:14 UTC
Review of attachment 287588 [details] [review]:

You are right, I didn't read this carefully enough - looks alright
Comment 13 Matthias Clasen 2014-10-07 03:18:51 UTC
Review of attachment 287590 [details] [review]:

sure
Comment 14 Matthias Clasen 2014-10-07 03:22:18 UTC
Review of attachment 287591 [details] [review]:

didn't read this in detail, but what I saw looks ok
Comment 15 Matthias Clasen 2014-10-07 03:27:06 UTC
Review of attachment 287840 [details] [review]:

::: modules/printbackends/cups/gtkprintbackendcups.c
@@ +5690,3 @@
   /* Always set the corresponding cups-specific setting */
+  if (is_ipp_option)
+    name = g_strdup_printf ("cups-%s", ipp_name);

Are ipp option names prefixed with 'cups', too ?
Comment 16 Matthias Clasen 2014-10-07 03:33:59 UTC
Review of attachment 287836 [details] [review]:

::: gtk/gtkpapersize.c
@@ +758,3 @@
+  return size->is_ipp;
+}
+

Why do we need to know if a papersize 'is ipp' ? Is this information used at any point ?
Comment 17 Marek Kašík 2014-10-07 08:47:50 UTC
(In reply to comment #16)
> Review of attachment 287836 [details] [review]:
> 
> ::: gtk/gtkpapersize.c
> @@ +758,3 @@
> +  return size->is_ipp;
> +}
> +
> 
> Why do we need to know if a papersize 'is ipp' ? Is this information used at
> any point ?

We need to know whether the paper size comes from IPP because of setting right setting in "cups_printers_prepare_for_print()" (whether to set "cups-PageSize" or "cups-media").
Comment 18 Marek Kašík 2014-10-07 09:21:50 UTC
(In reply to comment #15)
> Review of attachment 287840 [details] [review]:
> 
> ::: modules/printbackends/cups/gtkprintbackendcups.c
> @@ +5690,3 @@
>    /* Always set the corresponding cups-specific setting */
> +  if (is_ipp_option)
> +    name = g_strdup_printf ("cups-%s", ipp_name);
> 
> Are ipp option names prefixed with 'cups', too ?

I prefix them also with "cups-" since this is just an internal gtk+ indication that it is an option for CUPS (I think so at least). The prefix is removed before passing it to CUPS (in add_cups_options()).
Comment 19 Matthias Clasen 2014-10-09 23:56:20 UTC
ok, lets get this in
Comment 20 Marek Kašík 2014-10-10 11:42:57 UTC
Thank you for the reviews, I've pushed the patches into master except the one for duplex option. It needs a modification because of translations yet.
Comment 21 Marek Kašík 2014-10-10 11:50:13 UTC
Created attachment 288212 [details] [review]
Get duplex option via IPP (modified)

I've modified this patch so that visible names of IPP choices have context. This will be important for next options since they consist choices like "Left", "Bottom" and so on (for "output-bin"). The context is name of the option to which the choice belong.
Specifically for the duplex option it means that the translation of its choices needs to be duplicated, once without context for the PPD style and once with context for IPP style. But this should be more an exception than a rule.
Comment 22 Matthias Clasen 2014-10-12 22:39:21 UTC
Review of attachment 288212 [details] [review]:

looks fine to me
Comment 23 Marek Kašík 2014-10-13 09:59:08 UTC
Comment on attachment 288212 [details] [review]
Get duplex option via IPP (modified)

(In reply to comment #22)
> Review of attachment 288212 [details] [review]:
> 
> looks fine to me

Thank you for the review. I've pushed the patch to master.
Comment 24 Marek Kašík 2014-10-13 14:14:02 UTC
Created attachment 288391 [details] [review]
Get output bin via IPP

Add support for "output-bin" option processing via IPP
 - request "output-bin-supported" and "output-bin-default" attributes through IPP if there is no PPD for selected printer
 - pass "output-bin" option with other options in printer_get_options()
 - translate standard IPP values of "output-bin" option
Comment 25 Marek Kašík 2014-10-15 13:48:06 UTC
Created attachment 288585 [details] [review]
Get output bin via IPP

I forgot to free used memory here.
Comment 26 Matthias Clasen 2015-06-21 03:18:16 UTC
Review of attachment 288585 [details] [review]:

I've overlooked this patch - if it is still needed, please commit
Comment 27 Marek Kašík 2015-06-23 11:38:28 UTC
Comment on attachment 288585 [details] [review]
Get output bin via IPP

(In reply to Matthias Clasen from comment #26)
> Review of attachment 288585 [details] [review] [review]:
> 
> I've overlooked this patch - if it is still needed, please commit

Thank you for the review. I've pushed the patch to master.
Comment 28 Matthias Clasen 2018-02-10 05:17:53 UTC
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Comment 29 Matthias Clasen 2018-04-15 00:13:28 UTC
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla.

If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab:

https://gitlab.gnome.org/GNOME/gtk/issues/new