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

Add AirPrint and Mopria Compatibility #126

Merged
merged 26 commits into from
Mar 11, 2021
Merged

Add AirPrint and Mopria Compatibility #126

merged 26 commits into from
Mar 11, 2021

Conversation

michaelrsweet
Copy link
Member

@michaelrsweet michaelrsweet commented Mar 11, 2021

This pull request adds complete AirPrint and Mopria compatibility to the default configuration of CUPS. Key functionality is:

  • New ReadyPaperSizes directive that specifies the "loaded" (ready) media for each printer; the actual list is based on the supported media sizes for the printer, and allows the user to pick a size from a short list. Default list is based on locale (A4, etc. everywhere but North America which uses Letter, etc.)
  • Proper URF/urf-supported values for image/urf.
  • Other attributes/keys as needed.

The AirPrint functionality was tested from an iPhone Xs and iPad Pro. Ready media correctly lists the set of configured sizes that are supported by the printer. The Mopria functionality was tested from a Windows 10 laptop.

This PR also fixes localization of media-source/InputSlot. See the linked issues for details.

michaelrsweet and others added 21 commits March 7, 2021 17:44
…ia sizes and lookup the (smaller) list of ready sizes.
Don't include application/octet-stream in pdl value.
…slot

Renamed the default for "--with-cups-control-slot" from "admin" to
"cups-control".
If the client Snap is the same as our cupsd is snapped in, grant
access without calling "snapctl". This makes the checks faster and
less resource-consuming if the inquiries are from the command line
tools or the included cups-browsed.
@tillkamppeter
Copy link
Member

tillkamppeter commented Mar 11, 2021

For me everything makes sense and as you have tested with appropriate clients it seems all to work.

Now I have some doubts, but it can be that it is due to restrictions on current CUPS and PPD-file-based print queues.

When I poll the IPP attributes of my HP OfficeJet Pro 8730 with ipptool I get the following URF string:

CP1,MT1-2-8-9-10-11,PQ3-4-5,RS300-600,SRGB24,OB10,W8,DEVW8,DEVRGB24,ADOBERGB24,DM3,FN3,IS1-2,V1.4

"CP1" probably means "1 copy" and this means that for multiple copies in URF the page has to get sent repeatedly? What is what a CUPS queue is capable of here? It seems that you do not add this item.

"MT1-2-8-9-10-11" probably means "MediaType" and AFAIR PAPPL adds it but you do not add it in CUPS. Can it not be derived from the PPD's "MediaType" option?

"PQ3-4-5": You simply add all theree quality levels. Is there no way to determine from the PPD which levels are actually available?

"RS300-600" means that the printer can take URF in 300dpi or 600dpi. Probably CUPS can take URF as input in all the physical printer's resolutions. Your code only adds "RS" expressions with a single value.

"OB10" OutputBin? My printer has only one, what does it exactly mean? Could it be derived from the "outputBin" option of the PPD?

"IS1-2" Probably "InputSlot". My printer has two trays, named "Tray 1" and "Tray 2". Could this also be taken from the PPD?

"FN3" Finishers? My printer has no finishers.

Ar for all these entries equivalen options/drop-downs shown in the print dialog of an iOS device (I have no device to try out)?

Another point is MediaReady. First, I assume that CUPS has nowhere something like "loaded media" as PPDs do not support this, whereas Printer Applications based on PAPPL have "loaded media" and so provide true media-ready information.

So it is principally a good idea to list only the most common sizes based on the default size (A4 or Letter) and from these common sizes only show actually supported sizes. Also makes sense to only show the default size if it is neither A4 or Letter, as these are often specialty printers which can only hold one paper size at a time anyway (and this one one simply sets as default). And if it does not work out for some users one can set it in cupsd.conf.

Once, did you tell in the man pages and cupsd.conf comments that the ready media sizes have to be entered in PPD style?

Also, if the printer behind a CUPS queue is an IPP printer (ipp backend is used, URI starts with ipp(s):// and/or contains _ipp(s)._tcp) would it make sense to carry on the printer's media-ready/media-col-ready attribute?

These are only some ideas (of someone who has no iOS device), if they do not really give any improvement for iOS or Mopria client users, simply do the URF/Mopria support as you are doing it currently.

@michaelrsweet
Copy link
Member Author

@tillkamppeter WRT the URF values:

"CP1" probably means "1 copy" and this means that for multiple copies in URF the page has to get sent repeatedly? What is what a CUPS queue is capable of here? It seems that you do not add this item.

I should add CP1 (and yes it means per-page copies support, so definitely 1 to force the client to generate copies for URF)

"MT1-2-8-9-10-11" probably means "MediaType" and AFAIR PAPPL adds it but you do not add it in CUPS. Can it not be derived from the PPD's "MediaType" option?

It could, but always mirrors the "media-type" value in the job ticket for iOS, macOS, and Mopria clients (or 0 is passed for "default").

"PQ3-4-5": You simply add all theree quality levels. Is there no way to determine from the PPD which levels are actually available?

I can check the cupsPrintQuality option, but like MT you'll never have per-page print quality settings - it's a holdover for a theoretical non-IPP print path (USB before IPP-USB).

"RS300-600" means that the printer can take URF in 300dpi or 600dpi. Probably CUPS can take URF as input in all the physical printer's resolutions. Your code only adds "RS" expressions with a single value.

Right, because a) URF is a fallback path since PDF is supported, and b) spooling huge raster files is inefficient - most printers stream raster data to avoid hitting the disk/SSD but cupsd doesn't support that.

