summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/printerdrake.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/printer/printerdrake.pm')
-rw-r--r--perl-install/printer/printerdrake.pm1212
1 files changed, 746 insertions, 466 deletions
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