summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2003-02-23 22:08:04 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2003-02-23 22:08:04 +0000
commit96664bd499e9696f79110d02885d9393611f5514 (patch)
tree9ecdd28fb75fb2f1637432a53d20a5c4c8a62940 /perl-install/printer
parent373d8b2e3012afabb301b4ac8df49da2279bd401 (diff)
downloaddrakx-backup-do-not-use-96664bd499e9696f79110d02885d9393611f5514.tar
drakx-backup-do-not-use-96664bd499e9696f79110d02885d9393611f5514.tar.gz
drakx-backup-do-not-use-96664bd499e9696f79110d02885d9393611f5514.tar.bz2
drakx-backup-do-not-use-96664bd499e9696f79110d02885d9393611f5514.tar.xz
drakx-backup-do-not-use-96664bd499e9696f79110d02885d9393611f5514.zip
Several bug fixes on printerdrake
- "BrowsePoll <IP>:<Port>" needs "Browsing On" in /etc/cups/cupsd.conf. - If the same printer model is once on the parallel port and second on USB, there was a new USB queue created on every start of Printerdrake. - Now CUPS is restarted whenever a new USB print queue is set up so that CUPS can provide the model-related USB URI. - Made sure that the default printer is defined and that it is an existing queue so that during installation printerdrake does not show a line only containing " (Default)" in the list of installed printers. - Cleaned up data structure after automatic queue generation.
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/main.pm28
-rw-r--r--perl-install/printer/printerdrake.pm22
2 files changed, 39 insertions, 11 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index c63044413..996b4730d 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -115,7 +115,11 @@ sub assure_device_is_available_for_cups {
my ($result, $i);
# USB printers get special model-dependent URLs in "lpinfo -v" here
# checking is complicated, so we simply restart CUPS then and ready.
- my $maxattempts = ($device =~ /usb/ ? 1 : 3);
+ if ($device =~ /usb/) {
+ $result = printer::services::restart("cups");
+ return 1;
+ }
+ my $maxattempts = 3;
for ($i = 0; $i < $maxattempts; $i++) {
local *F;
open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
@@ -1155,10 +1159,12 @@ sub read_cups_config {
handle_configs::read_unique_directive($printer->{cupsconfig}{cupsd_conf},
'BrowseOrder', 'deny,allow');
- # Keyword "BrowsePoll"
- @{$printer->{cupsconfig}{BrowsePoll}} =
- handle_configs::read_directives($printer->{cupsconfig}{cupsd_conf},
- 'BrowsePoll');
+ # Keyword "BrowsePoll" (needs "Browsing On")
+ if ($printer->{cupsconfig}{keys}{Browsing} !~ /off/i) {
+ @{$printer->{cupsconfig}{BrowsePoll}} =
+ handle_configs::read_directives($printer->{cupsconfig}{cupsd_conf},
+ 'BrowsePoll');
+ }
# Root location
@{$printer->{cupsconfig}{rootlocation}} =
@@ -1229,7 +1235,8 @@ sub write_cups_config {
'BrowseOrder Deny,Allow');
}
} else {
- if ($printer->{cupsconfig}{localprintersshared}) {
+ if (($printer->{cupsconfig}{localprintersshared}) ||
+ ($#{$printer->{cupsconfig}{BrowsePoll}} >= 0)) {
# Deny all broadcasts, but leave all "BrowseAllow" lines
# untouched
handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf},
@@ -1237,8 +1244,9 @@ sub write_cups_config {
handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf},
'BrowseOrder Allow,Deny');
} else {
- # We also do not share printers, so we turn browsing off to
- # do not need to deal with any addresses
+ # We also do not share printers, if we also do not
+ # "BrowsePoll", we turn browsing off to do not need to deal
+ # with any addresses
handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf},
'Browsing Off');
}
@@ -1293,6 +1301,9 @@ sub write_cups_config {
'BrowsePoll ' .
join ("\nBrowsePoll ",
@{$printer->{cupsconfig}{BrowsePoll}}));
+ # "Browsing" must be on for "BrowsePoll" to work
+ handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf},
+ 'Browsing On');
} else {
handle_configs::comment_directive($printer->{cupsconfig}{cupsd_conf},
'BrowsePoll');
@@ -1988,6 +1999,7 @@ sub autodetectionentry_for_uri {
my $smake = handle_configs::searchstr($make);
my $smodel = handle_configs::searchstr($model);
foreach my $p (@autodetected) {
+ next if $p->{port} !~ /usb/i;
next if ((!$p->{val}{MANUFACTURER} or
($p->{val}{MANUFACTURER} ne $make)) and
(!$p->{val}{DESCRIPTION} or
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 3a28c4716..b0fb6b58b 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -483,8 +483,12 @@ N("Examples for correct IPs:\n") .
}
# 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}});
+ undef $w;
}
} else {
# Cancel clicked
@@ -742,6 +746,12 @@ Printerdrake could not determine which model your printer %s is. Please choose t
printer::default::set_printer($printer);
}
}
+ # Delete some variables
+ foreach (qw(OLD_QUEUE QUEUE TYPE str_type DBENTRY ARGS OLD_CHOICE)){
+ $printer->{$_} = "";
+ }
+ $printer->{currentqueue} = {};
+ $printer->{complete} = 0;
}
# Configure the current printer queues in applications
$_w =
@@ -3497,15 +3507,21 @@ sub main {
printer::default::set_spooler($printer);
}
- # Get the default printer (Done after non-interactive queue setup,
- # so that these queues are taken into account)
+ # 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);
+ # Make sure that default printer is registered
+ if ($nodefault) {
+ printer::default::set_printer($printer);
+ }
+
# Mark this part as done, it should not be done a second time.
if ($::isInstall) {
$::printerdrake_initialized = 1;
@@ -3565,7 +3581,7 @@ sub main {
if ($cursorpos eq "::" &&
$printer->{DEFAULT} &&
$printer->{DEFAULT} ne "") {
- if ($printer->{configured}{$printer->{DEFAULT}}) {
+ if (defined($printer->{configured}{$printer->{DEFAULT}})) {
$cursorpos =
$printer->{configured}{$printer->{DEFAULT}}{queuedata}{menuentry} . N(" (Default)");
} elsif ($printer->{SPOOLER} eq "cups") {