summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/main.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2003-01-21 02:27:57 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2003-01-21 02:27:57 +0000
commit23d074d2dbac7fd9507b102657cff2a5f2d2da1a (patch)
tree5638d9658cec29ffc79356f0e0faca3a7a40e902 /perl-install/printer/main.pm
parentddc8f09a87fac43c566afa4f9f691ae3f2edc8b6 (diff)
downloaddrakx-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar
drakx-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar.gz
drakx-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar.bz2
drakx-23d074d2dbac7fd9507b102657cff2a5f2d2da1a.tar.xz
drakx-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/printer/main.pm')
-rw-r--r--perl-install/printer/main.pm63
1 files changed, 58 insertions, 5 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);