summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/printer/main.pm44
-rw-r--r--perl-install/printer/printerdrake.pm111
2 files changed, 146 insertions, 9 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index ddadb605d..2bc625ddf 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -1396,6 +1396,36 @@ sub get_direct_uri() {
@direct_uri;
}
+sub checkppd {
+ # Check whether the PPD file is valid
+ my ($printer, $ppdfile) = @_;
+ return 1 if $printer->{SPOOLER} ne "cups";
+ return run_program::rooted($::prefix, "cupstestppd", "-q",
+ $ppdfile);
+}
+
+sub installppd {
+ # Install the PPD file in /usr/share/cups/model/printerdrake/
+ my ($printer, $ppdfile) = @_;
+ return "" if !$ppdfile;
+ # Install PPD file
+ mkdir_p("$::prefix/usr/share/cups/model/printerdrake");
+ # "cp_f()" is broken, it hangs infinitely
+ # cp_f($ppdfile, "$::prefix/usr/share/cups/model/printerdrake");
+ run_program::rooted($::prefix, "cp", "-f", "$ppdfile",
+ "$::prefix/usr/share/cups/model/printerdrake");
+ $ppdfile =~ s!^(.*)(/[^/]+)$!/usr/share/cups/model/printerdrake$2!;
+ chmod 0644, "$::prefix$ppdfile";
+ # Restart CUPS to register new PPD file
+ printer::services::restart("cups") if $printer->{SPOOLER} eq "cups";
+ # Re-read printer database
+ %thedb = ();
+ read_printer_db($printer, $printer->{SPOOLER});
+ # Return description string of the PPD file
+ my $ppdentry = get_descr_from_ppdfile($printer, $ppdfile);
+ return $ppdentry;
+}
+
sub clean_manufacturer_name {
my ($make) = @_;
# Clean some manufacturer's names so that every manufacturer has only
@@ -1508,15 +1538,23 @@ sub ppd_entry_str {
sub get_descr_from_ppd {
my ($printer) = @_;
- my %ppd;
-
#- if there is no ppd, this means this is a raw queue.
if (! -r "$::prefix/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd") {
return "|" . N("Unknown model");
}
+ return get_descr_from_ppdfile($printer, "/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd");
+}
+
+sub get_descr_from_ppdfile {
+ my ($printer, $ppdfile) = @_;
+ my %ppd;
+
+ # Remove ".gz" from end of file name, so that "catMaybeCompressed" works
+ $ppdfile =~ s/\.gz$//;
+
eval {
local $_;
- foreach (cat_("$::prefix/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd")) {
+ foreach (catMaybeCompressed("$::prefix$ppdfile")) {
# "OTHERS|Generic PostScript printer|PostScript (en)";
/^\*([^\s:]*)\s*:\s*\"([^\"]*)\"/ and
do { $ppd{$1} = $2; next };
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 59abb72d2..acf5f3617 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -2317,14 +2317,113 @@ sub choose_model {
$printer->{DBENTRY} = N("Raw printer (No driver)");
}
# Choose the printer/driver from the list
- return($printer->{DBENTRY} = $in->ask_from_treelist(N("Printer model selection"),
- N("Which printer model do you have?") .
- N("
+ my $choice = $printer->{DBENTRY};
+ my $loadppdchosen = 0;
+ while (1) {
+ if ($in->ask_from_({
+ title => N("Printer model selection"),
+ messages => N("Which printer model do you have?") .
+ N("
+
+Please check whether Printerdrake did the auto-detection of your printer model correctly. Find the correct model in the list when a wrong model or \"Raw printer\" is highlighted.")
+ . " " .
+ N("If your printer is not listed, choose a compatible (see printer manual) or a similar one."),
+ #cancel => (""),
+ #ok => (""),
+ }, [
+ # List the printers/drivers
+ { val => \$choice, format => \&translate,
+ sort => 0, separator => "|", tree_expanded => 0,
+ quit_if_double_click => 1, allow_empty_list => 1,
+ list => [ keys %printer::main::thedb ] },
+ # Button to install a manufacturer-supplied PPD file
+ { clicked_may_quit =>
+ sub {
+ $loadppdchosen = 1;
+ 1;
+ },
+ val => N("Install a manufacturer-supplied PPD file") },
+ ])) {
+ $printer->{DBENTRY} = $choice if !$loadppdchosen;
+ } else {
+ return 0;
+ }
+ last if !$loadppdchosen;
+ # Install a manufacturer-supplied PPD file
+ my $ppdentry;
+ if ($ppdentry = installppd($printer, $in)) {
+ $choice = $ppdentry;
+ }
+ $loadppdchosen = 0;
+ }
+ return 1;
+}
+
+sub installppd {
+ my ($printer, $in) = @_;
+
+ # Install a manufacturer-supplied PPD file
+
+ # The dialogs to choose the PPD file should appear as extra
+ # windows and not embedded in the "Add printer" wizard.
+ local $::isWizard = 0;
+
+ my $ppdfile;
+ my ($mediachoice);
+ while (1) {
+ # Tell user about PPD file installation
+ $in->ask_from('Printerdrake',
+ N("Every PostScript printer is delivered with a PPD file which describes the printer's options and features.") . " " .
+ N("This file is usually somewhere on the CD with the Windows and Mac drivers delivered with the printer.") . " " .
+ N("You can find the PPD files also on the manufacturer's web sites.") . " " .
+ N("If you have Windows installed on your machine, you can find the PPD file on your Windows partition, too.") . "\n" .
+ N("Installing the printer's PPD file and using it when setting up the printer makes all options of the printer available which are provided by the printer's hardware") . "\n" .
+ N("Here you can choose the PPD file to be installed on your machine, it will then be used for the setup of your printer."),
+ [
+ { label => N("Install PPD file from"),
+ val => \$mediachoice,
+ list => [N("CD-ROM"),
+ N("Floppy Disk"),
+ N("Other place")],
+ not_edit => 1, sort => 0 },
+ ],
+ ) or return 0;
+ my $dir;
+ if ($mediachoice eq N("CD-ROM")) {
+ $dir = "/mnt/cdrom";
+ } elsif ($mediachoice eq N("Floppy Disk")) {
+ $dir = "/mnt/floppy";
+ } elsif ($mediachoice eq N("Other place")) {
+ $dir = "/mnt";
+ } else {
+ return 0;
+ }
+ # Let user select a PPD file from a floppy, hard disk, ...
+ $ppdfile = $in->ask_file(N("Select PPD file"), "$dir");
+ last if !$ppdfile;
+ if (! -r $ppdfile) {
+ $in->ask_warn('Printerdrake',
+ N("The PPD file %s does not exist or is unreadable!",
+ $ppdfile));
+ next;
+ }
+ if (! printer::main::checkppd($printer, $ppdfile)) {
+ $in->ask_warn('Printerdrake',
+ N("The PPD file %s does not conform with the PPD specifications!",
+ $ppdfile));
+ next;
+ }
+ last;
+ }
-Please check whether Printerdrake did the auto-detection of your printer model correctly. Find the correct model in the list when a wrong model or \"Raw printer\" is highlighted.") . " " .
-N("If your printer is not listed, choose a compatible (see printer manual) or a similar one."), '|',
- [ keys %printer::main::thedb ], $printer->{DBENTRY}));
+ return 0 if !$ppdfile;
+ # Install the PPD file in /usr/share/cups/ppd/printerdrake/
+ my $_w = $in->wait_message(N("Printerdrake"),
+ N("Installing PPD file..."));
+ my $ppdentry = printer::main::installppd($printer, $ppdfile);
+ undef $_w;
+ return $ppdentry;
}
my %lexmarkinkjet_options = (