diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2003-01-21 02:27:57 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2003-01-21 02:27:57 +0000 |
commit | 23d074d2dbac7fd9507b102657cff2a5f2d2da1a (patch) | |
tree | 5638d9658cec29ffc79356f0e0faca3a7a40e902 /perl-install | |
parent | ddc8f09a87fac43c566afa4f9f691ae3f2edc8b6 (diff) | |
download | drakx-backup-do-not-use-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar drakx-backup-do-not-use-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar.gz drakx-backup-do-not-use-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar.bz2 drakx-backup-do-not-use-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar.xz drakx-backup-do-not-use-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.zip |
- Support for manufacturer-supplied PostScript PPDs also in recommended
mode.
- If "Foomatic + Postscript" is recommended driver for a printer and a
manufacturer-supplied PPD file exists for it, the PPD file gets the
recommended driver.
- Tried to extract IEEE-1284 auto-detection info from the PPD files but
this takes too long time (40 sec for 800 PPDs).
- Fixed long-standing bug in activation of auto-load of the USB "printer"
kernel module.
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/printer/main.pm | 63 | ||||
-rw-r--r-- | perl-install/printer/printerdrake.pm | 4 |
2 files changed, 60 insertions, 7 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index c8617a0a2..a63395181 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -506,7 +506,7 @@ sub read_printer_db(;$) { } #- Load CUPS driver database if CUPS is used as spooler - if ($spooler && $spooler eq "cups" && $::expert) { + if ($spooler && $spooler eq "cups") { poll_ppd_base(); } @@ -1497,7 +1497,29 @@ sub get_descr_from_ppd { my $descr = ($ppd{NickName} || $ppd{ShortNickName} || $ppd{ModelName}); my $make = $ppd{Manufacturer}; my $lang = $ppd{LanguageVersion}; - return ppd_entry_str($make, $descr, $lang); + my $entry = ppd_entry_str($make, $descr, $lang); + if (!$::expert) { + # Remove driver from printer list entry when in recommended mode + $entry =~ s/^([^\|]+\|[^\|]+)\|.*$/$1/; + } + return $entry; +} + +sub ppd_devid_data { + my ($ppd) = @_; + $ppd = "$::prefix/usr/share/cups/model/$ppd"; + my @content; + if ($ppd =~ /\.gz$/i) { + @content = cat_("$::prefix/bin/zcat $ppd |") or return ("", ""); + } else { + @content = cat_($ppd) or return ("", ""); + } + my ($devidmake, $devidmodel); + ($_ =~ /^\*Manufacturer:\s*\"(.*)\"\s*$/ and $devidmake = $1) + foreach @content; + ($_ =~ /^\*Product:\s*\"\(?(.*?)\)?\"\s*$/ and $devidmodel = $1) + foreach @content; + return ($devidmake, $devidmodel); } sub poll_ppd_base { @@ -1520,12 +1542,44 @@ sub poll_ppd_base { if ($ppd eq "raw") { next } $ppd && $mf && $descr and do { my $key = ppd_entry_str($mf, $descr, $lang); - $key =~ /^[^\|]\|([^\|])\|([^\|])\|/; + $key =~ /^[^\|]+\|([^\|]+)\|(.*)$/; my ($model, $driver) = ($1, $2); + $driver =~ s/\s+$//; + if (!$::expert) { + # Remove driver from printer list entry when in + # recommended mode + my $simplekey = $key; + $simplekey =~ s/^([^\|]+\|[^\|]+)\|.*$/$1/; + # Only replace the printer entry when it uses a + # "Foomatic + Postscript" driver + next if (defined($thedb{$key}) && + ($thedb{$key}{driver} !~ /PostScript/i)); + $key = $simplekey; + # Remove the old entry + delete $thedb{$key}; + } elsif (defined + $thedb{"$mf|$model|PostScript (recommended)"} && + ($driver =~ /PostScript/i)) { + # Expert mode: "Foomatic + Postscript" driver is + # recommended and this is a PostScript PPD? Make + # this PPD the recommended one + for (keys + %{$thedb{"$mf|$model|PostScript (recommended)"}}) { + $thedb{"$mf|$model|PostScript"}{$_} = + $thedb{"$mf|$model|PostScript (recommended)"}{$_}; + } + delete + $thedb{"$mf|$model|PostScript (recommended)"}; + $key .= " (recommended)"; + } $thedb{$key}{ppd} = $ppd; $thedb{$key}{make} = $mf; $thedb{$key}{model} = $model; $thedb{$key}{driver} = $driver; + # Get auto-detection data + #my ($devidmake, $devidmodel) = ppd_devid_data($ppd); + #$thedb{$key}{devidmake} = $devidmake; + #$thedb{$key}{devidmodel} = $devidmodel; } } close PPDS; @@ -1623,8 +1677,7 @@ sub configure_queue($) { $useUSB ||= (($_->{queuedata}{connect} =~ /usb/i) || ($_->{DeviceURI} =~ /usb/i)); } - $useUSB ||= ($printer->{currentqueue}{queue}{queuedata}{connect} =~ - /usb/i); + $useUSB ||= ($printer->{currentqueue}{connect} =~ /usb/i); if ($useUSB) { my $f = "$::prefix/etc/sysconfig/usb"; my %usb = getVarsFromSh($f); diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 1ad34fbaa..f4100bcab 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -1595,7 +1595,7 @@ sub setup_common { if ($mfg = $printer::main::thedb{$entry}{devidmake}) { $mfg =~ s/Hewlett[-\s_]Packard/HP/; $mfg =~ s/HEWLETT[-\s_]PACKARD/HP/; - if ($mfg ne $automake) { + if (uc($mfg) ne uc($automake)) { $matched = 0; } } @@ -1754,7 +1754,7 @@ sub get_db_entry { $printer->{DBENTRY} = "$make|$model"; } $printer->{OLD_CHOICE} = $printer->{DBENTRY}; - } elsif ($printer->{SPOOLER} eq "cups" && $::expert && + } elsif ($printer->{SPOOLER} eq "cups" && $printer->{configured}{$queue}{queuedata}{ppd}) { # Do we have a native CUPS driver or a PostScript PPD file? $printer->{DBENTRY} = printer::main::get_descr_from_ppd($printer) || $printer->{DBENTRY}; |