diff options
-rw-r--r-- | perl-install/printer.pm | 42 | ||||
-rw-r--r-- | perl-install/printerdrake.pm | 32 |
2 files changed, 58 insertions, 16 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm index 52fde82fb..59c5b0c2e 100644 --- a/perl-install/printer.pm +++ b/perl-install/printer.pm @@ -195,20 +195,35 @@ sub read_printer_db(;$) { if (m!^\s*</printer>\s*$!) { # entry completed $inentry = 0; + # Expert mode: # Make one database entry per driver with the entry name # manufacturer|model|driver - my $driver; - for $driver (@{$entry->{drivers}}) { - my $driverstr; - if ($driver eq "Postscript") { - $driverstr = "PostScript"; - } else { - $driverstr = "GhostScript + $driver"; + if ($::expert) { + my $driver; + for $driver (@{$entry->{drivers}}) { + my $driverstr; + if ($driver eq "Postscript") { + $driverstr = "PostScript"; + } else { + $driverstr = "GhostScript + $driver"; + } + if ($driver eq $entry->{defaultdriver}) { + $driverstr .= " (recommended)"; + } + $entry->{ENTRY} = "$entry->{make}|$entry->{model}|$driverstr"; + $entry->{driver} = $driver; + # Duplicate contents of $entry because it is multiply entered to the database + map { $thedb{$entry->{ENTRY}}->{$_} = $entry->{$_} } keys %$entry; + } + } else { + # Recommended mode + # Make one entry per printer, with the recommended + # driver (manufacturerer|model) + $entry->{ENTRY} = "$entry->{make}|$entry->{model}"; + if ($entry->{defaultdriver}) { + $entry->{driver} = $entry->{defaultdriver}; + map { $thedb{$entry->{ENTRY}}->{$_} = $entry->{$_} } keys %$entry; } - $entry->{ENTRY} = "$entry->{make}|$entry->{model}|$driverstr"; - $entry->{driver} = $driver; - # Duplicate contents of $entry because it is multiply entered to the database - map { $thedb{$entry->{ENTRY}}->{$_} = $entry->{$_} } keys %$entry; } $entry = {}; } elsif (m!^\s*<id>\s*([0-9]+)\s*</id>\s*$!) { @@ -220,6 +235,9 @@ sub read_printer_db(;$) { } elsif (m!^\s*<model>(.+)</model>\s*$!) { # Printer model $entry->{model} = $1; + } elsif (m!<driver>(.+)</driver>!) { + # Printer default driver + $entry->{defaultdriver} = $1; } elsif (m!^\s*<drivers>\s*$!) { # Drivers block $indrivers = 1; @@ -238,7 +256,7 @@ sub read_printer_db(;$) { } #- Load CUPS driver database if CUPS is used as spooler - if (($spooler) && ($spooler eq "cups")) { + if (($spooler) && ($spooler eq "cups") && ($::expert)) { #&$install('cups-drivers') unless $::testing; #my $w; #if ($in) { diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm index 18d368e78..9c9106e64 100644 --- a/perl-install/printerdrake.pm +++ b/perl-install/printerdrake.pm @@ -84,8 +84,7 @@ complete => sub { foreach (@parport) { $device eq $_->{port} or next; $printer->{DBENTRY} = - bestMatchSentence($_->{val}{DESCRIPTION}, - keys %printer::thedb); + bestMatchSentence ($_->{val}{DESCRIPTION}, keys %printer::thedb); } 1; } @@ -426,15 +425,40 @@ sub setup_gsdriver($$$;$) { my $make = $printer->{configured}{$queue}{'make'}; my $model = $printer->{configured}{$queue}{'model'}; - $printer->{DBENTRY} = "$make|$model|$driverstr"; - } elsif ($printer->{SPOOLER} eq "cups") { + if ($::expert) { + $printer->{DBENTRY} = "$make|$model|$driverstr"; + # database key contains te "(recommended)" for the + # recommended driver, so add it if necessary + if (!($printer::thedb{$printer->{DBENTRY}}{id})) { + $printer->{DBENTRY} .= " (recommended)"; + } + } else { + $printer->{DBENTRY} = "$make|$model"; + # Make sure that we use the recommended driver + $printer->{currentqueue}{'driver'} = + $printer::thedb{$printer->{DBENTRY}}{driver}; + } + } elsif (($::expert) && ($printer->{SPOOLER} eq "cups")) { # Do we have a native CUPS driver or a PostScript PPD file? $printer->{DBENTRY} = printer::get_descr_from_ppd($printer) || $printer->{DBENTRY}; } + } else { + if (($::expert) && ($printer->{DBENTRY} !~ (recommended))) { + $printer->{DBENTRY} =~ /^([^\|]+)\|([^\|]+)\|/; + my $make = $1; + my $model = $2; + my $key; + for $key (keys %printer::thedb) { + if ($key =~ /^$make\|$model\|.*\(recommended\)$/) { + $printer->{DBENTRY} = $key; + } + } + } } # Choose the printer/driver from the list my $oldchoice = $printer->{DBENTRY}; + $printer->{DBENTRY} = $in->ask_from_treelist (__("Printer model selection"), __("Which printer model do you have?"), '|', |