diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2003-01-20 02:48:22 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2003-01-20 02:48:22 +0000 |
commit | 830b8a584925f3152c7efac2009a69fe83f4c5f0 (patch) | |
tree | 517dfa9b6bd6e46aa9d47961267cff740f991782 /perl-install/printer/main.pm | |
parent | 3957374e1ded186023a817a82458f06d15150192 (diff) | |
download | drakx-backup-do-not-use-830b8a584925f3152c7efac2009a69fe83f4c5f0.tar drakx-backup-do-not-use-830b8a584925f3152c7efac2009a69fe83f4c5f0.tar.gz drakx-backup-do-not-use-830b8a584925f3152c7efac2009a69fe83f4c5f0.tar.bz2 drakx-backup-do-not-use-830b8a584925f3152c7efac2009a69fe83f4c5f0.tar.xz drakx-backup-do-not-use-830b8a584925f3152c7efac2009a69fe83f4c5f0.zip |
Improve association of printers with database entries (preparation for
non-interactive print queue generation):
- Make use of device ID strings in the Foomatic database
- Association of generic printers when PDL (PCL, PCL-XL, PostScript) could
be auto-detected
- Cleaned up entries from manufacturer-supplied PPDs for PostScript
printers to try to match model names of Foomatic entries
- Bug fixes on previous association mechanism
Diffstat (limited to 'perl-install/printer/main.pm')
-rw-r--r-- | perl-install/printer/main.pm | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index b45e1f7da..a94f577ab 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -383,6 +383,7 @@ sub read_printer_db(;$) { my $inentry = 0; my $indrivers = 0; my $inautodetect = 0; + my $autodetecttype = ""; local $_; while (<DBPATH>) { chomp; @@ -399,9 +400,31 @@ sub read_printer_db(;$) { } elsif ($inautodetect) { # We are inside the autodetect block of a printers entry # All entries inside this block will be ignored - if (m!^.*</autodetect>\s*$!) { - # End of autodetect block - $inautodetect = 0; + if ($autodetecttype) { + if (m!^.*</$autodetecttype>\s*$!) { + # End of parallel, USB, or SNMP section + $autodetecttype = ""; + } elsif (m!^\s*<manufacturer>\s*([^<>]+)\s*</manufacturer>\s*$!) { + # Manufacturer + $entry->{devidmake} = $1; + } elsif (m!^\s*<model>\s*([^<>]+)\s*</model>\s*$!) { + # Model + $entry->{devidmodel} = $1; + } elsif (m!^\s*<description>\s*([^<>]+)\s*</description>\s*$!) { + # Description + $entry->{deviddesc} = $1; + } elsif (m!^\s*<commandset>\s*([^<>]+)\s*</commandset>\s*$!) { + # Command set + $entry->{devidcmdset} = $1; + } + } else { + if (m!^.*</autodetect>\s*$!) { + # End of autodetect block + $inautodetect = 0; + } elsif (m!^\s*<(parallel|usb|snmp)>\s*$!) { + # Beginning of parallel, USB, or SNMP section + $autodetecttype = $1; + } } } else { if (m!^\s*</printer>\s*$!) { @@ -422,6 +445,9 @@ sub read_printer_db(;$) { $driverstr .= " (recommended)"; } $entry->{ENTRY} = "$entry->{make}|$entry->{model}|$driverstr"; + $entry->{ENTRY} =~ s/^CITOH/C.ITOH/i; + $entry->{ENTRY} =~ + s/^KYOCERA[\s\-]*MITA/KYOCERA/i; $entry->{driver} = $driver; # Duplicate contents of $entry because it is multiply entered to the database map { $thedb{$entry->{ENTRY}}{$_} = $entry->{$_} } keys %$entry; @@ -431,6 +457,9 @@ sub read_printer_db(;$) { # Make one entry per printer, with the recommended # driver (manufacturerer|model) $entry->{ENTRY} = "$entry->{make}|$entry->{model}"; + $entry->{ENTRY} =~ s/^CITOH/C.ITOH/i; + $entry->{ENTRY} =~ + s/^KYOCERA[\s\-]*MITA/KYOCERA/i; if ($entry->{defaultdriver}) { $entry->{driver} = $entry->{defaultdriver}; map { $thedb{$entry->{ENTRY}}{$_} = $entry->{$_} } keys %$entry; @@ -1459,9 +1488,30 @@ sub poll_ppd_base { if ($ppd eq "raw") { next } my ($model, $driver); if ($descr) { - if ($descr =~ /^([^,]+), (.*)$/) { + $descr =~ s/\s*Series//i; + $descr =~ s/\((.*?(PostScript|PS).*?)\)/$1/i; + if (($descr =~ /^([^,]+[^,\s])\s+(PS.*)$/i) || + ($descr =~ /^([^,]+[^,\s])\s*(PostScript.*)$/i) || + ($descr =~ + /^([^,]+[^,\s])\s*(\(\d\d\d\d\.\d\d\d\).*)$/i) || + ($descr =~ + /^([^,]+[^,\s])\s*(v\d+\.\d+.*)$/i) || + ($descr =~ /^([^,]+), (.*)$/)) { $model = $1; $driver = $2; + $model =~ s/[\-\s,]+$//; + $driver =~ + s/\b(PS|PostScript\b)/PostScript/gi; + $driver =~ + s/(PostScript)(.*)(PostScript)/$1$2/i; + $driver =~ + s/^\s*(\(\d\d\d\d\.\d\d\d\)|v\d+\.\d+)([,\s]*)(.*)/$3$2$1/; + $driver =~ s/[\-\s,]+$//; + $driver =~ s/^[\-\s,]+//; + if ($driver !~ /[a-z]/i) { + $driver = "PostScript " . $driver; + $driver =~ s/ $//; + } } else { # Some PPDs do not have the ", <driver>" part. $model = $descr; @@ -1475,6 +1525,7 @@ sub poll_ppd_base { } $ppd && $mf && $descr and do { my $key = "$mf|$model|$driver" . ($lang && " ($lang)"); + $key =~ s/^KYOCERA[\s\-]*MITA/KYOCERA/i; $thedb{$key}{ppd} = $ppd; $thedb{$key}{driver} = $driver; $thedb{$key}{make} = $mf; |