summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/cups.pm13
-rw-r--r--perl-install/printer/data.pm52
-rw-r--r--perl-install/printer/default.pm8
-rw-r--r--perl-install/printer/detect.pm2
-rw-r--r--perl-install/printer/gimp.pm361
-rw-r--r--perl-install/printer/main.pm504
-rw-r--r--perl-install/printer/office.pm375
-rw-r--r--perl-install/printer/printerdrake.pm1212
8 files changed, 1092 insertions, 1435 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm
index ab9e28b21..64b0df045 100644
--- a/perl-install/printer/cups.pm
+++ b/perl-install/printer/cups.pm
@@ -114,10 +114,10 @@ sub get_formatted_remote_queues {
map {
join('!', if_($printer->{expert}, N("CUPS")), N("Configured on other machines"), $_);
} map {
- my $comment = N("On CUPS server \"%s\"", $_->{ipp}) . ($_->{queuename} eq $printer->{DEFAULT} ? N(" (Default)") : "");
+ my $comment = N("On CUPS server \"%s\"", ($_->{ipp} ? $_->{ipp} : $printer->{remote_cups_server})) . ($_->{queuename} eq $printer->{DEFAULT} ? N(" (Default)") : "");
"$_->{queuename}: $comment";
} grep {
- $_->{ipp} && !$printer->{configured}{$_->{queuename}};
+ !$printer->{configured}{$_->{queuename}};
} lpstat_v();
}
@@ -133,4 +133,13 @@ sub get_remote_queues {
} lpstat_v();
}
+sub queue_enabled {
+ my ($queue) = @_;
+ 0 != grep {
+ /\b$queue\b.*\benabled\b/i
+ } run_program::rooted_get_stdout($::prefix, 'lpstat', '-p', $queue);
+}
+
+
+
1;
diff --git a/perl-install/printer/data.pm b/perl-install/printer/data.pm
index 4a64ead75..75616daf5 100644
--- a/perl-install/printer/data.pm
+++ b/perl-install/printer/data.pm
@@ -6,35 +6,55 @@ use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(%spoolers %spooler_inv %shortspooler_inv
- $kernelversion $usbprintermodule);
+ $kernelversion $usbprintermodule
+ $commonpackages $localqueuepackages);
+# Kernel-specific data
our $kernelversion = `uname -r 2>/dev/null`;
$kernelversion =~ s/^(\s*)(\d+\.\d+)(\..*)$/$2/;
chomp $kernelversion;
our $usbprintermodule = ($kernelversion eq '2.6' ? "usblp" : "printer");
+# Packages which are always needed to run printerdrake
+our $commonpackages = [ [ 'foomatic-db-engine' ],
+ [ '/usr/bin/foomatic-configure' ] ];
+
+# Packages which are needed to create and manage local print queues
+our $localqueuepackages = [ [ 'foomatic-filters', 'foomatic-db',
+ 'printer-utils', 'printer-testpages', 'nmap',
+ 'scli' ],
+ [qw(/usr/bin/foomatic-rip
+ /usr/share/foomatic/db/source/driver/ljet4.xml
+ /usr/bin/escputil
+ /usr/share/printer-testpages/testprint.ps
+ /usr/bin/nmap
+ /usr/bin/scli)] ];
+
+# Spooler-specific data
our %spoolers = ('pdq' => {
'help' => "/usr/bin/pdq -h -P %s 2>&1 |",
'print_command' => 'lpr-pdq',
'print_gui' => 'xpdq',
'long_name' => N("PDQ - Print, Don't Queue"),
'short_name' => N("PDQ"),
+ 'local_queues' => 1,
'packages2add' => [ [ 'pdq' ], [qw(/usr/bin/pdq /usr/X11R6/bin/xpdq)] ],
'alternatives' => [
[ 'lpr', '/usr/bin/lpr-pdq' ],
[ 'lpq', '/usr/bin/lpq-foomatic' ],
[ 'lprm', '/usr/bin/lprm-foomatic' ]
],
- },
- 'lpd' => {
+ },
+ 'lpd' => {
'print_command' => 'lpr-lpd',
'print_gui' => 'gpr',
'long_name' => N("LPD - Line Printer Daemon"),
'short_name' => N("LPD"),
'boot_spooler' => 'lpd',
'service' => 'lpd',
+ 'local_queues' => 1,
'packages2add' => [ [qw(lpr net-tools gpr a2ps ImageMagick)],
[qw(/usr/sbin/lpf
/usr/sbin/lpd
@@ -49,7 +69,7 @@ our %spoolers = ('pdq' => {
[ 'lprm', '/usr/bin/lprm-lpd' ],
[ 'lpc', '/usr/sbin/lpc-lpd' ]
]
- },
+ },
'lprng' => {
'print_command' => 'lpr-lpd',
'print_gui' => 'gpr',
@@ -57,6 +77,7 @@ our %spoolers = ('pdq' => {
'short_name' => N("LPRng"),
'boot_spooler' => 'lpd',
'service' => 'lpd',
+ 'local_queues' => 1,
'packages2add' => [ [qw(LPRng net-tools gpr a2ps ImageMagick)],
[qw(/usr/lib/filters/lpf
/usr/sbin/lpd
@@ -74,7 +95,7 @@ our %spoolers = ('pdq' => {
[ 'lpstat', '/usr/bin/lpstat-lpd' ],
[ 'lpc', '/usr/sbin/lpc-lpd' ]
]
- },
+ },
'cups' => {
'help' => "/usr/bin/lphelp %s |",
'print_command' => 'lpr-cups',
@@ -83,6 +104,7 @@ our %spoolers = ('pdq' => {
'short_name' => N("CUPS"),
'boot_spooler' => 'cups',
'service' => 'cups',
+ 'local_queues' => 1,
'packages2add' => [ ['cups', 'net-tools', 'xpp', 'cups-drivers',
$::isInstall ? 'curl' : 'webfetch'],
[ qw(/usr/lib/cups/cgi-bin/printers.cgi
@@ -102,6 +124,26 @@ our %spoolers = ('pdq' => {
[ 'lpstat', '/usr/bin/lpstat-cups' ],
[ 'lpc', '/usr/sbin/lpc-cups' ]
]
+ },
+ 'rcups' => {
+ 'help' => "/usr/bin/lphelp %s |",
+ 'print_command' => 'lpr-cups',
+ 'print_gui' => 'xpp',
+ 'long_name' => N("CUPS - Common Unix Printing System (remote server)"),
+ 'short_name' => N("Remote CUPS"),
+ 'local_queues' => 0,
+ 'packages2add' => [ ['cups-common', 'xpp'],
+ ['/usr/bin/lpr-cups',
+ '/usr/bin/xpp'] ],
+ 'alternatives' => [
+ [ 'lpr', '/usr/bin/lpr-cups' ],
+ [ 'lpq', '/usr/bin/lpq-cups' ],
+ [ 'lprm', '/usr/bin/lprm-cups' ],
+ [ 'lp', '/usr/bin/lp-cups' ],
+ [ 'cancel', '/usr/bin/cancel-cups' ],
+ [ 'lpstat', '/usr/bin/lpstat-cups' ],
+ [ 'lpc', '/usr/sbin/lpc-cups' ]
+ ]
}
);
our %spooler_inv = map { $spoolers{$_}{long_name} => $_ } keys %spoolers;
diff --git a/perl-install/printer/default.pm b/perl-install/printer/default.pm
index af997fd48..b6f45c889 100644
--- a/perl-install/printer/default.pm
+++ b/perl-install/printer/default.pm
@@ -11,17 +11,21 @@ my $FOOMATIC_DEFAULT_SPOOLER = "$FOOMATICCONFDIR/defaultspooler";
sub set_printer {
my ($printer) = $_[0];
+ my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
run_program::rooted($::prefix, "foomatic-configure",
- "-D", "-q", "-s", $printer->{SPOOLER},
+ "-D", "-q", "-s", $spooler,
"-n", $printer->{DEFAULT}) or return 0;
return 1;
}
sub get_printer {
my $printer = $_[0];
+ my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
local *F;
open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "foomatic-configure -Q -q -s $printer->{SPOOLER} |" or return undef;
+ "foomatic-configure -Q -q -s $spooler |" or return undef;
my $line;
while ($line = <F>) {
if ($line =~ m!^\s*<defaultqueue>(.*)</defaultqueue>\s*$!) {
diff --git a/perl-install/printer/detect.pm b/perl-install/printer/detect.pm
index 71adef0cf..c1f4f3aaa 100644
--- a/perl-install/printer/detect.pm
+++ b/perl-install/printer/detect.pm
@@ -7,7 +7,7 @@ use detect_devices;
use printer::data;
sub local_detect() {
- modules::get_probeall("usb-interface") and eval { modules::load($usbprintermodule) };
+ modules::any_conf->read->get_probeall("usb-interface") and eval { modules::load($usbprintermodule) };
eval { modules::unload(qw(lp parport_pc parport)) }; #- on kernel 2.4 parport has to be unloaded to probe again
eval { modules::load(qw(parport_pc lp)) }; #- take care as not available on 2.4 kernel (silent error).
whatPrinter();
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 fdfbdf317..102d42100 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;
@@ -57,9 +55,9 @@ sub spooler() {
# PDQ is not officially supported any more since version 9.1, so
# show it only in the spooler menu when it was manually installed.
- return map { $spoolers{$_}{long_name} } qw(cups),
+ return map { $spoolers{$_}{long_name} } ('cups', 'rcups' ,
if_(files_exist(qw(/usr/bin/pdq)), 'pdq'),
- if_(files_exist(qw(/usr/lib/filters/lpf /usr/sbin/lpd)), 'lprng');
+ if_(files_exist(qw(/usr/lib/filters/lpf /usr/sbin/lpd)), 'lprng'));
}
sub printer_type($) {
@@ -69,14 +67,15 @@ sub printer_type($) {
/lpd/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($printer->{expert}, qw(POSTPIPE URI))};
/lprng/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($printer->{expert}, qw(POSTPIPE URI))};
/pdq/ and return @printer_type_inv{qw(LOCAL LPD SOCKET), if_($printer->{expert}, qw(URI))};
+ /rcups/ and return ();
}
}
sub SIGHUP_daemon {
my ($service) = @_;
if ($service eq "cupsd") { $service = "cups" };
- # PDQ has no daemon, exit.
- if ($service eq "pdq") { return 1 };
+ # PDQ and remote CUPS have no daemons, exit.
+ if (($service eq "pdq") || ($service eq "rcups")) { return 1 };
# CUPS needs auto-correction for its configuration
run_program::rooted($::prefix, "/usr/sbin/correctcupsconfig") if $service eq "cups";
# Name of the daemon
@@ -126,18 +125,17 @@ sub assure_device_is_available_for_cups {
}
my $maxattempts = 3;
for ($i = 0; $i < $maxattempts; $i++) {
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- '/bin/sh -c "export LC_ALL=C; /usr/sbin/lpinfo -v" |' or
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ '/bin/sh -c "export LC_ALL=C; /usr/sbin/lpinfo -v" |') or
die 'Could not run "lpinfo"!';
- while (my $line = <F>) {
+ while (my $line = <$F>) {
if ($line =~ /$sdevice/) { # Found a line containing the device
# name, so CUPS knows it.
- close F;
+ close $F;
return 1;
}
}
- close F;
+ close $F;
$result = printer::services::restart("cups");
}
return $result;
@@ -151,15 +149,14 @@ sub spooler_in_security_level {
$sp = $spooler eq "lpr" || $spooler eq "lprng" ? "lpd" : $spooler;
my $file = "$::prefix/etc/security/msec/server.$level";
if (-f $file) {
- local *F;
- open F, "< $file" or return 0;
- while (my $line = <F>) {
+ open(my $F, "< $file") or return 0;
+ while (my $line = <$F>) {
if ($line =~ /^\s*$sp\s*$/) {
- close F;
+ close $F;
return 1;
}
}
- close F;
+ close $F;
}
return 0;
}
@@ -223,24 +220,26 @@ sub read_configured_queues($) {
$printer->{SPOOLER} ||= printer::default::get_spooler();
if (!$printer->{SPOOLER}) {
#- Find the first spooler where there are queues
- foreach my $spooler (qw(cups pdq lprng lpd)) {
+ foreach my $spooler (qw(rcups cups pdq lprng lpd)) {
#- Is the spooler's daemon running?
my $service = $spooler;
if ($service eq "lprng") {
$service = "lpd";
}
- if ($service ne "pdq") {
+ if (($service ne "pdq") && ($service ne "rcups")) {
next unless services::is_service_running($service);
# daemon is running, spooler found
$printer->{SPOOLER} = $spooler;
}
- #- poll queue info
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "foomatic-configure -P -q -s $spooler |" or
- die "Could not run foomatic-configure";
- eval join('', <F>);
- close F;
+ #- poll queue info
+ if ($service ne "rcups") {
+ open(my $F, ($::testing ?
+ $::prefix : "chroot $::prefix/ ") .
+ "foomatic-configure -P -q -s $spooler |") or
+ die "Could not run foomatic-configure";
+ eval join('', <$F>);
+ close $F;
+ }
if ($service eq "pdq") {
#- Have we found queues? PDQ has no damon, so we consider
#- it in use when there are defined printer queues
@@ -248,6 +247,17 @@ sub read_configured_queues($) {
$printer->{SPOOLER} = $spooler;
last;
}
+ } elsif ($service eq "rcups") {
+ #- In daemon-less CUPS mode there are no local queues,
+ #- we can only recognize it by a server entry in
+ #- /etc/cups/client.conf
+ my ($daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
+ if ($daemonless_cups) {
+ $printer->{SPOOLER} = $spooler;
+ $printer->{remote_cups_server} = $remote_cups_server;
+ last;
+ }
} else {
#- For other spoolers we have already found a running
#- daemon when we have arrived here
@@ -255,13 +265,18 @@ sub read_configured_queues($) {
}
}
} else {
- #- Poll the queues of the current default spooler
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "foomatic-configure -P -q -s $printer->{SPOOLER} -r |" or
- die "Could not run foomatic-configure";
- eval join('', <F>);
- close F;
+ if ($printer->{SPOOLER} ne "rcups") {
+ #- Poll the queues of the current default spooler
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ "foomatic-configure -P -q -s $printer->{SPOOLER} -r |") or
+ die "Could not run foomatic-configure";
+ eval join('', <$F>);
+ close $F;
+ } else {
+ my ($_daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
+ $printer->{remote_cups_server} = $remote_cups_server;
+ }
}
$printer->{configured} = {};
my $i;
@@ -286,14 +301,13 @@ sub read_configured_queues($) {
}
# Read out which PPD file was originally used to set up this
# queue
- local *F;
- if (open F, "< $::prefix/etc/cups/ppd/$QUEUES[$i]{queuedata}{queue}.ppd") {
- while (my $line = <F>) {
+ if (open(my $F, "< $::prefix/etc/cups/ppd/$QUEUES[$i]{queuedata}{queue}.ppd")) {
+ while (my $line = <$F>) {
if ($line =~ /^\*%MDKMODELCHOICE:(.+)$/) {
$printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{ppd} = $1;
}
}
- close F;
+ close $F;
}
# Mark that we have a CUPS queue but do not know the name
# the PPD file in /usr/share/cups/model
@@ -357,21 +371,27 @@ sub make_menuentry {
$connection = N(", multi-function device");
}
} elsif ($connect =~ m!^file:(.+)$!) {
- $connection = N(", printing to %s", $1);
+ my $file = $1;
+ $connection = N(", printing to %s", $file);
} elsif ($connect =~ m!^lpd://([^/]+)/([^/]+)/?$!) {
- $connection = N(" on LPD server \"%s\", printer \"%s\"", $1, $2);
+ my ($server, $printer) = ($1, $2);
+ $connection = N(" on LPD server \"%s\", printer \"%s\"", $server, $printer);
} elsif ($connect =~ m!^socket://([^/:]+):([^/:]+)/?$!) {
- $connection = N(", TCP/IP host \"%s\", port %s", $1, $2);
+ my ($host, $port) = ($1, $2);
+ $connection = N(", TCP/IP host \"%s\", port %s", $host, $port);
} elsif ($connect =~ m!^smb://([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^smb://.*/([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^smb://.*\@([^/\@]+)/([^/\@]+)/?$!) {
- $connection = N(" on SMB/Windows server \"%s\", share \"%s\"", $1, $2);
+ my ($server, $share) = ($1, $2);
+ $connection = N(" on SMB/Windows server \"%s\", share \"%s\"", $server, $share);
} elsif ($connect =~ m!^ncp://([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^ncp://.*/([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^ncp://.*\@([^/\@]+)/([^/\@]+)/?$!) {
- $connection = N(" on Novell server \"%s\", printer \"%s\"", $1, $2);
+ my ($server, $printer) = ($1, $2);
+ $connection = N(" on Novell server \"%s\", printer \"%s\"", $server, $printer);
} elsif ($connect =~ m!^postpipe:(.+)$!) {
- $connection = N(", using command %s", $1);
+ my $command = $1;
+ $connection = N(", using command %s", $command);
} else {
$connection = ($printer->{expert} ? ", URI: $connect" : "");
}
@@ -408,21 +428,27 @@ sub connectionstr {
$connection = N("Multi-function device");
}
} elsif ($connect =~ m!^file:(.+)$!) {
- $connection = N("Prints into %s", $1);
+ my $file = $1;
+ $connection = N("Prints into %s", $file);
} elsif ($connect =~ m!^lpd://([^/]+)/([^/]+)/?$!) {
- $connection = N("LPD server \"%s\", printer \"%s\"", $1, $2);
+ my ($server, $port) = ($1, $2);
+ $connection = N("LPD server \"%s\", printer \"%s\"", $server, $port);
} elsif ($connect =~ m!^socket://([^/:]+):([^/:]+)/?$!) {
- $connection = N("TCP/IP host \"%s\", port %s", $1, $2);
+ my ($host, $port) = ($1, $2);
+ $connection = N("TCP/IP host \"%s\", port %s", $host, $port);
} elsif ($connect =~ m!^smb://([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^smb://.*/([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^smb://.*\@([^/\@]+)/([^/\@]+)/?$!) {
- $connection = N("SMB/Windows server \"%s\", share \"%s\"", $1, $2);
+ my ($server, $share) = ($1, $2);
+ $connection = N("SMB/Windows server \"%s\", share \"%s\"", $server, $share);
} elsif ($connect =~ m!^ncp://([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^ncp://.*/([^/\@]+)/([^/\@]+)/?$! ||
$connect =~ m!^ncp://.*\@([^/\@]+)/([^/\@]+)/?$!) {
- $connection = N("Novell server \"%s\", printer \"%s\"", $1, $2);
+ my ($server, $share) = ($1, $2);
+ $connection = N("Novell server \"%s\", printer \"%s\"", $server, $share);
} elsif ($connect =~ m!^postpipe:(.+)$!) {
- $connection = N("Uses command %s", $1);
+ my $command = $1;
+ $connection = N("Uses command %s", $command);
} else {
$connection = N("URI: %s", $connect);
}
@@ -433,11 +459,14 @@ sub read_printer_db {
my ($printer, $spooler) = @_;
- local *DBPATH; #- don't have to do close ... and don't modify globals at least
+ # No local queues available in daemon-less CUPS mode
+ return 1 if $spooler eq "rcups";
+
+ my $DBPATH; #- don't have to do close ... and don't modify globals at least
# Generate the Foomatic printer/driver overview, read it from the
# appropriate file when it is already generated
- open DBPATH, ($::testing ? $::prefix : "chroot $::prefix/ ") . #-#
- "foomatic-configure -O -q |" or
+ open($DBPATH, ($::testing ? $::prefix : "chroot $::prefix/ ") . #-#
+ "foomatic-configure -O -q |") or
die "Could not run foomatic-configure";
my $entry = {};
@@ -446,7 +475,7 @@ sub read_printer_db {
my $inautodetect = 0;
my $autodetecttype = "";
local $_;
- while (<DBPATH>) {
+ while (<$DBPATH>) {
chomp;
if ($inentry) {
# We are inside a printer entry
@@ -566,7 +595,7 @@ sub read_printer_db {
}
}
}
- close DBPATH;
+ close $DBPATH;
# Add raw queue
$entry->{ENTRY} = N("Raw printer (No driver)");
@@ -592,18 +621,17 @@ sub read_foomatic_options ($) {
my ($printer) = @_;
# Generate the option data for the chosen printer/driver combo
my $COMBODATA;
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
"foomatic-configure -P -q -p $printer->{currentqueue}{printer}" .
" -d $printer->{currentqueue}{driver}" .
($printer->{OLD_QUEUE} ?
" -s $printer->{SPOOLER} -n $printer->{OLD_QUEUE}" : "") .
($printer->{SPECIAL_OPTIONS} ?
" $printer->{SPECIAL_OPTIONS}" : "")
- . " |" or
+ . " |") or
die "Could not run foomatic-configure";
- eval join('', (<F>));
- close F;
+ eval join('', (<$F>));
+ close $F;
# Return the arguments field
return $COMBODATA->{args};
}
@@ -612,18 +640,17 @@ sub read_ppd_options ($) {
my ($printer) = @_;
# Generate the option data for a given PPD file
my $COMBODATA;
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
"foomatic-configure -P -q" .
" --ppd /usr/share/cups/model/$printer->{currentqueue}{ppd}" .
($printer->{OLD_QUEUE} ?
" -s $printer->{SPOOLER} -n $printer->{OLD_QUEUE}" : "") .
($printer->{SPECIAL_OPTIONS} ?
" $printer->{SPECIAL_OPTIONS}" : "")
- . " |" or
+ . " |") or
die "Could not run foomatic-configure";
- eval join('', (<F>));
- close F;
+ eval join('', (<$F>));
+ close $F;
# Return the arguments field
return $COMBODATA->{args};
}
@@ -631,7 +658,7 @@ sub read_ppd_options ($) {
my %sysconfig = getVarsFromSh("$::prefix/etc/sysconfig/printing");
sub set_cups_special_options {
- my ($queue) = $_[0];
+ my ($queue) = @_;
# Set some special CUPS options
my @lpoptions = chomp_(cat_("$::prefix/etc/cups/lpoptions"));
# If nothing is already configured, set text file borders of half an inch
@@ -675,6 +702,10 @@ sub get_usermode() { $sysconfig{USER_MODE} eq 'expert' ? 1 : 0 }
sub set_jap_textmode {
my $textmode = ($_[0] ? 'cjk' : '');
+ # Do not write mime.convs if the file does not exist, as then
+ # CUPS is not installed and the created mime.convs will be broken.
+ # When installing CUPS later it will not work.
+ return 1 if (! -r "$::prefix/etc/cups/mime.convs");
substInFile {
s!^(\s*text/plain\s+\S+\s+\d+\s+)\S+(\s*$)!$1${textmode}texttops$2!
} "$::prefix/etc/cups/mime.convs";
@@ -692,15 +723,45 @@ sub get_jap_textmode() {
# Handling of /etc/cups/cupsd.conf
sub read_cupsd_conf() {
- cat_("$::prefix/etc/cups/cupsd.conf");
+ # If /etc/cups/cupsd.conf a default cupsd.conf will be put out to avoid
+ # writing of a broken cupsd.conf file when we write it back later.
+ my @cupsd_conf = cat_("$::prefix/etc/cups/cupsd.conf");
+ if (!@cupsd_conf) {
+ @cupsd_conf = map { /\n$/s or "$_\n" } split('\n',
+'LogLevel info
+TempDir /var/spool/cups/tmp
+Port 631
+Browsing On
+BrowseAddress @LOCAL
+BrowseDeny All
+BrowseAllow 127.0.0.1
+BrowseAllow @LOCAL
+BrowseOrder deny,allow
+<Location />
+Order Deny,Allow
+Deny From All
+Allow From 127.0.0.1
+Allow From @LOCAL
+</Location>
+<Location /admin>
+AuthType Basic
+AuthClass System
+Order Deny,Allow
+Deny From All
+Allow From 127.0.0.1
+</Location>
+');
+ }
+ return @cupsd_conf;
}
+
sub write_cupsd_conf {
my (@cupsd_conf) = @_;
-
+ # Do not write cupsd.conf if the file does not exist, as then
+ # CUPS is not installed and the created cupsd.conf will be broken.
+ # When installing CUPS later it will not start.
+ return 1 if (! -r "$::prefix/etc/cups/cupsd.conf");
output("$::prefix/etc/cups/cupsd.conf", @cupsd_conf);
-
- #- restart cups after updating configuration.
- printer::services::restart("cups");
}
sub read_location {
@@ -719,7 +780,7 @@ sub read_location {
my $location_end = -1;
# Go through all the lines, bail out when start and end line found
for (my $i = 0;
- $i <= $#{$cupsd_conf_ptr} and $location_end == -1;
+ $i <= $#{$cupsd_conf_ptr} && $location_end == -1;
$i++) {
if ($cupsd_conf_ptr->[$i] =~ m!^\s*<\s*Location\s+$path\s*>!) {
# Start line of block
@@ -740,7 +801,7 @@ sub read_location {
# "undef"
@result = undef;
}
- return (@result);
+ return @result;
}
sub rip_location {
@@ -762,7 +823,7 @@ sub rip_location {
if (any { m!^\s*<Location\s+$path\s*>! } @$cupsd_conf_ptr) {
# Go through all the lines, bail out when start and end line found
for (my $i = 0;
- $i <= $#{$cupsd_conf_ptr} and $location_end == -1;
+ $i <= $#{$cupsd_conf_ptr} && $location_end == -1;
$i++) {
if ($cupsd_conf_ptr->[$i] =~ m!^\s*<\s*Location\s+$path\s*>!) {
# Start line of block
@@ -785,7 +846,7 @@ sub rip_location {
@location = ("<Location $path>\n", "</Location>\n");
}
- return ($location_start, @location);
+ return $location_start, @location;
}
sub insert_location {
@@ -1069,7 +1130,7 @@ sub clientnetworks {
$haveallowedhostwithoutbrowseallow ||
$havebrowseallowwithoutallowedhost);
- return ($configunsupported, @sharehosts);
+ return $configunsupported, @sharehosts;
}
sub makesharehostlist {
@@ -1359,6 +1420,35 @@ sub clean_cups_config {
}
#----------------------------------------------------------------------
+# Handling of /etc/cups/client.conf
+
+sub read_client_conf() {
+ return (0, undef) if (! -r "$::prefix/etc/cups/client.conf");
+ my @client_conf = cat_("$::prefix/etc/cups/client.conf");
+ my @servers = handle_configs::read_directives(\@client_conf,
+ "ServerName");
+ return (@servers > 0,
+ $servers[0]); # If there is more than one entry in client.conf,
+ # the first one counts.
+}
+
+sub write_client_conf {
+ my ($daemonless_cups, $remote_cups_server) = @_;
+ # Create the directory for client.conf if needed
+ (-d "$::prefix/etc/cups/" ) || mkdir("$::prefix/etc/cups/") || return 1;
+ my (@client_conf) = cat_("$::prefix/etc/cups/client.conf");
+ if ($daemonless_cups) {
+ handle_configs::set_directive(\@client_conf,
+ "ServerName $remote_cups_server");
+ } else {
+ handle_configs::comment_directive(\@client_conf, "ServerName");
+ }
+ output("$::prefix/etc/cups/client.conf", @client_conf);
+}
+
+
+
+#----------------------------------------------------------------------
sub read_printers_conf {
my ($printer) = @_;
my $current;
@@ -1370,9 +1460,9 @@ sub read_printers_conf {
#- Location > Location Text
#- State > Idle|Stopped
#- Accepting > Yes|No
- local *PRINTERS; open PRINTERS, "$::prefix/etc/cups/printers.conf" or return;
+ open(my $PRINTERS, "$::prefix/etc/cups/printers.conf") or return;
local $_;
- while (<PRINTERS>) {
+ while (<$PRINTERS>) {
chomp;
/^\s*#/ and next;
if (/^\s*<(?:DefaultPrinter|Printer)\s+([^>]*)>/) { $current = { mode => 'cups', QUEUE => $1, } }
@@ -1380,7 +1470,7 @@ sub read_printers_conf {
add2hash($printer->{configured}{$current->{QUEUE}} ||= {}, $current); $current = undef }
elsif (/\s*(\S*)\s+(.*)/) { $current->{$1} = $2 }
}
- close PRINTERS;
+ close $PRINTERS;
#- assume this printing system.
$printer->{SPOOLER} ||= 'cups';
@@ -1389,12 +1479,12 @@ sub read_printers_conf {
sub get_direct_uri() {
#- get the local printer to access via a Device URI.
my @direct_uri;
- local *F; open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/sbin/lpinfo -v |";
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/sbin/lpinfo -v |");
local $_;
- while (<F>) {
+ while (<$F>) {
/^(direct|usb|serial)\s+(\S*)/ and push @direct_uri, $2;
}
- close F;
+ close $F;
@direct_uri;
}
@@ -1414,7 +1504,7 @@ sub installppd {
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",
+ 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";
@@ -1463,8 +1553,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) {
@@ -1520,7 +1610,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/;
}
@@ -1558,9 +1648,9 @@ sub get_descr_from_ppdfile {
local $_;
foreach (catMaybeCompressed("$::prefix$ppdfile")) {
# "OTHERS|Generic PostScript printer|PostScript (en)";
- /^\*([^\s:]*)\s*:\s*\"([^\"]*)\"/ and
+ /^\*([^\s:]*)\s*:\s*"([^"]*)"/ and
do { $ppd{$1} = $2; next };
- /^\*([^\s:]*)\s*:\s*([^\s\"]*)/ and
+ /^\*([^\s:]*)\s*:\s*([^\s"]*)/ and
do { $ppd{$1} = $2; next };
}
};
@@ -1580,19 +1670,19 @@ sub ppd_devid_data {
$ppd = "$::prefix/usr/share/cups/model/$ppd";
my @content;
if ($ppd =~ /\.gz$/i) {
- @content = cat_("$::prefix/bin/zcat $ppd |") or return ("", "");
+ @content = cat_("$::prefix/bin/zcat $ppd |") or return "", "";
} else {
- @content = cat_($ppd) or return ("", "");
+ @content = cat_($ppd) or return "", "";
}
my ($devidmake, $devidmodel);
- /^\*Manufacturer:\s*\"(.*)\"\s*$/ and $devidmake = $1
+ /^\*Manufacturer:\s*"(.*)"\s*$/ and $devidmake = $1
foreach @content;
- /^\*Product:\s*\"\(?(.*?)\)?\"\s*$/ and $devidmodel = $1
+ /^\*Product:\s*"\(?(.*?)\)?"\s*$/ and $devidmodel = $1
foreach @content;
- return ($devidmake, $devidmodel);
+ return $devidmake, $devidmodel;
}
-sub poll_ppd_base() {
+sub poll_ppd_base {
my ($printer) = @_;
#- Before trying to poll the ppd database available to cups, we have
#- to make sure the file /etc/cups/ppds.dat is no more modified.
@@ -1603,11 +1693,11 @@ sub poll_ppd_base() {
printer::services::start_not_running_service("cups");
my $driversthere = scalar(keys %thedb);
foreach (1..60) {
- local *PPDS; open PPDS, ($::testing ? $::prefix :
- "chroot $::prefix/ ") .
- "/usr/bin/poll_ppd_base -a |";
+ open(my $PPDS, ($::testing ? $::prefix :
+ "chroot $::prefix/ ") .
+ "/usr/bin/poll_ppd_base -a |");
local $_;
- while (<PPDS>) {
+ while (<$PPDS>) {
chomp;
my ($ppd, $mf, $descr, $lang) = split /\|/;
if ($ppd eq "raw") { next }
@@ -1633,7 +1723,7 @@ sub poll_ppd_base() {
# Native CUPS?
my $isnativecups = $driver =~ /CUPS/i;
# Native PostScript
- my $isnativeps = (!$isfoomatic and !$isnativecups);
+ my $isnativeps = !$isfoomatic && !$isnativecups;
# Key without language tag (key as it was produced for the
# entries from the Foomatic XML database)
my $keynolang = $key;
@@ -1664,13 +1754,15 @@ sub poll_ppd_base() {
if (defined($thedb{$key})) {
next if lc($thedb{$key}{driver}) eq
lc($driver);
- next unless $isnativeps &&
- $thedb{$key}{driver} =~ /^PostScript$/i ||
- $thedb{$key}{driver} ne "PPD" && $isrecommended ||
- $thedb{$key}{driver} eq "PPD" && $isrecommended && $driver ne "PostScript";
-
- # Remove the old entry
- delete $thedb{$key};
+ if ($isnativeps &&
+ $thedb{$key}{driver} =~ /^PostScript$/i ||
+ $thedb{$key}{driver} ne "PPD" && $isrecommended ||
+ $thedb{$key}{driver} eq "PPD" && $isrecommended && $driver ne "PostScript") {
+ # Remove the old entry
+ delete $thedb{$key};
+ } else {
+ next;
+ }
}
} elsif ((defined
$thedb{"$mf|$model|$fullfoomaticdriver"} ||
@@ -1748,7 +1840,7 @@ sub poll_ppd_base() {
#$thedb{$key}{devidmodel} = $devidmodel;
}
}
- close PPDS;
+ close $PPDS;
scalar(keys %thedb) - $driversthere > 5 and last;
#- we have to try again running the program, wait here a little
#- before.
@@ -1802,7 +1894,7 @@ sub configure_queue($) {
}
# Make sure that queue is active
- if ($printer->{SPOOLER} ne "pdq") {
+ if ($printer->{NEW} && ($printer->{SPOOLER} ne "pdq")) {
run_program::rooted($::prefix, "foomatic-printjob",
"-s", $printer->{currentqueue}{spooler},
"-C", "up", $printer->{currentqueue}{queue});
@@ -1860,9 +1952,19 @@ sub configure_queue($) {
return 1;
}
+sub enable_disable_queue {
+ my ($printer, $queue, $state) = @_;
+
+ if (($printer->{SPOOLER} ne "pdq") &&
+ ($printer->{SPOOLER} ne "rcups")) {
+ run_program::rooted($::prefix, "foomatic-printjob",
+ "-s", $printer->{SPOOLER},
+ "-C", ($state ? "start" : "stop"), $queue);
+ }
+}
+
sub remove_queue($$) {
- my ($printer) = $_[0];
- my ($queue) = $_[1];
+ my ($printer, $queue) = @_;
run_program::rooted($::prefix, "foomatic-configure", "-R", "-q",
"-s", $printer->{SPOOLER},
"-n", $queue);
@@ -1874,7 +1976,6 @@ sub remove_queue($$) {
$printer->{ARGS} = {};
$printer->{DBENTRY} = "";
$printer->{currentqueue} = {};
- removeprinterfromapplications($printer, $queue);
}
sub restart_queue($) {
@@ -1909,38 +2010,39 @@ sub print_pages($@) {
my $queue = $printer->{QUEUE};
my $lpr = "/usr/bin/foomatic-printjob";
my $lpq = "$lpr -Q";
+ my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
# Print the pages
foreach (@pages) {
my $page = $_;
- # Only text and PostScript can be printed directly with all spoolers,
- # images must be treated seperately
+ # Only text and PostScript can be printed directly with all
+ # spoolers, images must be treated seperately
if ($page =~ /\.jpg$/) {
- if ($printer->{SPOOLER} ne "cups") {
+ if ($spooler ne "cups") {
# Use "convert" from ImageMagick for non-CUPS spoolers
system(($::testing ? $::prefix : "chroot $::prefix/ ") .
"/usr/bin/convert $page -page 427x654+100+65 PS:- | " .
($::testing ? $::prefix : "chroot $::prefix/ ") .
- "$lpr -s $printer->{SPOOLER} -P $queue");
+ "$lpr -s $spooler -P $queue");
} else {
# Use CUPS's internal image converter with CUPS, tell it
# to let the image occupy 90% of the page size (so nothing
# gets cut off by unprintable borders)
- run_program::rooted($::prefix, $lpr, "-s", $printer->{SPOOLER},
+ run_program::rooted($::prefix, $lpr, "-s", $spooler,
"-P", $queue, "-o", "scaling=90", $page);
}
} else {
- run_program::rooted($::prefix, $lpr, "-s", $printer->{SPOOLER},
+ run_program::rooted($::prefix, $lpr, "-s", $spooler,
"-P", $queue, $page);
}
}
sleep 5; #- allow lpr to send pages.
# Check whether the job is queued
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "$lpq -s $printer->{SPOOLER} -P $queue |";
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "$lpq -s $spooler -P $queue |");
my @lpq_output =
- grep { !/^no entries/ && !(/^Rank\s+Owner/ .. /^\s*$/) } <F>;
- close F;
+ grep { !/^no entries/ && !(/^Rank\s+Owner/ .. /^\s*$/) } <$F>;
+ close $F;
@lpq_output;
}
@@ -1948,10 +2050,9 @@ sub help_output {
my ($printer, $spooler) = @_;
my $queue = $printer->{QUEUE};
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . sprintf($spoolers{$spooler}{help}, $queue);
- my $helptext = join("", <F>);
- close F;
+ open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . sprintf($spoolers{$spooler}{help}, $queue));
+ my $helptext = join("", <$F>);
+ close $F;
$helptext ||= "Option list not available!\n";
return $helptext;
}
@@ -1983,17 +2084,19 @@ sub print_optionlist {
sub get_copiable_queues {
my ($oldspooler, $newspooler) = @_;
+ # No local queues available in daemon-less CUPS mode
+ return () if ($oldspooler eq "rcups") or ($newspooler eq "rcups");
+
my @queuelist; #- here we will list all Foomatic-generated queues
# Get queue list with foomatic-configure
- local *QUEUEOUTPUT;
- open QUEUEOUTPUT, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "foomatic-configure -Q -q -s $oldspooler |" or
+ open(my $QUEUEOUTPUT, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ "foomatic-configure -Q -q -s $oldspooler |") or
die "Could not run foomatic-configure";
my $entry = {};
my $inentry = 0;
local $_;
- while (<QUEUEOUTPUT>) {
+ while (<$QUEUEOUTPUT>) {
chomp;
if ($inentry) {
# We are inside a queue entry
@@ -2018,7 +2121,7 @@ sub get_copiable_queues {
$entry->{connect} = $1;
}
} else {
- if (m!^\s*<queue\s+foomatic\s*=\s*\"?(\d+)\"?\s*spooler\s*=\s*\"?(\w+)\"?\s*>\s*$!) {
+ if (m!^\s*<queue\s+foomatic\s*=\s*"?(\d+)"?\s*spooler\s*=\s*"?(\w+)"?\s*>\s*$!) {
# new entry
$inentry = 1;
$entry->{foomatic} = $1;
@@ -2026,8 +2129,8 @@ sub get_copiable_queues {
}
}
}
- close QUEUEOUTPUT;
-
+ close $QUEUEOUTPUT;
+
return @queuelist;
}
@@ -2131,16 +2234,15 @@ sub configure_hpoj {
# It's only necessary to read it at the first call of this subroutine,
# the subroutine definitions stay valid after leaving this subroutine.
if (!$ptalinitread) {
- local *PTALINIT;
- open PTALINIT, "$::prefix/usr/sbin/ptal-init" or do {
+ open(my $PTALINIT, "$::prefix/usr/sbin/ptal-init") or do {
die "unable to open $::prefix/usr/sbin/ptal-init";
};
my @ptalinitfunctions; # subroutine definitions in /usr/sbin/ptal-init
local $_;
- while (<PTALINIT>) {
+ while (<$PTALINIT>) {
if (m!sub main!) {
last;
- } elsif ((m!^[^\#]!) && !(m!^\s*exec\b!)){
+ } elsif (m!^[^#]! && !(m!^\s*exec\b!)) {
# Comment lines and the "exec" line (probably obsolete
# Red Hat workaround) are skipped.
@@ -2164,7 +2266,7 @@ sub configure_hpoj {
push @ptalinitfunctions, $_;
}
}
- close PTALINIT;
+ close $PTALINIT;
eval "package printer::hpoj;
@ptalinitfunctions
@@ -2230,10 +2332,8 @@ sub configure_hpoj {
}
};
}
- my $devdata;
foreach (@autodetected) {
$device eq $_->{port} or next;
- $devdata = $_;
# $model is for the PTAL device name, so make sure that it is unique
# so in the case of the model name auto-detection having failed leave
# the port number or the host name as model name.
@@ -2244,12 +2344,12 @@ sub configure_hpoj {
$model = $_->{val}{MODEL};
}
$serialnumber = $_->{val}{SERIALNUMBER};
- services::stop("hpoj") if ($bus ne "hpjd");
+ services::stop("hpoj") if $bus ne "hpjd";
# Check if the device is really an HP multi-function device
#my $libusb = 0;
foreach my $libusb (0, 1) {
# Do access via libusb/user mode only if we have a USB device
- next if ($libusb && ($bus ne "usb"));
+ next if $libusb && $bus ne "usb";
# Preliminary workaround to make the user-mode USB devices
# (LIDIL devices) installable as verification of the HPOJ
# settings of these devices does not work yet. The workaround
@@ -2277,7 +2377,7 @@ sub configure_hpoj {
my $usbdev = usbdevice($_->{val});
if (defined($usbdev)) {
# Unload kernel module "printer"/"usblp"
- if (modules::get_probeall("usb-interface")) {
+ if (modules::any_conf->read->get_probeall("usb-interface")) {
eval(modules::unload($usbprintermodule));
$printermoduleunloaded = 1;
}
@@ -2294,16 +2394,14 @@ sub configure_hpoj {
}
$device_ok = 0;
my $ptalprobedevice = $bus eq "hpjd" ? "hpjd:$hostname" : "mlc:$bus:probe";
- local *F;
- if (open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/bin/ptal-devid $ptalprobedevice |") {
- my $devid = join("", <F>);
- close F;
+ if (open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/bin/ptal-devid $ptalprobedevice |")) {
+ my $devid = join("", <$F>);
+ close $F;
if ($devid) {
$device_ok = 1;
- local *F;
- if (open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/bin/ptal-devid $ptalprobedevice -long -mdl 2>/dev/null |") {
- $model_long = join("", <F>);
- close F;
+ if (open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/bin/ptal-devid $ptalprobedevice -long -mdl 2>/dev/null |")) {
+ $model_long = join("", <$F>);
+ close $F;
chomp $model_long;
# If SNMP or local port auto-detection failed but
# HPOJ auto-detection succeeded, fill in model name
@@ -2318,9 +2416,9 @@ sub configure_hpoj {
}
}
}
- if (open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/bin/ptal-devid $ptalprobedevice -long -sern 2>/dev/null |") { #-#
- $serialnumber_long = join("", <F>);
- close F;
+ if (open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . "/usr/bin/ptal-devid $ptalprobedevice -long -sern 2>/dev/null |")) { #-#
+ $serialnumber_long = join("", <$F>);
+ close $F;
chomp $serialnumber_long;
}
$cardreader = 1 if printer::hpoj::cardReaderDetected($ptalprobedevice);
@@ -2328,21 +2426,20 @@ sub configure_hpoj {
}
if ($bus ne "hpjd") {
# Stop ptal-mlcd daemon for locally connected devices
- local *F;
- if (open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . qq(ps auxwww | grep "ptal-mlcd $bus:probe" | grep -v grep | )) {
- my $line = <F>;
+ if (open(my $F, ($::testing ? $::prefix : "chroot $::prefix/ ") . qq(ps auxwww | grep "ptal-mlcd $bus:probe" | grep -v grep | ))) {
+ my $line = <$F>;
if ($line =~ /^\s*\S+\s+(\d+)\s+/) {
my $pid = $1;
kill 15, $pid;
}
- close F;
+ close $F;
}
$printermoduleunloaded &&
eval(modules::load($usbprintermodule));
}
last if $device_ok;
}
- printer::services::start("hpoj") if ($bus ne "hpjd");
+ printer::services::start("hpoj") if $bus ne "hpjd";
last;
}
# No, it is not an HP multi-function device.
@@ -2384,13 +2481,12 @@ sub configure_hpoj {
# Configure the device
# Open configuration file
- local *CONFIG;
- open(CONFIG, "> $::prefix/etc/ptal/$ptaldevice") or
+ open(my $CONFIG, "> $::prefix/etc/ptal/$ptaldevice") or
die "Could not open /etc/ptal/$ptaldevice for writing!\n";
# Write file header.
my $date = chomp_(`date`);
- print CONFIG
+ print $CONFIG
qq(
# Added $date by "printerdrake"
@@ -2412,56 +2508,56 @@ init.version=2
# Write model string.
if ($model_long !~ /\S/) {
- print CONFIG
+ print $CONFIG
"\n" .
qq(# "printerdrake" couldn't read the model but added this device anyway:\n) .
"# ";
} else {
- print CONFIG
+ print $CONFIG
"\n" .
"# The device model that was originally detected on this port:\n" .
qq(# If this ever changes, then you should re-run "printerdrake"\n) .
"# to delete and re-configure this device.\n";
if ($bus eq "par") {
- print CONFIG
+ print $CONFIG
"# Comment out if you don't care what model is really connected to this\n" .
"# parallel port.\n";
}
}
- print CONFIG
+ print $CONFIG
qq(init.mlcd.append+=-devidmatch "$model_long"\n);
# Write serial-number string.
if ($serialnumber_long !~ /\S/) {
- print CONFIG
+ print $CONFIG
"\n" .
"# The device's serial number is unknown.\n" .
"# ";
} else {
- print CONFIG
+ print $CONFIG
"\n" .
"# The serial number of the device that was originally detected on this port:\n";
if ($bus =~ /^[pu]/) {
- print CONFIG
+ print $CONFIG
"# Comment out if you want to disable serial-number matching.\n";
}
}
- print CONFIG
+ print $CONFIG
qq(init.mlcd.append+=-devidmatch "$serialnumber_long"\n);
if ($bus =~ /^[pu]/) {
- print CONFIG
+ print $CONFIG
"\n" .
"# Standard options passed to ptal-mlcd:\n" .
"init.mlcd.append+=";
if ($bus eq "usb") {
# Important: don't put more quotes around /dev/usb/lp[0-9]*,
# because ptal-mlcd currently does no globbing:
- print CONFIG "-device /dev/usb/lp0 /dev/usb/lp1 /dev/usb/lp2 /dev/usb/lp3 /dev/usb/lp4 /dev/usb/lp5 /dev/usb/lp6 /dev/usb/lp7 /dev/usb/lp8 /dev/usb/lp9 /dev/usb/lp10 /dev/usb/lp11 /dev/usb/lp12 /dev/usb/lp13 /dev/usb/lp14 /dev/usb/lp15";
+ print $CONFIG "-device /dev/usb/lp0 /dev/usb/lp1 /dev/usb/lp2 /dev/usb/lp3 /dev/usb/lp4 /dev/usb/lp5 /dev/usb/lp6 /dev/usb/lp7 /dev/usb/lp8 /dev/usb/lp9 /dev/usb/lp10 /dev/usb/lp11 /dev/usb/lp12 /dev/usb/lp13 /dev/usb/lp14 /dev/usb/lp15";
} elsif ($bus eq "par") {
- print CONFIG "$address_arg -device $device";
+ print $CONFIG "$address_arg -device $device";
}
- print CONFIG "\n" .
+ print $CONFIG "\n" .
"\n" .
"# ptal-mlcd's remote console can be useful for debugging, but may be a\n" .
"# security/DoS risk otherwise. In any case, it's accessible with the\n" .
@@ -2479,7 +2575,7 @@ init.version=2
"# following line to disable ptal-printd for this device:\n" .
"# init.printd.start=0\n";
} else {
- print CONFIG
+ print $CONFIG
"\n" .
"# By default ptal-printd isn't started for hpjd: devices.\n" .
"# If for some reason you want to start it for this device, then\n" .
@@ -2487,13 +2583,13 @@ init.version=2
"init.printd.start=1\n";
}
- print CONFIG
+ print $CONFIG
"\n" .
"# If you need to pass any additional command-line options to ptal-printd,\n" .
"# then add them to the following line and uncomment the line:\n" .
"# init.printd.append+=\n";
if ($cardreader) {
- print CONFIG
+ print $CONFIG
"\n" .
"# Uncomment the following line to enable ptal-photod for this device:\n" .
"init.photod.start=1\n" .
@@ -2503,7 +2599,7 @@ init.version=2
qq(# then change the line below to use the "-portoffset <n>" option.\n) .
"init.photod.append+=-maxaltports 26\n";
}
- close(CONFIG);
+ close($CONFIG);
printer::hpoj::readOneDevice($ptaldevice);
# Restart HPOJ
@@ -2517,27 +2613,26 @@ sub devicefound {
my ($usbid, $model, $serial) = @_;
# Compare the output of "lsusb -vv" with the elements of the device
# ID string
- if ($serial && ($usbid->{'SERIALNUMBER'} eq $serial)) {
+ if ($serial && $usbid->{SERIALNUMBER} eq $serial) {
# Match of serial number has absolute priority
return 1;
- } elsif ($model && ($usbid->{'MODEL'} eq $model)) {
+ } elsif ($model && $usbid->{MODEL} eq $model) {
# Try to match the model name otherwise
return 1;
}
return 0;
}
-sub usbdevice() {
+sub usbdevice {
my ($usbid) = @_;
# Run "lsusb -vv¨ and search the given device to get its USB bus and
# device numbers
- local *F;
- open F, ($::testing ? "" : "chroot $::prefix/ ") .
- '/bin/sh -c "export LC_ALL=C; lsusb -vv 2> /dev/null" |'
+ open(my $F, ($::testing ? "" : "chroot $::prefix/ ") .
+ '/bin/sh -c "export LC_ALL=C; lsusb -vv 2> /dev/null" |')
or return undef;
my ($bus, $device, $model, $serial) = ("", "", "", "");
my $found = 0;
- while (my $line = <F>) {
+ while (my $line = <$F>) {
chomp $line;
if ($line =~ m/^\s*Bus\s+(\d+)\s+Device\s+(\d+)\s*:/i) {
# head line of a new device
@@ -2555,7 +2650,7 @@ sub usbdevice() {
$serial = $1;
}
}
- close F;
+ close $F;
# Check last entry
$found = devicefound($usbid, $model, $serial);
@@ -2567,6 +2662,7 @@ sub config_sane() {
# Add HPOJ backend to /etc/sane.d/dll.conf if needed (no individual
# config file /etc/sane.d/hpoj.conf necessary, the HPOJ driver finds the
# scanner automatically)
+ return if (! -f "$::prefix/etc/sane.d/dll.conf");
return if member("hpoj", chomp_(cat_("$::prefix/etc/sane.d/dll.conf")));
eval { append_to_file("$::prefix/etc/sane.d/dll.conf", "hpoj\n") } or
die "can't write SANE config in /etc/sane.d/dll.conf: $!";
@@ -2594,7 +2690,7 @@ EOF
my $mtoolsfmconf;
if (-f "$::prefix/etc/mtoolsfm.conf") {
$mtoolsfmconf = cat_("$::prefix/etc/mtoolsfm.conf") or die "can't read MToolsFM config in $::prefix/etc/mtoolsfm.conf: $!";
- my $alloweddrives = lc($1) if $mtoolsfmconf =~ m/^\s*DRIVES\s*=\s*\"([A-Za-z ]*)\"/m;
+ my $alloweddrives = lc($1) if $mtoolsfmconf =~ m/^\s*DRIVES\s*=\s*"([A-Za-z ]*)"/m;
foreach my $letter ("p", "q", "r", "s") {
$alloweddrives .= $letter if $alloweddrives !~ /$letter/;
}
@@ -2623,44 +2719,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 0eb075250..80183e877 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -14,18 +14,15 @@ use printer::detect;
use printer::default;
use printer::data;
-my $companyname = "Mandrakesoft";
-my $distroname = "Mandrakelinux";
my $shortdistroname = "Mandrakelinux";
-my $domainname = "mandrakesoft.com";
-my $hp1000fwtext = N("The HP LaserJet 1000 needs its firmware to be uploaded after being turned on. Download the Windows driver package from the HP web site (the firmware on the printer's CD does not work) and extract the firmware file from it by uncompresing the self-extracting '.exe' file with the 'unzip' utility and searching for the 'sihp1000.img' file. Copy this file into the '/etc/printer' directory. There it will be found by the automatic uploader script and uploaded whenever the printer is connected and turned on.
+my $hp1000fwtext = N("The HP LaserJet 1000 needs its firmware to be uploaded after being turned on. Download the Windows driver package from the HP web site (the firmware on the printer's CD does not work) and extract the firmware file from it by decompressing the self-extracting '.exe' file with the 'unzip' utility and searching for the 'sihp1000.img' file. Copy this file into the '/etc/printer' directory. There it will be found by the automatic uploader script and uploaded whenever the printer is connected and turned on.
");
1;
sub config_cups {
- my ($printer, $in, $upNetwork) = @_;
+ my ($printer, $security, $in, $upNetwork) = @_;
local $::isWizard = 0;
# Check whether the network functionality is configured and
@@ -42,6 +39,9 @@ sub config_cups {
@{$printer->{cupsconfig}{cupsd_conf}} =
printer::main::read_cupsd_conf();
printer::main::read_cups_config($printer);
+ # Read client.conf file
+ my ($daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
# Read state of japanese text printing mode
my $jap_textmode = printer::main::get_jap_textmode();
# Read state for auto-correction of cupsd.conf
@@ -56,8 +56,7 @@ sub config_cups {
my $browsepoll = printer::main::makebrowsepolllist($printer);
my $buttonclicked;
#- Show dialog
- if ($in->ask_from_
- (
+ if ($in->ask_from_(
{
title => N("CUPS printer configuration"),
messages => N("Here you can choose whether the printers connected to this machine should be accessible by remote machines and by which remote machines.") .
@@ -65,9 +64,15 @@ sub config_cups {
},
[
{ text => N("The printers on this machine are available to other computers"), type => 'bool',
- val => \$printer->{cupsconfig}{localprintersshared} },
+ val => \$printer->{cupsconfig}{localprintersshared},
+ disabled => sub {
+ $daemonless_cups;
+ } },
{ text => N("Automatically find available printers on remote machines"), type => 'bool',
- val => \$printer->{cupsconfig}{remotebroadcastsaccepted} },
+ val => \$printer->{cupsconfig}{remotebroadcastsaccepted},
+ disabled => sub {
+ $daemonless_cups;
+ } },
{ val => N("Printer sharing on hosts/networks: ") .
($printer->{cupsconfig}{customsharingsetup} ?
N("Custom configuration") :
@@ -82,6 +87,7 @@ sub config_cups {
1;
},
disabled => sub {
+ $daemonless_cups ||
(!$printer->{cupsconfig}{localprintersshared} &&
!$printer->{cupsconfig}{remotebroadcastsaccepted});
} },
@@ -96,11 +102,17 @@ sub config_cups {
clicked_may_quit => sub {
$buttonclicked = "browsepoll";
1;
+ },
+ disabled => sub {
+ $daemonless_cups;
} },
{ text => N("Japanese text printing mode"),
- help => N("Turning on this allows to print plain text files in japanese language. Only use this function if you really want to print text in japanese, if it is activated you cannot print accentuated characters in latin fonts any more and you will not be able to adjust the margins, the character size, etc. This setting only affects printers defined on this machine. If you want to print japanese text on a printer set up on a remote machine, you have to activate this function on that remote machine."),
+ help => N("Turning on this allows to print plain text files in Japanese language. Only use this function if you really want to print text in Japanese, if it is activated you cannot print accentuated characters in latin fonts any more and you will not be able to adjust the margins, the character size, etc. This setting only affects printers defined on this machine. If you want to print Japanese text on a printer set up on a remote machine, you have to activate this function on that remote machine."),
type => 'bool',
- val => \$jap_textmode },
+ val => \$jap_textmode,
+ disabled => sub {
+ $daemonless_cups;
+ } },
if_($printer->{expert},
{ text => N("Automatic correction of CUPS configuration"),
type => 'bool',
@@ -113,7 +125,22 @@ sub config_cups {
- when printer information is broadcasted, it does not contain \"localhost\" as the server name.
If some of these measures lead to problems for you, turn this option off, but then you have to take care of these points."),
- val => \$printer->{cupsconfig}{autocorrection} }),
+ val => \$printer->{cupsconfig}{autocorrection},
+ disabled => sub {
+ $daemonless_cups;
+ } }),
+ { val => N("Remote CUPS server and no local CUPS daemon") .
+ ": " .
+ ($daemonless_cups ?
+ N("On") . "; " . N("Server") . ": " .
+ $remote_cups_server :
+ N("Off")),
+ help => N("In this mode the local CUPS daemon will be stopped and all printing requests go directly to the server specified below. Note that it is not possible to define local print queues then and if the specified server is down it cannot be printed at all from this machine."),
+ type => 'button',
+ clicked_may_quit => sub {
+ $buttonclicked = "daemonlesscups";
+ 1;
+ } },
]
)
) {
@@ -124,8 +151,7 @@ If some of these measures lead to problems for you, turn this option off, but th
while (!$subdone) {
# Entry should be edited when double-clicked
$buttonclicked = "edit";
- $in->ask_from_
- (
+ $in->ask_from_(
{ title => N("Sharing of local printers"),
messages => N("These are the machines and networks on which the locally connected printer(s) should be available:"),
ok => "",
@@ -151,7 +177,7 @@ If some of these measures lead to problems for you, turn this option off, but th
1;
},
disabled => sub {
- return ($#{$sharehosts->{list}} < 0);
+ return $#{$sharehosts->{list}} < 0;
} },
{ val => N("Remove selected host/network"),
type => 'button',
@@ -160,7 +186,7 @@ If some of these measures lead to problems for you, turn this option off, but th
1;
},
disabled => sub {
- return ($#{$sharehosts->{list}} < 0);
+ return $#{$sharehosts->{list}} < 0;
} },
{ val => N("Done"),
type => 'button',
@@ -200,8 +226,7 @@ If some of these measures lead to problems for you, turn this option off, but th
my $oldaddress =
($buttonclicked eq "edit" ?
$sharehosts->{invhash}{$choice} : "");
- if ($in->ask_from_
- (
+ if ($in->ask_from_(
{ title => N("Sharing of local printers"),
messages => N("Choose the network or host on which the local printers should be made available:"),
callbacks => {
@@ -211,7 +236,7 @@ If some of these measures lead to problems for you, turn this option off, but th
$ip =~ /^\s*$/) {
$in->ask_warn(N("Error"), N("Host/network IP address missing."));
- return (1,1);
+ return 1, 1;
}
if ($hostchoice eq
N("IP address of host/network:") &&
@@ -226,7 +251,7 @@ N("Examples for correct IPs:\n") .
"192.168.100.0/24\n" .
"192.168.100.0/255.255.255.0\n"
);
- return (1,1);
+ return 1, 1;
}
if ($hostchoice eq $menu[0]) {
$address = '@LOCAL';
@@ -246,9 +271,9 @@ N("Examples for correct IPs:\n") .
N("This host/network is already in the list, it cannot be added again.\n"));
if ($hostchoice eq
N("IP address of host/network:")) {
- return (1,1);
+ return 1, 1;
} else {
- return (1,0);
+ return 1, 0;
}
}
return 0;
@@ -311,8 +336,7 @@ N("Examples for correct IPs:\n") .
while (!$subdone) {
# Entry should be edited when double-clicked
$buttonclicked = "edit";
- $in->ask_from_
- (
+ $in->ask_from_(
{ title => N("Accessing printers on remote CUPS servers"),
messages => N("Add here the CUPS servers whose printers you want to use. You only need to do this if the servers do not broadcast their printer information into the local network."),
ok => "",
@@ -338,7 +362,7 @@ N("Examples for correct IPs:\n") .
1;
},
disabled => sub {
- return ($#{$browsepoll->{list}} < 0);
+ return $#{$browsepoll->{list}} < 0;
} },
{ val => N("Remove selected server"),
type => 'button',
@@ -347,7 +371,7 @@ N("Examples for correct IPs:\n") .
1;
},
disabled => sub {
- return ($#{$browsepoll->{list}} < 0);
+ return $#{$browsepoll->{list}} < 0;
} },
{ val => N("Done"),
type => 'button',
@@ -382,8 +406,7 @@ N("Examples for correct IPs:\n") .
my $oldaddress =
($buttonclicked eq "edit" ?
$browsepoll->{invhash}{$choice} : "");
- if ($in->ask_from_
- (
+ if ($in->ask_from_(
{ title => N("Accessing printers on remote CUPS servers"),
messages => N("Enter IP address and port of the host whose printers you want to use.") . ' ' .
N("If no port is given, 631 will be taken as default."),
@@ -391,7 +414,7 @@ N("Examples for correct IPs:\n") .
complete => sub {
if ($ip =~ /^\s*$/) {
$in->ask_warn(N("Error"), N("Server IP missing!"));
- return (1,0);
+ return 1, 0;
}
if ($ip !~
/^\s*(\d+\.\d+\.\d+\.\d+)\s*$/) {
@@ -401,7 +424,7 @@ N("Examples for correct IPs:\n") .
"192.168.100.194\n" .
"10.0.0.2\n"
);
- return (1,0);
+ return 1, 0;
} else {
$ip = $1;
}
@@ -409,7 +432,7 @@ N("Examples for correct IPs:\n") .
$port = '631';
} elsif ($port !~ /^\s*(\d+)\s*$/) {
$in->ask_warn(N("Error"), N("The port number should be an integer!"));
- return (1,1);
+ return 1, 1;
} else {
$port = $1;
}
@@ -420,7 +443,7 @@ N("Examples for correct IPs:\n") .
@{$printer->{cupsconfig}{BrowsePoll}})) {
$in->ask_warn(N("Error"),
N("This server is already in the list, it cannot be added again.\n"));
- return (1,0);
+ return 1, 0;
}
return 0;
},
@@ -460,6 +483,53 @@ N("Examples for correct IPs:\n") .
printer::main::makebrowsepolllist($printer);
}
}
+ } elsif ($buttonclicked eq "daemonlesscups") {
+ my ($modechoice, $rserver);
+ if ($daemonless_cups) {
+ $modechoice = N("On, Name or IP of remote server:");
+ $rserver = $remote_cups_server;
+ } else {
+ $modechoice = N("Off");
+ }
+ # Show the dialog
+ #my $address;
+ #my $oldaddress =
+ # ($buttonclicked eq "edit" ?
+ # $sharehosts->{invhash}{$choice} : "");
+ if ($in->ask_from_
+ ({ title => N("Remote CUPS server and no local CUPS daemon"),
+ messages => N("In this mode the local CUPS daemon will be stopped and all printing requests go directly to the server specified below. Note that it is not possible to define local print queues then and if the specified server is down it cannot be printed at all from this machine."),
+ callbacks => {
+ complete => sub {
+ if ($modechoice eq
+ N("On, Name or IP of remote server:") &&
+ $rserver =~ /^\s*$/) {
+
+ $in->ask_warn(N("Error"), N("CUPS server name or IP address missing."));
+ return 1, 1;
+ }
+ return 0;
+ },
+ },
+ },
+ # Show the widgets
+ [ { val => \$modechoice, format => \&translate,
+ type => 'list',
+ sort => 0,
+ list => [ N("Off"),
+ N("On, Name or IP of remote server:") ]},
+ { val => \$rserver,
+ disabled => sub {
+ $modechoice ne
+ N("On, Name or IP of remote server:");
+ } },
+ ],
+ )) {
+ # OK was clicked, update the data
+ $daemonless_cups =
+ ($modechoice eq N("On, Name or IP of remote server:"));
+ $remote_cups_server = $rserver;
+ }
} else {
# We have clicked "OK"
$retvalue = 1;
@@ -467,18 +537,52 @@ N("Examples for correct IPs:\n") .
# Write state for auto-correction of cupsd.conf
if ($oldautocorr !=
$printer->{cupsconfig}{autocorrection}) {
- printer::main::set_cups_autoconf
- ($printer->{cupsconfig}{autocorrection});
+ printer::main::set_cups_autoconf(
+ $printer->{cupsconfig}{autocorrection});
}
# Write state of japanese text printing mode
printer::main::set_jap_textmode($jap_textmode);
+ # Switch state of daemon-less CUPS mode and write
+ # client.conf
+ if (($daemonless_cups && $printer->{SPOOLER} ne "rcups") ||
+ (!$daemonless_cups && $printer->{SPOOLER} eq "rcups")) {
+ my $oldspooler = $printer->{SPOOLER};
+ $printer->{SPOOLER} = ($daemonless_cups ?
+ "rcups" : "cups");
+ if (install_spooler($printer, $security, $in->do_pkgs, $in, $upNetwork, 1)) {
+ printer::default::set_spooler($printer);
+ printer::main::write_client_conf
+ ($daemonless_cups, $remote_cups_server);
+ $printer->{remote_cups_server} =
+ $remote_cups_server;
+ # Get the queues of this spooler
+ my $w = $in->wait_message
+ (N("Printerdrake"),
+ N("Reading printer data..."));
+ printer::main::read_configured_queues($printer);
+ undef $w;
+ # Re-read the printer database next time
+ %printer::main::thedb = ();
+ assure_default_printer_is_set($printer, $in);
+ } else {
+ $printer->{SPOOLER} = $oldspooler;
+ }
+ } elsif ($daemonless_cups) {
+ printer::main::write_client_conf($daemonless_cups,
+ $remote_cups_server);
+ $printer->{remote_cups_server} = $remote_cups_server;
+ } else {
+ undef $printer->{remote_cups_server};
+ }
# Write cupsd.conf
printer::main::write_cups_config($printer);
my $w =
$in->wait_message(N("Printerdrake"),
N("Restarting CUPS..."));
- printer::main::write_cupsd_conf
- (@{$printer->{cupsconfig}{cupsd_conf}});
+ printer::main::write_cupsd_conf(
+ @{$printer->{cupsconfig}{cupsd_conf}});
+ #- restart cups after updating configuration.
+ printer::main::SIGHUP_daemon($printer->{SPOOLER});
undef $w;
}
} else {
@@ -586,7 +690,7 @@ sub first_time_dialog {
# configure networking.
my $havelocalnetworks =
check_network($printer, $in, $upNetwork, 1) &&
- printer::detect::getIPsInLocalNetworks() != ();
+ printer::detect::getIPsInLocalNetworks() != ();
# Finish building the dialog text
my $question = ($havelocalnetworks ?
@@ -602,14 +706,22 @@ sub first_time_dialog {
# Close wait message
undef $w;
- # Show dialog
+ while (1) {
+ # Show dialog
+ my $do_it = N("Yes");
+ my $quit = N("Quit");
+ my @choices = ($do_it, $quit);
+ my $choice = $in->ask_from_list(N("Printerdrake"), $dialogtext,
+ \@choices, $quit);
+ return 0 if $choice ne $do_it;
- my $do_it = N("Yes");
- my $quit = N("Quit");
- my @choices = ($do_it, $quit);
- my $choice = $in->ask_from_list(N("Printerdrake"), $dialogtext,
- \@choices, $quit);
- return ($choice eq $do_it);
+ if ($havelocalnetworks && !@autodetected ) {
+ return set_cups_daemon_mode($printer, $in);
+ } else {
+ $printer->{SPOOLER} = "cups";
+ return 1;
+ }
+ }
}
sub configure_new_printers {
@@ -625,8 +737,9 @@ sub configure_new_printers {
return 1 if $printer->{expert};
# Wait message
- my $w = $in->wait_message(N("Printerdrake"),
- N("Searching for new printers..."));
+ my $w = $::noX ||
+ $in->wait_message(N("Printerdrake"),
+ N("Searching for new printers..."));
# When HPOJ is running, it blocks the printer ports on which it is
# configured, so we stop it here. If it is not installed or not
@@ -651,8 +764,8 @@ sub configure_new_printers {
# Does the URI of this installed queue match one of the autodetected
# printers?
my $uri = $printer->{configured}{$queue}{queuedata}{connect};
- my $p = printer::main::autodetectionentry_for_uri
- ($uri, @autodetected);
+ my $p = printer::main::autodetectionentry_for_uri(
+ $uri, @autodetected);
if (defined($p)) {
# Blacklist the port
push(@blacklist, $p->{port});
@@ -662,7 +775,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
@@ -679,53 +791,29 @@ sub configure_new_printers {
connect => "",
spooler => $printer->{SPOOLER},
};
- # Generate a queue name from manufacturer and model
- my $queue;
- my $unknown;
- if (!$p->{val}{MANUFACTURER} || !$p->{val}{MODEL} ||
- $p->{val}{MODEL} eq N("Unknown Model")) {
- $queue = N("Printer");
- $unknown = 1;
- } else {
- my $make = $p->{val}{MANUFACTURER};
- if ($p->{val}{SKU}) {
- $queue = $make . $p->{val}{SKU};
- } else {
- $queue = $make . $p->{val}{MODEL};
- }
- $queue =~ s/series//gi;
- $queue =~ s/[\s\(\)\-,]//g;
- $queue =~ s/^$make$make/$make/;
- }
- # Append a number if the queue name already exists
- if ($printer->{configured}{$queue}) {
- $queue =~ s/(\d)$/$1_/;
- my $i = 1;
- while ($printer->{configured}{"$queue$i"}) {
- $i++;
- }
- $queue .= $i;
- }
- $printer->{currentqueue}{queue} = $queue;
undef $w;
- $w = $in->wait_message(N("Printerdrake"),
- ($unknown ?
- N("Configuring printer ...") :
- N("Configuring printer \"%s\"...",
- $printer->{currentqueue}{queue})));
+ $w = $::noX ||
+ $in->wait_message(N("Printerdrake"),
+ N("Found printer on %s...",
+ $p->{port}));
# Do configuration of multi-function devices and look up
# model name in the printer database
setup_common($printer, $in, $p->{val}{DESCRIPTION}, $p->{port},
1, @autodetected) or next;
- # Set also OLD_QUEUE field so that the subroutines for the
- # configuration work correctly.
- $printer->{OLD_QUEUE} = $printer->{QUEUE} =
- $printer->{currentqueue}{queue};
# Do the steps of queue setup
get_db_entry($printer, $in);
# Let the user choose the model manually if it could not be
# auto-detected.
if (!$printer->{DBENTRY}) {
+ # Skip this printer if we install print queues in a
+ # background without X access.
+ if ($::noX) {
+ # Delete some variables
+ foreach (qw(OLD_QUEUE QUEUE TYPE str_type DBENTRY ARGS OLD_CHOICE currentqueue NEW)) {
+ $printer->{$_} = "";
+ }
+ next;
+ }
# Set the OLD_CHOICE to a non-existing value
$printer->{OLD_CHOICE} = "XXX";
# Set model selection cursor onto the "Raw Printer" entry.
@@ -745,34 +833,23 @@ sub configure_new_printers {
Printerdrake could not determine which model your printer %s is. Please choose the correct model from the list.", $info) . " " .
N("If your printer is not listed, choose a compatible (see printer manual) or a similar one."), '|',
[ keys %printer::main::thedb ], $printer->{DBENTRY}) or next;
- if ($unknown) {
- # Rename the queue according to the chosen model
- $queue = $printer->{DBENTRY};
- $queue =~ s/\|/ /g;
- $printer->{currentqueue}{desc} = $queue;
- $queue =~ s/series//gi;
- $queue =~ s/[\s\(\)\-,]//g;
- # Append a number if the queue name already exists
- if ($printer->{configured}{$queue}) {
- $queue =~ s/(\d)$/$1_/;
- my $i = 1;
- while ($printer->{configured}{"$queue$i"}) {
- $i++;
- }
- $queue .= $i;
- }
- $printer->{currentqueue}{queue} = $queue;
- $printer->{QUEUE} = $printer->{currentqueue}{queue};
- }
# Restore wait message
- $w = $in->wait_message(N("Printerdrake"),
- N("Configuring printer \"%s\"...",
- $printer->{currentqueue}{queue}));
+ $w = $::noX ||
+ $in->wait_message(N("Printerdrake"),
+ N("Configuring printer on %s...",
+ $p->{port}));
}
get_printer_info($printer, $in) or next;
setup_options($printer, $in) or next;
+ my $_queue = generate_queuename($printer);
+ # Change wait message
+ undef $w;
+ $w = $::noX ||
+ $in->wait_message(N("Printerdrake"),
+ N("Configuring printer \"%s\"...",
+ $printer->{currentqueue}{queue}));
+ # Create the queue
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,18 +864,42 @@ 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};
}
+sub generate_queuename {
+ my ($printer) = @_;
+ my $queue;
+ if ($printer->{currentqueue}{model}) {
+ if ($printer->{currentqueue}{model} eq N("Unknown model")) {
+ $queue = N("Printer");
+ } else {
+ $queue = $printer->{currentqueue}{make} . '|' .
+ $printer->{currentqueue}{model};
+ }
+ } else {
+ $queue = $printer->{DBENTRY};
+ }
+ $queue =~ s/\|/ /g;
+ $printer->{currentqueue}{desc} = $queue;
+ $queue =~ s/series//gi;
+ $queue =~ s/[\s\(\)\-,]//g;
+ my $make = $printer->{currentqueue}{make};
+ $queue =~ s/$make$make/$make/gi;
+ # Append a number if the queue name already exists
+ if ($printer->{configured}{$queue}) {
+ $queue =~ s/(\d)$/$1_/;
+ my $i = 1;
+ while ($printer->{configured}{"$queue$i"}) {
+ $i++;
+ }
+ $queue .= $i;
+ }
+ $printer->{currentqueue}{queue} = $queue;
+ $printer->{OLD_QUEUE} = $printer->{QUEUE} = $queue;
+ return $queue;
+}
+
sub wizard_welcome {
my ($printer, $in, $upNetwork) = @_;
my $ret;
@@ -938,8 +1039,8 @@ sub setup_local_autoscan {
"Samba client") . " " .
N("Skipping Windows/SMB server auto-detection"));
$printer->{AUTODETECTSMB} = 0;
- return 0 if (!$printer->{AUTODETECTLOCAL} &&
- !$printer->{AUTODETECTNETWORK});
+ return 0 if !$printer->{AUTODETECTLOCAL} &&
+ !$printer->{AUTODETECTNETWORK};
};
}
my $_w = $in->wait_message(N("Printer auto-detection"), N("Detecting devices..."));
@@ -957,16 +1058,24 @@ sub setup_local_autoscan {
$printer->{MORETHANONE} = $#autodetected > 0;
my @str;
foreach my $p (@autodetected) {
- if ($p->{val}{DESCRIPTION}) {
- my $menustr = $p->{val}{DESCRIPTION};
+ if (($p->{val}{DESCRIPTION}) || ($p->{val}{MODEL})) {
+ my $menustr = ($p->{val}{DESCRIPTION} ?
+ $p->{val}{DESCRIPTION} :
+ (($p->{val}{MANUFACTURER} ?
+ ($p->{val}{MANUFACTURER} . " ") : ()) .
+ $p->{val}{MODEL}));
if ($p->{port} =~ m!^/dev/lp(\d+)$!) {
- $menustr .= N(" on parallel port #%s", $1);
+ my $port = $1;
+ $menustr .= N(" on parallel port #%s", $port);
} elsif ($p->{port} =~ m!^/dev/usb/lp(\d+)$!) {
- $menustr .= N(", USB printer #%s", $1);
+ my $printer = $1;
+ $menustr .= N(", USB printer #%s", $printer);
} elsif ($p->{port} =~ m!^socket://([^:]+):(\d+)$!) {
- $menustr .= N(", network printer \"%s\", port %s", $1, $2);
+ my ($printer, $port) = ($1, $2);
+ $menustr .= N(", network printer \"%s\", port %s", $printer, $port);
} elsif ($p->{port} =~ m!^smb://([^/:]+)/([^/:]+)$!) {
- $menustr .= N(", printer \"%s\" on SMB/Windows server \"%s\"", $2, $1);
+ my ($server, $printer) = ($1, $2);
+ $menustr .= N(", printer \"%s\" on SMB/Windows server \"%s\"", $printer, $server);
}
$menustr .= " ($p->{port})" if $printer->{expert};
$menuentries->{$menustr} = $p->{port};
@@ -974,13 +1083,17 @@ sub setup_local_autoscan {
} else {
my $menustr;
if ($p->{port} =~ m!^/dev/lp(\d+)$!) {
- $menustr = N("Printer on parallel port #%s", $1);
+ my $port = $1;
+ $menustr = N("Printer on parallel port #%s", $port);
} elsif ($p->{port} =~ m!^/dev/usb/lp(\d+)$!) {
- $menustr = N("USB printer #%s", $1);
+ my $printer = $1;
+ $menustr = N("USB printer #%s", $printer);
} elsif ($p->{port} =~ m!^socket://([^:]+):(\d+)$!) {
- $menustr .= N("Network printer \"%s\", port %s", $1, $2);
+ my ($printer, $port);
+ $menustr .= N("Network printer \"%s\", port %s", $printer, $port);
} elsif ($p->{port} =~ m!^smb://([^/:]+)/([^/:]+)$!) {
- $menustr .= N("Printer \"%s\" on SMB/Windows server \"%s\"", $2, $1);
+ my ($server, $printer) = ($1, $2);
+ $menustr .= N("Printer \"%s\" on SMB/Windows server \"%s\"", $printer, $server);
}
$menustr .= " ($p->{port})" if $printer->{expert};
$menuentries->{$menustr} = $p->{port};
@@ -997,9 +1110,11 @@ sub setup_local_autoscan {
}
my $menustr;
if ($q =~ m!^/dev/lp(\d+)$!) {
- $menustr = N("Printer on parallel port #%s", $1);
+ my $port = $1;
+ $menustr = N("Printer on parallel port #%s", $port);
} elsif ($q =~ m!^/dev/usb/lp(\d+)$!) {
- $menustr = N("USB printer #%s", $1);
+ my $printer;
+ $menustr = N("USB printer #%s", $printer);
}
$menustr .= " ($q)" if $printer->{expert};
$menuentries->{$menustr} = $q;
@@ -1039,8 +1154,8 @@ sub setup_local_autoscan {
my $oldmenuchoice = "";
my $device;
if ($printer->{configured}{$queue}) {
- my $p = printer::main::autodetectionentry_for_uri
- ($printer->{currentqueue}{connect}, @autodetected);
+ my $p = printer::main::autodetectionentry_for_uri(
+ $printer->{currentqueue}{connect}, @autodetected);
if (defined($p)) {
$device = $p->{port};
$menuchoice = { reverse %$menuentries }->{$device};
@@ -1065,7 +1180,7 @@ sub setup_local_autoscan {
complete => sub {
if ($menuchoice eq "") {
$in->ask_warn(N("Error"), N("You must enter a device or file name!"));
- return (1,0);
+ return 1, 0;
}
return 0;
}
@@ -1085,7 +1200,7 @@ sub setup_local_autoscan {
N("Available printers")),
messages => (($do_auto_detect ?
($printer->{expert} ?
- ($#menuentrieslist == 0 ?
+ (@menuentrieslist == 1 ?
(N("The following printer was auto-detected. ") .
($printer->{NEW} ?
N("If it is not the one you want to configure, enter a device name/file name in the input line") :
@@ -1094,7 +1209,7 @@ sub setup_local_autoscan {
($printer->{NEW} ?
N("Please choose the printer you want to set up or enter a device name/file name in the input line") :
N("Please choose the printer to which the print jobs should go or enter a device name/file name in the input line")))) :
- ($#menuentrieslist == 0 ?
+ (@menuentrieslist == 1 ?
(N("The following printer was auto-detected. ") .
($printer->{NEW} ?
N("The configuration of the printer will work fully automatically. If your printer was not correctly detected or if you prefer a customized printer configuration, turn on \"Manual configuration\".") :
@@ -1112,7 +1227,7 @@ sub setup_local_autoscan {
complete => sub {
unless ($menuchoice ne "") {
$in->ask_warn(N("Error"), N("You must choose/enter a printer/device!"));
- return (1,0);
+ return 1, 0;
}
return 0;
},
@@ -1193,11 +1308,11 @@ N("To use a remote lpd printer, you need to supply the hostname of the printer s
complete => sub {
if ($remotehost eq "") {
$in->ask_warn(N("Error"), N("Remote host name missing!"));
- return (1,0);
+ return 1, 0;
}
if ($remotequeue eq "") {
$in->ask_warn(N("Error"), N("Remote printer name missing!"));
- return (1,1);
+ return 1, 1;
}
return 0;
}
@@ -1381,15 +1496,15 @@ sub setup_smb {
complete => sub {
if (!is_ip($smbserverip) && $smbserverip ne "") {
$in->ask_warn(N("Error"), N("IP address should be in format 1.2.3.4"));
- return (1,1);
+ return 1, 1;
}
if ($smbserver eq "" && $smbserverip eq "") {
$in->ask_warn(N("Error"), N("Either the server name or the server's IP must be given!"));
- return (1,0);
+ return 1, 0;
}
if ($smbshare eq "") {
$in->ask_warn(N("Error"), N("Samba share name missing!"));
- return (1,2);
+ return 1, 2;
}
if ($smbpassword ne "") {
local $::isWizard = 0;
@@ -1412,7 +1527,7 @@ N("Connect your printer to a Linux server and let your Windows machine(s) connec
Do you really want to continue setting up this printer as you are doing now?"), 0);
return 0 if $yes;
- return (1,2);
+ return 1, 2;
}
return 0;
},
@@ -1495,11 +1610,11 @@ N("To print on a NetWare printer, you need to provide the NetWare print server n
complete => sub {
unless ($ncpserver ne "") {
$in->ask_warn(N("Error"), N("NCP server name missing!"));
- return (1,0);
+ return 1, 0;
}
unless ($ncpqueue ne "") {
$in->ask_warn(N("Error"), N("NCP queue name missing!"));
- return (1,1);
+ return 1, 1;
}
return 0;
}
@@ -1623,11 +1738,11 @@ sub setup_socket {
complete => sub {
unless ($remotehost ne "") {
$in->ask_warn(N("Error"), N("Printer host name or IP missing!"));
- return (1,0);
+ return 1, 0;
}
unless ($remoteport =~ /^[0-9]+$/) {
$in->ask_warn(N("Error"), N("The port number should be an integer!"));
- return (1,1);
+ return 1, 1;
}
return 0;
},
@@ -1699,7 +1814,7 @@ sub setup_uri {
my ($printer, $in, $upNetwork) = @_;
# $in->set_help('setupURI') if $::isInstall;
- if ($printer->{AUTODETECT} and ($printer->{SPOOLER} eq 'cups')) {
+ if ($printer->{AUTODETECT} && $printer->{SPOOLER} eq 'cups') {
my $_w = $in->wait_message(N("Printerdrake"),
N("Refreshing Device URI list..."));
printer::services::restart("cups");
@@ -1729,7 +1844,7 @@ list => [ if_($printer->{currentqueue}{connect},
complete => sub {
unless ($printer->{currentqueue}{connect} =~ /[^:]+:.+/) {
$in->ask_warn(N("Error"), N("A valid URI must be entered!"));
- return (1,0);
+ return 1, 0;
}
return 0;
}
@@ -1838,7 +1953,7 @@ val => \$commandline }, ],
complete => sub {
unless ($commandline ne "") {
$in->ask_warn(N("Error"), N("A command line must be entered!"));
- return (1,0);
+ return 1, 0;
}
return 0;
}
@@ -1883,32 +1998,36 @@ sub setup_common {
/usr/sbin/ptal-init
/usr/bin/xojpanel
/usr/sbin/lsusb))) {
- $w = $in->wait_message(N("Printerdrake"),
+ if ($::noX) {
+ $hpojinstallfailed = 1;
+ } else {
+ $w = $in->wait_message(N("Printerdrake"),
N("Installing HPOJ package..."))
- if !$printer->{noninteractive};
- $in->do_pkgs->install('hpoj', 'xojpanel', 'usbutils')
- or do {
- $in->ask_warn(N("Warning"),
- N("Could not install the %s packages!",
- "HPOJ") . " " .
- N("Only printing will be possible on the %s.",
- $makemodel));
- $hpojinstallfailed = 1;
- };
+ if !$printer->{noninteractive};
+ $in->do_pkgs->install('hpoj', 'xojpanel', 'usbutils')
+ or do {
+ $in->ask_warn(N("Warning"),
+ N("Could not install the %s packages!",
+ "HPOJ") . " " .
+ N("Only printing will be possible on the %s.",
+ $makemodel));
+ $hpojinstallfailed = 1;
+ };
+ }
}
# Configure and start HPOJ
undef $w;
- $w = $in->wait_message
- (N("Printerdrake"),
+ $w = $in->wait_message(
+ N("Printerdrake"),
N("Checking device and configuring HPOJ..."))
if !$printer->{noninteractive};
- eval {$ptaldevice = printer::main::configure_hpoj
- ($device, @autodetected) if !$hpojinstallfailed;};
+ eval { $ptaldevice = printer::main::configure_hpoj
+ ($device, @autodetected) if !$hpojinstallfailed };
if (my $err = $@) {
- warn qq(HPOJ conf faillure: "$err");
- log::l(qq(HPOJ conf faillure: "$err"));
+ warn qq(HPOJ conf failure: "$err");
+ log::l(qq(HPOJ conf failure: "$err"));
}
if ($ptaldevice) {
@@ -1939,16 +2058,19 @@ sub setup_common {
/usr/lib/libsane-hpoj.so.1)) ||
(!files_exist(qw(/usr/bin/xsane)) &&
!files_exist(qw(/usr/bin/kooka)) &&
- !$in->do_pkgs->is_installed('scanner-gui')))) {
+ ($::isInstall || !$in->do_pkgs->is_installed('scanner-gui'))))) {
undef $w;
- $w = $in->wait_message
- (N("Printerdrake"),
+ $w = $in->wait_message(
+ N("Printerdrake"),
N("Installing SANE packages..."))
if !$printer->{noninteractive};
- $in->do_pkgs->install('sane-backends',
- 'sane-frontends',
- 'scanner-gui',
- 'libsane-hpoj1')
+ $::noX
+ or $in->do_pkgs->install('sane-backends',
+ 'sane-frontends',
+ ($::isInstall ?
+ 'xsane' :
+ 'scanner-gui'),
+ 'libsane-hpoj1')
or do {
$in->ask_warn(N("Warning"),
N("Could not install the %s packages!",
@@ -1978,11 +2100,12 @@ sub setup_common {
/usr/bin/MToolsFM
))) {
undef $w;
- $w = $in->wait_message
- (N("Printerdrake"),
+ $w = $in->wait_message(
+ N("Printerdrake"),
N("Installing mtools packages..."))
if !$printer->{noninteractive};
- $in->do_pkgs->install('mtools', 'mtoolsfm')
+ $::noX
+ or $in->do_pkgs->install('mtools', 'mtoolsfm')
or do {
$in->ask_warn(N("Warning"),
N("Could not install the %s packages!",
@@ -2001,8 +2124,8 @@ sub setup_common {
$text = scanner_help($makemodel, "ptal://$ptaldevice");
if ($text) {
undef $w;
- $in->ask_warn
- (N("Scanning on your HP multi-function device"),
+ $in->ask_warn(
+ N("Scanning on your HP multi-function device"),
$text);
}
# Inform user about how to access photo cards with his
@@ -2020,8 +2143,8 @@ sub setup_common {
# make the DeviceURI from $device.
$printer->{currentqueue}{connect} = $device;
}
- $w = $in->wait_message
- (N("Printerdrake"),
+ $w = $in->wait_message(
+ N("Printerdrake"),
N("Checking device and configuring HPOJ..."))
if !$printer->{noninteractive} && !defined($w);
} else {
@@ -2057,8 +2180,8 @@ sub setup_common {
$device !~ /^socket:/ &&
$device !~ /^http:/ &&
$device !~ /^ipp:/) {
- my $_w = $in->wait_message
- (N("Printerdrake"),
+ my $_w = $in->wait_message(
+ N("Printerdrake"),
N("Making printer port available for CUPS..."))
if !$printer->{noninteractive};
printer::main::assure_device_is_available_for_cups($ptaldevice ||
@@ -2067,8 +2190,8 @@ sub setup_common {
#- Read the printer driver database if necessary
if (keys %printer::main::thedb == 0) {
- my $_w = $in->wait_message
- (N("Printerdrake"), N("Reading printer database..."))
+ my $_w = $in->wait_message(
+ N("Printerdrake"), N("Reading printer database..."))
if !$printer->{noninteractive};
printer::main::read_printer_db($printer, $printer->{SPOOLER});
}
@@ -2283,7 +2406,7 @@ sub choose_printer_name {
callbacks => { complete => sub {
unless ($printer->{currentqueue}{queue} =~ /^\w+$/) {
$in->ask_warn(N("Error"), N("Name of printer should contain only letters, numbers and the underscore"));
- return (1,0);
+ return 1, 0;
}
local $::isWizard = 0;
if ($printer->{configured}{$printer->{currentqueue}{queue}}
@@ -2291,7 +2414,7 @@ sub choose_printer_name {
!$in->ask_yesorno(N("Warning"), N("The printer \"%s\" already exists,\ndo you really want to overwrite its configuration?",
$printer->{currentqueue}{queue}),
0)) {
- return (1,0); # Let the user correct the name
+ return 1, 0; # Let the user correct the name
}
return 0;
},
@@ -2336,8 +2459,7 @@ sub get_db_entry {
$printer->{DBENTRY} = "$make|$model|$driverstr";
# database key contains the "(recommended)" for the
# recommended driver, so add it if necessary
- if (!member($printer->{DBENTRY},
- keys(%printer::main::thedb))) {
+ unless (exists($printer::main::thedb{$printer->{DBENTRY}})) {
$printer->{DBENTRY} .= " (recommended)";
}
} else {
@@ -2349,8 +2471,7 @@ sub get_db_entry {
$printer->{DBENTRY} =
printer::main::get_descr_from_ppd($printer) ||
$printer->{DBENTRY};
- if (!member($printer->{DBENTRY},
- keys(%printer::main::thedb))) {
+ unless (exists($printer::main::thedb{$printer->{DBENTRY}})) {
$printer->{DBENTRY} .= " (recommended)";
}
$printer->{OLD_CHOICE} = $printer->{DBENTRY};
@@ -2459,7 +2580,7 @@ sub choose_model {
N("Reading printer database..."));
printer::main::read_printer_db($printer, $printer->{SPOOLER});
}
- if (!member($printer->{DBENTRY}, keys(%printer::main::thedb))) {
+ unless (exists($printer::main::thedb{$printer->{DBENTRY}})) {
$printer->{DBENTRY} = N("Raw printer (No driver)");
}
# Choose the printer/driver from the list
@@ -2545,7 +2666,7 @@ sub installppd {
return 0;
}
# Let user select a PPD file from a floppy, hard disk, ...
- $ppdfile = $in->ask_file(N("Select PPD file"), "$dir");
+ $ppdfile = $in->ask_file(N("Select PPD file"), $dir);
last if !$ppdfile;
if (! -r $ppdfile) {
$in->ask_warn(N("Error"),
@@ -2565,10 +2686,10 @@ sub installppd {
return 0 if !$ppdfile;
# Install the PPD file in /usr/share/cups/ppd/printerdrake/
- my $_w = $in->wait_message(N("Printerdrake"),
+ my $w = $in->wait_message(N("Printerdrake"),
N("Installing PPD file..."));
my $ppdentry = printer::main::installppd($printer, $ppdfile);
- undef $_w;
+ undef $w;
return $ppdentry;
}
@@ -2674,13 +2795,17 @@ sub get_printer_info {
$printer->{SPECIAL_OPTIONS} .=
" -o PageSize=$pagesize";
}
+ # Do not embed the following messages in the add-printer
+ # wizard.
+ local $::isWizard = 0;
# oki4w driver -> OKI winprinter which needs the
# oki4daemon to work
if ($printer->{currentqueue}{driver} eq 'oki4w') {
if ($printer->{currentqueue}{connect} !~
m!^(parallel|file):/dev/lp0$!) {
- $in->ask_warn(N("OKI winprinter configuration"),
- N("You are configuring an OKI laser winprinter. These printers\nuse a very special communication protocol and therefore they work only when connected to the first parallel port. When your printer is connected to another port or to a print server box please connect the printer to the first parallel port before you print a test page. Otherwise the printer will not work. Your connection type setting will be ignored by the driver."));
+ $::noX ||
+ $in->ask_warn(N("OKI winprinter configuration"),
+ N("You are configuring an OKI laser winprinter. These printers\nuse a very special communication protocol and therefore they work only when connected to the first parallel port. When your printer is connected to another port or to a print server box please connect the printer to the first parallel port before you print a test page. Otherwise the printer will not work. Your connection type setting will be ignored by the driver."));
}
$printer->{currentqueue}{connect} = 'file:/dev/null';
# Start the oki4daemon
@@ -2704,8 +2829,9 @@ sub get_printer_info {
if ($opt) {
$printer->{SPECIAL_OPTIONS} .= $opt;
} else {
- $in->ask_warn(N("Lexmark inkjet configuration"),
- N("The inkjet printer drivers provided by Lexmark only support local printers, no printers on remote machines or print server boxes. Please connect your printer to a local port or configure it on the machine where it is connected to."));
+ $::noX ||
+ $in->ask_warn(N("Lexmark inkjet configuration"),
+ N("The inkjet printer drivers provided by Lexmark only support local printers, no printers on remote machines or print server boxes. Please connect your printer to a local port or configure it on the machine where it is connected to."));
return 0;
}
# Set device permissions
@@ -2728,13 +2854,14 @@ sub get_printer_info {
if ($drivertype eq 'Z23') { $drivertype = 'Z33' }
$drivertype = lc($drivertype);
if (!files_exist("/usr/local/lexmark/$drivertype/$drivertype")) {
- eval { $in->do_pkgs->install("lexmark-drivers-$drivertype") };
+ eval { $::noX or $in->do_pkgs->install("lexmark-drivers-$drivertype") };
}
if (!files_exist("/usr/local/lexmark/$drivertype/$drivertype")) {
# Driver installation failed, probably we do not have
# the commercial CDs
- $in->ask_warn(N("Lexmark inkjet configuration"),
- N("To be able to print with your Lexmark inkjet and this configuration, you need the inkjet printer drivers provided by Lexmark (http://www.lexmark.com/). Click on the \"Drivers\" link. Then choose your model and afterwards \"Linux\" as operating system. The drivers come as RPM packages or shell scripts with interactive graphical installation. You do not need to do this configuration by the graphical frontends. Cancel directly after the license agreement. Then print printhead alignment pages with \"lexmarkmaintain\" and adjust the head alignment settings with this program."));
+ $::noX ||
+ $in->ask_warn(N("Lexmark inkjet configuration"),
+ N("To be able to print with your Lexmark inkjet and this configuration, you need the inkjet printer drivers provided by Lexmark (http://www.lexmark.com/). Click on the \"Drivers\" link. Then choose your model and afterwards \"Linux\" as operating system. The drivers come as RPM packages or shell scripts with interactive graphical installation. You do not need to do this configuration by the graphical frontends. Cancel directly after the license agreement. Then print printhead alignment pages with \"lexmarkmaintain\" and adjust the head alignment settings with this program."));
}
} elsif ($printer->{currentqueue}{driver} eq 'drv_x125') {
# Set "Device" option
@@ -2743,8 +2870,9 @@ sub get_printer_info {
if ($opt) {
$printer->{SPECIAL_OPTIONS} .= $opt;
} else {
- $in->ask_warn(N("Lexmark X125 configuration"),
- N("The driver for this printer only supports printers locally connected via USB, no printers on remote machines or print server boxes. Please connect your printer to a local USB port or configure it on the machine where it is connected to."));
+ $::noX ||
+ $in->ask_warn(N("Lexmark X125 configuration"),
+ N("The driver for this printer only supports printers locally connected via USB, no printers on remote machines or print server boxes. Please connect your printer to a local USB port or configure it on the machine where it is connected to."));
return 0;
}
# Set device permissions
@@ -2761,6 +2889,56 @@ sub get_printer_info {
# This is needed to have the device not blocked by the
# spooler backend.
$printer->{currentqueue}{connect} = 'file:/dev/null';
+ } elsif ($printer->{currentqueue}{driver} eq 'ml85p') {
+ # Check whether printer is on first parallel port
+ if ($printer->{currentqueue}{connect} !~
+ m!^\s*(parallel|file):/dev/(lp|printers/)0\s*$!) {
+ $::noX ||
+ $in->ask_warn(N("Samsung ML/QL-85G configuration"),
+ N("The driver for this printer only supports printers locally connected on the first parallel port, no printers on remote machines or print server boxes or on other parallel ports. Please connect your printer to the first parallel port or configure it on the machine where it is connected to."));
+ return 0;
+ }
+ # Set driver executable permissions
+ if ($printer->{SPOOLER} eq 'cups') {
+ set_permissions('/usr/bin/ml85p',
+ '4750', 'root', 'sys');
+ } elsif ($printer->{SPOOLER} eq 'pdq') {
+ set_permissions('/usr/bin/ml85p',
+ '4755', 'root', 'sys');
+ } else {
+ set_permissions('/usr/bin/ml85p',
+ '4750', 'root', 'lp');
+ }
+ # This is needed to have the device not blocked by the
+ # spooler backend.
+ $printer->{currentqueue}{connect} = 'file:/dev/null';
+ } elsif (($printer->{currentqueue}{driver} =~
+ m!^\s*lbp[46]60\s*$!) ||
+ ($printer->{currentqueue}{ppd} &&
+ ($printer->{currentqueue}{ppd} =~
+ m!Canon-LBP-[46]60-lbp[46]60.ppd!))) {
+ # Check whether printer is on first parallel port
+ if ($printer->{currentqueue}{connect} !~
+ m!^\s*(parallel|file):/dev/(lp|printers/)0\s*$!) {
+ $::noX ||
+ $in->ask_warn(N("Canon LBP-460/660 configuration"),
+ N("The driver for this printer only supports printers locally connected on the first parallel port, no printers on remote machines or print server boxes or on other parallel ports. Please connect your printer to the first parallel port or configure it on the machine where it is connected to."));
+ return 0;
+ }
+ # Set driver executable permissions
+ if ($printer->{SPOOLER} eq 'cups') {
+ set_permissions('/usr/bin/lbp660',
+ '4750', 'root', 'sys');
+ } elsif ($printer->{SPOOLER} eq 'pdq') {
+ set_permissions('/usr/bin/lbp660',
+ '4755', 'root', 'sys');
+ } else {
+ set_permissions('/usr/bin/lbp660',
+ '4750', 'root', 'lp');
+ }
+ # This is needed to have the device not blocked by the
+ # spooler backend.
+ $printer->{currentqueue}{connect} = 'file:/dev/null';
} elsif ($printer->{currentqueue}{printer} eq 'HP-LaserJet_1000') {
$in->ask_warn(N("Firmware-Upload for HP LaserJet 1000"),
$hp1000fwtext);
@@ -2892,8 +3070,8 @@ You should make sure that the page size and the ink type/printing mode (if avail
# Should the option only show when the "Advanced" button was
# clicked?
my $advanced = ((defined($printer->{ARGS}[$i]{group}) &&
- ($printer->{ARGS}[$i]{group} !~
- /^(|General|.*install.*)$/i)) ||
+ $printer->{ARGS}[$i]{group} !~
+ /^(|General|.*install.*)$/i) ||
(!($printer->{ARGS}[$i]{group}) &&
!member($printer->{ARGS}[$i]{name},
@simple_options)) ? 1 : 0);
@@ -2927,7 +3105,7 @@ You should make sure that the page size and the ink type/printing mode (if avail
sort => 0,
advanced => $advanced,
help => $helptext })
- if ($printer->{ARGS}[$i]{name} ne 'PageRegion');
+ if $printer->{ARGS}[$i]{name} ne 'PageRegion';
} elsif ($printer->{ARGS}[$i]{type} eq 'bool') {
# boolean option
$choicelists[$i] = [($printer->{ARGS}[$i]{comment_true} ||
@@ -3008,15 +3186,15 @@ You should make sure that the page size and the ink type/printing mode (if avail
if ($printer->{ARGS}[$i]{type} eq 'int' || $printer->{ARGS}[$i]{type} eq 'float') {
if ($printer->{ARGS}[$i]{type} eq 'int' && $userinputs[$i] !~ /^[\-\+]?[0-9]+$/) {
$in->ask_warn(N("Error"), N("Option %s must be an integer number!", $printer->{ARGS}[$i]{comment}));
- return (1, $i);
+ return 1, $i;
}
if ($printer->{ARGS}[$i]{type} eq 'float' && $userinputs[$i] !~ /^[\-\+]?[0-9\.]+$/) {
$in->ask_warn(N("Error"), N("Option %s must be a number!", $printer->{ARGS}[$i]{comment}));
- return (1, $i);
+ return 1, $i;
}
if ($userinputs[$i] < $printer->{ARGS}[$i]{min} || $userinputs[$i] > $printer->{ARGS}[$i]{max}) {
$in->ask_warn(N("Error"), N("Option %s out of range!", $printer->{ARGS}[$i]{comment}));
- return (1, $i);
+ return 1, $i;
}
}
}
@@ -3146,6 +3324,9 @@ Note: the photo test page can take a rather long time to get printed and on lase
!files_exist('/usr/bin/convert')) {
$in->do_pkgs->install('ImageMagick')
or do {
+ # Do not embed this message in the add-printer
+ # wizard.
+ local $::isWizard = 0;
$in->ask_warn(N("Warning"),
N("Could not install the %s package!",
"ImageMagick") . " " .
@@ -3174,6 +3355,9 @@ Printing status:\n%s\n\n", @lpq_output);
It may take some time before the printer starts.\n");
}
if ($printer->{NEW} == 0) {
+ # Do not embed the following messages in the add-printer
+ # wizard.
+ local $::isWizard = 0;
$in->ask_warn(N("Printerdrake"),$dialogtext);
return 1;
} else {
@@ -3189,6 +3373,7 @@ It may take some time before the printer starts.\n");
sub printer_help {
my ($printer, $in) = @_;
my $spooler = $printer->{SPOOLER};
+ $spooler = "cups" if $spooler eq "rcups";
my $queue = $printer->{QUEUE};
my $default = $printer->{DEFAULT};
my $raw = 0;
@@ -3316,7 +3501,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
@@ -3419,14 +3604,14 @@ You can also type a new name or skip this printer.",
callbacks => { complete => sub {
unless ($newqueue =~ /^\w+$/) {
$in->ask_warn(N("Error"), N("Name of printer should contain only letters, numbers and the underscore"));
- return (1,0);
+ return 1, 0;
}
if ($printer->{configured}{$newqueue}
&& $newqueue ne $oldqueue &&
!$in->ask_yesorno(N("Warning"), N("The printer \"%s\" already exists,\ndo you really want to overwrite its configuration?",
$newqueue),
0)) {
- return (1,0); # Let the user correct the name
+ return 1, 0; # Let the user correct the name
}
return 0;
} }
@@ -3466,11 +3651,13 @@ sub start_network {
my $_w = $in->wait_message(N("Printerdrake"),
N("Starting network..."));
if ($::isInstall) {
- return ($upNetwork and
- do { my $ret = &$upNetwork();
- undef $upNetwork;
- sleep(1);
- $ret });
+ my $ret;
+ if ($upNetwork) {
+ $ret = &$upNetwork();
+ undef $upNetwork;
+ sleep(1);
+ }
+ return $ret;
} else { return printer::services::start("network") }
}
@@ -3491,7 +3678,7 @@ sub check_network {
# that the network is up and running so that the remote printer is
# reachable.
- my ($printer, $in, $upNetwork, $dontconfigure) = @_;
+ my ($printer, $in, $upNetwork, $b_dontconfigure) = @_;
# Any additional dialogs caused by this subroutine should appear as
# extra windows and not embedded in the "Add printer" wizard.
@@ -3502,7 +3689,7 @@ sub check_network {
# First check: Do configured networks
# (/etc/sysconfig/network-scripts/ifcfg*) exist?
- if (!$dontconfigure && !network_configured()) {
+ if (!$b_dontconfigure && !network_configured()) {
my $go_on = 0;
while (!$go_on) {
my $choice = N("Configure the network now");
@@ -3513,11 +3700,12 @@ sub check_network {
N("Go on without configuring the network") ] } ])) {
if ($choice eq N("Configure the network now")) {
if ($::isInstall) {
+ my $o = $in;
require network::netconnect;
network::netconnect::main(
- $in->{prefix}, $in->{netcnx} ||= {},
- $in, $in->{netc}, $in->{mouse},
- $in->{intf});
+ $o->{prefix}, $o->{netcnx} ||= {},
+ $in, $o->{modules_conf}, $o->{netc}, $o->{mouse},
+ $o->{intf});
# my ($prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
} else {
system("/usr/sbin/drakconnect");
@@ -3541,7 +3729,7 @@ sub check_network {
# The network is configured now, start it.
if (!start_network($in, $upNetwork) &&
- (!$dontconfigure || $::isInstall)) {
+ (!$b_dontconfigure || $::isInstall)) {
$in->ask_warn(N("Warning"),
($::isInstall ?
N("The network configuration done during the installation cannot be started now. Please check whether the network is accessible after booting your system and correct the configuration using the %s Control Center, section \"Network & Internet\"/\"Connection\", and afterwards set up the printer, also using the %s Control Center, section \"Hardware\"/\"Printer\"", $shortdistroname, $shortdistroname) :
@@ -3564,7 +3752,7 @@ N("The network access was not running and could not be started. Please check you
sub security_check {
# Check the security mode and when in "high" or "paranoid" mode ask the
# user whether he really wants to configure printing.
- my ($_printer, $in, $spooler) = @_;
+ my ($spooler, $security, $o_in) = @_;
# Any additional dialogs caused by this subroutine should appear as
# extra windows and not embedded in the "Add printer" wizard.
@@ -3572,15 +3760,6 @@ sub security_check {
# $in->set_help('securityCheck') if $::isInstall;
- # Get security level
- my $security;
- if ($::isInstall) {
- $security = $in->{security};
- } else {
- require security::level;
- $security = security::level::get();
- }
-
# Exit silently if the spooler is PDQ
if ($spooler eq "pdq") { return 1 }
@@ -3595,7 +3774,8 @@ sub security_check {
# wants to activate the spooler in the given security mode. Stop the
# operation of installing the spooler if he disagrees.
my $securitystr = ($security == 4 ? N("high") : N("paranoid"));
- if ($in->ask_yesorno(N("Installing a printing system in the %s security level", $securitystr),
+ if ($o_in &&
+ $o_in->ask_yesorno(N("Installing a printing system in the %s security level", $securitystr),
N("You are about to install the printing system %s on a system running in the %s security level.
This printing system runs a daemon (background process) which waits for print jobs and handles them. This daemon is also accessible by remote machines through the network and so it is a possible point for attacks. Therefore only a few selected daemons are started by default in this security level.
@@ -3620,24 +3800,25 @@ Do you really want to configure printing on this machine?",
sub start_spooler_on_boot {
# Checks whether the spooler will be started at boot time and if not,
# ask the user whether he wants to start the spooler at boot time.
- my ($printer, $in, $service) = @_;
+ my ($printer, $o_in, $b_service, $b_silentspooleronboot) = @_;
# PDQ has no daemon, so nothing needs to be started :
- return unless $service;
+ return unless $b_service;
# Any additional dialogs caused by this subroutine should appear as
# extra windows and not embedded in the "Add printer" wizard.
local $::isWizard = 0;
# $in->set_help('startSpoolerOnBoot') if $::isInstall;
- if (!services::starts_on_boot($service)) {
- if ($in->ask_yesorno(N("Starting the printing system at boot time"),
+ if (!services::starts_on_boot($b_service)) {
+ if ($b_silentspooleronboot ||
+ $o_in && $o_in->ask_yesorno(N("Starting the printing system at boot time"),
N("The printing system (%s) will not be started automatically when the machine is booted.
It is possible that the automatic starting was turned off by changing to a higher security level, because the printing system is a potential point for attacks.
Do you want to have the automatic starting of the printing system turned on again?",
$printer::data::spoolers{$printer->{SPOOLER}}{short_name}))) {
- services::start_service_on_boot($service);
+ services::start_service_on_boot($b_service);
}
}
1;
@@ -3645,36 +3826,44 @@ Do you want to have the automatic starting of the printing system turned on agai
sub install_spooler {
# installs the default spooler and start its daemon
- my ($printer, $in, $upNetwork) = @_;
+ my ($printer, $security, $do_pkgs, $o_in, $o_upNetwork, $b_silentspooleronboot) = @_;
return 1 if $::testing;
my $spooler = $printer->{SPOOLER};
# If the user refuses to install the spooler in high or paranoid
# security level, exit.
- return 0 unless security_check($printer, $in, $spooler);
- return 1 if $spooler !~ /^(cups|lpd|lprng|pqd)$/; # should not happen
- my $w = $in->wait_message(N("Printerdrake"), N("Checking installed software..."));
+ return 0 unless security_check($spooler, $security, $o_in);
+ # should not happen
+ return 0 if $spooler !~ /^(rcups|cups|lpd|lprng|pqd)$/;
+ my $w = $o_in && $o_in->wait_message(N("Printerdrake"), N("Checking installed software..."));
# "lpr" conflicts with "LPRng", remove either "LPRng" or remove "lpr"
my $packages = $spoolers{$spooler}{packages2rm};
if ($packages && files_exist($packages->[1])) {
undef $w;
- $w = $in->wait_message(N("Printerdrake"), N("Removing %s ..."), $spoolers{$packages->[0]}{short_name});
- $in->do_pkgs->remove_nodeps($packages->[0])
+ $w = $o_in && $o_in->wait_message(N("Printerdrake"), N("Removing %s..."), $spoolers{$packages->[0]}{short_name});
+ $do_pkgs->remove_nodeps($packages->[0])
or do {
- $in->ask_warn(N("Error"),
+ $o_in && $o_in->ask_warn(N("Error"),
N("Could not remove the %s printing system!",
$spoolers{$packages->[0]}{short_name}));
return 0;
};
}
+ # Install all packages needed to run printerdrake and the chosen spooler
$packages = $spoolers{$spooler}{packages2add};
- if ($packages && !files_exist(@{$packages->[1]})) {
+ push (@{$packages->[0]}, @{$commonpackages->[0]});
+ push (@{$packages->[0]}, @{$localqueuepackages->[0]}) if
+ $spoolers{$spooler}{local_queues};
+ push (@{$packages->[1]}, @{$commonpackages->[1]});
+ push (@{$packages->[1]}, @{$localqueuepackages->[1]}) if
+ $spoolers{$spooler}{local_queues};
+ if (@{$packages->[0]} && !files_exist(@{$packages->[1]})) {
undef $w;
- $w = $in->wait_message(N("Printerdrake"), N("Installing %s ..."), $spoolers{$spooler}{short_name});
- $in->do_pkgs->install(@{$packages->[0]})
+ $w = $o_in && $o_in->wait_message(N("Printerdrake"), N("Installing %s..."), $spoolers{$spooler}{short_name});
+ $do_pkgs->install(@{$packages->[0]})
or do {
- $in->ask_warn(N("Error"),
+ $o_in && $o_in->ask_warn(N("Error"),
N("Could not install the %s printing system!",
$spoolers{$spooler}{short_name}));
return 0;
@@ -3686,9 +3875,9 @@ sub install_spooler {
# Start the network (especially during installation), so the
# user can set up queues to remote printers.
- $upNetwork and do {
- &$upNetwork();
- undef $upNetwork;
+ $o_upNetwork and do {
+ &$o_upNetwork();
+ undef $o_upNetwork;
sleep(1);
};
@@ -3698,11 +3887,24 @@ sub install_spooler {
# Avoid unnecessary restarting of CUPS, this blocks the
# startup of printerdrake for several seconds.
printer::services::start_not_running_service("cups");
+ # Remove a remote CUPS server setting from the client.conf
+ # file, otherwise the local CUPS daemon gets overridden.
+ my ($daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
+ if ($daemonless_cups) {
+ printer::main::write_client_conf(0, $remote_cups_server);
+ }
+ } elsif ($spooler eq "rcups") {
+ # Stop CUPS daemon, we want to run daemon-less
+ services::stop("cups") if services::is_service_running("cups");
+ # Do not start CUPS daemon during boot
+ services::do_not_start_service_on_boot("cups");
} elsif ($spoolers{$spooler}{service}) {
printer::services::restart($spoolers{$spooler}{service});
}
- # Set the choosen spooler tools as defaults for "lpr", "lpq", "lprm", ...
+ # Set the choosen spooler tools as defaults for "lpr", "lpq",
+ # "lprm", ...
foreach (@{$spoolers{$spooler}{alternatives}}) {
set_alternative($_->[0], $_->[1]);
}
@@ -3711,11 +3913,51 @@ sub install_spooler {
printer::main::pdq_panic_button($spooler eq 'pdq' ? "add" : "remove");
# Should it be started at boot time?
- start_spooler_on_boot($printer, $in, $spoolers{$spooler}{boot_spooler});
+ start_spooler_on_boot($printer, $o_in, $spoolers{$spooler}{boot_spooler},
+ $b_silentspooleronboot);
# Give a SIGHUP to the devfsd daemon to correct the permissions
# for the /dev/... files according to the spooler
- printer::main::SIGHUP_daemon("devfs");
+ #printer::main::SIGHUP_daemon("devfs");
+ 1;
+}
+
+sub assure_remote_server_is_set {
+ my ($printer, $in) = @_;
+ # Check if a remote CUPS server is specified
+ if (!$printer->{remote_cups_server}) {
+ my ($daemonless_cups, $remote_cups_server) =
+ printer::main::read_client_conf();
+ if (!$daemonless_cups) {
+ if (!$in->ask_from_
+ ({ title => N("Remote CUPS server and no local CUPS daemon"),
+ messages => N("In this mode there is no local printing system, all printing requests go directly to the server specified below. Note that it is not possible to define local print queues then and if the specified server is down it cannot be printed at all from this machine.") .
+ "\n\n".
+ N("Enter the host name or IP of your CUPS server and click OK if you want to use this mode, click \"Quit\" otherwise."),
+ cancel => N("Quit"),
+ callbacks => {
+ complete => sub {
+ if ($remote_cups_server =~ /^\s*$/) {
+
+ $in->ask_warn(N("Error"), N("CUPS server name or IP address missing."));
+ return 1, 1;
+ }
+ return 0;
+ },
+ },
+ },
+ # Show the widgets
+ [ { label => N("Name or IP of remote server:"),
+ val => \$remote_cups_server,
+ } ],
+ )) {
+ # Cancel was clicked
+ exit 1;
+ }
+ printer::main::write_client_conf(1, $remote_cups_server);
+ $printer->{remote_cups_server} = $remote_cups_server;
+ }
+ }
1;
}
@@ -3723,8 +3965,9 @@ sub assure_default_printer_is_set {
my ($printer, $in) = @_;
if (defined($printer->{SPOOLER}) && $printer->{SPOOLER} &&
(!defined($printer->{DEFAULT}) || !$printer->{DEFAULT})) {
- my $_w = $in->wait_message(N("Printerdrake"),
- N("Setting Default Printer..."));
+ my $_w = $::noX ||
+ $in->wait_message(N("Printerdrake"),
+ N("Setting Default Printer..."));
$printer->{DEFAULT} = printer::default::get_printer($printer);
if ($printer->{DEFAULT}) {
# If a CUPS system has only remote printers and no default
@@ -3738,29 +3981,96 @@ sub assure_default_printer_is_set {
}
}
+sub set_cups_daemon_mode {
+ my ($printer, $in) = @_;
+ my ($modechoice, $daemonless_cups, $remote_cups_server);
+
+ if ($in->ask_from_
+ ({ title => N("Local CUPS printing system or remote CUPS server?"),
+ messages => N("The CUPS printing system can be used in two ways: ") .
+ "\n\n" .
+ N("1. The CUPS printing system can run locally. ") .
+ N("Then locally connected printers can be used and remote printers on other CUPS servers in the same network are automatically discovered. ") .
+ N("Disadvantage of this approach is, that more resources on the local machine are needed: Additional software packages need to be installed, the CUPS daemon has to run in the background and needs some memory, and the IPP port (port 631) is opened. ") .
+ "\n\n" .
+ N("2. All printing requests are immediately sent to a remote CUPS server. ") .
+ N("Here local resource occupation is reduced to a minimum. No CUPS daemon is started or port opened, no software infrastructure for setting up local print queues is installed, so less memory and disk space is used. ") .
+ N("Disadvantage is that it is not possible to define local printers then and if the specified server is down it cannot be printed at all from this machine. ") .
+ "\n\n" .
+ N("How should CUPS be set up on your machine?"),
+ callbacks => {
+ complete => sub {
+ if ($modechoice eq
+ N("Remote server, specify Name or IP here:") &&
+ $remote_cups_server =~ /^\s*$/) {
+
+ $in->ask_warn(N("Error"), N("CUPS server name or IP address missing."));
+ return 1, 1;
+ }
+ return 0;
+ },
+ },
+ },
+ # Show the widgets
+ [ { val => \$modechoice, format => \&translate,
+ type => 'list',
+ sort => 0,
+ list => [ N("Local CUPS printing system"),
+ N("Remote server, specify Name or IP here:") ]},
+ { val => \$remote_cups_server,
+ disabled => sub {
+ $modechoice ne
+ N("Remote server, specify Name or IP here:");
+ } },
+ ],
+ )) {
+ # OK was clicked, update the data
+ $daemonless_cups =
+ ($modechoice eq N("Remote server, specify Name or IP here:"));
+ if ($daemonless_cups) {
+ $printer->{SPOOLER} = "rcups";
+ $printer->{remote_cups_server} = $remote_cups_server;
+ } else {
+ $printer->{SPOOLER} = "cups";
+ undef $printer->{remote_cups_server};
+ }
+ printer::main::write_client_conf($daemonless_cups,
+ $remote_cups_server);
+ return 1;
+ } else {
+ # Cancel was clicked
+ return 0;
+ }
+}
+
+
sub setup_default_spooler {
- my ($printer, $in, $upNetwork) = @_;
- $printer->{SPOOLER} ||= 'cups';
+ my ($printer, $security, $in, $upNetwork) = @_;
my $oldspooler = $printer->{SPOOLER};
-
- my $str_spooler =
- $in->ask_from_listf_raw({ title => N("Select Printer Spooler"),
- messages => N("Which printing system (spooler) do you want to use?"),
- interactive_help_id => 'setupDefaultSpooler',
- },
- sub { translate($_[0]) },
- [ printer::main::spooler() ],
- $spoolers{$printer->{SPOOLER}}{long_name},
- ) or return;
- $printer->{SPOOLER} = $spooler_inv{$str_spooler};
+ $printer->{SPOOLER} ||= 'cups';
+ my @spoolerlist = printer::main::spooler();
+ if ($#spoolerlist == 1) {
+ set_cups_daemon_mode($printer, $in) || return;
+ } else {
+ my $str_spooler =
+ $in->ask_from_listf_raw({ title => N("Select Printer Spooler"),
+ messages => N("Which printing system (spooler) do you want to use?"),
+ interactive_help_id => 'setupDefaultSpooler',
+ },
+ sub { translate($_[0]) },
+ \@spoolerlist,
+ $spoolers{$printer->{SPOOLER}}{long_name},
+ ) or return;
+ $printer->{SPOOLER} = $spooler_inv{$str_spooler};
+ }
# Install the spooler if not done yet
- if (!install_spooler($printer, $in, $upNetwork)) {
+ if (!install_spooler($printer, $security, $in->do_pkgs, $in, $upNetwork)) {
$printer->{SPOOLER} = $oldspooler;
return;
}
+ assure_remote_server_is_set($printer, $in)
+ if ($printer->{SPOOLER} eq "rcups");
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"),
@@ -3768,16 +4078,12 @@ sub setup_default_spooler {
printer::main::read_configured_queues($printer);
}
# Copy queues from former spooler
- copy_queues_from($printer, $in, $oldspooler);
+ copy_queues_from($printer, $in, $oldspooler)
+ if ($oldspooler && ($oldspooler ne "rcups"));
# Re-read the printer database (CUPS has additional drivers, PDQ
# 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);
@@ -3836,7 +4142,7 @@ sub wizard_close {
#- Program entry point for configuration of the printing system.
sub main {
- my ($printer, $in, $install_step, $upNetwork) = @_;
+ my ($printer, $security, $in, $install_step, $upNetwork) = @_;
# $install_step is only made use of during the installation. It is
# 0 when this function is called during the preparation of the "Summary"
# screen and 1 when the user clicks on "Configure" on the "Summary"
@@ -3849,8 +4155,15 @@ sub main {
# screen is clicked. If the button is clicked after an automatic
# installation of local printers or if it is clicked for the
# second time, these steps are not repeated.
+
+ # Set the spooler to CUPS if we arrive here during the preparation
+ # of the "Summary" screen of the installation, as we have local
+ # printers then (if we do not have local printers, this function
+ # is not called during the preparation of the "Summary" screen).
if (!$::isInstall || !$::printerdrake_initialized) {
- init($printer, $in, $upNetwork) or return;
+ $printer->{SPOOLER} ||= 'cups'
+ if ($::isInstall && $install_step == 0 && !$printer->{expert});
+ init($printer, $security, $in, $upNetwork) or return;
}
# Main loop: During installation we only enter it when the user has
@@ -3859,12 +4172,12 @@ sub main {
if (!$::isInstall || $install_step == 1) {
# Ask for a spooler when none is defined yet
$printer->{SPOOLER} ||=
- setup_default_spooler($printer, $in, $upNetwork) || return;
+ setup_default_spooler($printer, $security, $in, $upNetwork) || return;
# Save the default spooler
printer::default::set_spooler($printer);
- mainwindow_interactive($printer, $in, $upNetwork);
+ mainwindow_interactive($printer, $security, $in, $upNetwork);
}
# In the installation we call the clean-up manually when we leave
# the "Summary" step
@@ -3874,79 +4187,67 @@ sub main {
}
sub init {
- my ($printer, $in, $upNetwork) = @_;
+ my ($printer, $security, $in, $upNetwork) = @_;
# Initialization of Printerdrake and queue auto-installation
+ # This subroutine is called on every start of printerdrake
+ # directly, from mcc, during installation, or for automatic print
+ # queue setup in the background, triggered when
+ # hotplug/udev/dynamic (script /etc/dynamic/script/lp.script)
+ # discovers a new printer being connected and turned on.
+
+ # In the latter case (background queue installation) only this
+ # subroutine is called as only the automatic, non-interactive
+ # print queue creation is needed. This must be totally
+ # non-interactive and cannot open any window on the X desktop,
+ # also packages cannot be installed, as the background process
+ # cannot ask the user to insert CDs. To reach this state of
+ # absolute silence, there is the global variable $::noX. If it is
+ # set, all interactivity or wait message is suppressed. If
+ # interactivity is required, the operation requiring interactivity
+ # will be skipped.
+
# Save the user mode, so that the same one is used on the next start
# of Printerdrake
printer::main::set_usermode($printer->{expert});
- # printerdrake does not work without foomatic, and for more
- # convenience we install some more stuff
- {
- my $_w = $in->wait_message(N("Printerdrake"),
- N("Checking installed software..."));
- if (!$::testing &&
- !files_exist(qw(/usr/bin/foomatic-configure
- /usr/lib/perl5/vendor_perl/5.8.0/Foomatic/DB.pm
- /usr/bin/foomatic-rip
- /usr/share/foomatic/db/source/driver/ljet4.xml
- /usr/bin/escputil
- /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'))
- or do {
- $in->ask_warn(N("Error"),
- N("Could not install necessary packages, %s cannot be started!",
- "printerdrake"));
- exit 1;
- };
- }
-
- # only experts should be asked for the spooler
- $printer->{SPOOLER} ||= 'cups' if !$printer->{expert};
-
- }
+ # only experts should be asked for the spooler also for background
+ # installation of print it should not be asked for the spooler,
+ # as this feature is only supported for CUPS.
+ $printer->{SPOOLER} ||= 'cups'
+ if (!$printer->{expert} || $::noX) && !$::isInstall;
# If we have chosen a spooler, install it and mark it as default
- # spooler
+ # spooler. Spooler installation is ommitted on background queue
+ # installation, because this only works when CUPS is already running
if ($printer->{SPOOLER}) {
- return 0 unless install_spooler($printer, $in, $upNetwork);
+ return 0 unless ($::noX ||
+ install_spooler($printer, $security, $in->do_pkgs, $in, $upNetwork));
+ assure_remote_server_is_set($printer, $in)
+ if ($printer->{SPOOLER} eq "rcups") && !$::noX;
+ printer::main::read_configured_queues($printer)
+ if (($printer->{SPOOLER} ne "rcups") &&
+ (keys(%{$printer->{configured}}) == 0));
printer::default::set_spooler($printer);
- }
- # Get the default printer (Done before non-interactive queue setup,
- # so that former default is not lost)
- assure_default_printer_is_set($printer, $in);
- my $nodefault = !$printer->{DEFAULT};
-
- # Non-interactive setup of newly detected printers (This is done
- # only when not in expert mode, so we always have a spooler defined
- # here)
- configure_new_printers($printer, $in, $upNetwork);
+ # Get the default printer (Done before non-interactive queue setup,
+ # so that former default is not lost)
+ assure_default_printer_is_set($printer, $in);
+ my $nodefault = !$printer->{DEFAULT};
+
+ # Non-interactive setup of newly detected printers (This is done
+ # only when not in expert mode, so we always have a spooler defined
+ # here)
+ configure_new_printers($printer, $in, $upNetwork)
+ if $printer->{SPOOLER} ne "rcups";
- # Make sure that default printer is registered
- if ($nodefault && $printer->{DEFAULT}) {
- printer::default::set_printer($printer);
+ # Make sure that default printer is registered
+ if ($nodefault && $printer->{DEFAULT}) {
+ 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;
@@ -3963,7 +4264,7 @@ sub init {
sub mainwindow_interactive {
- my ($printer, $in, $upNetwork) = @_;
+ my ($printer, $security, $in, $upNetwork) = @_;
# Control variables for the main loop
my ($menuchoice, $cursorpos) = ('', '::');
@@ -3987,7 +4288,8 @@ sub mainwindow_interactive {
if (defined($printer->{configured}{$printer->{DEFAULT}})) {
$cursorpos =
$printer->{configured}{$printer->{DEFAULT}}{queuedata}{menuentry} . N(" (Default)");
- } elsif ($printer->{SPOOLER} eq "cups") {
+ } elsif (($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups")){
$cursorpos = find { /!$printer->{DEFAULT}:[^!]*$/ } printer::cups::get_formatted_remote_queues($printer);
}
}
@@ -3998,7 +4300,8 @@ sub mainwindow_interactive {
N(" (Default)") : "") }
keys(%{$printer->{configured}
|| {}})),
- ($printer->{SPOOLER} eq "cups" ?
+ (($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups") ?
sort(printer::cups::get_formatted_remote_queues($printer)) :
()));
my $noprinters = $#printerlist < 0;
@@ -4018,36 +4321,39 @@ sub mainwindow_interactive {
sort => 0, separator => "!", tree_expanded => 1,
quit_if_double_click => 1, allow_empty_list => 1,
list => \@printerlist }),
- { clicked_may_quit =>
- sub {
- # Save the cursor position
- $cursorpos = $menuchoice;
- $menuchoice = '@addprinter';
- 1;
- },
- val => N("Add a new printer") },
- ($printer->{SPOOLER} eq "cups" &&
+ ($printer->{SPOOLER} ne "rcups" ?
+ { clicked_may_quit =>
+ sub {
+ # Save the cursor position
+ $cursorpos = $menuchoice;
+ $menuchoice = '@addprinter';
+ 1;
+ },
+ val => N("Add a new printer") } : ()),
+ ((($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups")) &&
$havelocalnetworks ?
- ({ clicked_may_quit =>
- sub {
- # Save the cursor position
- $cursorpos = $menuchoice;
- $menuchoice = '@refresh';
- 1;
- },
- val => ($noprinters ?
- N("Display all available remote CUPS printers") :
- N("Refresh printer list (to display all available remote CUPS printers)")) }) : ()),
- ($printer->{SPOOLER} eq "cups" &&
+ { clicked_may_quit =>
+ sub {
+ # Save the cursor position
+ $cursorpos = $menuchoice;
+ $menuchoice = '@refresh';
+ 1;
+ },
+ val => ($noprinters ?
+ N("Display all available remote CUPS printers") :
+ N("Refresh printer list (to display all available remote CUPS printers)")) } : ()),
+ ((($printer->{SPOOLER} eq "cups") ||
+ ($printer->{SPOOLER} eq "rcups")) &&
$havelocalnetworks_or_expert ?
- ({ clicked_may_quit =>
+ { clicked_may_quit =>
sub {
# Save the cursor position
$cursorpos = $menuchoice;
$menuchoice = '@cupsconfig';
1;
},
- val => N("CUPS configuration") }) : ()),
+ val => N("CUPS configuration") } : ()),
($printer->{expert} &&
(files_exist(qw(/usr/bin/pdq)) ||
files_exist(qw(/usr/lib/filters/lpf
@@ -4103,12 +4409,12 @@ sub mainwindow_interactive {
next if $menuchoice eq '@refresh';
# Configure CUPS
if ($menuchoice eq '@cupsconfig') {
- config_cups($printer, $in, $upNetwork);
+ config_cups($printer, $security, $in, $upNetwork);
next;
}
# Call function to switch to another spooler
if ($menuchoice eq '@spooler') {
- $printer->{SPOOLER} = setup_default_spooler($printer, $in, $upNetwork) || $printer->{SPOOLER};
+ $printer->{SPOOLER} = setup_default_spooler($printer, $security, $in, $upNetwork) || $printer->{SPOOLER};
next;
}
# Add a new print queue
@@ -4168,26 +4474,13 @@ sub add_printer {
# Tell subroutines that we add a new printer
$printer->{NEW} = 1;
- # Default printer name, we do not use "lp" so that one can
- # switch the default printer under LPD without needing to
- # rename another printer. Under LPD the alias "lp" will be
- # given to the default printer.
- my $defaultprname = N("Printer");
-
- # Determine a default name for a new printer queue
- my %queues;
- @queues{map { split '\|', $_ } keys %{$printer->{configured}}} = ();
- my $i = '';
- while ($i < 99999) {
- last unless exists $queues{"$defaultprname$i"};
- $i ++;
- }
- my $queue = "$defaultprname$i";
+ # Printer queue name
+ my $queue = "";
#- Set default values for a new queue
$printer_type_inv{$printer->{TYPE}} or
$printer->{TYPE} = printer::default::printer_type();
- $printer->{currentqueue} = { queue => $queue,
+ $printer->{currentqueue} = { queue => "",
foomatic => 0,
desc => "",
loc => "",
@@ -4198,15 +4491,12 @@ sub add_printer {
connect => "",
spooler => $printer->{SPOOLER},
};
- #- Set OLD_QUEUE field so that the subroutines for the
- #- configuration work correctly.
- $printer->{OLD_QUEUE} = $printer->{QUEUE} = $queue;
#- Do all the configuration steps for a new queue
step_0:
#if (!$::isEmbedded && !$::isInstall &&
- if ((!$::isInstall) &&
+ if (!$::isInstall &&
$in->isa('interactive::gtk')) {
- # Enter wizard mode
+ # Enter wizard mode (only after installation)
$::Wizard_pix_up = "printerdrake.png";
$::Wizard_title = N("Add a new printer");
$::isWizard = 1;
@@ -4233,19 +4523,10 @@ sub add_printer {
goto step_1 if $printer->{expert};
goto step_0;
};
- step_3:
- if ($printer->{expert} || $printer->{MANUAL} ||
- $printer->{MORETHANONE}) {
- choose_printer_name($printer, $in) or
- goto step_2;
- }
get_db_entry($printer, $in);
step_3_9:
if (!$printer->{expert} && !$printer->{MANUAL}) {
- is_model_correct($printer, $in) or do {
- goto step_3 if $printer->{MORETHANONE};
- goto step_2;
- }
+ is_model_correct($printer, $in) or goto step_2;
}
step_4:
# Remember DB entry for "Previous" button in wizard
@@ -4256,21 +4537,32 @@ sub add_printer {
# Restore DB entry
$printer->{DBENTRY} = $dbentry;
goto step_3_9 if $printer->{MANUALMODEL};
- goto step_3;
+ goto step_2;
};
}
- get_printer_info($printer, $in) or return 0;
+ get_printer_info($printer, $in) or do {
+ goto step_4 if $printer->{expert} || $printer->{MANUAL} ||
+ $printer->{MANUALMODEL};
+ goto step_3_9;
+ };
+ $queue = generate_queuename($printer);
step_5:
setup_options($printer, $in) or
goto step_4;
+ step_6:
+ if ($printer->{expert} || $printer->{MANUAL} ||
+ $printer->{MORETHANONE}) {
+ choose_printer_name($printer, $in) or do {
+ goto step_5 if $printer->{expert} || $printer->{MANUAL};
+ goto step_4 if $printer->{MANUALMODEL};
+ goto step_3_9;
+ }
+ }
configure_queue($printer, $in) or die 'wizcancel';
undef $printer->{MANUAL} if $printer->{MANUAL};
+ step_7:
$::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
@@ -4284,18 +4576,19 @@ sub add_printer {
$queue = $printer->{QUEUE};
edit_printer($printer, $in, $upNetwork, $queue);
return 1;
+ } else {
+ # "Previous" button clicked in test page dialog
+ goto step_7;
}
};
- wizard_close($in, 0) if $@ =~ /wizcancel/;
+ die if $@ && $@ !~ /^wizcancel/;
+ wizard_close($in, 0);
} else {
+ # Print queue setup without wizard (for installation)
$printer->{expert} or $printer->{TYPE} = "LOCAL";
wizard_welcome($printer, $in, $upNetwork) or return 0;
!$printer->{expert} or choose_printer_type($printer, $in, $upNetwork) or return 0;
setup_printer_connection($printer, $in, $upNetwork) or return 0;
- if ($printer->{expert} || $printer->{MANUAL} ||
- $printer->{MORETHANONE}) {
- choose_printer_name($printer, $in) or return 0;
- }
get_db_entry($printer, $in);
if (!$printer->{expert} && !$printer->{MANUAL}) {
is_model_correct($printer, $in) or return 0;
@@ -4305,15 +4598,15 @@ sub add_printer {
choose_model($printer, $in) or return 0;
}
get_printer_info($printer, $in) or return 0;
+ $queue = generate_queuename($printer);
setup_options($printer, $in) or return 0;
+ if ($printer->{expert} || $printer->{MANUAL} ||
+ $printer->{MORETHANONE}) {
+ choose_printer_name($printer, $in) or return 0;
+ }
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
@@ -4335,10 +4628,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");
@@ -4378,14 +4667,17 @@ sub edit_printer {
if ($in->ask_from_(
{ title => N("Modify printer configuration"),
messages =>
- N("Printer %s
+ N("Printer %s%s
What do you want to modify on this printer?",
- $infoline),
+ $infoline,
+ if_(($printer->{SPOOLER} =~ /cups/) &&
+ !printer::cups::queue_enabled($queue),
+ "\n" . N("This printer is disabled"))),
cancel => N("Close"),
ok => N("Do it!")
},
[ { val => \$modify, format => \&translate,
- type => 'list',
+ type => 'list', separator => '|',
list => [ ($printer->{configured}{$queue} ?
(N("Printer connection type"),
N("Printer name, description, location"),
@@ -4398,25 +4690,22 @@ 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")),
+ if_(($printer->{SPOOLER} ne "pdq") &&
+ $printer->{configured}{$queue},
+ if_(($printer->{SPOOLER} !~ /cups/) ||
+ !printer::cups::queue_enabled($queue),
+ N("Enable Printer")),
+ if_(($printer->{SPOOLER} !~ /cups/) ||
+ printer::cups::queue_enabled($queue),
+ N("Disable Printer"))),
N("Print test pages"),
N("Learn how to use this printer"),
if_($printer->{configured}{$queue}, N("Remove printer")) ] } ])) {
#- Copy the queue data and work on the copy
$printer->{currentqueue} = {};
- my $driver;
if ($printer->{configured}{$queue}) {
printer::main::copy_printer_params($printer->{configured}{$queue}{queuedata}, $printer->{currentqueue});
- #- Keep in mind the printer driver which was
- #- used, so it can be determined whether the
- #- driver is only available in expert and so
- #- for setting the options for the driver in
- #- recommended mode a special treatment has
- #- to be applied.
- $driver = $printer->{currentqueue}{driver};
}
#- keep in mind old name of queue (in case of changing)
$printer->{OLD_QUEUE} = $printer->{QUEUE} = $queue;
@@ -4448,15 +4737,16 @@ What do you want to modify on this printer?",
if ($modify eq N("Printer connection type")) {
choose_printer_type($printer, $in, $upNetwork) &&
setup_printer_connection($printer, $in, $upNetwork) &&
+ #get_db_entry($printer, $in) &&
+ #get_printer_info($printer, $in) &&
configure_queue($printer, $in);
} elsif ($modify eq N("Printer name, description, location")) {
- choose_printer_name($printer, $in) &&
- configure_queue($printer, $in) &&
- ($configapps = 1);
+ choose_printer_name($printer, $in) and
+ 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
- (N("Printerdrake"),
+ my $_w = $in->wait_message(
+ N("Printerdrake"),
N("Removing old printer \"%s\"...",
$printer->{OLD_QUEUE}));
printer::main::remove_queue($printer, $printer->{OLD_QUEUE});
@@ -4474,36 +4764,33 @@ 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("Enable Printer")) {
+ printer::main::enable_disable_queue($printer, $queue, 1) &&
+ $in->ask_warn(N("Enable Printer"),
+ N("Printer \"%s\" is now enabled.",
+ $queue));
+ } elsif ($modify eq N("Disable Printer")) {
+ printer::main::enable_disable_queue($printer, $queue, 0) &&
+ $in->ask_warn(N("Disable Printer"),
+ N("Printer \"%s\" is now disabled.",
+ $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};
@@ -4511,13 +4798,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 {
@@ -4539,11 +4819,11 @@ sub remove_printer {
# and, if yes, removes it. The default printer will be reassigned if
# needed.
- if ($in->ask_yesorno
- (N("Warning"), N("Do you really want to remove the printer \"%s\"?", $queue),
+ if ($in->ask_yesorno(
+ N("Warning"), N("Do you really want to remove the printer \"%s\"?", $queue),
1)) {
- my $_w = $in->wait_message
- (N("Printerdrake"),
+ my $_w = $in->wait_message(
+ N("Printerdrake"),
N("Removing printer \"%s\"...", $queue));
if (printer::main::remove_queue($printer, $queue)) {
# Define a new default printer if we have