Closed Bug 251754 Opened 20 years ago Closed 20 years ago

CUPS support for Mozilla

Categories

(Core :: Printing: Output, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mkaply, Assigned: mkaply)

References

Details

(Keywords: fixed-aviary1.0, fixed1.7.5, relnote)

Attachments

(1 file, 3 obsolete files)

I'd like to add support so that Mozilla can query the list of printers through CUPS.

Eventually we'll do printer settings, but this is a good first start.
*** Bug 251755 has been marked as a duplicate of this bug. ***
Attached patch Query destinations from CUPS (obsolete) — Splinter Review
OK, this is pass one.

If you have the prefs or env variable set (the old way) nothing changes.

If you don't we query from CUPS - I need to add dynamic loading of the CUPS
API.

We also query destinations, not printers explicitly - this provides support for
printer classes, not just printers.

You may wonder why we prepend "Postscript/" to every name - this is because the
print code uses that prefix to decide whether to use Postscript or XPrint - I'm
looking into this.
mkaply:
1. The functionality should live in a seperate XPCOM module to avoid that the
main gfx module depends on CUPS which isn't available on many platforms.
2. The list of destinations returns by the CUPS API must be cached. Anotherwise
it may happen that the print dialog hangs _minutes_ if the CUPS print API has to
wait for (unreachable) printer queues.
1. No, it shouldn't. I'm tired of us creating a new module for every print type
on Linux. This is vrey straightforward - CUPS wll be in the postscript code, and
it will dynload CUPS if it is there.

2. If you cache the printers, you don't get updated printers in the list when
new ones are added. Please provide me a way to recreate this scenario you are
referring to.
(In reply to comment #4)
> 1. No, it shouldn't. I'm tired of us creating a new module for every print 
> type on Linux.
> This is vrey straightforward - CUPS wll be in the postscript code, and
> it will dynload CUPS if it is there.

Do you want to use dlload() ?

> 2. If you cache the printers, you don't get updated printers in the list when
> new ones are added. Please provide me a way to recreate this scenario you are
> referring to.

Simply use network printers via the lpr or JetDirect printer protocols and turn
one of the printers OFF. It may take some time until the spooler will get the
timeout and stop trying to contact it.
Attached patch New patch (obsolete) — Splinter Review
This patch queries CUPS stuff on the fly, so no dependencies on CUPS at all.
Attachment #153428 - Attachment is obsolete: true
Attached patch Better patch (obsolete) — Splinter Review
Don't NS_ERROR_FAILURE if you can't find CUPS, just go the old way.
Attachment #156332 - Attachment is obsolete: true
Attachment #156333 - Flags: superreview?(blizzard)
Attachment #156333 - Flags: review?(pkwarren)
Comment on attachment 156333 [details] [diff] [review]
Better patch

Patch looks fine.  However, just for your information libcups.so doesn't exist
on my machine.	It's called libcups.so.2.
Attachment #156333 - Flags: superreview?(blizzard) → superreview+
Comment on attachment 156333 [details] [diff] [review]
Better patch

>-    if (printerList) {
>+    if (printerList && (strlen(printerList) > 0)) {

You could also do:
      if (printerList && *printerList) {

>+        CupsGetDests = (CupsGetDestsType) PR_FindSymbol( clib, "cupsGetDests");
>+        CupsGetDest = (CupsGetDestType) PR_FindSymbol( clib, "cupsGetDest");
>+        CupsFreeDests = (CupsFreeDestsType) PR_FindSymbol( clib, "cupsFreeDests");

Don't you want to check that these are valid before you reference them?

Also do you need to call PR_UnloadLibrary?
OK, use the .2 and unload the library.

I also did some reformatting to put my variables only in the scope they are
used. I like it like that.
Attachment #156333 - Attachment is obsolete: true
Attachment #156359 - Flags: superreview+
Attachment #156359 - Flags: review?(pkwarren)
Comment on attachment 156359 [details] [diff] [review]
An even better patch

Looks good.
Attachment #156359 - Flags: review?(pkwarren) → review+
Attachment #156359 - Flags: approval1.8a3?
Attachment #156359 - Flags: approval1.7.3?
Comment on attachment 156359 [details] [diff] [review]
An even better patch

unsetting 1.8a3 approval request. we've shipped already.
Attachment #156359 - Flags: approval1.8a3?
Attachment #156333 - Flags: review?(pkwarren)
Attachment #156359 - Flags: approval1.7.3?
Attachment #156359 - Flags: approval1.7.3+
Attachment #156359 - Flags: approval-aviary+
Fix checked in everywhere.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
mkaply, did you not land this on 1.7?  It doesn't appear in 1.7.3
How to set the page format e.g. to A4 for all printers???
I allways see the page beeing letter, CUPS *knows* that there is
only e.g. A4 and A3 (may be others in US)
This was very basic CUPS support that did not involve querying page types from
the printer.
How to disabe CUPS
How to select PERMANENT another printer than the first one?
Why would you want to disable CUPS?
All those Linux users do not want cups, that are not using cups on their system, 
e.g. lprng (that is at now me) 
Or if you got a "silly" installation you do not like.
There are allways people, who want to set up this by hand.
I prefer to have the possibility to use e.g. kdeprint.
It should be enough to set it in about:config to use any external
print command with fixed page size.
So I could set up all A4 pages and use kdeprint instead of lpr...
I'm not using CUPS.
The list for printers is derivated from /etc/printcap as it looks like.
I try to print to CUPS/lp
nothing is printed.
There are remote CUPS server on our net.
I think we have to check for CUPS before using it.
There are ways to override printers using prefs.

I found this on the net:

Printers

There is no GUI for setting these up. Hints suggest setting print.printer_list
to a space separated list of printers. The following comes from my .cfg file, so
uses defaultPref, not user_pref:

defaultPref("print.print_paper_name", "A4");
defaultPref("print.printer_list", "ps2 ps psc");
defaultPref("print.printer_PostScript/ps2.print_command", "lpr -Pps2");
defaultPref("print.printer_PostScript/psc.print_command", "lpr -Ppsc");
defaultPref("print.printer_PostScript/ps.print_command", "lpr -Pps");

The heavily-qualified settings apply to a single printer, whereas the
unqualified ones apply to all printers. Many other options exist.
I do not have ANY *.cfg in the mozilla tree or in the user tree.
Putting this into user_prefs (prefs.js) did not change anything.
It is NOT visible in about:config too.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: