Kurt Pfeifle k1pfeifle at
Sat Nov 3 15:51:46 GMT 2007

John Layt wrote:

> I've now added the CUPS auto-detect code taken from KDEPrint, but I have some 
> issues with it.  The CUPS/IPP service detection fails with 
> QAbstractSocket::ConnectionRefusedError, but that's not fatal as just 
> detecting the config file should be good enough for our purposes.

Are you saying you detect the cupsd.conf config file? And doing so by
searching the local file system?

If so, that is not "good enough". The CUPS daemon to connect to may not
be running locally, but on a remote server.

Also, does the code take into account that the local cupsd may not at
all listen at a TCP/UDP port, but only at a local unix domain socket?

> If there's 
> nothing obviously wrong in the code I'll just leave that check out.
> The bigger problem is that even if CUPS is installed, there's no guarantee 
> that the CUPS version of lpr is installed, and thus that it's safe to pass 
> through the CUPS specific options using -o. 

I think that was one of the reasons why KDE3's printing code had the
"cupsdoprint" helper utility.

> I've looked at how various 
> distros package things and (no surprise) there is no consistant way we can 
> tell if it is installed or not via checking a file exists, and no way I can 
> see to query lpr itself as to its origins.

Can't you look if that lpr binary is linked to libcups? On a shell I'd
do the "ldd $(which lpr)|grep libcups" test...

Also, you may want to take into account that some distros do not install
both CUPS client print commands (lpr, lp); you may not find an "lpr"
binary, but an "lp" one you will...

> Instead, I've put a fallback in 
> place, if CUPS is detected but the lpr returns an error code, blindly try 
> again but without the CUPS options.

KDEPrint3 didn't use the CUPS lpr/lp commands at all. It knew how to
talk IPP to CUPS, and it used "cupsdoprint" as a helper utility.

Kurt Pfeifle
System & Network Printing Consultant ---- Linux/Unix/Windows/Samba/CUPS
Infotec Deutschland GmbH  .....................  Hedelfinger Strasse 58
A RICOH Company  ...........................  D-70327 Stuttgart/Germany

More information about the kde-core-devel mailing list