summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/main.pm63
-rw-r--r--perl-install/printer/printerdrake.pm4
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};