diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2004-08-19 09:32:51 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2004-08-19 09:32:51 +0000 |
commit | 421c1c957761a2a7da2510458ea9ae7260ac7480 (patch) | |
tree | 7da1214a7cc8fce13730efd47d64670342ffd771 /perl-install | |
parent | 2fd93913c0ac9f0e6daffaa140778f14931a8ea1 (diff) | |
download | drakx-backup-do-not-use-421c1c957761a2a7da2510458ea9ae7260ac7480.tar drakx-backup-do-not-use-421c1c957761a2a7da2510458ea9ae7260ac7480.tar.gz drakx-backup-do-not-use-421c1c957761a2a7da2510458ea9ae7260ac7480.tar.bz2 drakx-backup-do-not-use-421c1c957761a2a7da2510458ea9ae7260ac7480.tar.xz drakx-backup-do-not-use-421c1c957761a2a7da2510458ea9ae7260ac7480.zip |
- Removed installation of "gimpprint" package, it is part of GIMP 2.0.x now.
- Removed configuration of applications, GIMP and OpenOffice.org are patched now so that they do not need configuration of print queues any more.
- Text fix for scanners in HP's multi-function devices.
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/printer/gimp.pm | 361 | ||||
-rw-r--r-- | perl-install/printer/main.pm | 47 | ||||
-rw-r--r-- | perl-install/printer/office.pm | 375 | ||||
-rw-r--r-- | perl-install/printer/printerdrake.pm | 77 |
4 files changed, 8 insertions, 852 deletions
diff --git a/perl-install/printer/gimp.pm b/perl-install/printer/gimp.pm deleted file mode 100644 index 8da3a7625..000000000 --- a/perl-install/printer/gimp.pm +++ /dev/null @@ -1,361 +0,0 @@ -package printer::gimp; - -use strict; -use run_program; -use common; -use printer::common; -use printer::data; -use printer::cups; - -# ------------------------------------------------------------------ -# GIMP-print related stuff -# ------------------------------------------------------------------ - -sub configure { - my ($printer) = @_; - # Do we have files to treat? - my @configfilenames = findconfigfiles(); - return 1 if $#configfilenames < 0; - # There is no system-wide config file, treat every user's config file - foreach my $configfilename (@configfilenames) { - # Load GIMP's printer config file - my $configfilecontent = readconfigfile($configfilename); - # Update local printer queues - foreach my $queue (keys(%{$printer->{configured}})) { - # Check if we have a PPD file - if (! -r "$::prefix/etc/foomatic/$queue.ppd") { - if (-r "$::prefix/etc/cups/ppd/$queue.ppd") { - # If we have a PPD file in the CUPS config dir, link to it - run_program::rooted($::prefix, - "ln", "-sf", - "/etc/cups/ppd/$queue.ppd", - "/etc/foomatic/$queue.ppd"); - } elsif (-r "$::prefix/usr/share/postscript/ppd/$queue.ppd") { - # Check PPD directory of GPR, too - run_program::rooted( - $::prefix, - "ln", "-sf", - "/usr/share/postscript/ppd/$queue.ppd", - "/etc/foomatic/$queue.ppd"); - } else { - # No PPD file at all? We cannot set up this printer - next; - } - } - # Add the printer entry - if (!isprinterconfigured($queue, $configfilecontent)) { - # Remove the old printer entry - $configfilecontent = - removeprinter($queue, $configfilecontent); - # Add the new printer entry - $configfilecontent = - makeprinterentry($printer, $queue, - $configfilecontent); - } - } - # Default printer - if ($printer->{DEFAULT}) { - if ($configfilecontent !~ /^\s*Current\-Printer\s*:/m) { - $configfilecontent =~ - s/\n/\nCurrent-Printer: $printer->{DEFAULT}\n/s; - } else { - if ($configfilecontent =~ /^\s*Current\-Printer\s*:\s*(\S+)\s*$/m && - !isprinterconfigured($1, $configfilecontent)) { - $configfilecontent =~ - s/(Current\-Printer\s*:\s*)\S+/$1$printer->{DEFAULT}/; - } - } - } - # Write back GIMP's printer configuration file - writeconfigfile($configfilename, $configfilecontent); - } - return 1; -} - -sub addcupsremoteto { - my ($printer, $queue) = @_; - # Do we have files to treat? - my @configfilenames = findconfigfiles(); - return 1 if $#configfilenames < 0; - my @printerlist = printer::cups::get_remote_queues(); - my $ppdfile = ""; - if ($printer->{SPOOLER} eq "cups" && - (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { - foreach my $listentry (@printerlist) { - next if $listentry !~ /^([^\|]+)\|([^\|]+)$/; - my $q = $1; - next if $q ne $queue; - my $server = $2; - # Remove server name from queue name - $q =~ s/^([^@]*)@.*$/$1/; - if (-x "$::prefix/usr/bin/wget") { - eval(run_program::rooted( - $::prefix, "/usr/bin/wget", "-O", - "/etc/foomatic/$queue.ppd", - "http://$server:631/printers/$q.ppd")); - } else { - eval(run_program::rooted( - $::prefix, "/usr/bin/curl", "-o", - "/etc/foomatic/$queue.ppd", - "http://$server:631/printers/$q.ppd")); - } - # Does the file exist and is it not an error message? - if (-r "$::prefix/etc/foomatic/$queue.ppd" && - cat_("$::prefix/etc/foomatic/$queue.ppd") =~ /^\*PPD-Adobe/) { - $ppdfile = "/etc/foomatic/$queue.ppd"; - } else { - unlink "$::prefix/etc/foomatic/$queue.ppd"; - return 0; - } - } - } else { return 1 } - # There is no system-wide config file, treat every user's config file - foreach my $configfilename (@configfilenames) { - # Load GIMP's printer config file - my $configfilecontent = readconfigfile($configfilename); - # Add the printer entry - if (!isprinterconfigured($queue, $configfilecontent)) { - # Remove the old printer entry - $configfilecontent = removeprinter($queue, $configfilecontent); - # Add the new printer entry - $configfilecontent = makeprinterentry($printer, $queue, $configfilecontent); - } - # Write back GIMP's printer configuration file - writeconfigfile($configfilename, $configfilecontent); - } - return 1; -} - -sub removeprinterfrom { - my ($_printer, $queue) = @_; - # Do we have files to treat? - my @configfilenames = findconfigfiles(); - return 1 if $#configfilenames < 0; - # There is no system-wide config file, treat every user's config file - foreach my $configfilename (@configfilenames) { - # Load GIMP's printer config file - my $configfilecontent = readconfigfile($configfilename); - # Remove the printer entry - $configfilecontent = removeprinter($queue, $configfilecontent); - # Write back GIMP's printer configuration file - writeconfigfile($configfilename, $configfilecontent); - } - return 1; -} - -sub removelocalprintersfrom { - my ($printer) = @_; - # Do we have files to treat? - my @configfilenames = findconfigfiles(); - return 1 if $#configfilenames < 0; - # There is no system-wide config file, treat every user's config file - foreach my $configfilename (@configfilenames) { - # Load GIMP's printer config file - my $configfilecontent = readconfigfile($configfilename); - # Remove the printer entries - foreach my $queue (keys(%{$printer->{configured}})) { - $configfilecontent = removeprinter($queue, $configfilecontent); - } - # Write back GIMP's printer configuration file - writeconfigfile($configfilename, $configfilecontent); - } - return 1; -} - -sub makeprinterentry { - my ($printer, $queue, $configfile) = @_; - # Make printer's section - $configfile = addprinter($queue, $configfile); - # Load PPD file - my $ppd = cat_("$::prefix/etc/foomatic/$queue.ppd"); - # Is the printer configured with GIMP-Print? - my $gimpprintqueue = 0; - my $gimpprintdriver = "ps2"; - if ($ppd =~ /CUPS\s*\+\s*GIMP\s*\-\s*Print/im) { - # Native CUPS driver - $gimpprintqueue = 1; - $gimpprintdriver = $1 if $ppd =~ /\s*\*ModelName:\s*\"(\S+)\"\s*$/im; - } elsif ($ppd =~ /Foomatic\s*\+\s*gimp\s*\-\s*print/im) { - # GhostScript + Foomatic driver - $gimpprintqueue = 1; - $ppd =~ /\-sModel=((escp2|pcl|bjc|lexmark)\-[^\s\"\']*)/im and - $gimpprintdriver = $1; - } - if ($gimpprintqueue) { - # Get the paper size from the PPD file - if ($ppd =~ /^\s*\*DefaultPageSize:\s*(\S+)\s*$/m) { - my $papersize = $1; - $configfile = removeentry($queue, - "Media-Size", $configfile); - $configfile = addentry($queue, - "Media-Size: $papersize", $configfile); - } - $configfile = removeentry($queue, "PPD-File:", $configfile); - $configfile = addentry($queue, "PPD-File:", $configfile); - $configfile = removeentry($queue, "Driver:", $configfile); - $configfile = addentry($queue, "Driver: $gimpprintdriver", $configfile); - $configfile = removeentry($queue, "Destination:", $configfile); - $configfile = addentry($queue, - sprintf("Destination: /usr/bin/%s -P %s -o raw", $spoolers{$printer->{SPOOLER}}{print_command}, $queue), $configfile); - } else { - $configfile = removeentry($queue, "PPD-File:", $configfile); - $configfile = addentry($queue, "PPD-File: /etc/foomatic/$queue.ppd", $configfile); - $configfile = removeentry($queue, "Driver:", $configfile); - $configfile = addentry($queue, "Driver: ps2", $configfile); - $configfile = removeentry($queue, "Destination:", $configfile); - $configfile = addentry($queue, - sprintf("Destination: /usr/bin/%s -P %s", $spoolers{$printer->{SPOOLER}}{print_command}, $queue), $configfile); - } - return $configfile; -} - -sub findconfigfiles() { - my @configfilenames = (if_(-d "$::prefix/usr/lib/gimp/1.2", ".gimp-1.2/printrc"), - if_(-d "$::prefix/usr/lib/gimp/1.3", ".gimp-1.3/printrc"), - if_(-d "$::prefix/usr/lib/gimp/2.0", ".gimp-2.0/printrc")); - return () unless @configfilenames; - my @filestotreat; - foreach (&list_passwd()) { - last if ($#filestotreat > 50); - my ($username, undef, $uid, $gid, undef, undef, undef, $homedir) = @$_; - next if 0 < $uid && $uid < 500 || $username eq "nobody"; - foreach my $file (@configfilenames) { - my $dir = "$homedir/$file"; - $dir =~ s,/[^/]*$,,; - next if -f $dir; - if (! -d "$::prefix$dir") { - eval { mkdir_p("$::prefix$dir") } or next; - run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", $dir) or next; - } - if (! -f "$::prefix$homedir/$file") { - eval { output("$::prefix$homedir/$file", "#PRINTRCv1 written by GIMP-PRINT 4.2.2 - 13 Sep 2002\n") } or next; - run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", "$homedir/$file") or next; - } - push @filestotreat, "$homedir/$file"; - } - } - @filestotreat; -} - -sub readconfigfile { - my ($file) = @_; - local *F; - open F, "< $::prefix$file" or return ""; - my $filecontent = join("", <F>); - close F; - return $filecontent; -} - -sub writeconfigfile { - my ($file, $filecontent) = @_; - local *F; - open F, "> $::prefix$file" or return 0; - print F $filecontent; - close F; - return 1; -} - -sub addentry { - my ($section, $entry, $filecontent) = @_; - my $sectionfound = 0; - my $entryinserted = 0; - my @lines = pop_spaces(split("\n", $filecontent)); - foreach (@lines) { - if (!$sectionfound) { - $sectionfound = 1 if /^\s*Printer\s*:\s*($section)\s*$/; - } else { - if (!/^\s*$/ && !/^\s*;/) { - $_ = "$entry\n$_"; - $entryinserted = 1; - last; - } - } - } - push(@lines, $entry) if $sectionfound && !$entryinserted; - return join("\n", @lines) . "\n"; -} - -sub addprinter { - my ($section, $filecontent) = @_; - foreach (pop_spaces(split("\n", $filecontent))) { - # section already there, nothing to be done - return $filecontent if /^\s*Printer\s*:\s*($section)\s*$/; - } - return $filecontent . "\nPrinter: $section\n"; -} - -sub pop_spaces { - my @lines = @_; - pop @lines while @lines && $lines[-1] !~ /\S/; -} - -sub removeentry { - my ($section, $entry, $filecontent) = @_; - my $sectionfound; - my @lines = pop_spaces(split(/^/, $filecontent)); - foreach (@lines) { - if (!$sectionfound) { - $sectionfound = /^\s*Printer\s*:\s*($section)\s*$/; - } else { - last if /^\s*Printer\s*:\s*.*\s*$/; # Next section - if (/^\s*$entry/) { - $_ = ""; - last; - } - } - } - return join "", @lines; -} - -sub removeprinter { - my ($section, $filecontent) = @_; - my $sectionfound; - my @lines = pop_spaces(split(/^/, $filecontent)); - foreach (@lines) { - if (!$sectionfound) { - if (/^\s*Printer\s*:\s*($section)\s*$/) { - $_ = ""; - $sectionfound = 1; - } - } else { - last if /^\s*Printer\s*:\s*.*\s*$/; # Next section - $_ = ""; - } - } - return join "", @lines; -} - -sub isprinterconfigured { - my ($queue, $filecontent) = @_; - my $sectionfound = 0; - my $done = 0; - my $drivernotps2 = 0; - my $ppdfileset = 0; - my $nonrawprinting = 0; - foreach (split("\n", $filecontent)) { - if (!$sectionfound) { - if (/^\s*Printer\s*:\s*($queue)\s*$/) { - $sectionfound = 1; - } - } else { - if (/^\s*Printer\s*:\s*.*\s*$/) { # Next section - $done = 1; - last; - } elsif (/^\s*Driver:\s*(\S+)\s*$/) { - $drivernotps2 = $1 ne "ps2"; - } elsif (/^\s*PPD\-File:\s*(\S+)\s*$/) { - $ppdfileset = 1; - } elsif (my ($dest) = /^\s*Destination:\s*(\S+.*)$/) { - $nonrawprinting = $dest !~ /\-o\s*raw/; - } - } - } - return 0 if $done && !$sectionfound; # FIXME: IMPOSSIBLE; should be just $done - return 1 if $ppdfileset || $drivernotps2 || $nonrawprinting; - return 0; -} - - -# ------------------------------------------------------------------ - -1; diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 9f3ed0fee..d6b778e16 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -9,9 +9,7 @@ use run_program; use printer::data; use printer::services; use printer::default; -use printer::gimp; use printer::cups; -use printer::office; use printer::detect; use handle_configs; use services; @@ -1464,8 +1462,8 @@ sub ppd_entry_str { $descr =~ s/Foomatic \+ Postscript/PostScript/; } elsif ($descr =~ /Foomatic/i) { $descr =~ s/Foomatic/GhostScript/i; - } elsif ($descr =~ /CUPS\+GIMP-print/i) { - $descr =~ s/CUPS\+GIMP-print/CUPS + GIMP-Print/i; + } elsif ($descr =~ /CUPS\+Gimp-Print/i) { + $descr =~ s/CUPS\+Gimp-Print/CUPS + Gimp-Print/i; } elsif ($descr =~ /Series CUPS/i) { $descr =~ s/Series CUPS/Series, CUPS/i; } elsif ($descr !~ /(PostScript|GhostScript|CUPS|Foomatic)/i) { @@ -1521,7 +1519,7 @@ sub ppd_entry_str { $model =~ s/BJC\s+/BJC-/; } # New MF devices from Epson have mis-spelled name in PPD files for - # native CUPS drivers of GIMP-Print + # native CUPS drivers of Gimp-Print if ($mf eq "EPSON") { $model =~ s/Stylus CX\-/Stylus CX/; } @@ -1875,7 +1873,6 @@ sub remove_queue($$) { $printer->{ARGS} = {}; $printer->{DBENTRY} = ""; $printer->{currentqueue} = {}; - removeprinterfromapplications($printer, $queue); } sub restart_queue($) { @@ -2624,44 +2621,6 @@ EOF output("$::prefix/etc/mtoolsfm.conf", $mtoolsfmconf); } -# ------------------------------------------------------------------ -# -# Configuration of printers in applications -# -# ------------------------------------------------------------------ - -sub configureapplications { - my ($printer) = @_; - setcupslink($printer); - printer::office::configureoffice('Star Office', $printer); - printer::office::configureoffice('OpenOffice.Org', $printer); - printer::gimp::configure($printer); -} - -sub addcupsremotetoapplications { - my ($printer, $queue) = @_; - setcupslink($printer); - return printer::office::add_cups_remote_to_office('Star Office', $printer, $queue) && - printer::office::add_cups_remote_to_office('OpenOffice.Org', $printer, $queue) && - printer::gimp::addcupsremoteto($printer, $queue); -} - -sub removeprinterfromapplications { - my ($printer, $queue) = @_; - setcupslink($printer); - return printer::office::remove_printer_from_office('Star Office', $printer, $queue) && - printer::office::remove_printer_from_office('OpenOffice.Org', $printer, $queue) && - printer::gimp::removeprinterfrom($printer, $queue); -} - -sub removelocalprintersfromapplications { - my ($printer) = @_; - setcupslink($printer); - printer::office::remove_local_printers_from_office('Star Office', $printer); - printer::office::remove_local_printers_from_office('OpenOffice.Org', $printer); - printer::gimp::removelocalprintersfrom($printer); -} - sub setcupslink { my ($printer) = @_; return 1 if !$::isInstall || $printer->{SPOOLER} ne "cups" || -d "/etc/cups/ppd"; diff --git a/perl-install/printer/office.pm b/perl-install/printer/office.pm deleted file mode 100644 index 4a6ae02b5..000000000 --- a/perl-install/printer/office.pm +++ /dev/null @@ -1,375 +0,0 @@ -package printer::office; - -use strict; -use common; -use run_program; -use printer::data; -use printer::common; -use printer::cups; - -# ------------------------------------------------------------------ -# Star Office/OpenOffice.org -# ------------------------------------------------------------------ - -# OpenOffice.org stuff applies only for Star Office 6.x now, as our -# OpenOffice.org is patched for native CUPS support - -our $suites = { - 'OpenOffice.Org' => { - 'make' => \&makeopenofficeprinterentry, - 'remove' => \&removeopenofficeprinterentry, - 'file_name' => '^(.*)/share/psprint/psprint.conf$', - 'param' => ["Generic Printer", "Command="], - 'perl' => '/usr/bin/perl -p -e "s=/euro /unused=/Euro /unused=" | /usr/bin/', - 'files' => ["/usr/lib/office6*/share/psprint/psprint.conf", - "/usr/local/lib/office6*/share/psprint/psprint.conf", - "/usr/local/office6*/share/psprint/psprint.conf", - "/opt/office6*/share/psprint/psprint.conf"], - }, - 'Star Office' => { - 'make' => \&makestarofficeprinterentry, - 'remove' => \&removestarofficeprinterentry, - 'file_name' => '^(.*)/share/xp3/Xpdefaults$', - 'param' => ["ports", "default_queue="], - 'perl' => '/usr/bin/perl -p -e "s=16#80 /euro=16#80 /Euro=" | /usr/bin/', - 'files' => ["/usr/lib/*/share/xp3/Xpdefaults", - "/usr/local/lib/*/share/xp3/Xpdefaults", - "/usr/local/*/share/xp3/Xpdefaults", - "/opt/*/share/xp3/Xpdefaults"], - } -}; - -sub configureoffice { - my ($suite, $printer) = @_; - # Do we have Star Office installed? - my $configfilename = find_config_file($suite); - return 1 unless $configfilename; - my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; - # Load Star Office printer config file - my $configfilecontent = cat_("$::prefix$configfilename"); - # Update remote CUPS queues - if (0 && $printer->{SPOOLER} eq "cups" && - (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { - my @printerlist = printer::cups::get_remote_queues(); - foreach my $listentry (@printerlist) { - next unless $listentry =~ /^([^\|]+)\|([^\|]+)$/; - my $queue = $1; - my $server = $2; - if (-x "$::prefix/usr/bin/wget") { - eval(run_program::rooted( - $::prefix, "/usr/bin/wget", "-O", - "/etc/foomatic/$queue.ppd", - "http://$server:631/printers/$queue.ppd")); - } else { - eval(run_program::rooted( - $::prefix, "/usr/bin/curl", "-o", - "/etc/foomatic/$queue.ppd", - "http://$server:631/printers/$queue.ppd")); - } - if (-r "$::prefix/etc/foomatic/$queue.ppd") { - $configfilecontent = - $suites->{$suite}{make}($printer, $queue, - $configprefix, - $configfilecontent); - } - } - } - # Update local printer queues - foreach my $queue (keys(%{$printer->{configured}})) { - # Check if we have a PPD file - if (! -r "$::prefix/etc/foomatic/$queue.ppd") { - if (-r "$::prefix/etc/cups/ppd/$queue.ppd") { - # If we have a PPD file in the CUPS config dir, link to it - run_program::rooted($::prefix, - "ln", "-sf", - "/etc/cups/ppd/$queue.ppd", - "/etc/foomatic/$queue.ppd"); - } elsif (-r "$::prefix/usr/share/postscript/ppd/$queue.ppd") { - # Check PPD directory of GPR, too - run_program::rooted($::prefix, - "ln", "-sf", - "/usr/share/postscript/ppd/$queue.ppd", - "/etc/foomatic/$queue.ppd"); - } else { - # No PPD file at all? We cannot set up this printer - next; - } - } - $configfilecontent = - $suites->{$suite}{make}($printer, $queue, $configprefix, - $configfilecontent); - } - # Patch PostScript output to print Euro symbol correctly also for - # the "Generic Printer" - my @parameters = @{$suites->{$suite}{param}}; - $configfilecontent = removeentry($parameters[0], $parameters[1], - $configfilecontent); - $configfilecontent = - addentry($parameters[0], - $parameters[1] . $suites->{$suite}{perl} . - $spoolers{$printer->{SPOOLER}}{print_gui}, - $configfilecontent); - # Write back Star Office configuration file - return eval { output("$::prefix$configfilename", $configfilecontent) }; -} - -sub add_cups_remote_to_office { - my ($suite, $printer, $queue) = @_; - # Do we have Star Office installed? - my $configfilename = find_config_file($suite); - return 1 unless $configfilename; - my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; - # Load Star Office printer config file - my $configfilecontent = cat_("$::prefix$configfilename"); - # Update remote CUPS queues - if ($printer->{SPOOLER} eq "cups" && - (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { - my @printerlist = printer::cups::get_remote_queues(); - foreach my $listentry (@printerlist) { - next unless $listentry =~ /^([^\|]+)\|([^\|]+)$/; - my $q = $1; - next if $q ne $queue; - my $server = $2; - # Remove server name from queue name - $q =~ s/^([^@]*)@.*$/$1/; - if (-x "$::prefix/usr/bin/wget") { - eval(run_program::rooted( - $::prefix, "/usr/bin/wget", "-O", - "/etc/foomatic/$queue.ppd", - "http://$server:631/printers/$q.ppd")); - } else { - eval(run_program::rooted( - $::prefix, "/usr/bin/curl", "-o", - "/etc/foomatic/$queue.ppd", - "http://$server:631/printers/$q.ppd")); - } - # Does the file exist and is it not an error message? - if (-r "$::prefix/etc/foomatic/$queue.ppd" && - cat_("$::prefix/etc/foomatic/$queue.ppd") =~ - /^\*PPD-Adobe/) { - $configfilecontent = - $suites->{$suite}{make}($printer, $queue, - $configprefix, - $configfilecontent); - } else { - unlink "$::prefix/etc/foomatic/$queue.ppd"; - return 0; - } - last if $suite eq 'Star Office'; - } - } - # Write back Star Office configuration file - return eval { output("$::prefix$configfilename", $configfilecontent) }; -} - -sub remove_printer_from_office { - my ($suite, $printer, $queue) = @_; - # Do we have Star Office installed? - my $configfilename = find_config_file($suite); - return 1 unless $configfilename; - my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; - # Load Star Office printer config file - my $configfilecontent = cat_("$::prefix$configfilename"); - # Remove the printer entry - $configfilecontent = - $suites->{$suite}{remove}($printer, $queue, $configprefix, - $configfilecontent); - # Write back Star Office configuration file - return eval { output("$::prefix$configfilename", $configfilecontent) }; -} - -sub remove_local_printers_from_office { - my ($suite, $printer) = @_; - # Do we have Star Office installed? - my $configfilename = find_config_file($suite); - return 1 unless $configfilename; - my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; - # Load Star Office printer config file - my $configfilecontent = cat_("$::prefix$configfilename"); - # Remove the printer entries - foreach my $queue (keys(%{$printer->{configured}})) { - $configfilecontent = - $suites->{$suite}{remove}($printer, $queue, $configprefix, - $configfilecontent); - } - # Write back Star Office configuration file - return eval { output("$::prefix$configfilename", $configfilecontent) }; -} - - -sub makestarofficeprinterentry { - my ($printer, $queue, $configprefix, $configfile) = @_; - # Set default printer - if ($queue eq $printer->{DEFAULT}) { - $configfile = removeentry("windows", "device=", $configfile); - $configfile = addentry("windows", - "device=$queue,$queue PostScript,$queue", - $configfile); - } - # Make an entry in the "[devices]" section - $configfile = removeentry("devices", "$queue=", $configfile); - $configfile = addentry("devices", - "$queue=$queue PostScript,$queue", - $configfile); - # Make an entry in the "[ports]" section - # The "perl" command patches the PostScript output to print the Euro - # symbol correctly. - $configfile = removeentry("ports", "$queue=", $configfile); - $configfile = addentry("ports", - qq($queue=/usr/bin/perl -p -e "s=16#80 /euro=16#80 /Euro=" | /usr/bin/) . $spoolers{$printer->{SPOOLER}}{print_command} . " -P $queue", - $configfile); - # Make printer's section - $configfile = addsection("$queue,PostScript,$queue", $configfile); - # Load PPD file - my $ppd = cat_("$::prefix/etc/foomatic/$queue.ppd"); - # Set the PostScript level - my $pslevel; - if ($ppd =~ /^\s*\*LanguageLevel:\s*\"?([^\s\"]+)\"?\s*$/m) { - $pslevel = $1; - $pslevel = "2" if $pslevel eq "3"; - } else { $pslevel = "2" } - $configfile = removeentry("$queue.PostScript.$queue", - "Level=", $configfile); - $configfile = addentry("$queue.PostScript.$queue", - "Level=$pslevel", $configfile); - # Set Color/BW - my $color = $ppd =~ /^\s*\*ColorDevice:\s*\"?([Tt]rue)\"?\s*$/m ? "1" : "0"; - $configfile = removeentry("$queue.PostScript.$queue", "BitmapColor=", $configfile); - $configfile = addentry("$queue.PostScript.$queue", "BitmapColor=$color", $configfile); - # Set the default paper size - if ($ppd =~ /^\s*\*DefaultPageSize:\s*(\S+)\s*$/m) { - my $papersize = $1; - $configfile = removeentry("$queue.PostScript.$queue", "PageSize=", $configfile); - $configfile = removeentry("$queue.PostScript.$queue", "PPD_PageSize=", $configfile); - $configfile = addentry("$queue.PostScript.$queue", "PageSize=$papersize", $configfile); - $configfile = addentry("$queue.PostScript.$queue", "PPD_PageSize=$papersize", $configfile); - } - # Link the PPD file - run_program::rooted($::prefix, - "ln", "-sf", "/etc/foomatic/$queue.ppd", - "$configprefix/share/xp3/ppds/$queue.PS"); - return $configfile; -} - -sub makeopenofficeprinterentry { - my ($printer, $queue, $configprefix, $configfile) = @_; - # Make printer's section - $configfile = addsection($queue, $configfile); - # Load PPD file - my $ppd = cat_("$::prefix/etc/foomatic/$queue.ppd"); - # "PPD_PageSize" line - if ($ppd =~ /^\s*\*DefaultPageSize:\s*(\S+)\s*$/m) { - my $papersize = $1; - $configfile = removeentry($queue, - "PPD_PageSize=", $configfile); - $configfile = addentry($queue, - "PPD_PageSize=$papersize", $configfile); - } - # "Command" line - # The "perl" command patches the PostScript output to print the Euro - # symbol correctly. - $configfile = removeentry($queue, "Command=", $configfile); - $configfile = addentry($queue, - qq(Command=/usr/bin/perl -p -e "s=/euro /unused=/Euro /unused=" | /usr/bin/) . $spoolers{$printer->{SPOOLER}}{print_command} . " -P $queue", - $configfile); - # "Comment" line - $configfile = removeentry($queue, "Comment=", $configfile); - if ($printer->{configured}{$queue} && - $printer->{configured}{$queue}{queuedata}{desc}) { - $configfile = addentry( - $queue, - "Comment=$printer->{configured}{$queue}{queuedata}{desc}", - $configfile); - } else { - $configfile = addentry($queue, - "Comment=", - $configfile); - } - # "Location" line - $configfile = removeentry($queue, "Location=", $configfile); - if ($printer->{configured}{$queue} && - $printer->{configured}{$queue}{queuedata}{loc}) { - $configfile = addentry( - $queue, - "Location=$printer->{configured}{$queue}{queuedata}{loc}", - $configfile); - } else { - $configfile = addentry($queue, "Location=", $configfile); - } - # "DefaultPrinter" line - $configfile = removeentry($queue, "DefaultPrinter=", $configfile); - my $default = "0"; - if ($queue eq $printer->{DEFAULT}) { - $default = "1"; - # "DefaultPrinter=0" for the "Generic Printer" - $configfile = removeentry("Generic Printer", "DefaultPrinter=", - $configfile); - $configfile = addentry("Generic Printer", - "DefaultPrinter=0", - $configfile); - } - $configfile = addentry($queue, "DefaultPrinter=$default", $configfile); - # "Printer" line - $configfile = removeentry($queue, "Printer=", $configfile); - $configfile = addentry($queue, "Printer=$queue/$queue", $configfile); - # Link the PPD file - run_program::rooted($::prefix, - "ln", "-sf", "/etc/foomatic/$queue.ppd", - "$configprefix/share/psprint/driver/$queue.PS"); - return $configfile; -} - -sub removestarofficeprinterentry { - my ($_printer, $queue, $configprefix, $configfile) = @_; - # Remove default printer entry - $configfile = removeentry("windows", "device=$queue,", $configfile); - # Remove entry in the "[devices]" section - $configfile = removeentry("devices", "$queue=", $configfile); - # Remove entry in the "[ports]" section - $configfile = removeentry("ports", "$queue=", $configfile); - # Remove "[$queue,PostScript,$queue]" section - $configfile = removesection("$queue,PostScript,$queue", $configfile); - # Remove Link of PPD file - run_program::rooted($::prefix, - "rm", "-f", - "$configprefix/share/xp3/ppds/$queue.PS"); - return $configfile; -} - -sub removeopenofficeprinterentry { - my ($_printer, $queue, $configprefix, $configfile) = @_; - # Remove printer's section - $configfile = removesection($queue, $configfile); - # Remove Link of PPD file - run_program::rooted($::prefix, - "rm", "-f", - "$configprefix/share/psprint/driver/$queue.PS"); - return $configfile; -} - -sub find_config_file { - my ($suite) = @_; - my $configfilenames = $suites->{$suite}{files}; - foreach my $configfilename (@$configfilenames) { - local *F; - if (open F, "ls -r $::prefix$configfilename 2> /dev/null |") { - my $filename = <F>; - close F; - if ($filename) { - $filename =~ s/^$::prefix// if $::prefix; - # Work around a bug in the "ls" of "busybox". During - # installation it outputs the mask given on the command line - # instead of nothing when the mask does not match any file - next if $filename =~ /\*/; - return $filename; - } - } - } - return ""; -} - -sub writesofficeconfigfile { - my ($file, $filecontent) = @_; - eval { output("$::prefix$file", $filecontent) }; -} - diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 16ce47230..acf282f8f 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -662,7 +662,6 @@ sub configure_new_printers { # Now install queues for all auto-detected printers which have no queue # yet $printer->{noninteractive} = 1; # Suppress all interactive steps - my $configapps = 0; foreach my $p (@autodetected) { if (!member($p->{port}, @blacklist)) { # Initialize some variables for queue setup @@ -772,7 +771,6 @@ Printerdrake could not determine which model your printer %s is. Please choose t get_printer_info($printer, $in) or next; setup_options($printer, $in) or next; configure_queue($printer, $in) or next; - $configapps = 1; # If there is no default printer set, let this one get the # default if (!$printer->{DEFAULT}) { @@ -787,15 +785,6 @@ Printerdrake could not determine which model your printer %s is. Please choose t $printer->{currentqueue} = {}; $printer->{complete} = 0; } - # Configure the current printer queues in applications - undef $w; - if ($configapps) { - $w = - $in->wait_message(N("Printerdrake"), - N("Configuring applications...")); - printer::main::configureapplications($printer); - undef $w; - } undef $printer->{noninteractive}; } @@ -3316,7 +3305,7 @@ sub scanner_help { # Models with built-in scanner return N("Your multi-function device was configured automatically to be able to scan. Now you can scan with \"scanimage\" (\"scanimage -d hp:%s\" to specify the scanner when you have more than one) from the command line or with the graphical interfaces \"xscanimage\" or \"xsane\". If you are using the GIMP, you can also scan by choosing the appropriate point in the \"File\"/\"Acquire\" menu. Call also \"man scanimage\" on the command line to get more information. -Do not use \"scannerdrake\" for this device!", +You do not need to run \"scannerdrake\" for setting up scanning on this device, you only need to use \"scannerdrake\" if you want to share the scanner on the network.", $ptaldevice); } else { # Scanner-less models @@ -3760,8 +3749,6 @@ sub setup_default_spooler { return; } if ($printer->{SPOOLER} ne $oldspooler) { - # Remove the local printers from Star Office/OpenOffice.org/GIMP - printer::main::removelocalprintersfromapplications($printer); # Get the queues of this spooler { my $_w = $in->wait_message(N("Printerdrake"), @@ -3774,11 +3761,6 @@ sub setup_default_spooler { # has no raw queue) %printer::main::thedb = (); assure_default_printer_is_set($printer, $in); - # Configure the current printer queues in applications - my $_w = - $in->wait_message(N("Printerdrake"), - N("Configuring applications...")); - printer::main::configureapplications($printer); } # Save spooler choice printer::default::set_spooler($printer); @@ -3897,15 +3879,10 @@ sub init { /usr/share/printer-testpages/testprint.ps /usr/bin/nmap /usr/bin/scli - ), - if_(files_exist("/usr/bin/gimp"), - "/usr/lib/gimp/1.2/plug-ins/print") - )) { + ))) { $in->do_pkgs->install('foomatic-db-engine', 'foomatic-filters', 'foomatic-db', 'printer-utils', - 'printer-testpages', 'nmap', 'scli', - if_($in->do_pkgs->is_installed('gimp'), - 'gimpprint')) + 'printer-testpages', 'nmap', 'scli') or do { $in->ask_warn(N("Error"), N("Could not install necessary packages, %s cannot be started!", @@ -3941,13 +3918,6 @@ sub init { printer::default::set_printer($printer); } - # Configure the current printer queues in applications - my $w = - $in->wait_message(N("Printerdrake"), - N("Configuring applications...")); - printer::main::configureapplications($printer); - undef $w; - # Turn on printer autodetection by default $printer->{AUTODETECT} = 1; $printer->{AUTODETECTLOCAL} = 1; @@ -4268,10 +4238,6 @@ sub add_printer { undef $printer->{MANUAL} if $printer->{MANUAL}; $::Wizard_no_previous = 1; setasdefault($printer, $in); - my $_w = $in->wait_message(N("Printerdrake"), - N("Configuring applications...")); - printer::main::configureapplications($printer); - undef $_w; my $testpages = print_testpages($printer, $in, $printer->{TYPE} !~ /LOCAL/ && $upNetwork); if ($testpages == 1) { # User was content with test pages @@ -4310,11 +4276,6 @@ sub add_printer { configure_queue($printer, $in) or return 0; undef $printer->{MANUAL} if $printer->{MANUAL}; setasdefault($printer, $in); - # Configure the current printer queue in applications - my $_w = $in->wait_message(N("Printerdrake"), - N("Configuring applications...")); - printer::main::configureapplications($printer); - undef $_w; my $testpages = print_testpages($printer, $in, $printer->{TYPE} !~ /LOCAL/ && $upNetwork); if ($testpages == 2) { # User was not content with test pages @@ -4336,10 +4297,6 @@ sub edit_printer { # The menu for doing modifications on an existing print queue - # If one, we have to update the application configuration (GIMP, - # StarOffice, ...) - my $configapps = 0; - # Cursor position in queue modification window my $modify = N("Printer options"); @@ -4399,9 +4356,6 @@ What do you want to modify on this printer?", N("Printer options"))) : ()), if_($queue ne $printer->{DEFAULT}, N("Set this printer as the default")), - if_(!$printer->{configured}{$queue}, - N("Add this printer to Star Office/OpenOffice.org/GIMP"), - N("Remove this printer from Star Office/OpenOffice.org/GIMP")), N("Print test pages"), N("Learn how to use this printer"), if_($printer->{configured}{$queue}, N("Remove printer")) ] } ])) { @@ -4452,8 +4406,7 @@ What do you want to modify on this printer?", configure_queue($printer, $in); } elsif ($modify eq N("Printer name, description, location")) { choose_printer_name($printer, $in) && - configure_queue($printer, $in) && - ($configapps = 1); + configure_queue($printer, $in); # Delete old queue when it was renamed if (lc($printer->{QUEUE}) ne lc($printer->{OLD_QUEUE})) { my $_w = $in->wait_message @@ -4475,36 +4428,23 @@ What do you want to modify on this printer?", choose_model($printer, $in) && get_printer_info($printer, $in) && setup_options($printer, $in) && - configure_queue($printer, $in) && - ($configapps = 1); + configure_queue($printer, $in); } elsif ($modify eq N("Printer options")) { get_printer_info($printer, $in) && setup_options($printer, $in) && configure_queue($printer, $in); } elsif ($modify eq N("Set this printer as the default")) { default_printer($printer, $in, $queue); - $configapps = 1; # The "Set this printer as the default" menu entry will # disappear if the printer is the default, so go back to the # default entry $modify = N("Printer options"); - } elsif ($modify eq N("Add this printer to Star Office/OpenOffice.org/GIMP")) { - $in->ask_warn(N("Adding printer to Star Office/OpenOffice.org/GIMP"), - printer::main::addcupsremotetoapplications($printer, $queue) ? - N("The printer \"%s\" was successfully added to Star Office/OpenOffice.org/GIMP.", $queue) : - N("Failed to add the printer \"%s\" to Star Office/OpenOffice.org/GIMP.", $queue)); - } elsif ($modify eq N("Remove this printer from Star Office/OpenOffice.org/GIMP")) { - $in->ask_warn(N("Removing printer from Star Office/OpenOffice.org/GIMP"), - printer::main::removeprinterfromapplications($printer, $queue) ? - N("The printer \"%s\" was successfully removed from Star Office/OpenOffice.org/GIMP.", $queue) : - N("Failed to remove the printer \"%s\" from Star Office/OpenOffice.org/GIMP.", $queue)); } elsif ($modify eq N("Print test pages")) { print_testpages($printer, $in, $upNetwork); } elsif ($modify eq N("Learn how to use this printer")) { printer_help($printer, $in); } elsif ($modify eq N("Remove printer")) { if (remove_printer($printer, $in, $queue)) { - $configapps = 1; # Let the main menu cursor go to the default # position delete $printer->{QUEUE}; @@ -4512,13 +4452,6 @@ What do you want to modify on this printer?", } } - # Configure the current printer queue in applications - if ($configapps) { - my $_w = - $in->wait_message(N("Printerdrake"), - N("Configuring applications...")); - printer::main::configureapplications($printer); - } # Delete some variables cleanup($printer); } else { |