"OB10" OutputBin? My printer has only one, what does it exactly mean? Could it be derived from the "outputBin" option of the PPD?

Yes, however you don't see it embedded in the raster file.

"IS1-2" Probably "InputSlot". My printer has two trays, named "Tray 1" and "Tray 2". Could this also be taken from the PPD?

Yes, and yes. But since we aren't advertising media-ready/media-col-ready values tied to specific InputSlot (media-source) values it won't be used by iOS clients. macOS and Mopria clients use media-source-supported anyways.

"FN3" Finishers? My printer has no finishers.

Yes, IPP finishings enum values. Might be worthwhile to include for iOS for the common ones we can detect, but otherwise clients will exclusively use finishings-supported/finishings-col-supported (which we do report).

Ar for all these entries equivalen options/drop-downs shown in the print dialog of an iOS device (I have no device to try out)?

iOS provides options for copies (independent of the CP value), duplex, color, staple, and media size/type/source (from media-col-ready).

Another point is MediaReady. First, I assume that CUPS has nowhere something like "loaded media" as PPDs do not support this, whereas Printer Applications based on PAPPL have "loaded media" and so provide true media-ready information.

Correct.

So it is principally a good idea to list only the most common sizes based on the default size (A4 or Letter) and from these common sizes only show actually supported sizes. Also makes sense to only show the default size if it is neither A4 or Letter, as these are often specialty printers which can only hold one paper size at a time anyway (and this one one simply sets as default). And if it does not work out for some users one can set it in cupsd.conf.

That's what the current code does - cupsd.conf provides a default set of sizes, and we list the matching sizes from the PPD or the default size if none of the sizes match.

Once, did you tell in the man pages and cupsd.conf comments that the ready media sizes have to be entered in PPD style?

The examples use the PPD size names. I can add a comment to make that explicit (for ReadyPaperSizes and DefaultPaperSize).

Also, if the printer behind a CUPS queue is an IPP printer (ipp backend is used, URI starts with ipp(s):// and/or contains _ipp(s)._tcp) would it make sense to carry on the printer's media-ready/media-col-ready attribute?

No, because a) the value will become out of date quickly and b) that printer is probably accessible directly. This is intended to support AirPrint sharing of legacy or access-limited printers in a controlled environment (think the office copier that only has A4 and A3 loaded in it).

Thanks for the feedback, I'll make the documentation, FN, and CP changes and merge.

jschwender and others added 2 commits March 11, 2021 10:59
this adds a missing translation
@tillkamppeter
Copy link
Member

I have done a quick test now by building the CUPSSnap with the apmo branch of CUPS. The Snap works so far, but if I poll the attributes of a CUPS queue withh ipptool I get an URF string ('V1.4,PQ3-4-5,W8,SRGB24,RS600,DM1`) but the whole get-printer-attributes IPP response does nowhere contain the word "mopria".

On my Pixel 5 (Android 11) I have installed the Mopria app. In the app I only see my printer directly and also some queues of the PostScript Printer Application, but no entry for the queues of the CUPS Snap, probably caused by the missing "mopria" entry. Printer sharing is turned on according to cupsctl.

@michaelrsweet
Copy link
Member Author

Hmm, I didn't update the cache file version so maybe you are still using old cached data?

Also, "mopria-certified" isn't a default ("all" group) attribute - need to add that and some AirPrint-specific attributes to the ipp-support list...

@tillkamppeter
Copy link
Member

What is strange for me is that Mopria does not show the printers.

- Add mopria-certified and printer-wifi-xxx to list of Printer Description
  attributes.
- Bump the PPD cache version to reflect the additional attributes we are adding.
- Update the documentation to note that DefaultPaperSize and ReadyPaperSizes
  contain a list of PPD size names.
- Update urf-supported/URF values to include copies (CP), finishings (FN), and
  print-quality (PQ) values.
@tillkamppeter
Copy link
Member

Solved it, as the printer was auto-created by cups-browsed it was not shared. I have set it shared via the web interface now and now it appears in both ippfind and in the Mopria app. Now all works as expected.

@michaelrsweet
Copy link
Member Author

@tillkamppeter Please re-test from the latest apmo branch code...

[apmo 954d47c] Address review by Till Kamppeter:

@tillkamppeter
Copy link
Member

Mopria app does not show ready media, but it prints the test page.

@michaelrsweet
Copy link
Member Author

Done!

@michaelrsweet michaelrsweet merged commit 51636c9 into master Mar 11, 2021
@michaelrsweet michaelrsweet deleted the apmo branch March 11, 2021 17:41
@tillkamppeter
Copy link
Member

Thank you very much, it is now already on the way into the Snap Store. The first time the CUPS Snap has no patches at all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix localization of InputSlot for IPP Everywhere PPDs Add AirPrint and Mopria compatibility
4 participants