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

ppd-cache.c: Check for urf-supported if image/urf is found #890

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

zdohnal
Copy link
Member

@zdohnal zdohnal commented Feb 13, 2024

Some devices have image/urf in document-format-supported, but is missing urf-supported if AirPrint support is turned off, which breaks PPD generation.

Check for attribute urf-supported when we are about to decide whether the printer uses AirPrint, so in case the device supports another driverless standard, we can use it for PPD generation.

Fixes Fedora issue

Copy link
Member

@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 looks good, just add the check for the other PWG attribute and we should be good.

cups/ppd-cache.c Outdated
is_pdf = ippContainsString(attr, "application/pdf");
is_pwg = ippContainsString(attr, "image/pwg-raster") && !is_apple;
is_pwg = ippContainsString(attr, "image/pwg-raster") && !is_apple &&
(ippFindAttribute(supported, "pwg-raster-document-resolution-supported", IPP_TAG_KEYWORD) != NULL);
Copy link
Member

Choose a reason for hiding this comment

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

You should also look for "pwg-raster-document-type-supported"...

Copy link
Member Author

@zdohnal zdohnal Feb 14, 2024

Choose a reason for hiding this comment

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

@michaelrsweet I thought about the attribute as well (since it is required in the standard too), but according this code further down:

4156   if ((attr = ippFindAttribute(supported, "urf-supported", IPP_TAG_KEYWORD)) == NULL)
4157     if ((attr = ippFindAttribute(supported, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
4158       if ((attr = ippFindAttribute(supported, "print-color-mode-supported", IPP_TAG_KEYWORD)) == NULL)
4159         attr = ippFindAttribute(supported, "output-mode-supported", IPP_TAG_KEYWORD);

we fallback to print-color-mode-supported and output-mode-supported if the attribute is missing. We don't use the attribute anywhere else (AFAIK) in the function, so requiring the attribute would break the PPD generation for such devices.
I aimed PR to match with the existing code, so that's why I didn't check the attribute.

I can add the check, but then I would make further changes. So I see the following possibilities:

  1. add check for the mentioned attribute, and rewrote the code snippet I mentioned to don't do fallback if we have PWG raster,
  2. add extensive check in is_pwg line, incorporating fallbacks there as well,
  3. has the PR as it is.

IMO option 3 provides wider support for possibly broken devices, so I would go with that.

Copy link
Member

Choose a reason for hiding this comment

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

@zdohnal Technically the lack of urf-supported or pwg-raster-document-type-supported means that we have a very low chance of anything working (i.e. if the printer supports PDF but isn't able to print the PDF file we send it, what kind of raster will it accept if it doesn't tell us?)

urf-supported combines the three pwg-raster-document-xxx attributes - resolution (RSn-n-n), type (Wnn, SRGBnn, ADOBERGBnn, etc.), and sheet back (DMn) - that are needed for properly generating raster data. So the Apple Raster (URF) check needs to look at one attribute while the PWG Raster check needs to look at more (pwg-raster-document-{resolution-supported,sheet-back,type-supported} are used for resolution, duplex printing, and color space/bit depth).

Copy link
Member Author

Choose a reason for hiding this comment

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

@michaelrsweet ok, makes sense this way. I'll add check for pwg-raster-document-type-supported.

@tillkamppeter do you want to add it to libppd as well (through direct push to the repo)?

Copy link
Member

Choose a reason for hiding this comment

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

@zdohnal OK, will do for libppd.

Copy link
Member

Choose a reason for hiding this comment

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

Done in OpenPrinting/libppd@c7a62e8c4c37. Thanks for the hint @michaelrsweet and @zdohnal !

@zdohnal zdohnal force-pushed the check-urf-supported branch from 3173be1 to 876ac1a Compare February 14, 2024 14:38
Some devices have `image/urf` in `document-format-supported`, but is
missing `urf-supported` if AirPrint support is turned off, which breaks
PPD generation.

Check for attribute `urf-supported` when we are about to decide whether
the printer uses AirPrint, so in case the device supports another
driverless standard, we can use it for PPD generation.

Fixes [Fedora issue](https://bugzilla.redhat.com/show_bug.cgi?id=2263053)
If the device reports image/pwg-raster and we are about to use it, check
for pwg-raster-document-resolution-supported too.
Copy link
Member

@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.

+1

tillkamppeter added a commit to OpenPrinting/libppd that referenced this pull request Feb 14, 2024
…orted"

If the printer supports printing input in PWG Raster format, it should
not only tell that it accepts PWG Raster in
"document-format-supported" but also provide the attributes with the
specifications of what raster formats are exactly supported, and here
not only resolutions via "pwg-raster-document-resolution-supported"
but also color spaces and depths via
"pwg-raster-document-type-supported". If one of these two attributes
is missing, we disconsider PWG Raster.

See also the discussion in

OpenPrinting/cups#890

Thanks Zdenek Dohnal and Michael Sweet.
@zdohnal zdohnal merged commit df8c1bf into OpenPrinting:master Feb 15, 2024
6 checks passed
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.

3 participants