diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2005-08-15 20:20:22 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2005-08-15 20:20:22 +0000 |
commit | 7f9eea64cc14d0bf7f41da524972bccb59189f94 (patch) | |
tree | d88feff134a37560d5c7c7b44c55bc7bec2975aa | |
parent | 5e7d21f830a7924c152750dee4b7f0dce1a190f7 (diff) | |
download | drakx-7f9eea64cc14d0bf7f41da524972bccb59189f94.tar drakx-7f9eea64cc14d0bf7f41da524972bccb59189f94.tar.gz drakx-7f9eea64cc14d0bf7f41da524972bccb59189f94.tar.bz2 drakx-7f9eea64cc14d0bf7f41da524972bccb59189f94.tar.xz drakx-7f9eea64cc14d0bf7f41da524972bccb59189f94.zip |
- Added per-printer configurable handling of CUPS backend errors. This
way CUPS does not disable print queues automatically any more (for
example if printer not turned on).
-rw-r--r-- | perl-install/printer/main.pm | 12 | ||||
-rw-r--r-- | perl-install/printer/printerdrake.pm | 87 |
2 files changed, 97 insertions, 2 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 78085b39e..951e6734a 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -803,8 +803,9 @@ sub get_jap_textmode() { # Handling of /etc/cups/cupsd.conf sub read_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. + # If /etc/cups/cupsd.conf does not exist 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', @@ -1977,6 +1978,13 @@ sub configure_queue($) { ("-d", "raw"))), "-N", $printer->{currentqueue}{desc}, "-L", $printer->{currentqueue}{loc}, + if_($printer->{SPOOLER} eq "cups", + "--backend-dont-disable=" . + $printer->{currentqueue}{dd}, + "--backend-attempts=" . + $printer->{currentqueue}{att}, + "--backend-delay=" . + $printer->{currentqueue}{delay}), @{$printer->{currentqueue}{options}} ) or return 0; if ($printer->{currentqueue}{ppd} && diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 3ddf80239..0be3e2fb4 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -660,6 +660,77 @@ sub config_auto_admin { } } +sub config_backend_error_handling { + my ($printer, $in) = @_; + + local $::isEmbedded = 0; + + # Get currentconfiguration + my $dontdisable = $printer->{currentqueue}{dd}; + my $infiniteretries = ($printer->{currentqueue}{att} == 0); + my $retries = ($printer->{currentqueue}{att} != 0 ? + $printer->{currentqueue}{att} : 1); + my $delay = $printer->{currentqueue}{delay}; + my $queue = $printer->{currentqueue}{queue}; + + # Configuration dialog + if ($in->ask_from_ + ({ + title => + N("Communication error handling for the printer \"%s\"", + $queue), + messages => N("Here you can configure how errors during the communication between your computer and the printer \"%s\" should be handled (for example if the printer is not turned on).", $queue), + callbacks => { + complete => sub { + unless (($retries =~ /^[0-9]+$/) && ($retries > 0)) { + $in->ask_warn(N("Error"), N("The number of retries should be an integer number of at least 1!")); + return 1, 0; + } + unless ($delay =~ /^[0-9]+$/) { + $in->ask_warn(N("Error"), N("The delay between retries should be a positive integer number!")); + return 1, 1; + } + return 0; + }, + changed => sub { + return 0; + } + } + }, + [ + { text => N("Do not disable the printer"), + type => 'bool', + val => \$dontdisable }, + { text => N("Retry infinitely often"), + type => 'bool', + val => \$infiniteretries }, + { val => N("Number of retries") }, + { val => \$retries, + disabled => sub { + $infiniteretries; + } }, + { val => N("Delay between retries (in sec)") }, + { val => \$delay, + disabled => sub { + ($retries eq 1) && !$infiniteretries; + } }, + ] + ) + ) { + # Apply new settings + $dontdisable = "0" if $dontdisable eq ""; + $retries = "0" if $retries eq ""; + $delay = "0" if $delay eq ""; + $printer->{currentqueue}{dd} = $dontdisable; + $printer->{currentqueue}{att} = + ($infiniteretries ? "0" : $retries); + $printer->{currentqueue}{delay} = $delay; + return 1; + } else { + return 0; + } +} + sub choose_printer_type { my ($printer, $in, $upNetwork) = @_; my $havelocalnetworks = check_network($printer, $in, $upNetwork, 1) && @@ -887,6 +958,9 @@ sub configure_new_printers { printer => "", driver => "", connect => "", + dd => 1, + att => 0, + delay => 30, spooler => $printer->{SPOOLER}, }; undef $w; @@ -5041,6 +5115,9 @@ sub add_printer { printer => "", driver => "", connect => "", + dd => 1, + att => 0, + delay => 30, spooler => $printer->{SPOOLER}, }; #- Do all the configuration steps for a new queue @@ -5265,6 +5342,10 @@ What do you want to modify on this printer?", if_(($printer->{SPOOLER} !~ /cups/) || printer::cups::queue_enabled($queue), N("Disable Printer"))), + if_(($printer->{SPOOLER} eq "cups") && + $printer->{configured}{$queue} && + ($printer->{configured}{$queue}{queuedata}{connect} !~ m!^hp:/!), + N("Printer communication error handling")), N("Print test pages"), N("Learn how to use this printer"), if_($printer->{configured}{$queue}, N("Remove printer")) ] } ])) { @@ -5348,11 +5429,17 @@ What do you want to modify on this printer?", $in->ask_warn(N("Enable Printer"), N("Printer \"%s\" is now enabled.", $queue)); + $modify = N("Disable Printer"); } 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)); + $modify = N("Enable Printer"); + } elsif ($modify eq N("Printer communication error handling")) { + config_backend_error_handling($printer, $in) && + get_printer_info($printer, $in) && + configure_queue($printer, $in); } elsif ($modify eq N("Print test pages")) { print_testpages($printer, $in, $upNetwork); } elsif ($modify eq N("Learn how to use this printer")) { |